@@ -312,13 +312,13 @@ export class OperationsService {
312
312
} ) ;
313
313
bopalgoBuilder . Perform ( new this . occ . Message_ProgressRange_1 ( ) ) ;
314
314
let shapes ;
315
- if ( ! inputs . nonDestructive ) {
315
+ if ( ! inputs . nonDestructive ) {
316
316
const res = bopalgoBuilder . Modified ( inputs . shape ) ;
317
317
const shapeCompound = this . occ . BitByBitDev . BitListOfShapesToCompound ( res ) ;
318
- shapes = this . shapeGettersService . getShapesOfCompound ( { shape : shapeCompound } ) ;
318
+ shapes = this . shapeGettersService . getShapesOfCompound ( { shape : shapeCompound } ) ;
319
319
} else {
320
320
const res = bopalgoBuilder . Shape ( ) ;
321
- shapes = this . shapeGettersService . getShapesOfCompound ( { shape : res } ) ;
321
+ shapes = this . shapeGettersService . getShapesOfCompound ( { shape : res } ) ;
322
322
}
323
323
324
324
return shapes ;
@@ -399,7 +399,11 @@ export class OperationsService {
399
399
pipe . Add_1 ( inputs . shape , false , false ) ;
400
400
pipe . Add_1 ( upperPolygon , false , false ) ;
401
401
pipe . Build ( new this . occ . Message_ProgressRange_1 ( ) ) ;
402
- pipe . MakeSolid ( ) ;
402
+
403
+ // default should be to make the solid for backwards compatibility
404
+ if ( inputs . makeSolid || inputs . makeSolid === undefined ) {
405
+ pipe . MakeSolid ( ) ;
406
+ }
403
407
404
408
const pipeShape = pipe . Shape ( ) ;
405
409
const result = this . converterService . getActualTypeOfShape ( pipeShape ) ;
@@ -430,30 +434,52 @@ export class OperationsService {
430
434
const wire = inputs . shape ;
431
435
const shapesToPassThrough : TopoDS_Shape [ ] = [ ] ;
432
436
const edges = this . shapeGettersService . getEdges ( { shape : wire } ) ;
437
+
438
+ // Check if the wire is closed
439
+ const isClosed = this . wiresService . isWireClosed ( { shape : wire } ) ; // Assuming such a method exists
440
+
433
441
edges . forEach ( ( e , index ) => {
434
442
const edgeStartPt = this . edgesService . startPointOnEdge ( { shape : e } ) ;
435
443
const tangent = this . edgesService . tangentOnEdgeAtParam ( { shape : e , param : 0 } ) ;
436
- let tangentPreviousEdgeEnd : Inputs . Base . Vector3 ;
437
444
let averageTangentVec = tangent ;
438
445
439
- if ( index > 0 && index < edges . length - 1 ) {
440
- const previousEdge = edges [ index - 1 ] ;
441
- tangentPreviousEdgeEnd = this . edgesService . tangentOnEdgeAtParam ( { shape : previousEdge , param : 1 } ) ;
442
- averageTangentVec = [ tangent [ 0 ] + tangentPreviousEdgeEnd [ 0 ] / 2 , tangent [ 1 ] + tangentPreviousEdgeEnd [ 1 ] / 2 , tangent [ 2 ] + tangentPreviousEdgeEnd [ 2 ] / 2 ] ;
446
+ if ( edges . length > 1 ) { // Only average tangents if there’s more than one edge
447
+ if ( index > 0 || ( isClosed && index === 0 ) ) {
448
+ const previousEdge = edges [ ( index - 1 + edges . length ) % edges . length ] ; // Wrap around for closed wires
449
+ const tangentPreviousEdgeEnd = this . edgesService . tangentOnEdgeAtParam ( { shape : previousEdge , param : 1 } ) ;
450
+ averageTangentVec = [
451
+ ( tangent [ 0 ] + tangentPreviousEdgeEnd [ 0 ] ) / 2 ,
452
+ ( tangent [ 1 ] + tangentPreviousEdgeEnd [ 1 ] ) / 2 ,
453
+ ( tangent [ 2 ] + tangentPreviousEdgeEnd [ 2 ] ) / 2
454
+ ] ;
455
+ }
443
456
}
444
- const ngon = this . wiresService . createNGonWire ( { radius : inputs . radius , center : edgeStartPt , direction : averageTangentVec , nrCorners : inputs . nrCorners } ) as TopoDS_Wire ;
457
+
458
+ const ngon = this . wiresService . createNGonWire ( {
459
+ radius : inputs . radius ,
460
+ center : edgeStartPt ,
461
+ direction : averageTangentVec ,
462
+ nrCorners : inputs . nrCorners
463
+ } ) as TopoDS_Wire ;
445
464
shapesToPassThrough . push ( ngon ) ;
446
- if ( index === edges . length - 1 ) {
465
+
466
+ // For open wires, add a final n-gon at the end of the last edge
467
+ if ( ! isClosed && index === edges . length - 1 ) {
447
468
const edgeEndPt = this . edgesService . endPointOnEdge ( { shape : e } ) ;
448
469
const tangentEndPt = this . edgesService . tangentOnEdgeAtParam ( { shape : e , param : 1 } ) ;
449
- const ngon = this . wiresService . createNGonWire ( { radius : inputs . radius , center : edgeEndPt , direction : tangentEndPt , nrCorners : inputs . nrCorners } ) as TopoDS_Wire ;
470
+ const ngon = this . wiresService . createNGonWire ( {
471
+ radius : inputs . radius ,
472
+ center : edgeEndPt ,
473
+ direction : tangentEndPt ,
474
+ nrCorners : inputs . nrCorners
475
+ } ) as TopoDS_Wire ;
450
476
shapesToPassThrough . push ( ngon ) ;
451
477
}
452
478
} ) ;
453
479
454
480
const pipe = new this . occ . BRepOffsetAPI_MakePipeShell ( wire ) ;
455
481
shapesToPassThrough . forEach ( s => {
456
- pipe . Add_1 ( s , false , false ) ;
482
+ pipe . Add_1 ( s , inputs . withContact === true ? true : false , inputs . withCorrection === true ? true : false ) ;
457
483
} ) ;
458
484
459
485
pipe . Build ( new this . occ . Message_ProgressRange_1 ( ) ) ;
@@ -469,30 +495,52 @@ export class OperationsService {
469
495
const wire = inputs . shape ;
470
496
const shapesToPassThrough : TopoDS_Shape [ ] = [ ] ;
471
497
const edges = this . shapeGettersService . getEdges ( { shape : wire } ) ;
498
+
499
+ // Check if the wire is closed
500
+ const isClosed = this . wiresService . isWireClosed ( { shape : wire } ) ; // Assuming such a method exists
501
+
472
502
edges . forEach ( ( e , index ) => {
473
503
const edgeStartPt = this . edgesService . startPointOnEdge ( { shape : e } ) ;
474
504
const tangent = this . edgesService . tangentOnEdgeAtParam ( { shape : e , param : 0 } ) ;
475
- let tangentPreviousEdgeEnd : Inputs . Base . Vector3 ;
476
505
let averageTangentVec = tangent ;
477
506
478
- if ( index > 0 && index < edges . length - 1 ) {
479
- const previousEdge = edges [ index - 1 ] ;
480
- tangentPreviousEdgeEnd = this . edgesService . tangentOnEdgeAtParam ( { shape : previousEdge , param : 1 } ) ;
481
- averageTangentVec = [ tangent [ 0 ] + tangentPreviousEdgeEnd [ 0 ] / 2 , tangent [ 1 ] + tangentPreviousEdgeEnd [ 1 ] / 2 , tangent [ 2 ] + tangentPreviousEdgeEnd [ 2 ] / 2 ] ;
507
+ if ( edges . length > 1 ) { // Only average tangents if there’s more than one edge
508
+ if ( index > 0 || ( isClosed && index === 0 ) ) {
509
+ const previousEdge = edges [ ( index - 1 + edges . length ) % edges . length ] ; // Wrap around for closed wires
510
+ const tangentPreviousEdgeEnd = this . edgesService . tangentOnEdgeAtParam ( { shape : previousEdge , param : 1 } ) ;
511
+ averageTangentVec = [
512
+ ( tangent [ 0 ] + tangentPreviousEdgeEnd [ 0 ] ) / 2 ,
513
+ ( tangent [ 1 ] + tangentPreviousEdgeEnd [ 1 ] ) / 2 ,
514
+ ( tangent [ 2 ] + tangentPreviousEdgeEnd [ 2 ] ) / 2
515
+ ] ;
516
+ }
482
517
}
483
- const circle = this . entitiesService . createCircle ( inputs . radius , edgeStartPt , averageTangentVec , Inputs . OCCT . typeSpecificityEnum . wire ) as TopoDS_Wire ;
518
+
519
+ const circle = this . entitiesService . createCircle (
520
+ inputs . radius ,
521
+ edgeStartPt ,
522
+ averageTangentVec ,
523
+ Inputs . OCCT . typeSpecificityEnum . wire
524
+ ) as TopoDS_Wire ;
484
525
shapesToPassThrough . push ( circle ) ;
485
- if ( index === edges . length - 1 ) {
526
+
527
+ // For open wires, add a final circle at the end of the last edge
528
+ if ( ! isClosed && index === edges . length - 1 ) {
486
529
const edgeEndPt = this . edgesService . endPointOnEdge ( { shape : e } ) ;
487
530
const tangentEndPt = this . edgesService . tangentOnEdgeAtParam ( { shape : e , param : 1 } ) ;
488
- const line = this . entitiesService . createCircle ( inputs . radius , edgeEndPt , tangentEndPt , Inputs . OCCT . typeSpecificityEnum . wire ) as TopoDS_Wire ;
489
- shapesToPassThrough . push ( line ) ;
531
+ const circle = this . entitiesService . createCircle (
532
+ inputs . radius ,
533
+ edgeEndPt ,
534
+ tangentEndPt ,
535
+ Inputs . OCCT . typeSpecificityEnum . wire
536
+ ) as TopoDS_Wire ;
537
+ shapesToPassThrough . push ( circle ) ;
490
538
}
491
539
} ) ;
492
540
493
541
const pipe = new this . occ . BRepOffsetAPI_MakePipeShell ( wire ) ;
494
542
shapesToPassThrough . forEach ( s => {
495
- pipe . Add_1 ( s , false , false ) ;
543
+ pipe . Add_1 ( s , inputs . withContact === true ? true : false , inputs . withCorrection === true ? true : false ) ;
496
544
} ) ;
497
545
498
546
pipe . Build ( new this . occ . Message_ProgressRange_1 ( ) ) ;
@@ -506,7 +554,7 @@ export class OperationsService {
506
554
507
555
pipeWiresCylindrical ( inputs : Inputs . OCCT . PipeWiresCylindricalDto < TopoDS_Wire > ) {
508
556
return inputs . shapes . map ( wire => {
509
- return this . pipeWireCylindrical ( { shape : wire , radius : inputs . radius } ) ;
557
+ return this . pipeWireCylindrical ( { shape : wire , radius : inputs . radius , withContact : inputs . withContact , withCorrection : inputs . withCorrection } ) ;
510
558
} ) ;
511
559
}
512
560
0 commit comments