geometrix 0.5.41 → 0.5.43

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.
Files changed (2) hide show
  1. package/dist/index.js +44 -23
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -3703,8 +3703,9 @@ function fcFaceContour(paxCtr, outName) {
3703
3703
  let px1 = 0;
3704
3704
  let py1 = 0;
3705
3705
  let pIdx = 0;
3706
+ let pIdxLast = 0;
3706
3707
  let sIdx = 0;
3707
- for (const seg of paxCtr) {
3708
+ for (const [segIdx, seg] of paxCtr.entries()) {
3708
3709
  if (seg.typ === 0 /* eStart */) {
3709
3710
  rStr += ` P${fid(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3710
3711
  `;
@@ -3712,7 +3713,12 @@ function fcFaceContour(paxCtr, outName) {
3712
3713
  } else if (seg.typ === 1 /* eStroke */) {
3713
3714
  rStr += ` P${fid(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3714
3715
  `;
3715
- rStr += ` S${fid(sIdx)} = Part.LineSegment(P${fid(pIdx - 1)}, P${fid(pIdx)})
3716
+ if (segIdx < paxCtr.length - 1) {
3717
+ pIdxLast = pIdx;
3718
+ } else {
3719
+ pIdxLast = 0;
3720
+ }
3721
+ rStr += ` S${fid(sIdx)} = Part.LineSegment(P${fid(pIdx - 1)}, P${fid(pIdxLast)})
3716
3722
  `;
3717
3723
  pIdx += 1;
3718
3724
  sIdx += 1;
@@ -3728,7 +3734,12 @@ function fcFaceContour(paxCtr, outName) {
3728
3734
  }
3729
3735
  rStr += ` P${fid(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3730
3736
  `;
3731
- rStr += ` S${fid(sIdx)} = Part.Arc(P${fid(pIdx - 2)}, P${fid(pIdx - 1)}, P${fid(pIdx)})
3737
+ if (segIdx < paxCtr.length - 1) {
3738
+ pIdxLast = pIdx;
3739
+ } else {
3740
+ pIdxLast = 0;
3741
+ }
3742
+ rStr += ` S${fid(sIdx)} = Part.Arc(P${fid(pIdx - 2)}, P${fid(pIdx - 1)}, P${fid(pIdxLast)})
3732
3743
  `;
3733
3744
  pIdx += 1;
3734
3745
  sIdx += 1;
@@ -3861,10 +3872,10 @@ print(f"outFileName: {outFileName}")
3861
3872
  rStr += ` VEX = FIG.revolve(App.Vector(0, 0, 0), App.Vector(0, 1, 0), 360).rotate(App.Vector(0, 0, 0), App.Vector(1, 0, 0), 90)`;
3862
3873
  }
3863
3874
  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]}))
3875
+ VR1 = VEX.rotate(App.Vector(0, 0, 0), App.Vector(1, 0, 0), ${ff6(radToDeg(extrud.rotate[0]))})
3876
+ VR2 = VR1.rotate(App.Vector(0, 0, 0), App.Vector(0, 1, 0), ${ff6(radToDeg(extrud.rotate[1]))})
3877
+ VR3 = VR2.rotate(App.Vector(0, 0, 0), App.Vector(0, 0, 1), ${ff6(radToDeg(extrud.rotate[2]))})
3878
+ VFP = VR3.translate(App.Vector(${ff6(extrud.translate[0])}, ${ff6(extrud.translate[1])}, ${ff6(extrud.translate[2])}))
3868
3879
  return VFP
3869
3880
  ${extrud.outName} = fex_${extrud.outName}()
3870
3881
 
@@ -3883,30 +3894,38 @@ ${extrud.outName} = fex_${extrud.outName}()
3883
3894
  let rStr = "";
3884
3895
  if (volum.inList.length === 0) {
3885
3896
  console.log(`err215: ${volum.outName} has an empty inList`);
3886
- } else if (volum.inList.length === 1) {
3897
+ } else if (volum.inList.length === 1 || volum.boolMethod === 0 /* eIdentity */) {
3887
3898
  rStr += `${volum.outName} = ${volum.inList[0]}
3888
3899
  `;
3889
3900
  } else {
3890
3901
  const firstV = volum.inList[0];
3891
3902
  const othersV = volum.inList.slice(1);
3903
+ let combMethod = "dbg897";
3892
3904
  switch (volum.boolMethod) {
3893
- case 0 /* eIdentity */:
3894
- rStr += `${volum.outName} = ${firstV}
3895
- `;
3896
- break;
3897
3905
  case 1 /* eIntersection */:
3898
- rStr += `${volum.outName} = ${firstV}.common([${othersV.join(", ")}])
3899
- `;
3906
+ combMethod = "common";
3900
3907
  break;
3901
3908
  case 2 /* eUnion */:
3902
- rStr += `${volum.outName} = ${firstV}.fuse([${othersV.join(", ")}])
3903
- `;
3909
+ combMethod = "fuse";
3904
3910
  break;
3905
3911
  case 3 /* eSubstraction */:
3906
- rStr += `${volum.outName} = ${firstV}.cut([${othersV.join(", ")}])
3907
- `;
3912
+ combMethod = "cut";
3908
3913
  break;
3909
3914
  }
3915
+ rStr += `def fvol_${volum.outName}():
3916
+ V000 = ${firstV}
3917
+ `;
3918
+ let vidx = 0;
3919
+ for (const vol of othersV) {
3920
+ rStr += ` V${fid(vidx + 1)} = V${fid(vidx)}.${combMethod}(${vol})
3921
+ `;
3922
+ vidx += 1;
3923
+ }
3924
+ rStr += ` VFC = V${fid(vidx)}.removeSplitter()
3925
+ return VFC
3926
+ ${volum.outName} = fvol_${volum.outName}()
3927
+
3928
+ `;
3910
3929
  }
3911
3930
  return rStr;
3912
3931
  }
@@ -3928,11 +3947,13 @@ ${extrud.outName} = fex_${extrud.outName}()
3928
3947
  return rGeoms;
3929
3948
  }
3930
3949
  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]}))
3950
+ const rStr = `def finh_${inherit.outName}():
3951
+ IVR1 = ${inherit.subdesign}.rotate(App.Vector(0, 0, 0), App.Vector(1, 0, 0), ${ff6(radToDeg(inherit.rotate[0]))})
3952
+ IVR2 = IVR1.rotate(App.Vector(0, 0, 0), App.Vector(0, 1, 0), ${ff6(radToDeg(inherit.rotate[1]))})
3953
+ IVR3 = IVR2.rotate(App.Vector(0, 0, 0), App.Vector(0, 0, 1), ${ff6(radToDeg(inherit.rotate[2]))})
3954
+ IVF = IVR3.translate(App.Vector(${ff6(inherit.translate[0])}, ${ff6(inherit.translate[1])}, ${ff6(inherit.translate[2])}))
3955
+ return IVF
3956
+ ${inherit.outName} = finh_${inherit.outName}()
3936
3957
 
3937
3958
  `;
3938
3959
  return rStr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geometrix",
3
- "version": "0.5.41",
3
+ "version": "0.5.43",
4
4
  "description": "The 2D geometry engine of the parametrix",
5
5
  "private": false,
6
6
  "repository": {
@@ -67,7 +67,7 @@
67
67
  "json5": "^2.2.3"
68
68
  },
69
69
  "devDependencies": {
70
- "@types/node": "^20.14.0",
70
+ "@types/node": "^20.14.1",
71
71
  "@typescript-eslint/eslint-plugin": "^7.0.1",
72
72
  "@typescript-eslint/parser": "^7.0.1",
73
73
  "eslint": "^8.57.0",