Skip to content

Commit 12e7856

Browse files
refactored to use 'new' for options in some runner examples
1 parent ee15875 commit 12e7856

File tree

2 files changed

+131
-109
lines changed

2 files changed

+131
-109
lines changed

examples/runner/threejs/full/simple/index.html

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,28 @@
4646
const curvePts = [[[-10, 0, -10], [0, 3, -10], [10, -1, -10], [20, 2, -10]], [[-10, -5, 0], [0, -3, 0], [10, 1, 0], [20, -2, 0]], [[-10, 0, 10], [0, 3, 10], [10, -1, 10], [20, 2, 10]]];
4747

4848
const wirePromises = curvePts.map((pts) => {
49-
return bitbybit.occt.shapes.wire.interpolatePoints({ points: pts, periodic: false, tolerance: 1e-7 });
49+
const interpolateDto = new Bit.Inputs.OCCT.InterpolationDto();
50+
interpolateDto.points = pts;
51+
interpolateDto.periodic = false;
52+
interpolateDto.tolerance = 1e-7;
53+
return bitbybit.occt.shapes.wire.interpolatePoints(interpolateDto);
5054
});
5155

5256
const wires = await Promise.all(wirePromises);
53-
const loft = await bitbybit.occt.operations.loft({ shapes: wires, makeSolid: false });
54-
const translated = await bitbybit.occt.transforms.translate({ shape: loft, translation: [0, 10, 0] });
55-
const faces = await bitbybit.occt.shapes.face.getFaces({ shape: translated });
57+
58+
const loftDto = new Bit.Inputs.OCCT.LoftDto();
59+
loftDto.shapes = wires;
60+
loftDto.makeSolid = false;
61+
const loft = await bitbybit.occt.operations.loft(loftDto);
62+
63+
const translateDto = new Bit.Inputs.OCCT.TranslateDto();
64+
translateDto.shape = loft;
65+
translateDto.translation = [0, 10, 0];
66+
const translated = await bitbybit.occt.transforms.translate(translateDto);
67+
68+
const getFacesDto = new Bit.Inputs.OCCT.ShapeDto();
69+
getFacesDto.shape = translated;
70+
const faces = await bitbybit.occt.shapes.face.getFaces(getFacesDto);
5671

5772
const subdivideOptions = new Bit.Inputs.OCCT.FaceSubdivideToRectangleHolesDto(faces[0]);
5873
subdivideOptions.nrRectanglesU = model.vRec;
@@ -65,7 +80,11 @@
6580
subdivideOptions.offsetFromBorderV = 0.01;
6681

6782
const withHoles = await bitbybit.occt.shapes.face.subdivideToRectangleHoles(subdivideOptions);
68-
const finalShape = await bitbybit.occt.operations.makeThickSolidSimple({ shape: withHoles[0], offset: 0.5 });
83+
84+
const thickSolidDto = new Bit.Inputs.OCCT.ThisckSolidSimpleDto();
85+
thickSolidDto.shape = withHoles[0];
86+
thickSolidDto.offset = 0.5;
87+
const finalShape = await bitbybit.occt.operations.makeThickSolidSimple(thickSolidDto);
6988

7089
const options = new Bit.Inputs.Draw.DrawOcctShapeOptions();
7190
options.precision = 0.02;

examples/runner/threejs/lite/threejs-logo/index.html

Lines changed: 107 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,24 @@
137137

138138
const downloadStep = async () => {
139139
if (bitbybit && finalShape) {
140-
await bitbybit.occt.io.saveShapeSTEP({
141-
shape: finalShape,
142-
fileName: 'threejs.stp',
143-
adjustYtoZ: true,
144-
tryDownload: true
145-
});
140+
const saveStepDto = new Bit.Inputs.OCCT.SaveStepDto();
141+
saveStepDto.shape = finalShape;
142+
saveStepDto.fileName = 'threejs.stp';
143+
saveStepDto.adjustYtoZ = true;
144+
saveStepDto.tryDownload = true;
145+
await bitbybit.occt.io.saveShapeSTEP(saveStepDto);
146146
}
147147
}
148148

149149
const downloadSTL = async () => {
150150
if (bitbybit && finalShape) {
151-
await bitbybit.occt.io.saveShapeStl({
152-
shape: finalShape,
153-
fileName: 'threejs.stl',
154-
precision: 0.01,
155-
adjustYtoZ: true,
156-
tryDownload: true
157-
});
151+
const saveStlDto = new Bit.Inputs.OCCT.SaveStlDto();
152+
saveStlDto.shape = finalShape;
153+
saveStlDto.fileName = 'threejs.stl';
154+
saveStlDto.precision = 0.01;
155+
saveStlDto.adjustYtoZ = true;
156+
saveStlDto.tryDownload = true;
157+
await bitbybit.occt.io.saveShapeStl(saveStlDto);
158158
}
159159
}
160160

@@ -184,94 +184,96 @@
184184
const createShape = async () => {
185185

186186
if (shapesToClean.length > 0) {
187-
await bitbybit.occt.deleteShapes({ shapes: shapesToClean });
187+
const deleteShapesDto = new Bit.Inputs.OCCT.ShapesDto();
188+
deleteShapesDto.shapes = shapesToClean;
189+
await bitbybit.occt.deleteShapes(deleteShapesDto);
188190
shapesToClean = [];
189191
}
190192

191-
const triangleFrame1 = await bitbybit.occt.shapes.wire.createNGonWire({
192-
nrCorners: 3,
193-
radius: 9,
194-
center: [0, 0, 0],
195-
direction: [0, 1, 0]
196-
});
193+
const ngonWireDto1 = new Bit.Inputs.OCCT.NGonWireDto();
194+
ngonWireDto1.nrCorners = 3;
195+
ngonWireDto1.radius = 9;
196+
ngonWireDto1.center = [0, 0, 0];
197+
ngonWireDto1.direction = [0, 1, 0];
198+
const triangleFrame1 = await bitbybit.occt.shapes.wire.createNGonWire(ngonWireDto1);
197199

198-
const triangleFrame2 = await bitbybit.occt.shapes.wire.createNGonWire({
199-
nrCorners: 3,
200-
radius: 6,
201-
center: [0, 0, 0],
202-
direction: [0, 1, 0]
203-
});
200+
const ngonWireDto2 = new Bit.Inputs.OCCT.NGonWireDto();
201+
ngonWireDto2.nrCorners = 3;
202+
ngonWireDto2.radius = 6;
203+
ngonWireDto2.center = [0, 0, 0];
204+
ngonWireDto2.direction = [0, 1, 0];
205+
const triangleFrame2 = await bitbybit.occt.shapes.wire.createNGonWire(ngonWireDto2);
204206

205207
const shape1 = await createTriangle1(model.heightBase, model.scale1, model.heightMid1);
206208
const shape2 = await createTriangle1(model.heightBase, model.scale2, model.heightMid2);
207209

208210
shapesToClean.push(shape1, shape2);
209211

210-
const shape2Rot = await bitbybit.occt.transforms.rotate({
211-
shape: shape2,
212-
angle: 180,
213-
axis: [0, 1, 0],
214-
});
212+
const rotateDto1 = new Bit.Inputs.OCCT.RotateDto();
213+
rotateDto1.shape = shape2;
214+
rotateDto1.angle = 180;
215+
rotateDto1.axis = [0, 1, 0];
216+
const shape2Rot = await bitbybit.occt.transforms.rotate(rotateDto1);
215217
shapesToClean.push(shape2Rot);
216218

217-
const points1 = await bitbybit.occt.shapes.wire.divideWireByEqualDistanceToPoints({
218-
shape: triangleFrame1,
219-
nrOfDivisions: 9,
220-
removeStartPoint: true,
221-
removeEndPoint: false,
222-
});
219+
const divideDto1 = new Bit.Inputs.OCCT.DivideDto();
220+
divideDto1.shape = triangleFrame1;
221+
divideDto1.nrOfDivisions = 9;
222+
divideDto1.removeStartPoint = true;
223+
divideDto1.removeEndPoint = false;
224+
const points1 = await bitbybit.occt.shapes.wire.divideWireByEqualDistanceToPoints(divideDto1);
223225

224226
points1.push([0, 0, 0]);
225227

226-
const points2 = await bitbybit.occt.shapes.wire.divideWireByEqualDistanceToPoints({
227-
shape: triangleFrame2,
228-
nrOfDivisions: 6,
229-
removeStartPoint: true,
230-
removeEndPoint: false,
231-
});
232-
233-
const triangles1 = await bitbybit.occt.transforms.translateShapes({
234-
shapes: points1.map(() => shape1),
235-
translations: points1
236-
});
228+
const divideDto2 = new Bit.Inputs.OCCT.DivideDto();
229+
divideDto2.shape = triangleFrame2;
230+
divideDto2.nrOfDivisions = 6;
231+
divideDto2.removeStartPoint = true;
232+
divideDto2.removeEndPoint = false;
233+
const points2 = await bitbybit.occt.shapes.wire.divideWireByEqualDistanceToPoints(divideDto2);
234+
235+
const translateShapesDto1 = new Bit.Inputs.OCCT.TranslateShapesDto();
236+
translateShapesDto1.shapes = points1.map(() => shape1);
237+
translateShapesDto1.translations = points1;
238+
const triangles1 = await bitbybit.occt.transforms.translateShapes(translateShapesDto1);
237239
shapesToClean.push(...triangles1);
238240

239-
const triangles2 = await bitbybit.occt.transforms.translateShapes({
240-
shapes: points2.map(() => shape2Rot),
241-
translations: points2
242-
});
241+
const translateShapesDto2 = new Bit.Inputs.OCCT.TranslateShapesDto();
242+
translateShapesDto2.shapes = points2.map(() => shape2Rot);
243+
translateShapesDto2.translations = points2;
244+
const triangles2 = await bitbybit.occt.transforms.translateShapes(translateShapesDto2);
243245
shapesToClean.push(...triangles2);
244246

245-
const triangleBase = await bitbybit.occt.shapes.wire.createNGonWire({
246-
nrCorners: 3,
247-
radius: 12,
248-
center: [0, -model.heightBase, 0],
249-
direction: [0, 1, 0]
250-
});
247+
const ngonWireDto3 = new Bit.Inputs.OCCT.NGonWireDto();
248+
ngonWireDto3.nrCorners = 3;
249+
ngonWireDto3.radius = 12;
250+
ngonWireDto3.center = [0, -model.heightBase, 0];
251+
ngonWireDto3.direction = [0, 1, 0];
252+
const triangleBase = await bitbybit.occt.shapes.wire.createNGonWire(ngonWireDto3);
251253
shapesToClean.push(triangleBase);
252254

253-
const extrusion = await bitbybit.occt.operations.extrude({
254-
shape: triangleBase,
255-
direction: [0, model.heightBase * 2, 0]
256-
});
255+
const extrudeDto = new Bit.Inputs.OCCT.ExtrudeDto();
256+
extrudeDto.shape = triangleBase;
257+
extrudeDto.direction = [0, model.heightBase * 2, 0];
258+
const extrusion = await bitbybit.occt.operations.extrude(extrudeDto);
257259
shapesToClean.push(extrusion);
258260

259-
const shell = await bitbybit.occt.shapes.shell.sewFaces({
260-
shapes: [extrusion, ...triangles1, ...triangles2],
261-
tolerance: 1e-7
262-
});
261+
const sewDto = new Bit.Inputs.OCCT.SewDto();
262+
sewDto.shapes = [extrusion, ...triangles1, ...triangles2];
263+
sewDto.tolerance = 1e-7;
264+
const shell = await bitbybit.occt.shapes.shell.sewFaces(sewDto);
263265
shapesToClean.push(shell);
264266

265-
finalShape = await bitbybit.occt.shapes.solid.fromClosedShell({
266-
shape: shell,
267-
});
267+
const shapeDto = new Bit.Inputs.OCCT.ShapeDto();
268+
shapeDto.shape = shell;
269+
finalShape = await bitbybit.occt.shapes.solid.fromClosedShell(shapeDto);
268270
shapesToClean.push(finalShape);
269271

270-
const solidRot = await bitbybit.occt.transforms.rotate({
271-
shape: finalShape,
272-
angle: 15,
273-
axis: [0, 1, 0],
274-
});
272+
const rotateDto2 = new Bit.Inputs.OCCT.RotateDto();
273+
rotateDto2.shape = finalShape;
274+
rotateDto2.angle = 15;
275+
rotateDto2.axis = [0, 1, 0];
276+
const solidRot = await bitbybit.occt.transforms.rotate(rotateDto2);
275277
shapesToClean.push(solidRot);
276278

277279
const options = new Bit.Inputs.Draw.DrawOcctShapeOptions();
@@ -312,44 +314,45 @@
312314
useScale = 0.0001;
313315
}
314316
const midScale = (1 - useScale) / 2 + useScale;
315-
const triangleBaseOne = await bitbybit.occt.shapes.wire.createNGonWire({
316-
nrCorners: 3,
317-
radius: 3,
318-
center: [0, heightBase, 0],
319-
direction: [0, 1, 0]
320-
});
317+
318+
const ngonBaseOneDto = new Bit.Inputs.OCCT.NGonWireDto();
319+
ngonBaseOneDto.nrCorners = 3;
320+
ngonBaseOneDto.radius = 3;
321+
ngonBaseOneDto.center = [0, heightBase, 0];
322+
ngonBaseOneDto.direction = [0, 1, 0];
323+
const triangleBaseOne = await bitbybit.occt.shapes.wire.createNGonWire(ngonBaseOneDto);
321324
shapesToClean.push(triangleBaseOne);
322325

323-
const triangleMidOne = await bitbybit.occt.shapes.wire.createNGonWire({
324-
nrCorners: 3,
325-
radius: 3 * midScale,
326-
center: [0, heightMid, 0],
327-
direction: [0, 1, 0]
328-
});
326+
const ngonMidOneDto = new Bit.Inputs.OCCT.NGonWireDto();
327+
ngonMidOneDto.nrCorners = 3;
328+
ngonMidOneDto.radius = 3 * midScale;
329+
ngonMidOneDto.center = [0, heightMid, 0];
330+
ngonMidOneDto.direction = [0, 1, 0];
331+
const triangleMidOne = await bitbybit.occt.shapes.wire.createNGonWire(ngonMidOneDto);
329332
shapesToClean.push(triangleMidOne);
330333

331-
const triangleCoreOne = await bitbybit.occt.shapes.wire.createNGonWire({
332-
nrCorners: 3,
333-
radius: 3 * useScale,
334-
center: [0, 0, 0],
335-
direction: [0, 1, 0]
336-
});
334+
const ngonCoreOneDto = new Bit.Inputs.OCCT.NGonWireDto();
335+
ngonCoreOneDto.nrCorners = 3;
336+
ngonCoreOneDto.radius = 3 * useScale;
337+
ngonCoreOneDto.center = [0, 0, 0];
338+
ngonCoreOneDto.direction = [0, 1, 0];
339+
const triangleCoreOne = await bitbybit.occt.shapes.wire.createNGonWire(ngonCoreOneDto);
337340
shapesToClean.push(triangleCoreOne);
338341

339-
const triangleBaseDown = await bitbybit.occt.shapes.wire.createNGonWire({
340-
nrCorners: 3,
341-
radius: 3,
342-
center: [0, -heightBase, 0],
343-
direction: [0, 1, 0]
344-
});
342+
const ngonBaseDownDto = new Bit.Inputs.OCCT.NGonWireDto();
343+
ngonBaseDownDto.nrCorners = 3;
344+
ngonBaseDownDto.radius = 3;
345+
ngonBaseDownDto.center = [0, -heightBase, 0];
346+
ngonBaseDownDto.direction = [0, 1, 0];
347+
const triangleBaseDown = await bitbybit.occt.shapes.wire.createNGonWire(ngonBaseDownDto);
345348
shapesToClean.push(triangleBaseDown);
346349

347-
const triangleMidDown = await bitbybit.occt.shapes.wire.createNGonWire({
348-
nrCorners: 3,
349-
radius: 3 * midScale,
350-
center: [0, -heightMid, 0],
351-
direction: [0, 1, 0]
352-
});
350+
const ngonMidDownDto = new Bit.Inputs.OCCT.NGonWireDto();
351+
ngonMidDownDto.nrCorners = 3;
352+
ngonMidDownDto.radius = 3 * midScale;
353+
ngonMidDownDto.center = [0, -heightMid, 0];
354+
ngonMidDownDto.direction = [0, 1, 0];
355+
const triangleMidDown = await bitbybit.occt.shapes.wire.createNGonWire(ngonMidDownDto);
353356
shapesToClean.push(triangleMidDown);
354357

355358
const loftOptions = new Bit.Inputs.OCCT.LoftAdvancedDto();

0 commit comments

Comments
 (0)