geometrix 0.5.38 → 0.5.40
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 +26 -8
- package/dist/index.js +463 -74
- package/package.json +4 -4
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[];
|
|
@@ -294,6 +296,7 @@ declare abstract class AContour {
|
|
|
294
296
|
abstract toPax(): tPaxContour;
|
|
295
297
|
abstract getPerimeter(): number;
|
|
296
298
|
}
|
|
299
|
+
declare function midArcPoint(px1: number, py1: number, seg: Segment1): Point;
|
|
297
300
|
/**
|
|
298
301
|
* class `Contour`
|
|
299
302
|
*
|
|
@@ -403,11 +406,15 @@ interface tLayers {
|
|
|
403
406
|
ruler: boolean;
|
|
404
407
|
refframe: boolean;
|
|
405
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* The face-type is a list of contours. The first contour is the outer, the remaining are the inner contours
|
|
411
|
+
*/
|
|
412
|
+
type tOuterInner = tContour[];
|
|
406
413
|
declare class Figure {
|
|
407
414
|
pointList: Point[];
|
|
408
415
|
lineList: Line[];
|
|
409
416
|
vectorList: Vector[];
|
|
410
|
-
mainList:
|
|
417
|
+
mainList: tOuterInner[];
|
|
411
418
|
mainBList: tContour[];
|
|
412
419
|
secondList: tContour[];
|
|
413
420
|
secondBList: tContour[];
|
|
@@ -422,13 +429,23 @@ declare class Figure {
|
|
|
422
429
|
addLine(iline: Line): void;
|
|
423
430
|
addLines(ilines: Line[]): void;
|
|
424
431
|
addVector(ivector: Vector): void;
|
|
425
|
-
|
|
432
|
+
/**
|
|
433
|
+
* add one Outer contour and several Inner contours to the Main Layer
|
|
434
|
+
* @param {tOuterInner} iFace - the Face (i.e one Outer and several Inner contours) to be added
|
|
435
|
+
*/
|
|
436
|
+
addMainOI(iFace: tOuterInner): void;
|
|
437
|
+
/**
|
|
438
|
+
* add one Outer contour to the Main Layer
|
|
439
|
+
* @param {tContour} iFace - the Face (without inner contours) to be added
|
|
440
|
+
*/
|
|
441
|
+
addMainO(iFace: tContour): void;
|
|
426
442
|
addSecond(icontour: tContour): void;
|
|
427
443
|
addDynamics(icontour: tContour): void;
|
|
428
444
|
translate(ix: number, iy: number): Figure;
|
|
429
445
|
translatePolar(ia: number, il: number): Figure;
|
|
430
446
|
rotate(ix: number, iy: number, ia: number): Figure;
|
|
431
447
|
mergeFigure(ifig: Figure, mainToSecond?: boolean): void;
|
|
448
|
+
mainListC(): tContour[];
|
|
432
449
|
clear(): void;
|
|
433
450
|
/** @internal */
|
|
434
451
|
getMinMax(): void;
|
|
@@ -440,9 +457,9 @@ declare class Figure {
|
|
|
440
457
|
draw(ctx: CanvasRenderingContext2D, adjust: tCanvasAdjust, layers: tLayers): void;
|
|
441
458
|
}
|
|
442
459
|
declare function figure(): Figure;
|
|
443
|
-
type
|
|
460
|
+
type tFigures = Record<string, Figure>;
|
|
444
461
|
/** For cli-app and ui-app */
|
|
445
|
-
declare function mergeFaces(
|
|
462
|
+
declare function mergeFaces(iFigures: tFigures): Figure;
|
|
446
463
|
declare function initLayers(): tLayers;
|
|
447
464
|
declare function copyLayers(iLayers: tLayers): tLayers;
|
|
448
465
|
|
|
@@ -524,7 +541,7 @@ interface tGeom {
|
|
|
524
541
|
partName: string;
|
|
525
542
|
calcErr: boolean;
|
|
526
543
|
logstr: string;
|
|
527
|
-
fig:
|
|
544
|
+
fig: tFigures;
|
|
528
545
|
vol: tVolume;
|
|
529
546
|
sub: tSubDesign;
|
|
530
547
|
}
|
|
@@ -587,7 +604,8 @@ declare enum EFormat {
|
|
|
587
604
|
ePAX = 5,
|
|
588
605
|
eOPENSCAD = 6,
|
|
589
606
|
eJSCAD = 7,
|
|
590
|
-
|
|
607
|
+
eFREECAD = 8,
|
|
608
|
+
eZIP = 9
|
|
591
609
|
}
|
|
592
610
|
declare function fileTextContent(fgeom: tGeomFunc, paramVal: tParamVal, ipDef: tParamDef, eFace: string, exportFormat: EFormat): string;
|
|
593
611
|
declare function fileBinContent(fgeom: tGeomFunc, tSim: number, paramVal: tParamVal, ipDef: tParamDef, exportFormat: EFormat): Promise<Blob>;
|
|
@@ -657,4 +675,4 @@ declare function version_details(appPackage: tPackage): string[];
|
|
|
657
675
|
|
|
658
676
|
declare function checkImpPages(pages: tAllPageDef): [boolean, string];
|
|
659
677
|
|
|
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
|
|
678
|
+
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, midArcPoint, 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",
|
|
@@ -1672,6 +1673,17 @@ function paxPath() {
|
|
|
1672
1673
|
// src/contour.ts
|
|
1673
1674
|
var AContour = class {
|
|
1674
1675
|
};
|
|
1676
|
+
function midArcPoint(px1, py1, seg) {
|
|
1677
|
+
const seg2 = arcSeg1To2(px1, py1, seg);
|
|
1678
|
+
const p3 = point(seg2.pc.cx, seg2.pc.cy);
|
|
1679
|
+
const a12h = withinPiPi((seg2.a2 - seg2.a1) / 2);
|
|
1680
|
+
let a3 = seg2.a1 + a12h;
|
|
1681
|
+
if (Math.sign(a12h) > 0 && !seg.arcCcw || Math.sign(a12h) < 0 && seg.arcCcw) {
|
|
1682
|
+
a3 += Math.PI;
|
|
1683
|
+
}
|
|
1684
|
+
const p4 = p3.translatePolar(a3, seg.radius);
|
|
1685
|
+
return p4;
|
|
1686
|
+
}
|
|
1675
1687
|
var Contour = class _Contour extends AContour {
|
|
1676
1688
|
/** @internal */
|
|
1677
1689
|
circle = false;
|
|
@@ -2212,14 +2224,7 @@ var Contour = class _Contour extends AContour {
|
|
|
2212
2224
|
for (const seg of this.segments) {
|
|
2213
2225
|
if (seg.sType === 1 /* eArc */) {
|
|
2214
2226
|
try {
|
|
2215
|
-
const
|
|
2216
|
-
const p3 = point(seg2.pc.cx, seg2.pc.cy);
|
|
2217
|
-
const a12h = withinPiPi((seg2.a2 - seg2.a1) / 2);
|
|
2218
|
-
let a3 = seg2.a1 + a12h;
|
|
2219
|
-
if (Math.sign(a12h) > 0 && !seg.arcCcw || Math.sign(a12h) < 0 && seg.arcCcw) {
|
|
2220
|
-
a3 += Math.PI;
|
|
2221
|
-
}
|
|
2222
|
-
const p4 = p3.translatePolar(a3, seg.radius);
|
|
2227
|
+
const p4 = midArcPoint(px1, py1, seg);
|
|
2223
2228
|
rPoints.push(p4);
|
|
2224
2229
|
} catch (emsg) {
|
|
2225
2230
|
console.log("err453: " + emsg);
|
|
@@ -2493,12 +2498,28 @@ var Figure = class _Figure {
|
|
|
2493
2498
|
addVector(ivector) {
|
|
2494
2499
|
this.vectorList.push(ivector);
|
|
2495
2500
|
}
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2501
|
+
/**
|
|
2502
|
+
* add one Outer contour and several Inner contours to the Main Layer
|
|
2503
|
+
* @param {tOuterInner} iFace - the Face (i.e one Outer and several Inner contours) to be added
|
|
2504
|
+
*/
|
|
2505
|
+
addMainOI(iFace) {
|
|
2506
|
+
const oneFace = [];
|
|
2507
|
+
for (const oneCtr of iFace) {
|
|
2508
|
+
const roundedContour = oneCtr.generateContour();
|
|
2509
|
+
this.addPoints(roundedContour.generatePoints());
|
|
2510
|
+
this.addLines(roundedContour.generateLines());
|
|
2511
|
+
oneFace.push(roundedContour);
|
|
2512
|
+
this.mainBList.push(oneCtr.extractSkeleton());
|
|
2513
|
+
}
|
|
2514
|
+
this.mainList.push(oneFace);
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* add one Outer contour to the Main Layer
|
|
2518
|
+
* @param {tContour} iFace - the Face (without inner contours) to be added
|
|
2519
|
+
*/
|
|
2520
|
+
addMainO(iFace) {
|
|
2521
|
+
const face = [iFace];
|
|
2522
|
+
this.addMainOI(face);
|
|
2502
2523
|
}
|
|
2503
2524
|
addSecond(icontour) {
|
|
2504
2525
|
const roundedContour = icontour.generateContour();
|
|
@@ -2523,8 +2544,12 @@ var Figure = class _Figure {
|
|
|
2523
2544
|
for (const vec of this.vectorList) {
|
|
2524
2545
|
rfig.addVector(vec.translate(ix, iy));
|
|
2525
2546
|
}
|
|
2526
|
-
for (const
|
|
2527
|
-
|
|
2547
|
+
for (const face of this.mainList) {
|
|
2548
|
+
const oneFace = [];
|
|
2549
|
+
for (const ctr of face) {
|
|
2550
|
+
oneFace.push(ctr.translate(ix, iy));
|
|
2551
|
+
}
|
|
2552
|
+
rfig.addMainOI(oneFace);
|
|
2528
2553
|
}
|
|
2529
2554
|
for (const ctr of this.secondList) {
|
|
2530
2555
|
rfig.addSecond(ctr.translate(ix, iy));
|
|
@@ -2549,8 +2574,12 @@ var Figure = class _Figure {
|
|
|
2549
2574
|
for (const vec of this.vectorList) {
|
|
2550
2575
|
rfig.addVector(vec.rotate(pt0, ia));
|
|
2551
2576
|
}
|
|
2552
|
-
for (const
|
|
2553
|
-
|
|
2577
|
+
for (const face of this.mainList) {
|
|
2578
|
+
const oneFace = [];
|
|
2579
|
+
for (const ctr of face) {
|
|
2580
|
+
oneFace.push(ctr.rotate(ix, iy, ia));
|
|
2581
|
+
}
|
|
2582
|
+
rfig.addMainOI(oneFace);
|
|
2554
2583
|
}
|
|
2555
2584
|
for (const ctr of this.secondList) {
|
|
2556
2585
|
rfig.addSecond(ctr.rotate(ix, iy, ia));
|
|
@@ -2570,11 +2599,17 @@ var Figure = class _Figure {
|
|
|
2570
2599
|
for (const vec of ifig.vectorList) {
|
|
2571
2600
|
this.addVector(vec.clone());
|
|
2572
2601
|
}
|
|
2573
|
-
for (const
|
|
2602
|
+
for (const face of ifig.mainList) {
|
|
2603
|
+
const oneFace = [];
|
|
2604
|
+
for (const ctr of face) {
|
|
2605
|
+
oneFace.push(ctr.clone());
|
|
2606
|
+
}
|
|
2574
2607
|
if (mainToSecond) {
|
|
2575
|
-
|
|
2608
|
+
for (const ctr of oneFace) {
|
|
2609
|
+
this.addSecond(ctr);
|
|
2610
|
+
}
|
|
2576
2611
|
} else {
|
|
2577
|
-
this.
|
|
2612
|
+
this.addMainOI(oneFace);
|
|
2578
2613
|
}
|
|
2579
2614
|
}
|
|
2580
2615
|
for (const ctr of ifig.secondList) {
|
|
@@ -2584,6 +2619,15 @@ var Figure = class _Figure {
|
|
|
2584
2619
|
this.addDynamics(ctr.clone());
|
|
2585
2620
|
}
|
|
2586
2621
|
}
|
|
2622
|
+
mainListC() {
|
|
2623
|
+
const rListC = [];
|
|
2624
|
+
for (const face of this.mainList) {
|
|
2625
|
+
for (const ctr of face) {
|
|
2626
|
+
rListC.push(ctr);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
return rListC;
|
|
2630
|
+
}
|
|
2587
2631
|
clear() {
|
|
2588
2632
|
this.pointList = [];
|
|
2589
2633
|
this.lineList = [];
|
|
@@ -2676,8 +2720,14 @@ var Figure = class _Figure {
|
|
|
2676
2720
|
}
|
|
2677
2721
|
}
|
|
2678
2722
|
if (layers.main) {
|
|
2679
|
-
for (const
|
|
2680
|
-
|
|
2723
|
+
for (const face of this.mainList) {
|
|
2724
|
+
for (const [idx, li] of face.entries()) {
|
|
2725
|
+
let ctrColor = colors.mainOuter;
|
|
2726
|
+
if (idx > 0) {
|
|
2727
|
+
ctrColor = colors.mainInner;
|
|
2728
|
+
}
|
|
2729
|
+
li.draw(ctx, adjust, ctrColor);
|
|
2730
|
+
}
|
|
2681
2731
|
}
|
|
2682
2732
|
}
|
|
2683
2733
|
if (layers.mainB) {
|
|
@@ -2717,10 +2767,10 @@ var Figure = class _Figure {
|
|
|
2717
2767
|
function figure() {
|
|
2718
2768
|
return new Figure();
|
|
2719
2769
|
}
|
|
2720
|
-
function mergeFaces(
|
|
2770
|
+
function mergeFaces(iFigures) {
|
|
2721
2771
|
const rfig = figure();
|
|
2722
|
-
for (const
|
|
2723
|
-
const fig =
|
|
2772
|
+
for (const ifig in iFigures) {
|
|
2773
|
+
const fig = iFigures[ifig];
|
|
2724
2774
|
for (const ipoint of fig.pointList) {
|
|
2725
2775
|
rfig.pointList.push(ipoint);
|
|
2726
2776
|
}
|
|
@@ -2730,8 +2780,8 @@ function mergeFaces(iFaces) {
|
|
|
2730
2780
|
for (const ivector of fig.vectorList) {
|
|
2731
2781
|
rfig.vectorList.push(ivector);
|
|
2732
2782
|
}
|
|
2733
|
-
for (const
|
|
2734
|
-
rfig.mainList.push(
|
|
2783
|
+
for (const face of fig.mainList) {
|
|
2784
|
+
rfig.mainList.push(face);
|
|
2735
2785
|
}
|
|
2736
2786
|
for (const ctr of fig.mainBList) {
|
|
2737
2787
|
rfig.mainBList.push(ctr);
|
|
@@ -3005,10 +3055,14 @@ function prefixLog(iLog, iPartName) {
|
|
|
3005
3055
|
// src/write_pax.ts
|
|
3006
3056
|
var PaxWrite = class {
|
|
3007
3057
|
//constructor() {}
|
|
3008
|
-
figureToPaxF(
|
|
3058
|
+
figureToPaxF(aFaces) {
|
|
3009
3059
|
const rPaxF = [];
|
|
3010
|
-
for (const
|
|
3011
|
-
|
|
3060
|
+
for (const face of aFaces) {
|
|
3061
|
+
const oneFace = [];
|
|
3062
|
+
for (const ctr of face) {
|
|
3063
|
+
oneFace.push(ctr.toPax());
|
|
3064
|
+
}
|
|
3065
|
+
rPaxF.push(oneFace);
|
|
3012
3066
|
}
|
|
3013
3067
|
return rPaxF;
|
|
3014
3068
|
}
|
|
@@ -3025,7 +3079,7 @@ var PaxWrite = class {
|
|
|
3025
3079
|
partName: geome0.partName,
|
|
3026
3080
|
pDef: ipDef,
|
|
3027
3081
|
params: paramVal,
|
|
3028
|
-
|
|
3082
|
+
figures: this.getFigures(geome0.fig),
|
|
3029
3083
|
volume: geome0.vol,
|
|
3030
3084
|
subs: geome0.sub,
|
|
3031
3085
|
log: geome0.logstr
|
|
@@ -3051,6 +3105,17 @@ function convTypePaxToSeg1(paxType) {
|
|
|
3051
3105
|
}
|
|
3052
3106
|
return rType;
|
|
3053
3107
|
}
|
|
3108
|
+
function convPaxToSeg1(seg) {
|
|
3109
|
+
const rSeg1 = new Segment1(
|
|
3110
|
+
convTypePaxToSeg1(seg.typ),
|
|
3111
|
+
seg.px,
|
|
3112
|
+
seg.py,
|
|
3113
|
+
seg.radius,
|
|
3114
|
+
seg.large,
|
|
3115
|
+
seg.ccw
|
|
3116
|
+
);
|
|
3117
|
+
return rSeg1;
|
|
3118
|
+
}
|
|
3054
3119
|
|
|
3055
3120
|
// src/arc_to_stroke.ts
|
|
3056
3121
|
function calcAngleStep(max_angle, max_length, radius, arc_angle) {
|
|
@@ -3201,26 +3266,28 @@ var OpenscadWrite = class {
|
|
|
3201
3266
|
const rStr = "// Generated by Parametrix\n";
|
|
3202
3267
|
return rStr;
|
|
3203
3268
|
}
|
|
3204
|
-
getOneFigure(
|
|
3269
|
+
getOneFigure(aFaces, faceId) {
|
|
3205
3270
|
const oscadWF = new OpenscadWriteFigure();
|
|
3206
|
-
for (const
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3271
|
+
for (const paxFace of aFaces) {
|
|
3272
|
+
for (const paxCtr of paxFace) {
|
|
3273
|
+
if (paxCtr.circle === true) {
|
|
3274
|
+
const paxCircle2 = paxCtr;
|
|
3275
|
+
const oscadSeg = oscadSegCircle(paxCircle2.cx, paxCircle2.cy, paxCircle2.radius);
|
|
3276
|
+
oscadWF.addContour(oscadSeg);
|
|
3277
|
+
} else {
|
|
3278
|
+
const paxPath2 = paxCtr;
|
|
3279
|
+
const oscadSeg = toOpenscadSeg(paxPath2.seg);
|
|
3280
|
+
oscadWF.addContour(oscadSeg);
|
|
3281
|
+
}
|
|
3215
3282
|
}
|
|
3216
3283
|
}
|
|
3217
3284
|
const rOscadF = oscadWF.getFigure(faceId);
|
|
3218
3285
|
return rOscadF;
|
|
3219
3286
|
}
|
|
3220
|
-
getAllFigures(
|
|
3287
|
+
getAllFigures(figures, partName) {
|
|
3221
3288
|
let rStr = "";
|
|
3222
|
-
for (const face in
|
|
3223
|
-
const figu = this.getOneFigure(
|
|
3289
|
+
for (const face in figures) {
|
|
3290
|
+
const figu = this.getOneFigure(figures[face], `${partName}_${face}`);
|
|
3224
3291
|
rStr += figu;
|
|
3225
3292
|
}
|
|
3226
3293
|
return rStr;
|
|
@@ -3331,7 +3398,7 @@ module ${inherit.outName} () {
|
|
|
3331
3398
|
const subGeoms = this.getAllSubGeoms(vol.inherits);
|
|
3332
3399
|
for (const oneGeom of subGeoms) {
|
|
3333
3400
|
const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
|
|
3334
|
-
rStr += this.getAllFigures(paxJson.
|
|
3401
|
+
rStr += this.getAllFigures(paxJson.figures, paxJson.partName);
|
|
3335
3402
|
rStr += this.getVolume(oneGeom.vol);
|
|
3336
3403
|
}
|
|
3337
3404
|
rStr += this.getAllInherits(vol.inherits);
|
|
@@ -3348,7 +3415,7 @@ pax_${partName}();
|
|
|
3348
3415
|
}
|
|
3349
3416
|
getExportFile(pax) {
|
|
3350
3417
|
let rStr = this.getHeader();
|
|
3351
|
-
rStr += this.getAllFigures(pax.
|
|
3418
|
+
rStr += this.getAllFigures(pax.figures, pax.partName);
|
|
3352
3419
|
rStr += this.getVolume(pax.volume);
|
|
3353
3420
|
rStr += this.getFooter(pax.partName);
|
|
3354
3421
|
return rStr;
|
|
@@ -3464,17 +3531,19 @@ const main = () => {
|
|
|
3464
3531
|
`;
|
|
3465
3532
|
return rStr;
|
|
3466
3533
|
}
|
|
3467
|
-
getOneFigure(
|
|
3534
|
+
getOneFigure(aFaces, faceId) {
|
|
3468
3535
|
const ojscadWF = new OjscadWriteFigure();
|
|
3469
|
-
for (const
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3536
|
+
for (const paxFace of aFaces) {
|
|
3537
|
+
for (const paxCtr of paxFace) {
|
|
3538
|
+
if (paxCtr.circle === true) {
|
|
3539
|
+
const paxCircle2 = paxCtr;
|
|
3540
|
+
const ojscadSeg = ojscadSegCircle(paxCircle2.cx, paxCircle2.cy, paxCircle2.radius);
|
|
3541
|
+
ojscadWF.addContour(ojscadSeg);
|
|
3542
|
+
} else {
|
|
3543
|
+
const paxPath2 = paxCtr;
|
|
3544
|
+
const ojscadSeg = toOpenjscadSeg(paxPath2.seg);
|
|
3545
|
+
ojscadWF.addContour(ojscadSeg);
|
|
3546
|
+
}
|
|
3478
3547
|
}
|
|
3479
3548
|
}
|
|
3480
3549
|
const rOjscadF = ojscadWF.getFigure(faceId);
|
|
@@ -3580,7 +3649,7 @@ const ${inherit.outName} =
|
|
|
3580
3649
|
const subGeoms = this.getAllSubGeoms(vol.inherits);
|
|
3581
3650
|
for (const oneGeom of subGeoms) {
|
|
3582
3651
|
const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
|
|
3583
|
-
rStr += this.getAllFigures(paxJson.
|
|
3652
|
+
rStr += this.getAllFigures(paxJson.figures, paxJson.partName);
|
|
3584
3653
|
rStr += this.getVolume(oneGeom.vol);
|
|
3585
3654
|
}
|
|
3586
3655
|
rStr += this.getAllInherits(vol.inherits);
|
|
@@ -3599,7 +3668,7 @@ module.exports = { main };
|
|
|
3599
3668
|
}
|
|
3600
3669
|
getExportFile(pax) {
|
|
3601
3670
|
let rStr = this.getHeader();
|
|
3602
|
-
rStr += this.getAllFigures(pax.
|
|
3671
|
+
rStr += this.getAllFigures(pax.figures, pax.partName);
|
|
3603
3672
|
rStr += this.getVolume(pax.volume);
|
|
3604
3673
|
rStr += this.getFooter(pax.partName);
|
|
3605
3674
|
return rStr;
|
|
@@ -3610,6 +3679,311 @@ function ojscadWrite() {
|
|
|
3610
3679
|
return rOjscadWrite;
|
|
3611
3680
|
}
|
|
3612
3681
|
|
|
3682
|
+
// src/write_freecad.ts
|
|
3683
|
+
function ff6(ifloat) {
|
|
3684
|
+
return ifloat.toFixed(4);
|
|
3685
|
+
}
|
|
3686
|
+
function fid(iIdx) {
|
|
3687
|
+
return iIdx.toString().padStart(3, "0");
|
|
3688
|
+
}
|
|
3689
|
+
function fcFaceCircle(cx, cy, radius, outName) {
|
|
3690
|
+
const rStr = `def ${outName}():
|
|
3691
|
+
# Radius, XYZ-position, orientation
|
|
3692
|
+
aCircle = Part.makeCircle(${ff6(radius)}, App.Vector(${ff6(cx)}, ${ff6(cy)}, 0), App.Vector(0, 0, 1))
|
|
3693
|
+
aWire = Part.Wire(aCircle)
|
|
3694
|
+
rFace = Part.Face(aWire)
|
|
3695
|
+
return rFace
|
|
3696
|
+
|
|
3697
|
+
`;
|
|
3698
|
+
return rStr;
|
|
3699
|
+
}
|
|
3700
|
+
function fcFaceContour(paxCtr, outName) {
|
|
3701
|
+
let rStr = `def ${outName}():
|
|
3702
|
+
`;
|
|
3703
|
+
let px1 = 0;
|
|
3704
|
+
let py1 = 0;
|
|
3705
|
+
let pIdx = 0;
|
|
3706
|
+
let sIdx = 0;
|
|
3707
|
+
for (const seg of paxCtr) {
|
|
3708
|
+
if (seg.typ === 0 /* eStart */) {
|
|
3709
|
+
rStr += ` P${fid(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
|
|
3710
|
+
`;
|
|
3711
|
+
pIdx += 1;
|
|
3712
|
+
} else if (seg.typ === 1 /* eStroke */) {
|
|
3713
|
+
rStr += ` P${fid(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
|
|
3714
|
+
`;
|
|
3715
|
+
rStr += ` S${fid(sIdx)} = Part.LineSegment(P${fid(pIdx - 1)}, P${fid(pIdx)})
|
|
3716
|
+
`;
|
|
3717
|
+
pIdx += 1;
|
|
3718
|
+
sIdx += 1;
|
|
3719
|
+
} else if (seg.typ === 2 /* eArc */) {
|
|
3720
|
+
try {
|
|
3721
|
+
const seg1 = convPaxToSeg1(seg);
|
|
3722
|
+
const p4 = midArcPoint(px1, py1, seg1);
|
|
3723
|
+
rStr += ` P${fid(pIdx)} = App.Vector(${ff6(p4.cx)}, ${ff6(p4.cy)}, 0)
|
|
3724
|
+
`;
|
|
3725
|
+
pIdx += 1;
|
|
3726
|
+
} catch (emsg) {
|
|
3727
|
+
console.log("err730: " + emsg);
|
|
3728
|
+
}
|
|
3729
|
+
rStr += ` P${fid(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
|
|
3730
|
+
`;
|
|
3731
|
+
rStr += ` S${fid(sIdx)} = Part.Arc(P${fid(pIdx - 2)}, P${fid(pIdx - 1)}, P${fid(pIdx)})
|
|
3732
|
+
`;
|
|
3733
|
+
pIdx += 1;
|
|
3734
|
+
sIdx += 1;
|
|
3735
|
+
}
|
|
3736
|
+
px1 = seg.px;
|
|
3737
|
+
py1 = seg.py;
|
|
3738
|
+
}
|
|
3739
|
+
const segList = Array.from({ length: sIdx }, (v, i) => `S${fid(i)}`);
|
|
3740
|
+
rStr += ` aShape = Part.Shape([${segList.join(", ")}])
|
|
3741
|
+
aWire = Part.Wire(aShape.Edges)
|
|
3742
|
+
subFace = Part.Face(aWire)
|
|
3743
|
+
subFace.check()
|
|
3744
|
+
return subFace
|
|
3745
|
+
|
|
3746
|
+
`;
|
|
3747
|
+
return rStr;
|
|
3748
|
+
}
|
|
3749
|
+
function fcOneFace(ctrNames, outName) {
|
|
3750
|
+
let rStr = `def ${outName}():
|
|
3751
|
+
`;
|
|
3752
|
+
const ctrShorts = [];
|
|
3753
|
+
for (const [idx, ctr] of ctrNames.entries()) {
|
|
3754
|
+
const short = `FC${fid(idx)}`;
|
|
3755
|
+
rStr += ` ${short} = ${ctr}()
|
|
3756
|
+
`;
|
|
3757
|
+
ctrShorts.push(short);
|
|
3758
|
+
}
|
|
3759
|
+
const outer = ctrShorts[0];
|
|
3760
|
+
const inner = ctrShorts.slice(1);
|
|
3761
|
+
if (inner.length > 0) {
|
|
3762
|
+
rStr += ` rOneFace = ${outer}.cut([${inner.join(", ")}])
|
|
3763
|
+
`;
|
|
3764
|
+
} else {
|
|
3765
|
+
rStr += ` rOneFace = ${outer}
|
|
3766
|
+
`;
|
|
3767
|
+
}
|
|
3768
|
+
rStr += ` rOneFace.check()
|
|
3769
|
+
return rOneFace
|
|
3770
|
+
|
|
3771
|
+
`;
|
|
3772
|
+
return rStr;
|
|
3773
|
+
}
|
|
3774
|
+
function fcOneFig(faceNames, outName) {
|
|
3775
|
+
let rStr = `def ${outName}():
|
|
3776
|
+
`;
|
|
3777
|
+
const faceShorts = [];
|
|
3778
|
+
for (const [idx, face] of faceNames.entries()) {
|
|
3779
|
+
const short = `FA${fid(idx)}`;
|
|
3780
|
+
rStr += ` ${short} = ${face}()
|
|
3781
|
+
`;
|
|
3782
|
+
faceShorts.push(short);
|
|
3783
|
+
}
|
|
3784
|
+
const firstFace = faceShorts[0];
|
|
3785
|
+
const otherFace = faceShorts.slice(1);
|
|
3786
|
+
if (otherFace.length > 0) {
|
|
3787
|
+
rStr += ` rOneFig = ${firstFace}.fuse([${otherFace.join(", ")}])
|
|
3788
|
+
`;
|
|
3789
|
+
} else {
|
|
3790
|
+
rStr += ` rOneFig = ${firstFace}
|
|
3791
|
+
`;
|
|
3792
|
+
}
|
|
3793
|
+
rStr += ` rOneFig.check()
|
|
3794
|
+
return rOneFig
|
|
3795
|
+
|
|
3796
|
+
`;
|
|
3797
|
+
return rStr;
|
|
3798
|
+
}
|
|
3799
|
+
var FreecadWrite = class {
|
|
3800
|
+
//constructor() {}
|
|
3801
|
+
getHeader(outFileName) {
|
|
3802
|
+
const rStr = `# freecad-python generated by Parametrix
|
|
3803
|
+
# run the script with:
|
|
3804
|
+
# freecad.cmd myScript.py
|
|
3805
|
+
|
|
3806
|
+
import FreeCAD as App
|
|
3807
|
+
import Part
|
|
3808
|
+
|
|
3809
|
+
#print(sys.argv)
|
|
3810
|
+
outFileName = "${outFileName}"
|
|
3811
|
+
if (len(sys.argv) == 3):
|
|
3812
|
+
outFileName = sys.argv[2]
|
|
3813
|
+
print(f"outFileName: {outFileName}")
|
|
3814
|
+
|
|
3815
|
+
`;
|
|
3816
|
+
return rStr;
|
|
3817
|
+
}
|
|
3818
|
+
getOneFigure(aFaces, figName) {
|
|
3819
|
+
let rStr = "";
|
|
3820
|
+
const figFaceList = [];
|
|
3821
|
+
for (const [faceIdx, paxFace] of aFaces.entries()) {
|
|
3822
|
+
const faceName = `face_${figName}_Fa${faceIdx}`;
|
|
3823
|
+
const faceCtrList = [];
|
|
3824
|
+
for (const [ctrIdx, paxCtr] of paxFace.entries()) {
|
|
3825
|
+
const subFaceName = `ctr_${faceName}_Ctr${ctrIdx}`;
|
|
3826
|
+
if (paxCtr.circle === true) {
|
|
3827
|
+
const paxCircle2 = paxCtr;
|
|
3828
|
+
rStr += fcFaceCircle(paxCircle2.cx, paxCircle2.cy, paxCircle2.radius, subFaceName);
|
|
3829
|
+
} else {
|
|
3830
|
+
const paxPath2 = paxCtr;
|
|
3831
|
+
rStr += fcFaceContour(paxPath2.seg, subFaceName);
|
|
3832
|
+
}
|
|
3833
|
+
faceCtrList.push(subFaceName);
|
|
3834
|
+
}
|
|
3835
|
+
rStr += fcOneFace(faceCtrList, faceName);
|
|
3836
|
+
figFaceList.push(faceName);
|
|
3837
|
+
}
|
|
3838
|
+
rStr += fcOneFig(figFaceList, figName);
|
|
3839
|
+
return rStr;
|
|
3840
|
+
}
|
|
3841
|
+
getAllFigures(figs, partName) {
|
|
3842
|
+
let rStr = "";
|
|
3843
|
+
for (const ifig in figs) {
|
|
3844
|
+
const figu = this.getOneFigure(figs[ifig], `${partName}_${ifig}`);
|
|
3845
|
+
rStr += figu;
|
|
3846
|
+
}
|
|
3847
|
+
return rStr;
|
|
3848
|
+
}
|
|
3849
|
+
getOneExtrude(extrud) {
|
|
3850
|
+
let rStr = `def fex_${extrud.outName}():
|
|
3851
|
+
FIG = ${extrud.face}()
|
|
3852
|
+
`;
|
|
3853
|
+
if (extrud.extrudeMethod === 0 /* eLinearOrtho */) {
|
|
3854
|
+
if (extrud.length === void 0) {
|
|
3855
|
+
console.log(
|
|
3856
|
+
`err103: ${extrud.face} ${extrud.outName} design error: eLinearOrtho length undefined!`
|
|
3857
|
+
);
|
|
3858
|
+
}
|
|
3859
|
+
rStr += ` VEX = FIG.extrude(App.Vector(0, 0, ${extrud.length}))`;
|
|
3860
|
+
} else if (extrud.extrudeMethod === 1 /* eRotate */) {
|
|
3861
|
+
rStr += ` VEX = FIG.rotate(App.Vector(0, 0, 0), App.Vector(1, 0, 0), 90).revolve(App.Vector(0, 0, 0), App.Vector(0, 0, 1), 360)`;
|
|
3862
|
+
}
|
|
3863
|
+
rStr += `
|
|
3864
|
+
VR1 = VEX.rotate(App.Vector(0, 0, 0), App.Vector(1, 0, 0), ${radToDeg(extrud.rotate[0])})
|
|
3865
|
+
VR2 = VR1.rotate(App.Vector(0, 0, 0), App.Vector(0, 1, 0), ${radToDeg(extrud.rotate[1])})
|
|
3866
|
+
VR3 = VR2.rotate(App.Vector(0, 0, 0), App.Vector(0, 0, 1), ${radToDeg(extrud.rotate[2])})
|
|
3867
|
+
VFP = VR3.translate(App.Vector(${extrud.translate[0]}, ${extrud.translate[1]}, ${extrud.translate[2]}))
|
|
3868
|
+
return VFP
|
|
3869
|
+
${extrud.outName} = fex_${extrud.outName}()
|
|
3870
|
+
|
|
3871
|
+
`;
|
|
3872
|
+
return rStr;
|
|
3873
|
+
}
|
|
3874
|
+
getAllExtrudes(extrudes) {
|
|
3875
|
+
let rStr = "";
|
|
3876
|
+
for (const extrud of extrudes) {
|
|
3877
|
+
const subp = this.getOneExtrude(extrud);
|
|
3878
|
+
rStr += subp;
|
|
3879
|
+
}
|
|
3880
|
+
return rStr;
|
|
3881
|
+
}
|
|
3882
|
+
getOneVolume(volum) {
|
|
3883
|
+
let rStr = "";
|
|
3884
|
+
if (volum.inList.length === 0) {
|
|
3885
|
+
console.log(`err215: ${volum.outName} has an empty inList`);
|
|
3886
|
+
} else if (volum.inList.length === 1) {
|
|
3887
|
+
rStr += `${volum.outName} = ${volum.inList[0]}
|
|
3888
|
+
`;
|
|
3889
|
+
} else {
|
|
3890
|
+
const firstV = volum.inList[0];
|
|
3891
|
+
const othersV = volum.inList.slice(1);
|
|
3892
|
+
switch (volum.boolMethod) {
|
|
3893
|
+
case 0 /* eIdentity */:
|
|
3894
|
+
rStr += `${volum.outName} = ${firstV}
|
|
3895
|
+
`;
|
|
3896
|
+
break;
|
|
3897
|
+
case 1 /* eIntersection */:
|
|
3898
|
+
rStr += `${volum.outName} = ${firstV}.common([${othersV.join(", ")}])
|
|
3899
|
+
`;
|
|
3900
|
+
break;
|
|
3901
|
+
case 2 /* eUnion */:
|
|
3902
|
+
rStr += `${volum.outName} = ${firstV}.fuse([${othersV.join(", ")}])
|
|
3903
|
+
`;
|
|
3904
|
+
break;
|
|
3905
|
+
case 3 /* eSubstraction */:
|
|
3906
|
+
rStr += `${volum.outName} = ${firstV}.cut([${othersV.join(", ")}])
|
|
3907
|
+
`;
|
|
3908
|
+
break;
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
return rStr;
|
|
3912
|
+
}
|
|
3913
|
+
getAllVolumes(volumes) {
|
|
3914
|
+
let rStr = "";
|
|
3915
|
+
for (const volum of volumes) {
|
|
3916
|
+
const subp = this.getOneVolume(volum);
|
|
3917
|
+
rStr += subp;
|
|
3918
|
+
}
|
|
3919
|
+
return rStr;
|
|
3920
|
+
}
|
|
3921
|
+
getAllSubGeoms(inherits) {
|
|
3922
|
+
const rGeoms = [];
|
|
3923
|
+
for (const inher of inherits) {
|
|
3924
|
+
if (!rGeoms.includes(inher.subgeom)) {
|
|
3925
|
+
rGeoms.push(inher.subgeom);
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
return rGeoms;
|
|
3929
|
+
}
|
|
3930
|
+
getOneInherit(inherit) {
|
|
3931
|
+
const rStr = `
|
|
3932
|
+
IVR1_${inherit.subdesign} = ${inherit.subdesign}.rotate(App.Vector(0, 0, 0), App.Vector(1, 0, 0), ${radToDeg(inherit.rotate[0])})
|
|
3933
|
+
IVR2_${inherit.subdesign} = IVR1_${inherit.subdesign}.rotate(App.Vector(0, 0, 0), App.Vector(0, 1, 0), ${radToDeg(inherit.rotate[1])})
|
|
3934
|
+
IVR3_${inherit.subdesign} = IVR2_${inherit.subdesign}.rotate(App.Vector(0, 0, 0), App.Vector(0, 0, 1), ${radToDeg(inherit.rotate[2])})
|
|
3935
|
+
${inherit.outName} = IVR3_${inherit.subdesign}.translate(App.Vector(${inherit.translate[0]}, ${inherit.translate[1]}, ${inherit.translate[2]}))
|
|
3936
|
+
|
|
3937
|
+
`;
|
|
3938
|
+
return rStr;
|
|
3939
|
+
}
|
|
3940
|
+
getAllInherits(inherits) {
|
|
3941
|
+
let rStr = "";
|
|
3942
|
+
for (const inher of inherits) {
|
|
3943
|
+
const subinhe = this.getOneInherit(inher);
|
|
3944
|
+
rStr += subinhe;
|
|
3945
|
+
}
|
|
3946
|
+
return rStr;
|
|
3947
|
+
}
|
|
3948
|
+
getVolume(vol) {
|
|
3949
|
+
let rStr = "";
|
|
3950
|
+
if (vol.inherits !== void 0) {
|
|
3951
|
+
const subGeoms = this.getAllSubGeoms(vol.inherits);
|
|
3952
|
+
for (const oneGeom of subGeoms) {
|
|
3953
|
+
const paxJson = paxWrite().getPaxJson({}, oneGeom, zeroPDef);
|
|
3954
|
+
rStr += this.getAllFigures(paxJson.figures, paxJson.partName);
|
|
3955
|
+
rStr += this.getVolume(oneGeom.vol);
|
|
3956
|
+
}
|
|
3957
|
+
rStr += this.getAllInherits(vol.inherits);
|
|
3958
|
+
}
|
|
3959
|
+
rStr += this.getAllExtrudes(vol.extrudes);
|
|
3960
|
+
rStr += this.getAllVolumes(vol.volumes);
|
|
3961
|
+
return rStr;
|
|
3962
|
+
}
|
|
3963
|
+
getFooter(partName) {
|
|
3964
|
+
const rStr = `
|
|
3965
|
+
pax_${partName}.check()
|
|
3966
|
+
#pax_${partName}.exportBrep(f"{outFileName}.brep")
|
|
3967
|
+
#pax_${partName}.exportIges(f"{outFileName}.igs")
|
|
3968
|
+
#pax_${partName}.exportStep(f"{outFileName}.stp")
|
|
3969
|
+
pax_${partName}.exportStl(f"{outFileName}.stl")
|
|
3970
|
+
|
|
3971
|
+
`;
|
|
3972
|
+
return rStr;
|
|
3973
|
+
}
|
|
3974
|
+
getExportFile(pax) {
|
|
3975
|
+
let rStr = this.getHeader(pax.partName);
|
|
3976
|
+
rStr += this.getAllFigures(pax.figures, pax.partName);
|
|
3977
|
+
rStr += this.getVolume(pax.volume);
|
|
3978
|
+
rStr += this.getFooter(pax.partName);
|
|
3979
|
+
return rStr;
|
|
3980
|
+
}
|
|
3981
|
+
};
|
|
3982
|
+
function freecadWrite() {
|
|
3983
|
+
const rFreecadWrite = new FreecadWrite();
|
|
3984
|
+
return rFreecadWrite;
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3613
3987
|
// src/aaExportContent.ts
|
|
3614
3988
|
import * as zip from "@zip.js/zip.js";
|
|
3615
3989
|
var MinMaxPoint = class {
|
|
@@ -3699,7 +4073,7 @@ function figureToSvg(aCtr) {
|
|
|
3699
4073
|
}
|
|
3700
4074
|
function figureToSvgDeco(fig) {
|
|
3701
4075
|
const sw2 = svgWriter2();
|
|
3702
|
-
sw2.addAContour(fig.
|
|
4076
|
+
sw2.addAContour(fig.mainListC(), "main", colors.mainInner);
|
|
3703
4077
|
sw2.addAContour(fig.mainBList, "mainB", colors.mainB);
|
|
3704
4078
|
sw2.addAContour(fig.secondList, "second", colors.second);
|
|
3705
4079
|
sw2.addAContour(fig.secondBList, "secondB", colors.secondB);
|
|
@@ -3745,6 +4119,11 @@ function makeOpenjscad(geome0) {
|
|
|
3745
4119
|
const rStr = ojscadWrite().getExportFile(paxJson);
|
|
3746
4120
|
return rStr;
|
|
3747
4121
|
}
|
|
4122
|
+
function makeFreecad(geome0) {
|
|
4123
|
+
const paxJson = paxWrite().getPaxJson({}, geome0, zeroPDef);
|
|
4124
|
+
const rStr = freecadWrite().getExportFile(paxJson);
|
|
4125
|
+
return rStr;
|
|
4126
|
+
}
|
|
3748
4127
|
async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
3749
4128
|
const zipFileWriter = new zip.BlobWriter("application/zip");
|
|
3750
4129
|
const zipWriter = new zip.ZipWriter(zipFileWriter);
|
|
@@ -3756,9 +4135,9 @@ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
|
3756
4135
|
const zLog1 = new zip.TextReader(geome1.logstr);
|
|
3757
4136
|
await zipWriter.add(`geom_${partName}_t${tSim}_log.txt`, zLog1);
|
|
3758
4137
|
for (const face in geome0.fig) {
|
|
3759
|
-
const svgOne = new zip.TextReader(figureToSvg(geome0.fig[face].
|
|
4138
|
+
const svgOne = new zip.TextReader(figureToSvg(geome0.fig[face].mainListC()));
|
|
3760
4139
|
await zipWriter.add(`face_${partName}_${face}.svg`, svgOne);
|
|
3761
|
-
const dxfOne = new zip.TextReader(figureToDxf(geome0.fig[face].
|
|
4140
|
+
const dxfOne = new zip.TextReader(figureToDxf(geome0.fig[face].mainListC()));
|
|
3762
4141
|
await zipWriter.add(`face_${partName}_${face}.dxf`, dxfOne);
|
|
3763
4142
|
const svgOneDeco = new zip.TextReader(figureToSvgDeco(geome0.fig[face]));
|
|
3764
4143
|
await zipWriter.add(`deco_${partName}_${face}.svg`, svgOneDeco);
|
|
@@ -3766,9 +4145,9 @@ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
|
3766
4145
|
await zipWriter.add(`deco_${partName}_${face}_t${tSim}.svg`, svgOneDecoT);
|
|
3767
4146
|
}
|
|
3768
4147
|
const mergedFace = mergeFaces(geome0.fig);
|
|
3769
|
-
const svgMerged = new zip.TextReader(figureToSvg(mergedFace.
|
|
4148
|
+
const svgMerged = new zip.TextReader(figureToSvg(mergedFace.mainListC()));
|
|
3770
4149
|
await zipWriter.add(`face_${partName}_all_merged.svg`, svgMerged);
|
|
3771
|
-
const dxfMerged = new zip.TextReader(figureToDxf(mergedFace.
|
|
4150
|
+
const dxfMerged = new zip.TextReader(figureToDxf(mergedFace.mainListC()));
|
|
3772
4151
|
await zipWriter.add(`face_${partName}_all_merged.dxf`, dxfMerged);
|
|
3773
4152
|
const svgMergedDeco = new zip.TextReader(figureToSvgDeco(mergedFace));
|
|
3774
4153
|
await zipWriter.add(`deco_${partName}_all_merged.svg`, svgMergedDeco);
|
|
@@ -3780,6 +4159,8 @@ async function makeZip(paramVal, geome0, tSim, geome1, ipDef) {
|
|
|
3780
4159
|
await zipWriter.add(`${partName}_noarc_openscad.scad`, zSCad);
|
|
3781
4160
|
const zJScad = new zip.TextReader(makeOpenjscad(geome0));
|
|
3782
4161
|
await zipWriter.add(`${partName}_noarc_jscad.js`, zJScad);
|
|
4162
|
+
const zFreecad = new zip.TextReader(makeFreecad(geome0));
|
|
4163
|
+
await zipWriter.add(`${partName}_freecad.py`, zFreecad);
|
|
3783
4164
|
await zipWriter.close();
|
|
3784
4165
|
const rFileContent = await zipFileWriter.getData();
|
|
3785
4166
|
return rFileContent;
|
|
@@ -3795,7 +4176,8 @@ var EFormat = /* @__PURE__ */ ((EFormat2) => {
|
|
|
3795
4176
|
EFormat2[EFormat2["ePAX"] = 5] = "ePAX";
|
|
3796
4177
|
EFormat2[EFormat2["eOPENSCAD"] = 6] = "eOPENSCAD";
|
|
3797
4178
|
EFormat2[EFormat2["eJSCAD"] = 7] = "eJSCAD";
|
|
3798
|
-
EFormat2[EFormat2["
|
|
4179
|
+
EFormat2[EFormat2["eFREECAD"] = 8] = "eFREECAD";
|
|
4180
|
+
EFormat2[EFormat2["eZIP"] = 9] = "eZIP";
|
|
3799
4181
|
return EFormat2;
|
|
3800
4182
|
})(EFormat || {});
|
|
3801
4183
|
function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
|
|
@@ -3806,23 +4188,23 @@ function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
|
|
|
3806
4188
|
if (exportFormat === 0 /* eSVG */) {
|
|
3807
4189
|
if (figList.includes(eFace)) {
|
|
3808
4190
|
const figu = geome0.fig[eFace];
|
|
3809
|
-
rFileContent = figureToSvg(figu.
|
|
4191
|
+
rFileContent = figureToSvg(figu.mainListC());
|
|
3810
4192
|
} else {
|
|
3811
4193
|
console.log(`err749: fileTextContent eFace ${eFace} invalid`);
|
|
3812
4194
|
}
|
|
3813
4195
|
} else if (exportFormat === 1 /* eSVGALL */) {
|
|
3814
4196
|
const figu = mergeFaces(geome0.fig);
|
|
3815
|
-
rFileContent = figureToSvg(figu.
|
|
4197
|
+
rFileContent = figureToSvg(figu.mainListC());
|
|
3816
4198
|
} else if (exportFormat === 2 /* eDXF */) {
|
|
3817
4199
|
if (figList.includes(eFace)) {
|
|
3818
4200
|
const figu = geome0.fig[eFace];
|
|
3819
|
-
rFileContent = figureToDxf(figu.
|
|
4201
|
+
rFileContent = figureToDxf(figu.mainListC());
|
|
3820
4202
|
} else {
|
|
3821
4203
|
console.log(`err759: fileTextContent eFace ${eFace} invalid`);
|
|
3822
4204
|
}
|
|
3823
4205
|
} else if (exportFormat === 3 /* eDXFALL */) {
|
|
3824
4206
|
const figu = mergeFaces(geome0.fig);
|
|
3825
|
-
rFileContent = figureToDxf(figu.
|
|
4207
|
+
rFileContent = figureToDxf(figu.mainListC());
|
|
3826
4208
|
} else if (exportFormat === 4 /* eTXTLOG */) {
|
|
3827
4209
|
rFileContent = makeLog(geome0);
|
|
3828
4210
|
} else if (exportFormat === 5 /* ePAX */) {
|
|
@@ -3831,6 +4213,8 @@ function fileTextContent(fgeom, paramVal, ipDef, eFace, exportFormat) {
|
|
|
3831
4213
|
rFileContent = makeOpenscad(geome0);
|
|
3832
4214
|
} else if (exportFormat === 7 /* eJSCAD */) {
|
|
3833
4215
|
rFileContent = makeOpenjscad(geome0);
|
|
4216
|
+
} else if (exportFormat === 8 /* eFREECAD */) {
|
|
4217
|
+
rFileContent = makeFreecad(geome0);
|
|
3834
4218
|
} else {
|
|
3835
4219
|
console.log(`err912: unknown exportFormat ${exportFormat}`);
|
|
3836
4220
|
}
|
|
@@ -3844,7 +4228,7 @@ async function fileBinContent(fgeom, tSim, paramVal, ipDef, exportFormat) {
|
|
|
3844
4228
|
const geome1 = fgeom(tSim, paramVal);
|
|
3845
4229
|
let rFileContent = new Blob();
|
|
3846
4230
|
if (!geome0.calcErr && !geome1.calcErr) {
|
|
3847
|
-
if (exportFormat ===
|
|
4231
|
+
if (exportFormat === 9 /* eZIP */) {
|
|
3848
4232
|
rFileContent = await makeZip(paramVal, geome0, tSim, geome1, ipDef);
|
|
3849
4233
|
} else {
|
|
3850
4234
|
console.log(`err913: unknown exportFormat ${exportFormat}`);
|
|
@@ -3868,7 +4252,9 @@ function fileMime(exportFormat) {
|
|
|
3868
4252
|
rMime = "text/plain";
|
|
3869
4253
|
} else if (exportFormat === 7 /* eJSCAD */) {
|
|
3870
4254
|
rMime = "text/plain";
|
|
3871
|
-
} else if (exportFormat === 8 /*
|
|
4255
|
+
} else if (exportFormat === 8 /* eFREECAD */) {
|
|
4256
|
+
rMime = "text/plain";
|
|
4257
|
+
} else if (exportFormat === 9 /* eZIP */) {
|
|
3872
4258
|
rMime = "application/zip";
|
|
3873
4259
|
}
|
|
3874
4260
|
return rMime;
|
|
@@ -3887,14 +4273,16 @@ function fileSuffix(exportFormat) {
|
|
|
3887
4273
|
rSuffix = "_noarc_openscad.scad";
|
|
3888
4274
|
} else if (exportFormat === 7 /* eJSCAD */) {
|
|
3889
4275
|
rSuffix = "_noarc_jscad.js";
|
|
3890
|
-
} else if (exportFormat === 8 /*
|
|
4276
|
+
} else if (exportFormat === 8 /* eFREECAD */) {
|
|
4277
|
+
rSuffix = "_freecad.py";
|
|
4278
|
+
} else if (exportFormat === 9 /* eZIP */) {
|
|
3891
4279
|
rSuffix = ".zip";
|
|
3892
4280
|
}
|
|
3893
4281
|
return rSuffix;
|
|
3894
4282
|
}
|
|
3895
4283
|
function fileBin(exportFormat) {
|
|
3896
4284
|
let rBin = false;
|
|
3897
|
-
if (exportFormat ===
|
|
4285
|
+
if (exportFormat === 9 /* eZIP */) {
|
|
3898
4286
|
rBin = true;
|
|
3899
4287
|
}
|
|
3900
4288
|
return rBin;
|
|
@@ -4258,6 +4646,7 @@ export {
|
|
|
4258
4646
|
linePP,
|
|
4259
4647
|
makeCorner,
|
|
4260
4648
|
mergeFaces,
|
|
4649
|
+
midArcPoint,
|
|
4261
4650
|
oneDesignParam,
|
|
4262
4651
|
orientedArc,
|
|
4263
4652
|
pCheckbox,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geometrix",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.40",
|
|
4
4
|
"description": "The 2D geometry engine of the parametrix",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -63,17 +63,17 @@
|
|
|
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",
|
|
74
74
|
"eslint-config-prettier": "^9.1.0",
|
|
75
75
|
"npm-run-all": "^4.1.5",
|
|
76
|
-
"prettier": "^3.
|
|
76
|
+
"prettier": "^3.3.0",
|
|
77
77
|
"shx": "^0.3.4",
|
|
78
78
|
"tsup": "^8.0.2",
|
|
79
79
|
"typescript": "^5.4.5",
|