Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
feat: sesli CAD asistani, bellek optimizasyonlari ve akilli cozunurluk
- SnapVoice Turkce sesli CAD ve komut konsolu (/denetle, /ram, /eko, /otomatik, /sessiz) - 3B uzamsal sesli radar ve gorme engelli gelistirici geometri denetim motoru - LibreDWG/DXF ikili sikistirma, font tembel yukleme ve RAM optimizasyonu - Monitor cozunurlugune gore otomatik uyarlamali dinamik grafik modu
This commit is contained in:
@@ -2,9 +2,12 @@ import Drawing from "dxf-writer";
|
||||
import type { ObjExportMesh } from "@/lib/objExport";
|
||||
import type { SvgProjectionLayer } from "@/lib/svgExport";
|
||||
|
||||
export const MAX_DXF_EXPORT_3DFACES = 25_000;
|
||||
export const MAX_DXF_EXPORT_EDGES = 50_000;
|
||||
|
||||
/**
|
||||
* Exports 3D meshes and 2D projected cutting contours to AutoCAD DXF format.
|
||||
* Generates standards-compliant DXF with 3D_MESH and CUT_CONTOURS layers,
|
||||
* Generates standards-compliant DXF with 2D contours or optimized 3D wireframe/mesh,
|
||||
* fully compatible with AutoCAD, SolidWorks, Fusion 360, FreeCAD, and CNC laser cutters.
|
||||
*/
|
||||
export function exportMeshesToDxf(
|
||||
@@ -15,40 +18,18 @@ export function exportMeshesToDxf(
|
||||
const dxf = new Drawing();
|
||||
dxf.setUnits("Millimeters");
|
||||
|
||||
// Layers
|
||||
// Always define standard CAD layers so CAD software and tests find them
|
||||
dxf.addLayer("3D_GEOMETRY", Drawing.ACI.CYAN, "CONTINUOUS");
|
||||
dxf.addLayer("CUT_OUTLINE", Drawing.ACI.WHITE, "CONTINUOUS");
|
||||
dxf.addLayer("CUT_HOLES", Drawing.ACI.RED, "CONTINUOUS");
|
||||
|
||||
// 1. Export 3D Mesh Faces (3DFACE entities)
|
||||
dxf.setActiveLayer("3D_GEOMETRY");
|
||||
for (const mesh of meshes) {
|
||||
for (const [a, b, c] of mesh.faces) {
|
||||
const v1 = mesh.vertices[a];
|
||||
const v2 = mesh.vertices[b];
|
||||
const v3 = mesh.vertices[c];
|
||||
if (!v1 || !v2 || !v3) continue;
|
||||
const hasProjected2D =
|
||||
projectedLayers &&
|
||||
projectedLayers.length > 0 &&
|
||||
projectedLayers.some((l) => l.polygons && l.polygons.length > 0);
|
||||
|
||||
// In DXF 3DFACE, a triangle repeats vertex 3 as vertex 4
|
||||
dxf.drawFace(
|
||||
Number(v1[0].toFixed(5)),
|
||||
Number(v1[1].toFixed(5)),
|
||||
Number(v1[2].toFixed(5)),
|
||||
Number(v2[0].toFixed(5)),
|
||||
Number(v2[1].toFixed(5)),
|
||||
Number(v2[2].toFixed(5)),
|
||||
Number(v3[0].toFixed(5)),
|
||||
Number(v3[1].toFixed(5)),
|
||||
Number(v3[2].toFixed(5)),
|
||||
Number(v3[0].toFixed(5)),
|
||||
Number(v3[1].toFixed(5)),
|
||||
Number(v3[2].toFixed(5)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Export 2D Projected Contours (for CNC Laser, Vinyl, Plasma cutting)
|
||||
if (projectedLayers && projectedLayers.length > 0) {
|
||||
// 1. Export 2D Projected Contours (for CNC Laser, Vinyl, Plasma cutting)
|
||||
if (hasProjected2D && projectedLayers) {
|
||||
for (const layer of projectedLayers) {
|
||||
for (const polygon of layer.polygons) {
|
||||
if (!polygon || polygon.length < 2) continue;
|
||||
@@ -74,6 +55,89 @@ export function exportMeshesToDxf(
|
||||
dxf.drawPolyline(points, true);
|
||||
}
|
||||
}
|
||||
return dxf.toDxfString();
|
||||
}
|
||||
|
||||
// 2. Export 3D Geometry (Wireframe or 3DFACE capped to safe limit)
|
||||
let totalFaces = 0;
|
||||
for (const mesh of meshes) {
|
||||
totalFaces += mesh.faces.length;
|
||||
}
|
||||
|
||||
if (totalFaces <= MAX_DXF_EXPORT_3DFACES) {
|
||||
// Clean, manageable mesh -> write 3DFACE
|
||||
dxf.setActiveLayer("3D_GEOMETRY");
|
||||
|
||||
for (const mesh of meshes) {
|
||||
for (const [a, b, c] of mesh.faces) {
|
||||
const v1 = mesh.vertices[a];
|
||||
const v2 = mesh.vertices[b];
|
||||
const v3 = mesh.vertices[c];
|
||||
if (!v1 || !v2 || !v3) continue;
|
||||
|
||||
// In DXF 3DFACE, a triangle repeats vertex 3 as vertex 4
|
||||
dxf.drawFace(
|
||||
Number(v1[0].toFixed(4)),
|
||||
Number(v1[1].toFixed(4)),
|
||||
Number(v1[2].toFixed(4)),
|
||||
Number(v2[0].toFixed(4)),
|
||||
Number(v2[1].toFixed(4)),
|
||||
Number(v2[2].toFixed(4)),
|
||||
Number(v3[0].toFixed(4)),
|
||||
Number(v3[1].toFixed(4)),
|
||||
Number(v3[2].toFixed(4)),
|
||||
Number(v3[0].toFixed(4)),
|
||||
Number(v3[1].toFixed(4)),
|
||||
Number(v3[2].toFixed(4)),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Dense mesh (>25,000 faces, e.g. DWG line-ribbon extrusions)
|
||||
// Extract unique wireframe edges as 3D lines to prevent generating 200+ MB ASCII files!
|
||||
dxf.addLayer("3D_WIREFRAME", Drawing.ACI.CYAN, "CONTINUOUS");
|
||||
dxf.setActiveLayer("3D_WIREFRAME");
|
||||
|
||||
let edgeCount = 0;
|
||||
const edgeMap = new Map<string, [number, number]>();
|
||||
|
||||
for (const mesh of meshes) {
|
||||
if (edgeCount >= MAX_DXF_EXPORT_EDGES) break;
|
||||
|
||||
for (const [a, b, c] of mesh.faces) {
|
||||
const pairs: Array<[number, number]> = [
|
||||
[a, b],
|
||||
[b, c],
|
||||
[c, a],
|
||||
];
|
||||
for (const [p1, p2] of pairs) {
|
||||
const key = p1 < p2 ? `${p1}_${p2}` : `${p2}_${p1}`;
|
||||
if (!edgeMap.has(key)) {
|
||||
edgeMap.set(key, [p1, p2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const [, [p1, p2]] of edgeMap) {
|
||||
if (edgeCount >= MAX_DXF_EXPORT_EDGES) break;
|
||||
const v1 = mesh.vertices[p1];
|
||||
const v2 = mesh.vertices[p2];
|
||||
if (v1 && v2) {
|
||||
// dxf-writer implements drawLine3d at runtime
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(dxf as any).drawLine3d(
|
||||
Number(v1[0].toFixed(4)),
|
||||
Number(v1[1].toFixed(4)),
|
||||
Number(v1[2].toFixed(4)),
|
||||
Number(v2[0].toFixed(4)),
|
||||
Number(v2[1].toFixed(4)),
|
||||
Number(v2[2].toFixed(4)),
|
||||
);
|
||||
edgeCount++;
|
||||
}
|
||||
}
|
||||
edgeMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return dxf.toDxfString();
|
||||
|
||||
Reference in New Issue
Block a user