geometrix 0.5.44 → 0.5.45

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 +30 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3157,8 +3157,14 @@ function arc_to_stroke(cx, cy, radius, a1, a2, ccw, max_angle = Math.PI / 6, max
3157
3157
  }
3158
3158
 
3159
3159
  // src/write_openscad.ts
3160
- var approxMaxAngle = Math.PI / 8;
3161
- var approxMaxLength = 20;
3160
+ var approxMaxAngle = Math.PI / 16;
3161
+ var approxMaxLength = 2;
3162
+ function ff4(ifloat) {
3163
+ return ifloat.toFixed(4);
3164
+ }
3165
+ function fid(iIdx) {
3166
+ return iIdx.toString().padStart(3, "0");
3167
+ }
3162
3168
  function oscadSegLine(p2x, p2y) {
3163
3169
  const rSeg = [[p2x, p2y]];
3164
3170
  return rSeg;
@@ -3211,9 +3217,6 @@ function toOpenscadSeg(paxCtr) {
3211
3217
  }
3212
3218
  return rOscadSeg;
3213
3219
  }
3214
- function ff4(ifloat) {
3215
- return ifloat.toFixed(4);
3216
- }
3217
3220
  var OpenscadWriteFigure = class {
3218
3221
  pts;
3219
3222
  ptIdx;
@@ -3242,8 +3245,8 @@ var OpenscadWriteFigure = class {
3242
3245
  const aList = [];
3243
3246
  const bList = [];
3244
3247
  for (const idx of this.pts.keys()) {
3245
- const aId = `ca_${faceId}_${idx}`;
3246
- const bId = `cb_${faceId}_${idx}`;
3248
+ const aId = `ca_${faceId}_${fid(idx)}`;
3249
+ const bId = `cb_${faceId}_${fid(idx)}`;
3247
3250
  rStr += `${aId} = ${this.pts[idx]};
3248
3251
  `;
3249
3252
  rStr += `${bId} = ${this.ptIdx[idx]};
@@ -3429,6 +3432,12 @@ function oscadWrite() {
3429
3432
  // src/write_openjscad.ts
3430
3433
  var approxMaxAngle2 = Math.PI / 16;
3431
3434
  var approxMaxLength2 = 2;
3435
+ function ff5(ifloat) {
3436
+ return ifloat.toFixed(4);
3437
+ }
3438
+ function fid2(iIdx) {
3439
+ return iIdx.toString().padStart(3, "0");
3440
+ }
3432
3441
  function ojscadSegLine(p2x, p2y) {
3433
3442
  const rSeg = [[p2x, p2y]];
3434
3443
  return rSeg;
@@ -3481,12 +3490,6 @@ function jcSegCircle(cx, cy, radius) {
3481
3490
  const rSeg = circle_to_stroke(cx, cy, radius, approxMaxAngle2, approxMaxLength2);
3482
3491
  return rSeg;
3483
3492
  }
3484
- function ff5(ifloat) {
3485
- return ifloat.toFixed(4);
3486
- }
3487
- function fid(iIdx) {
3488
- return iIdx.toString().padStart(3, "0");
3489
- }
3490
3493
  function makeContourString(iCtr, ctrId) {
3491
3494
  const pts2 = [];
3492
3495
  for (const pt of iCtr) {
@@ -3556,10 +3559,10 @@ const main = () => {
3556
3559
  let rStr = "";
3557
3560
  const figFaceList = [];
3558
3561
  for (const [faceIdx, paxFace] of aFaces.entries()) {
3559
- const faceName = `face_${figName}_Fa${fid(faceIdx)}`;
3562
+ const faceName = `face_${figName}_Fa${fid2(faceIdx)}`;
3560
3563
  const faceCtrList = [];
3561
3564
  for (const [ctrIdx, paxCtr] of paxFace.entries()) {
3562
- const subFaceName = `ctr_${faceName}_Ctr${fid(ctrIdx)}`;
3565
+ const subFaceName = `ctr_${faceName}_Ctr${fid2(ctrIdx)}`;
3563
3566
  if (paxCtr.circle === true) {
3564
3567
  const paxCircle2 = paxCtr;
3565
3568
  rStr += jcFaceCircle(paxCircle2.cx, paxCircle2.cy, paxCircle2.radius, subFaceName);
@@ -3710,7 +3713,7 @@ function ojscadWrite() {
3710
3713
  function ff6(ifloat) {
3711
3714
  return ifloat.toFixed(4);
3712
3715
  }
3713
- function fid2(iIdx) {
3716
+ function fid3(iIdx) {
3714
3717
  return iIdx.toString().padStart(3, "0");
3715
3718
  }
3716
3719
  function fcFaceCircle(cx, cy, radius, outName) {
@@ -3734,18 +3737,18 @@ function fcFaceContour(paxCtr, outName) {
3734
3737
  let sIdx = 0;
3735
3738
  for (const [segIdx, seg] of paxCtr.entries()) {
3736
3739
  if (seg.typ === 0 /* eStart */) {
3737
- rStr += ` P${fid2(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3740
+ rStr += ` P${fid3(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3738
3741
  `;
3739
3742
  pIdx += 1;
3740
3743
  } else if (seg.typ === 1 /* eStroke */) {
3741
- rStr += ` P${fid2(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3744
+ rStr += ` P${fid3(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3742
3745
  `;
3743
3746
  if (segIdx < paxCtr.length - 1) {
3744
3747
  pIdxLast = pIdx;
3745
3748
  } else {
3746
3749
  pIdxLast = 0;
3747
3750
  }
3748
- rStr += ` S${fid2(sIdx)} = Part.LineSegment(P${fid2(pIdx - 1)}, P${fid2(pIdxLast)})
3751
+ rStr += ` S${fid3(sIdx)} = Part.LineSegment(P${fid3(pIdx - 1)}, P${fid3(pIdxLast)})
3749
3752
  `;
3750
3753
  pIdx += 1;
3751
3754
  sIdx += 1;
@@ -3753,20 +3756,20 @@ function fcFaceContour(paxCtr, outName) {
3753
3756
  try {
3754
3757
  const seg1 = convPaxToSeg1(seg);
3755
3758
  const p4 = midArcPoint(px1, py1, seg1);
3756
- rStr += ` P${fid2(pIdx)} = App.Vector(${ff6(p4.cx)}, ${ff6(p4.cy)}, 0)
3759
+ rStr += ` P${fid3(pIdx)} = App.Vector(${ff6(p4.cx)}, ${ff6(p4.cy)}, 0)
3757
3760
  `;
3758
3761
  pIdx += 1;
3759
3762
  } catch (emsg) {
3760
3763
  console.log("err730: " + emsg);
3761
3764
  }
3762
- rStr += ` P${fid2(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3765
+ rStr += ` P${fid3(pIdx)} = App.Vector(${ff6(seg.px)}, ${ff6(seg.py)}, 0)
3763
3766
  `;
3764
3767
  if (segIdx < paxCtr.length - 1) {
3765
3768
  pIdxLast = pIdx;
3766
3769
  } else {
3767
3770
  pIdxLast = 0;
3768
3771
  }
3769
- rStr += ` S${fid2(sIdx)} = Part.Arc(P${fid2(pIdx - 2)}, P${fid2(pIdx - 1)}, P${fid2(pIdxLast)})
3772
+ rStr += ` S${fid3(sIdx)} = Part.Arc(P${fid3(pIdx - 2)}, P${fid3(pIdx - 1)}, P${fid3(pIdxLast)})
3770
3773
  `;
3771
3774
  pIdx += 1;
3772
3775
  sIdx += 1;
@@ -3774,7 +3777,7 @@ function fcFaceContour(paxCtr, outName) {
3774
3777
  px1 = seg.px;
3775
3778
  py1 = seg.py;
3776
3779
  }
3777
- const segList = Array.from({ length: sIdx }, (v, i) => `S${fid2(i)}`);
3780
+ const segList = Array.from({ length: sIdx }, (v, i) => `S${fid3(i)}`);
3778
3781
  rStr += ` aShape = Part.Shape([${segList.join(", ")}])
3779
3782
  aWire = Part.Wire(aShape.Edges)
3780
3783
  subFace = Part.Face(aWire)
@@ -3789,7 +3792,7 @@ function fcOneFace(ctrNames, outName) {
3789
3792
  `;
3790
3793
  const ctrShorts = [];
3791
3794
  for (const [idx, ctr] of ctrNames.entries()) {
3792
- const short = `FC${fid2(idx)}`;
3795
+ const short = `FC${fid3(idx)}`;
3793
3796
  rStr += ` ${short} = ${ctr}()
3794
3797
  `;
3795
3798
  ctrShorts.push(short);
@@ -3814,7 +3817,7 @@ function fcOneFig(faceNames, outName) {
3814
3817
  `;
3815
3818
  const faceShorts = [];
3816
3819
  for (const [idx, face] of faceNames.entries()) {
3817
- const short = `FA${fid2(idx)}`;
3820
+ const short = `FA${fid3(idx)}`;
3818
3821
  rStr += ` ${short} = ${face}()
3819
3822
  `;
3820
3823
  faceShorts.push(short);
@@ -3944,11 +3947,11 @@ ${extrud.outName} = fex_${extrud.outName}()
3944
3947
  `;
3945
3948
  let vidx = 0;
3946
3949
  for (const vol of othersV) {
3947
- rStr += ` V${fid2(vidx + 1)} = V${fid2(vidx)}.${combMethod}(${vol})
3950
+ rStr += ` V${fid3(vidx + 1)} = V${fid3(vidx)}.${combMethod}(${vol})
3948
3951
  `;
3949
3952
  vidx += 1;
3950
3953
  }
3951
- rStr += ` VFC = V${fid2(vidx)}.removeSplitter()
3954
+ rStr += ` VFC = V${fid3(vidx)}.removeSplitter()
3952
3955
  return VFC
3953
3956
  ${volum.outName} = fvol_${volum.outName}()
3954
3957
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geometrix",
3
- "version": "0.5.44",
3
+ "version": "0.5.45",
4
4
  "description": "The 2D geometry engine of the parametrix",
5
5
  "private": false,
6
6
  "repository": {