geometrix 0.5.38 → 0.5.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +25 -8
- package/dist/index.js +404 -66
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ declare const colors: {
|
|
|
3
3
|
line: string;
|
|
4
4
|
vector: string;
|
|
5
5
|
contour: string;
|
|
6
|
-
|
|
6
|
+
mainOuter: string;
|
|
7
|
+
mainInner: string;
|
|
7
8
|
mainB: string;
|
|
8
9
|
second: string;
|
|
9
10
|
secondB: string;
|
|
@@ -269,6 +270,7 @@ interface tPaxContourPath {
|
|
|
269
270
|
seg: tPaxSeg[];
|
|
270
271
|
}
|
|
271
272
|
type tPaxContour = tPaxContourPath | tPaxContourCircle;
|
|
273
|
+
type tPaxFace = tPaxContour[];
|
|
272
274
|
declare function paxCircle(cx: number, cy: number, radius: number): tPaxContourCircle;
|
|
273
275
|
declare class PaxPath {
|
|
274
276
|
seg: tPaxSeg[];
|
|
@@ -403,11 +405,15 @@ interface tLayers {
|
|
|
403
405
|
ruler: boolean;
|
|
404
406
|
refframe: boolean;
|
|
405
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* The face-type is a list of contours. The first contour is the outer, the remaining are the inner contours
|
|
410
|
+
*/
|
|
411
|
+
type tOuterInner = tContour[];
|
|
406
412
|
declare class Figure {
|
|
407
413
|
pointList: Point[];
|
|
408
414
|
lineList: Line[];
|
|
409
415
|
vectorList: Vector[];
|
|
410
|
-
mainList:
|
|
416
|
+
mainList: tOuterInner[];
|
|
411
417
|
mainBList: tContour[];
|
|
412
418
|
secondList: tContour[];
|
|
413
419
|
secondBList: tContour[];
|
|
@@ -422,13 +428,23 @@ declare class Figure {
|
|
|
422
428
|
addLine(iline: Line): void;
|
|
423
429
|
addLines(ilines: Line[]): void;
|
|
424
430
|
addVector(ivector: Vector): void;
|
|
425
|
-
|
|
431
|
+
/**
|
|
432
|
+
* add one Outer contour and several Inner contours to the Main Layer
|
|
433
|
+
* @param {tOuterInner} iFace - the Face (i.e one Outer and several Inner contours) to be added
|
|
434
|
+
*/
|
|
435
|
+
addMainOI(iFace: tOuterInner): void;
|
|
436
|
+
/**
|
|
437
|
+
* add one Outer contour to the Main Layer
|
|
438
|
+
* @param {tContour} iFace - the Face (without inner contours) to be added
|
|
439
|
+
*/
|
|
440
|
+
addMainO(iFace: tContour): void;
|
|
426
441
|
addSecond(icontour: tContour): void;
|
|
427
442
|
addDynamics(icontour: tContour): void;
|
|
428
443
|
translate(ix: number, iy: number): Figure;
|
|
429
444
|
translatePolar(ia: number, il: number): Figure;
|
|
430
445
|
rotate(ix: number, iy: number, ia: number): Figure;
|
|
431
446
|
mergeFigure(ifig: Figure, mainToSecond?: boolean): void;
|
|
447
|
+
mainListC(): tContour[];
|
|
432
448
|
clear(): void;
|
|
433
449
|
/** @internal */
|
|
434
450
|
getMinMax(): void;
|
|
@@ -440,9 +456,9 @@ declare class Figure {
|
|
|
440
456
|
draw(ctx: CanvasRenderingContext2D, adjust: tCanvasAdjust, layers: tLayers): void;
|
|
441
457
|
}
|
|
442
458
|
declare function figure(): Figure;
|
|
443
|
-
type
|
|
459
|
+
type tFigures = Record<string, Figure>;
|
|
444
460
|
/** For cli-app and ui-app */
|
|
445
|
-
declare function mergeFaces(
|
|
461
|
+
declare function mergeFaces(iFigures: tFigures): Figure;
|
|
446
462
|
declare function initLayers(): tLayers;
|
|
447
463
|
declare function copyLayers(iLayers: tLayers): tLayers;
|
|
448
464
|
|
|
@@ -524,7 +540,7 @@ interface tGeom {
|
|
|
524
540
|
partName: string;
|
|
525
541
|
calcErr: boolean;
|
|
526
542
|
logstr: string;
|
|
527
|
-
fig:
|
|
543
|
+
fig: tFigures;
|
|
528
544
|
vol: tVolume;
|
|
529
545
|
sub: tSubDesign;
|
|
530
546
|
}
|
|
@@ -587,7 +603,8 @@ declare enum EFormat {
|
|
|
587
603
|
ePAX = 5,
|
|
588
604
|
eOPENSCAD = 6,
|
|
589
605
|
eJSCAD = 7,
|
|
590
|
-
|
|
606
|
+
eFREECAD = 8,
|
|
607
|
+
eZIP = 9
|
|
591
608
|
}
|
|
592
609
|
declare function fileTextContent(fgeom: tGeomFunc, paramVal: tParamVal, ipDef: tParamDef, eFace: string, exportFormat: EFormat): string;
|
|
593
610
|
declare function fileBinContent(fgeom: tGeomFunc, tSim: number, paramVal: tParamVal, ipDef: tParamDef, exportFormat: EFormat): Promise<Blob>;
|
|
@@ -657,4 +674,4 @@ declare function version_details(appPackage: tPackage): string[];
|
|
|
657
674
|
|
|
658
675
|
declare function checkImpPages(pages: tAllPageDef): [boolean, string];
|
|
659
676
|
|
|
660
|
-
export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Transform3d, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustInit, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, ctrOblong, ctrRectRot, ctrRectRot2, ctrRectangle, ctrTrapezoid, ctrTrapezoidRot2, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tExtrude, type
|
|
677
|
+
export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Transform3d, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustInit, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, ctrOblong, ctrRectRot, ctrRectRot2, ctrRectangle, ctrTrapezoid, ctrTrapezoidRot2, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tExtrude, type tFigures, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tOuterInner, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxFace, type tPaxSeg, type tPaxSegArc, type tPaxSegSt, type tPolar, type tPosiOrien, type tSimTime, type tSubDesign, type tSubInst, type tT3dMatrix, type tVec3, type tVec4, type tVolume, tolerance, transform3d, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi, zeroPDef };
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,8 @@ var colors = {
|
|
|
71
71
|
line: "grey",
|
|
72
72
|
vector: "DarkTurquoise",
|
|
73
73
|
contour: "green",
|
|
74
|
-
|
|
74
|
+
mainOuter: "SlateBlue",
|
|
75
|
+
mainInner: "SteelBlue",
|
|
75
76
|
mainB: "SlateGrey",
|
|
76
77
|
second: "Violet",
|
|
77
78
|
secondB: "SlateGrey",
|
|
@@ -2493,12 +2494,28 @@ var Figure = class _Figure {
|
|
|
2493
2494
|
addVector(ivector) {
|
|
2494
2495
|
this.vectorList.push(ivector);
|
|
2495
2496
|
}
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2497
|
+
/**
|
|
2498
|
+
* add one Outer contour and several Inner contours to the Main Layer
|
|
2499
|
+
* @param {tOuterInner} iFace - the Face (i.e one Outer and several Inner contours) to be added
|
|
2500
|
+
*/
|
|
2501
|
+
addMainOI(iFace) {
|
|
2502
|
+
const oneFace = [];
|
|
2503
|
+
for (const oneCtr of iFace) {
|
|
2504
|
+
const roundedContour = oneCtr.generateContour();
|
|
2505
|
+
this.addPoints(roundedContour.generatePoints());
|
|
2506
|
+
this.addLines(roundedContour.generateLines());
|
|
2507
|
+
oneFace.push(roundedContour);
|
|
2508
|
+
this.mainBList.push(oneCtr.extractSkeleton());
|
|
2509
|
+
}
|
|
2510
|
+
this.mainList.push(oneFace);
|
|
2511
|
+
}
|
|
2512
|
+
/**
|
|
2513
|
+
* add one Outer contour to the Main Layer
|
|
2514
|
+
* @param {tContour} iFace - the Face (without inner contours) to be added
|
|
2515
|
+
*/
|
|
2516
|
+
addMainO(iFace) {
|
|
2517
|
+
const face = [iFace];
|
|
2518
|
+
this.addMainOI(face);
|
|
2502
2519
|
}
|
|
2503
2520
|
addSecond(icontour) {
|
|
2504
2521
|
const roundedContour = icontour.generateContour();
|
|
@@ -2523,8 +2540,12 @@ var Figure = class _Figure {
|
|
|
2523
2540
|
for (const vec of this.vectorList) {
|
|
2524
2541
|
rfig.addVector(vec.translate(ix, iy));
|
|
2525
2542
|
}
|
|
2526
|
-
for (const
|
|
2527
|
-
|
|
2543
|
+
for (const face of this.mainList) {
|
|
2544
|
+
const oneFace = [];
|
|
2545
|
+
for (const ctr of face) {
|
|
2546
|
+
oneFace.push(ctr.translate(ix, iy));
|
|
2547
|
+
}
|
|
2548
|
+
rfig.addMainOI(oneFace);
|
|
2528
2549
|
}
|
|
2529
2550
|
for (const ctr of this.secondList) {
|
|
2530
2551
|
rfig.addSecond(ctr.translate(ix, iy));
|
|
@@ -2549,8 +2570,12 @@ var Figure = class _Figure {
|
|
|
2549
2570
|
for (const vec of this.vectorList) {
|
|
2550
2571
|
rfig.addVector(vec.rotate(pt0, ia));
|
|
2551
2572
|
}
|
|
2552
|
-
for (const
|
|
2553
|
-
|
|
2573
|
+
for (const face of this.mainList) {
|
|
2574
|
+
const oneFace = [];
|
|
2575
|
+
for (const ctr of face) {
|
|
2576
|
+
oneFace.push(ctr.rotate(ix, iy, ia));
|
|
2577
|
+
}
|
|
2578
|
+
rfig.addMainOI(oneFace);
|
|
2554
2579
|
}
|
|
2555
2580
|
for (const ctr of this.secondList) {
|
|
2556
2581
|
rfig.addSecond(ctr.rotate(ix, iy, ia));
|
|
@@ -2570,11 +2595,17 @@ var Figure = class _Figure {
|
|
|
2570
2595
|
for (const vec of ifig.vectorList) {
|
|
2571
2596
|
this.addVector(vec.clone());
|
|
2572
2597
|
}
|
|
2573
|
-
for (const
|
|
2598
|
+
for (const face of ifig.mainList) {
|
|
2599
|
+
const oneFace = [];
|
|
2600
|
+
for (const ctr of face) {
|
|
2601
|
+
oneFace.push(ctr.clone());
|
|
2602
|
+
}
|
|
2574
2603
|
if (mainToSecond) {
|
|
2575
|
-
|
|
2604
|
+
for (const ctr of oneFace) {
|
|
2605
|
+
this.addSecond(ctr);
|
|
2606
|
+
}
|
|
2576
2607
|
} else {
|
|
2577
|
-
this.
|
|
2608
|
+
this.addMainOI(oneFace);
|
|
2578
2609
|
}
|
|
2579
2610
|
}
|
|
2580
2611
|
for (const ctr of ifig.secondList) {
|
|
@@ -2584,6 +2615,15 @@ var Figure = class _Figure {
|
|
|
2584
2615
|
this.addDynamics(ctr.clone());
|
|
2585
2616
|
}
|
|
2586
2617
|
}
|
|
2618
|
+
mainListC() {
|
|
2619
|
+
const rListC = [];
|
|
2620
|
+
for (const face of this.mainList) {
|
|
2621
|
+
for (const ctr of face) {
|
|
2622
|
+
rListC.push(ctr);
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
return rListC;
|
|
2626
|
+
}
|
|
2587
2627
|
clear() {
|
|
2588
2628
|
this.pointList = [];
|
|
2589
2629
|
this.lineList = [];
|
|
@@ -2676,8 +2716,14 @@ var Figure = class _Figure {
|
|
|
2676
2716
|
}
|
|
2677
2717
|
}
|
|
2678
2718
|
if (layers.main) {
|
|
2679
|
-
for (const
|
|
2680
|
-
|
|
2719
|
+
for (const face of this.mainList) {
|
|
2720
|
+
for (const [idx, li] of face.entries()) {
|
|
2721
|
+
let ctrColor = colors.mainOuter;
|
|
2722
|
+
if (idx > 0) {
|
|
2723
|
+
ctrColor = colors.mainInner;
|
|
2724
|
+
}
|
|
2725
|
+
li.draw(ctx, adjust, ctrColor);
|
|
2726
|
+
}
|
|
2681
2727
|
}
|
|
2682
2728
|
}
|
|
2683
2729
|
if (layers.mainB) {
|
|
@@ -2717,10 +2763,10 @@ var Figure = class _Figure {
|
|
|
2717
2763
|
function figure() {
|
|
2718
2764
|
return new Figure();
|
|
2719
2765
|
}
|
|
2720
|
-
function mergeFaces(
|
|
2766
|
+
function mergeFaces(iFigures) {
|
|
2721
2767
|
const rfig = figure();
|
|
2722
|
-
for (const
|
|
2723
|
-
const fig =
|
|
2768
|
+
for (const ifig in iFigures) {
|
|
2769
|
+
const fig = iFigures[ifig];
|
|
2724
2770
|
for (const ipoint of fig.pointList) {
|
|
2725
2771
|
rfig.pointList.push(ipoint);
|
|
2726
2772
|
}
|
|
@@ -2730,8 +2776,8 @@ function mergeFaces(iFaces) {
|
|
|
2730
2776
|
for (const ivector of fig.vectorList) {
|
|
2731
2777
|
rfig.vectorList.push(ivector);
|
|
2732
2778
|
}
|
|
2733
|
-
for (const
|
|
2734
|
-
rfig.mainList.push(
|
|
2779
|
+
for (const face of fig.mainList) {
|
|
2780
|
+
rfig.mainList.push(face);
|
|
2735
2781
|
}
|
|
2736
2782
|
for (const ctr of fig.mainBList) {
|
|
2737
2783
|
rfig.mainBList.push(ctr);
|
|
@@ -3005,10 +3051,14 @@ function prefixLog(iLog, iPartName) {
|
|
|
3005
3051
|
// src/write_pax.ts
|
|
3006
3052
|
var PaxWrite = class {
|
|
3007
3053
|
//constructor() {}
|
|
3008
|
-
figureToPaxF(
|
|
3054
|
+
figureToPaxF(aFaces) {
|
|
3009
3055
|
const rPaxF = [];
|
|
3010
|
-
for (const
|
|
3011
|
-
|
|
3056
|
+
for (const face of aFaces) {
|
|
3057
|
+
const oneFace = [];
|
|
3058
|
+
for (const ctr of face) {
|
|
3059
|
+
oneFace.push(ctr.toPax());
|
|
3060
|
+
}
|
|
3061
|
+
rPaxF.push(oneFace);
|
|
3012
3062
|
}
|
|
3013
3063
|
return rPaxF;
|
|
3014
3064
|
}
|
|
@@ -3025,7 +3075,7 @@ var PaxWrite = class {
|
|
|
3025
3075
|
partName: geome0.partName,
|
|
3026
3076
|
pDef: ipDef,
|
|
3027
3077
|
params: paramVal,
|
|
3028
|
-
|
|
3078
|
+
figures: this.getFigures(geome0.fig),
|
|
3029
3079
|
volume: geome0.vol,
|
|
3030
3080
|
subs: geome0.sub,
|
|
3031
3081
|
log: geome0.logstr
|
|
@@ -3201,26 +3251,28 @@ var OpenscadWrite = class {
|
|
|
3201
3251
|
const rStr = "// Generated by Parametrix\n";
|
|
3202
3252
|
return rStr;
|
|
3203
3253
|
}
|
|
3204
|
-
getOneFigure(
|
|
3254
|
+
getOneFigure(aFaces, faceId) {
|
|
3205
3255
|
const oscadWF = new OpenscadWriteFigure();
|
|
3206
|
-
for (const
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3256
|
+
for (const paxFace of aFaces) {
|
|
3257
|
+
for (const paxCtr of paxFace) {
|
|
3258
|
+
if (paxCtr.circle === true) {
|
|
3259
|
+
const paxCircle2 = paxCtr;
|
|
3260
|
+
const oscadSeg = oscadSegCircle(paxCircle2.cx, paxCircle2.cy, paxCircle2.radius);
|
|
3261
|
+
oscadWF.addContour(oscadSeg);
|
|
3262
|
+
} else {
|
|
3263
|
+
const paxPath2 = paxCtr;
|
|
3264
|
+
const oscadSeg = toOpenscadSeg(paxPath2.seg);
|
|
3265
|
+
oscadWF.addContour(oscadSeg);
|
|
3266
|
+
}
|
|
3215
3267
|
}
|
|
3216
3268
|
}
|
|
3217
3269
|
const rOscadF = oscadWF.getFigure(faceId);
|
|
3218
3270
|
return rOscadF;
|
|
3219
3271
|
}
|
|
3220
|
-
getAllFigures(
|
|
3272
|
+
getAllFigures(figures, partName) {
|
|
3221
3273
|
let rStr = "";
|
|
3222
|
-
for (const face in
|
|
3223
|
-
const figu = this.getOneFigure(
|
|
3274
|
+
for (const face in figures) {
|
|
3275
|
+
const figu = this.getOneFigure(figures[face], `${partName}_${face}`);
|
|
3224
3276
|
rStr += figu;
|
|
3225
3277
|
}
|
|
3226
3278
|
return rStr;
|
|
@@ -3331,7 +3383,7 @@ module ${inherit.outName} () {
|
|
|
3331
3383
|
const subGeoms = this.getAllSubGeoms(vol.inherits);
|
|
3332
3384
|
for (const oneGeom of subGeoms) {
|
|
3333
3385
|
const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
|
|
3334
|
-
rStr += this.getAllFigures(paxJson.
|
|
3386
|
+
rStr += this.getAllFigures(paxJson.figures, paxJson.partName);
|
|
3335
3387
|
rStr += this.getVolume(oneGeom.vol);
|
|
3336
3388
|
}
|
|
3337
3389
|
rStr += this.getAllInherits(vol.inherits);
|
|
@@ -3348,7 +3400,7 @@ pax_${partName}();
|
|
|
3348
3400
|
}
|
|
3349
3401
|
getExportFile(pax) {
|
|
3350
3402
|
let rStr = this.getHeader();
|
|
3351
|
-
rStr += this.getAllFigures(pax.
|
|
3403
|
+
rStr += this.getAllFigures(pax.figures, pax.partName);
|
|
3352
3404
|
rStr += this.getVolume(pax.volume);
|
|
3353
3405
|
rStr += this.getFooter(pax.partName);
|
|
3354
3406
|
return rStr;
|
|
@@ -3464,17 +3516,19 @@ const main = () => {
|
|
|
3464
3516
|
`;
|
|
3465
3517
|
return rStr;
|
|
3466
3518
|
}
|
|
3467
|
-
getOneFigure(
|
|
3519
|
+
getOneFigure(aFaces, faceId) {
|
|
3468
3520
|
const ojscadWF = new OjscadWriteFigure();
|
|
3469
|
-
for (const
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3521
|
+
for (const paxFace of aFaces) {
|
|
3522
|
+
for (const paxCtr of paxFace) {
|
|
3523
|
+
if (paxCtr.circle === true) {
|
|
3524
|
+
const paxCircle2 = paxCtr;
|
|
3525
|
+
const ojscadSeg = ojscadSegCircle(paxCircle2.cx, paxCircle2.cy, paxCircle2.radius);
|
|
3526
|
+
ojscadWF.addContour(ojscadSeg);
|
|
3527
|
+
} else {
|
|
3528
|
+
const paxPath2 = paxCtr;
|
|
3529
|
+
const ojscadSeg = toOpenjscadSeg(paxPath2.seg);
|
|
3530
|
+
ojscadWF.addContour(ojscadSeg);
|
|
3531
|
+
}
|
|
3478
3532
|
}
|
|
3479
3533
|
}
|
|
3480
3534
|
const rOjscadF = ojscadWF.getFigure(faceId);
|
|
@@ -3580,7 +3634,7 @@ const ${inherit.outName} =
|
|
|
3580
3634
|
const subGeoms = this.getAllSubGeoms(vol.inherits);
|
|
3581
3635
|
for (const oneGeom of subGeoms) {
|
|
3582
3636
|
const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
|
|
3583
|
-
rStr += this.getAllFigures(paxJson.
|
|
3637
|
+
rStr += this.getAllFigures(paxJson.figures, paxJson.partName);
|
|
3584
3638
|
rStr += this.getVolume(oneGeom.vol);
|
|
3585
3639
|
}
|
|
3586
3640
|
rStr += this.getAllInherits(vol.inherits);
|
|
@@ -3599,7 +3653,7 @@ module.exports = { main };
|
|
|
3599
3653
|
}
|
|
3600
3654
|
getExportFile(pax) {
|
|
3601
3655
|
let rStr = this.getHeader();
|
|
3602
|
-
rStr += this.getAllFigures(pax.
|
|
3656
|
+
rStr += this.getAllFigures(pax.figures, pax.partName);
|
|
3603
3657
|
rStr += this.getVolume(pax.volume);
|
|
3604
3658
|
rStr += this.getFooter(pax.partName);
|
|
3605
3659
|
return rStr;
|
|
@@ -3610,6 +3664,276 @@ function ojscadWrite() {
|
|
|
3610
3664
|
return rOjscadWrite;
|
|
3611
3665
|
}
|
|
3612
3666
|
|
|
3667
|
+
// src/write_freecad.ts
|
|
3668
|
+
var approxMaxAngle3 = Math.PI / 8;
|
|
3669
|
+
var approxMaxLength3 = 20;
|
|
3670
|
+
function oscadSegLine2(p2x, p2y) {
|
|
3671
|
+
const rSeg = [[p2x, p2y]];
|
|
3672
|
+
return rSeg;
|
|
3673
|
+
}
|
|
3674
|
+
function oscadSegArc2(cx, cy, radius, aa1, aa2, arcCcw) {
|
|
3675
|
+
const rSeg = arc_to_stroke(cx, cy, radius, aa1, aa2, arcCcw, approxMaxAngle3, approxMaxLength3);
|
|
3676
|
+
return rSeg;
|
|
3677
|
+
}
|
|
3678
|
+
function oscadSegCircle2(cx, cy, radius) {
|
|
3679
|
+
const rSeg = circle_to_stroke(cx, cy, radius, approxMaxAngle3, approxMaxLength3);
|
|
3680
|
+
return rSeg;
|
|
3681
|
+
}
|
|
3682
|
+
function toOpenscadSeg2(paxCtr) {
|
|
3683
|
+
const rOscadSeg = [];
|
|
3684
|
+
let px1 = 0;
|
|
3685
|
+
let py1 = 0;
|
|
3686
|
+
for (const seg of paxCtr) {
|
|
3687
|
+
if (seg.typ === 0 /* eStart */) {
|
|
3688
|
+
rOscadSeg.push(...oscadSegLine2(seg.px, seg.py));
|
|
3689
|
+
} else if (seg.typ === 1 /* eStroke */) {
|
|
3690
|
+
rOscadSeg.push(...oscadSegLine2(seg.px, seg.py));
|
|
3691
|
+
} else if (seg.typ === 2 /* eArc */) {
|
|
3692
|
+
try {
|
|
3693
|
+
const sega = seg;
|
|
3694
|
+
const seg1 = new Segment1(
|
|
3695
|
+
convTypePaxToSeg1(sega.typ),
|
|
3696
|
+
sega.px,
|
|
3697
|
+
sega.py,
|
|
3698
|
+
sega.radius,
|
|
3699
|
+
sega.large,
|
|
3700
|
+
sega.ccw
|
|
3701
|
+
);
|
|
3702
|
+
const seg2 = arcSeg1To2(px1, py1, seg1);
|
|
3703
|
+
rOscadSeg.push(
|
|
3704
|
+
...oscadSegArc2(
|
|
3705
|
+
seg2.pc.cx,
|
|
3706
|
+
seg2.pc.cy,
|
|
3707
|
+
seg1.radius,
|
|
3708
|
+
seg2.a1,
|
|
3709
|
+
seg2.a2,
|
|
3710
|
+
seg2.arcCcw
|
|
3711
|
+
)
|
|
3712
|
+
);
|
|
3713
|
+
} catch (emsg) {
|
|
3714
|
+
console.log("err730: " + emsg);
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
px1 = seg.px;
|
|
3718
|
+
py1 = seg.py;
|
|
3719
|
+
}
|
|
3720
|
+
return rOscadSeg;
|
|
3721
|
+
}
|
|
3722
|
+
function ff6(ifloat) {
|
|
3723
|
+
return ifloat.toFixed(4);
|
|
3724
|
+
}
|
|
3725
|
+
var OpenscadWriteFigure2 = class {
|
|
3726
|
+
pts;
|
|
3727
|
+
ptIdx;
|
|
3728
|
+
idx;
|
|
3729
|
+
constructor() {
|
|
3730
|
+
this.pts = [];
|
|
3731
|
+
this.ptIdx = [];
|
|
3732
|
+
this.idx = 0;
|
|
3733
|
+
}
|
|
3734
|
+
addContour(ictr) {
|
|
3735
|
+
const pts2 = [];
|
|
3736
|
+
const ptIdx2 = [];
|
|
3737
|
+
for (const pt of ictr) {
|
|
3738
|
+
const [px, py] = pt;
|
|
3739
|
+
pts2.push(`[ ${ff6(px)}, ${ff6(py)} ]`);
|
|
3740
|
+
ptIdx2.push(` ${this.idx}`);
|
|
3741
|
+
this.idx += 1;
|
|
3742
|
+
}
|
|
3743
|
+
const ptStr = `[ ${pts2.join(",")} ]`;
|
|
3744
|
+
const ptIdxStr = `[ ${ptIdx2.join(",")} ]`;
|
|
3745
|
+
this.pts.push(ptStr);
|
|
3746
|
+
this.ptIdx.push(ptIdxStr);
|
|
3747
|
+
}
|
|
3748
|
+
getFigure(faceId) {
|
|
3749
|
+
let rStr = "";
|
|
3750
|
+
const aList = [];
|
|
3751
|
+
const bList = [];
|
|
3752
|
+
for (const idx of this.pts.keys()) {
|
|
3753
|
+
const aId = `ca_${faceId}_${idx}`;
|
|
3754
|
+
const bId = `cb_${faceId}_${idx}`;
|
|
3755
|
+
rStr += `${aId} = ${this.pts[idx]};
|
|
3756
|
+
`;
|
|
3757
|
+
rStr += `${bId} = ${this.ptIdx[idx]};
|
|
3758
|
+
`;
|
|
3759
|
+
aList.push(aId);
|
|
3760
|
+
bList.push(bId);
|
|
3761
|
+
}
|
|
3762
|
+
const aListStr = aList.join(", ");
|
|
3763
|
+
const bListStr = bList.join(", ");
|
|
3764
|
+
rStr += `a_${faceId} = concat(${aListStr});
|
|
3765
|
+
`;
|
|
3766
|
+
rStr += `b_${faceId} = [${bListStr}];
|
|
3767
|
+
`;
|
|
3768
|
+
return rStr;
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
var FreecadWrite = class {
|
|
3772
|
+
//constructor() {}
|
|
3773
|
+
getHeader() {
|
|
3774
|
+
const rStr = "// Generated by Parametrix\n";
|
|
3775
|
+
return rStr;
|
|
3776
|
+
}
|
|
3777
|
+
getOneFigure(aFaces, faceId) {
|
|
3778
|
+
const oscadWF = new OpenscadWriteFigure2();
|
|
3779
|
+
for (const paxFace of aFaces) {
|
|
3780
|
+
for (const paxCtr of paxFace) {
|
|
3781
|
+
if (paxCtr.circle === true) {
|
|
3782
|
+
const paxCircle2 = paxCtr;
|
|
3783
|
+
const oscadSeg = oscadSegCircle2(paxCircle2.cx, paxCircle2.cy, paxCircle2.radius);
|
|
3784
|
+
oscadWF.addContour(oscadSeg);
|
|
3785
|
+
} else {
|
|
3786
|
+
const paxPath2 = paxCtr;
|
|
3787
|
+
const oscadSeg = toOpenscadSeg2(paxPath2.seg);
|
|
3788
|
+
oscadWF.addContour(oscadSeg);
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
const rOscadF = oscadWF.getFigure(faceId);
|
|
3793
|
+
return rOscadF;
|
|
3794
|
+
}
|
|
3795
|
+
getAllFigures(faces, partName) {
|
|
3796
|
+
let rStr = "";
|
|
3797
|
+
for (const face in faces) {
|
|
3798
|
+
const figu = this.getOneFigure(faces[face], `${partName}_${face}`);
|
|
3799
|
+
rStr += figu;
|
|
3800
|
+
}
|
|
3801
|
+
return rStr;
|
|
3802
|
+
}
|
|
3803
|
+
getOneExtrude(extrud) {
|
|
3804
|
+
let extrudMethod = "rotate_extrude";
|
|
3805
|
+
let extrudOption = "";
|
|
3806
|
+
if (extrud.extrudeMethod === 0 /* eLinearOrtho */) {
|
|
3807
|
+
if (extrud.length === void 0) {
|
|
3808
|
+
console.log("err103: design error: scad-linear_extrude length undefined!");
|
|
3809
|
+
}
|
|
3810
|
+
extrudMethod = "linear_extrude";
|
|
3811
|
+
extrudOption = `height = ${extrud.length}`;
|
|
3812
|
+
}
|
|
3813
|
+
const rStr = `
|
|
3814
|
+
module ${extrud.outName} () {
|
|
3815
|
+
translate( [ ${extrud.translate[0]}, ${extrud.translate[1]}, ${extrud.translate[2]} ])
|
|
3816
|
+
rotate( [ ${radToDeg(extrud.rotate[0])}, ${radToDeg(extrud.rotate[1])}, ${radToDeg(
|
|
3817
|
+
extrud.rotate[2]
|
|
3818
|
+
)} ])
|
|
3819
|
+
${extrudMethod}(${extrudOption}) polygon(a_${extrud.face}, b_${extrud.face});
|
|
3820
|
+
}
|
|
3821
|
+
`;
|
|
3822
|
+
return rStr;
|
|
3823
|
+
}
|
|
3824
|
+
getAllExtrudes(extrudes) {
|
|
3825
|
+
let rStr = "";
|
|
3826
|
+
for (const extrud of extrudes) {
|
|
3827
|
+
const subp = this.getOneExtrude(extrud);
|
|
3828
|
+
rStr += subp;
|
|
3829
|
+
}
|
|
3830
|
+
return rStr;
|
|
3831
|
+
}
|
|
3832
|
+
getOneVolume(volum) {
|
|
3833
|
+
let vMethod = "identity";
|
|
3834
|
+
switch (volum.boolMethod) {
|
|
3835
|
+
case 1 /* eIntersection */:
|
|
3836
|
+
vMethod = "intersection";
|
|
3837
|
+
break;
|
|
3838
|
+
case 2 /* eUnion */:
|
|
3839
|
+
vMethod = "union";
|
|
3840
|
+
break;
|
|
3841
|
+
case 3 /* eSubstraction */:
|
|
3842
|
+
vMethod = "difference";
|
|
3843
|
+
break;
|
|
3844
|
+
}
|
|
3845
|
+
const inList2 = [];
|
|
3846
|
+
for (const elem of volum.inList) {
|
|
3847
|
+
inList2.push(`${elem}();`);
|
|
3848
|
+
}
|
|
3849
|
+
const inList3 = inList2.join("\n");
|
|
3850
|
+
let rStr = `
|
|
3851
|
+
module ${volum.outName} () {
|
|
3852
|
+
${vMethod} () {
|
|
3853
|
+
${inList3}
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
`;
|
|
3857
|
+
if (volum.boolMethod === 0 /* eIdentity */) {
|
|
3858
|
+
rStr = `
|
|
3859
|
+
module ${volum.outName} () {
|
|
3860
|
+
${inList3}
|
|
3861
|
+
}
|
|
3862
|
+
`;
|
|
3863
|
+
}
|
|
3864
|
+
return rStr;
|
|
3865
|
+
}
|
|
3866
|
+
getAllVolumes(volumes) {
|
|
3867
|
+
let rStr = "";
|
|
3868
|
+
for (const volum of volumes) {
|
|
3869
|
+
const subp = this.getOneVolume(volum);
|
|
3870
|
+
rStr += subp;
|
|
3871
|
+
}
|
|
3872
|
+
return rStr;
|
|
3873
|
+
}
|
|
3874
|
+
getAllSubGeoms(inherits) {
|
|
3875
|
+
const rGeoms = [];
|
|
3876
|
+
for (const inher of inherits) {
|
|
3877
|
+
if (!rGeoms.includes(inher.subgeom)) {
|
|
3878
|
+
rGeoms.push(inher.subgeom);
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
return rGeoms;
|
|
3882
|
+
}
|
|
3883
|
+
getOneInherit(inherit) {
|
|
3884
|
+
const rStr = `
|
|
3885
|
+
module ${inherit.outName} () {
|
|
3886
|
+
translate( [ ${inherit.translate[0]}, ${inherit.translate[1]}, ${inherit.translate[2]} ])
|
|
3887
|
+
rotate( [ ${radToDeg(inherit.rotate[0])}, ${radToDeg(inherit.rotate[1])}, ${radToDeg(
|
|
3888
|
+
inherit.rotate[2]
|
|
3889
|
+
)} ])
|
|
3890
|
+
${inherit.subdesign}();
|
|
3891
|
+
}
|
|
3892
|
+
`;
|
|
3893
|
+
return rStr;
|
|
3894
|
+
}
|
|
3895
|
+
getAllInherits(inherits) {
|
|
3896
|
+
let rStr = "";
|
|
3897
|
+
for (const inher of inherits) {
|
|
3898
|
+
const subinhe = this.getOneInherit(inher);
|
|
3899
|
+
rStr += subinhe;
|
|
3900
|
+
}
|
|
3901
|
+
return rStr;
|
|
3902
|
+
}
|
|
3903
|
+
getVolume(vol) {
|
|
3904
|
+
let rStr = "";
|
|
3905
|
+
if (vol.inherits !== void 0) {
|
|
3906
|
+
const subGeoms = this.getAllSubGeoms(vol.inherits);
|
|
3907
|
+
for (const oneGeom of subGeoms) {
|
|
3908
|
+
const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
|
|
3909
|
+
rStr += this.getAllFigures(paxJson.figures, paxJson.partName);
|
|
3910
|
+
rStr += this.getVolume(oneGeom.vol);
|
|
3911
|
+
}
|
|
3912
|
+
rStr += this.getAllInherits(vol.inherits);
|
|
3913
|
+
}
|
|
3914
|
+
rStr += this.getAllExtrudes(vol.extrudes);
|
|
3915
|
+
rStr += this.getAllVolumes(vol.volumes);
|
|
3916
|
+
return rStr;
|
|
3917
|
+
}
|
|
3918
|
+
getFooter(partName) {
|
|
3919
|
+
const rStr = `
|
|
3920
|
+
pax_${partName}();
|
|
3921
|
+
`;
|
|
3922
|
+
return rStr;
|
|
3923
|
+
}
|
|
3924
|
+
getExportFile(pax) {
|
|
3925
|
+
let rStr = this.getHeader();
|
|
3926
|
+
rStr += this.getAllFigures(pax.figures, pax.partName);
|
|
3927
|
+
rStr += this.getVolume(pax.volume);
|
|
3928
|
+
rStr += this.getFooter(pax.partName);
|
|
3929
|
+
return rStr;
|
|
3930
|
+
}
|
|
3931
|
+
};
|
|
3932
|
+
function freecadWrite() {
|
|
3933
|
+
const rFreecadWrite = new FreecadWrite();
|
|
3934
|
+
return rFreecadWrite;
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3613
3937
|
// src/aaExportContent.ts
|
|
3614
3938
|
import * as zip from "@zip.js/zip.js";
|
|
3615
3939
|
var MinMaxPoint = class {
|
|
@@ -3699,7 +4023,7 @@ function figureToSvg(aCtr) {
|
|
|
3699
4023
|
}
|
|
3700
4024
|
function figureToSvgDeco(fig) {
|
|
3701
4025
|
const sw2 = svgWriter2();
|
|
3702
|
-
sw2.addAContour(fig.
|
|
4026
|
+
sw2.addAContour(fig.mainListC(), "main", colors.mainInner);
|
|
3703
4027
|
sw2.addAContour(fig.mainBList, "mainB", colors.mainB);
|
|
3704
4028
|
sw2.addAContour(fig.secondList, "second", colors.second);
|
|
3705
4029
|
sw2.addAContour(fig.secondBList, "secondB", colors.secondB);
|
|
@@ -3745,6 +4069,11 @@ function makeOpenjscad(geome0) {
|
|
|
3745
4069
|
const rStr = ojscadWrite().getExportFile(paxJson);
|
|
3746
4070
|
return rStr;
|
|
3747
4071
|
}
|
|
4072
|
+
function makeFreecad(geome0) {
|
|
4073
|
+
const paxJson = paxWrite().getPaxJson({}, geome0, zeroPDef);
|
|
4074
|
+
const rStr = freecadWrite().getExportFile(paxJson);
|
|
4075
|
+
return rStr;
|
|
4076
|
+
}
|
|
3748
4077
|
async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
3749
4078
|
const zipFileWriter = new zip.BlobWriter("application/zip");
|
|
3750
4079
|
const zipWriter = new zip.ZipWriter(zipFileWriter);
|
|
@@ -3756,9 +4085,9 @@ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
|
3756
4085
|
const zLog1 = new zip.TextReader(geome1.logstr);
|
|
3757
4086
|
await zipWriter.add(`geom_${partName}_t${tSim}_log.txt`, zLog1);
|
|
3758
4087
|
for (const face in geome0.fig) {
|
|
3759
|
-
const svgOne = new zip.TextReader(figureToSvg(geome0.fig[face].
|
|
4088
|
+
const svgOne = new zip.TextReader(figureToSvg(geome0.fig[face].mainListC()));
|
|
3760
4089
|
await zipWriter.add(`face_${partName}_${face}.svg`, svgOne);
|
|
3761
|
-
const dxfOne = new zip.TextReader(figureToDxf(geome0.fig[face].
|
|
4090
|
+
const dxfOne = new zip.TextReader(figureToDxf(geome0.fig[face].mainListC()));
|
|
3762
4091
|
await zipWriter.add(`face_${partName}_${face}.dxf`, dxfOne);
|
|
3763
4092
|
const svgOneDeco = new zip.TextReader(figureToSvgDeco(geome0.fig[face]));
|
|
3764
4093
|
await zipWriter.add(`deco_${partName}_${face}.svg`, svgOneDeco);
|
|
@@ -3766,9 +4095,9 @@ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
|
3766
4095
|
await zipWriter.add(`deco_${partName}_${face}_t${tSim}.svg`, svgOneDecoT);
|
|
3767
4096
|
}
|
|
3768
4097
|
const mergedFace = mergeFaces(geome0.fig);
|
|
3769
|
-
const svgMerged = new zip.TextReader(figureToSvg(mergedFace.
|
|
4098
|
+
const svgMerged = new zip.TextReader(figureToSvg(mergedFace.mainListC()));
|
|
3770
4099
|
await zipWriter.add(`face_${partName}_all_merged.svg`, svgMerged);
|
|
3771
|
-
const dxfMerged = new zip.TextReader(figureToDxf(mergedFace.
|
|
4100
|
+
const dxfMerged = new zip.TextReader(figureToDxf(mergedFace.mainListC()));
|
|
3772
4101
|
await zipWriter.add(`face_${partName}_all_merged.dxf`, dxfMerged);
|
|
3773
4102
|
const svgMergedDeco = new zip.TextReader(figureToSvgDeco(mergedFace));
|
|
3774
4103
|
await zipWriter.add(`deco_${partName}_all_merged.svg`, svgMergedDeco);
|
|
@@ -3780,6 +4109,8 @@ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
|
3780
4109
|
await zipWriter.add(`${partName}_noarc_openscad.scad`, zSCad);
|
|
3781
4110
|
const zJScad = new zip.TextReader(makeOpenjscad(geome0));
|
|
3782
4111
|
await zipWriter.add(`${partName}_noarc_jscad.js`, zJScad);
|
|
4112
|
+
const zFreecad = new zip.TextReader(makeFreecad(geome0));
|
|
4113
|
+
await zipWriter.add(`${partName}_freecad.py`, zFreecad);
|
|
3783
4114
|
await zipWriter.close();
|
|
3784
4115
|
const rFileContent = await zipFileWriter.getData();
|
|
3785
4116
|
return rFileContent;
|
|
@@ -3795,7 +4126,8 @@ var EFormat = /* @__PURE__ */ ((EFormat2) => {
|
|
|
3795
4126
|
EFormat2[EFormat2["ePAX"] = 5] = "ePAX";
|
|
3796
4127
|
EFormat2[EFormat2["eOPENSCAD"] = 6] = "eOPENSCAD";
|
|
3797
4128
|
EFormat2[EFormat2["eJSCAD"] = 7] = "eJSCAD";
|
|
3798
|
-
EFormat2[EFormat2["
|
|
4129
|
+
EFormat2[EFormat2["eFREECAD"] = 8] = "eFREECAD";
|
|
4130
|
+
EFormat2[EFormat2["eZIP"] = 9] = "eZIP";
|
|
3799
4131
|
return EFormat2;
|
|
3800
4132
|
})(EFormat || {});
|
|
3801
4133
|
function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
|
|
@@ -3806,23 +4138,23 @@ function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
|
|
|
3806
4138
|
if (exportFormat === 0 /* eSVG */) {
|
|
3807
4139
|
if (figList.includes(eFace)) {
|
|
3808
4140
|
const figu = geome0.fig[eFace];
|
|
3809
|
-
rFileContent = figureToSvg(figu.
|
|
4141
|
+
rFileContent = figureToSvg(figu.mainListC());
|
|
3810
4142
|
} else {
|
|
3811
4143
|
console.log(`err749: fileTextContent eFace ${eFace} invalid`);
|
|
3812
4144
|
}
|
|
3813
4145
|
} else if (exportFormat === 1 /* eSVGALL */) {
|
|
3814
4146
|
const figu = mergeFaces(geome0.fig);
|
|
3815
|
-
rFileContent = figureToSvg(figu.
|
|
4147
|
+
rFileContent = figureToSvg(figu.mainListC());
|
|
3816
4148
|
} else if (exportFormat === 2 /* eDXF */) {
|
|
3817
4149
|
if (figList.includes(eFace)) {
|
|
3818
4150
|
const figu = geome0.fig[eFace];
|
|
3819
|
-
rFileContent = figureToDxf(figu.
|
|
4151
|
+
rFileContent = figureToDxf(figu.mainListC());
|
|
3820
4152
|
} else {
|
|
3821
4153
|
console.log(`err759: fileTextContent eFace ${eFace} invalid`);
|
|
3822
4154
|
}
|
|
3823
4155
|
} else if (exportFormat === 3 /* eDXFALL */) {
|
|
3824
4156
|
const figu = mergeFaces(geome0.fig);
|
|
3825
|
-
rFileContent = figureToDxf(figu.
|
|
4157
|
+
rFileContent = figureToDxf(figu.mainListC());
|
|
3826
4158
|
} else if (exportFormat === 4 /* eTXTLOG */) {
|
|
3827
4159
|
rFileContent = makeLog(geome0);
|
|
3828
4160
|
} else if (exportFormat === 5 /* ePAX */) {
|
|
@@ -3831,6 +4163,8 @@ function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
|
|
|
3831
4163
|
rFileContent = makeOpenscad(geome0);
|
|
3832
4164
|
} else if (exportFormat === 7 /* eJSCAD */) {
|
|
3833
4165
|
rFileContent = makeOpenjscad(geome0);
|
|
4166
|
+
} else if (exportFormat === 8 /* eFREECAD */) {
|
|
4167
|
+
rFileContent = makeFreecad(geome0);
|
|
3834
4168
|
} else {
|
|
3835
4169
|
console.log(`err912: unknown exportFormat ${exportFormat}`);
|
|
3836
4170
|
}
|
|
@@ -3844,7 +4178,7 @@ async function fileBinContent(fgeom, tSim, paramVal, ipDef, exportFormat) {
|
|
|
3844
4178
|
const geome1 = fgeom(tSim, paramVal);
|
|
3845
4179
|
let rFileContent = new Blob();
|
|
3846
4180
|
if (!geome0.calcErr && !geome1.calcErr) {
|
|
3847
|
-
if (exportFormat ===
|
|
4181
|
+
if (exportFormat === 9 /* eZIP */) {
|
|
3848
4182
|
rFileContent = await makeZip(paramVal, geome0, tSim, geome1, ipDef);
|
|
3849
4183
|
} else {
|
|
3850
4184
|
console.log(`err913: unknown exportFormat ${exportFormat}`);
|
|
@@ -3868,7 +4202,9 @@ function fileMime(exportFormat) {
|
|
|
3868
4202
|
rMime = "text/plain";
|
|
3869
4203
|
} else if (exportFormat === 7 /* eJSCAD */) {
|
|
3870
4204
|
rMime = "text/plain";
|
|
3871
|
-
} else if (exportFormat === 8 /*
|
|
4205
|
+
} else if (exportFormat === 8 /* eFREECAD */) {
|
|
4206
|
+
rMime = "text/plain";
|
|
4207
|
+
} else if (exportFormat === 9 /* eZIP */) {
|
|
3872
4208
|
rMime = "application/zip";
|
|
3873
4209
|
}
|
|
3874
4210
|
return rMime;
|
|
@@ -3887,14 +4223,16 @@ function fileSuffix(exportFormat) {
|
|
|
3887
4223
|
rSuffix = "_noarc_openscad.scad";
|
|
3888
4224
|
} else if (exportFormat === 7 /* eJSCAD */) {
|
|
3889
4225
|
rSuffix = "_noarc_jscad.js";
|
|
3890
|
-
} else if (exportFormat === 8 /*
|
|
4226
|
+
} else if (exportFormat === 8 /* eFREECAD */) {
|
|
4227
|
+
rSuffix = "_freecad.py";
|
|
4228
|
+
} else if (exportFormat === 9 /* eZIP */) {
|
|
3891
4229
|
rSuffix = ".zip";
|
|
3892
4230
|
}
|
|
3893
4231
|
return rSuffix;
|
|
3894
4232
|
}
|
|
3895
4233
|
function fileBin(exportFormat) {
|
|
3896
4234
|
let rBin = false;
|
|
3897
|
-
if (exportFormat ===
|
|
4235
|
+
if (exportFormat === 9 /* eZIP */) {
|
|
3898
4236
|
rBin = true;
|
|
3899
4237
|
}
|
|
3900
4238
|
return rBin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geometrix",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.39",
|
|
4
4
|
"description": "The 2D geometry engine of the parametrix",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
"clean": "shx rm -fr dist node_modules"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@zip.js/zip.js": "^2.7.
|
|
66
|
+
"@zip.js/zip.js": "^2.7.45",
|
|
67
67
|
"json5": "^2.2.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@types/node": "^20.
|
|
70
|
+
"@types/node": "^20.13.0",
|
|
71
71
|
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
|
72
72
|
"@typescript-eslint/parser": "^7.0.1",
|
|
73
73
|
"eslint": "^8.57.0",
|