|
137 | 137 |
|
138 | 138 | const downloadStep = async () => { |
139 | 139 | 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); |
146 | 146 | } |
147 | 147 | } |
148 | 148 |
|
149 | 149 | const downloadSTL = async () => { |
150 | 150 | 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); |
158 | 158 | } |
159 | 159 | } |
160 | 160 |
|
|
184 | 184 | const createShape = async () => { |
185 | 185 |
|
186 | 186 | 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); |
188 | 190 | shapesToClean = []; |
189 | 191 | } |
190 | 192 |
|
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); |
197 | 199 |
|
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); |
204 | 206 |
|
205 | 207 | const shape1 = await createTriangle1(model.heightBase, model.scale1, model.heightMid1); |
206 | 208 | const shape2 = await createTriangle1(model.heightBase, model.scale2, model.heightMid2); |
207 | 209 |
|
208 | 210 | shapesToClean.push(shape1, shape2); |
209 | 211 |
|
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); |
215 | 217 | shapesToClean.push(shape2Rot); |
216 | 218 |
|
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); |
223 | 225 |
|
224 | 226 | points1.push([0, 0, 0]); |
225 | 227 |
|
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); |
237 | 239 | shapesToClean.push(...triangles1); |
238 | 240 |
|
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); |
243 | 245 | shapesToClean.push(...triangles2); |
244 | 246 |
|
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); |
251 | 253 | shapesToClean.push(triangleBase); |
252 | 254 |
|
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); |
257 | 259 | shapesToClean.push(extrusion); |
258 | 260 |
|
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); |
263 | 265 | shapesToClean.push(shell); |
264 | 266 |
|
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); |
268 | 270 | shapesToClean.push(finalShape); |
269 | 271 |
|
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); |
275 | 277 | shapesToClean.push(solidRot); |
276 | 278 |
|
277 | 279 | const options = new Bit.Inputs.Draw.DrawOcctShapeOptions(); |
|
312 | 314 | useScale = 0.0001; |
313 | 315 | } |
314 | 316 | 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); |
321 | 324 | shapesToClean.push(triangleBaseOne); |
322 | 325 |
|
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); |
329 | 332 | shapesToClean.push(triangleMidOne); |
330 | 333 |
|
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); |
337 | 340 | shapesToClean.push(triangleCoreOne); |
338 | 341 |
|
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); |
345 | 348 | shapesToClean.push(triangleBaseDown); |
346 | 349 |
|
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); |
353 | 356 | shapesToClean.push(triangleMidDown); |
354 | 357 |
|
355 | 358 | const loftOptions = new Bit.Inputs.OCCT.LoftAdvancedDto(); |
|
0 commit comments