@@ -312,13 +312,13 @@ export class OperationsService {
312312 } ) ;
313313 bopalgoBuilder . Perform ( new this . occ . Message_ProgressRange_1 ( ) ) ;
314314 let shapes ;
315- if ( ! inputs . nonDestructive ) {
315+ if ( ! inputs . nonDestructive ) {
316316 const res = bopalgoBuilder . Modified ( inputs . shape ) ;
317317 const shapeCompound = this . occ . BitByBitDev . BitListOfShapesToCompound ( res ) ;
318- shapes = this . shapeGettersService . getShapesOfCompound ( { shape : shapeCompound } ) ;
318+ shapes = this . shapeGettersService . getShapesOfCompound ( { shape : shapeCompound } ) ;
319319 } else {
320320 const res = bopalgoBuilder . Shape ( ) ;
321- shapes = this . shapeGettersService . getShapesOfCompound ( { shape : res } ) ;
321+ shapes = this . shapeGettersService . getShapesOfCompound ( { shape : res } ) ;
322322 }
323323
324324 return shapes ;
@@ -399,7 +399,11 @@ export class OperationsService {
399399 pipe . Add_1 ( inputs . shape , false , false ) ;
400400 pipe . Add_1 ( upperPolygon , false , false ) ;
401401 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+ }
403407
404408 const pipeShape = pipe . Shape ( ) ;
405409 const result = this . converterService . getActualTypeOfShape ( pipeShape ) ;
@@ -430,30 +434,52 @@ export class OperationsService {
430434 const wire = inputs . shape ;
431435 const shapesToPassThrough : TopoDS_Shape [ ] = [ ] ;
432436 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+
433441 edges . forEach ( ( e , index ) => {
434442 const edgeStartPt = this . edgesService . startPointOnEdge ( { shape : e } ) ;
435443 const tangent = this . edgesService . tangentOnEdgeAtParam ( { shape : e , param : 0 } ) ;
436- let tangentPreviousEdgeEnd : Inputs . Base . Vector3 ;
437444 let averageTangentVec = tangent ;
438445
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+ }
443456 }
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 ;
445464 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 ) {
447468 const edgeEndPt = this . edgesService . endPointOnEdge ( { shape : e } ) ;
448469 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 ;
450476 shapesToPassThrough . push ( ngon ) ;
451477 }
452478 } ) ;
453479
454480 const pipe = new this . occ . BRepOffsetAPI_MakePipeShell ( wire ) ;
455481 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 ) ;
457483 } ) ;
458484
459485 pipe . Build ( new this . occ . Message_ProgressRange_1 ( ) ) ;
@@ -469,30 +495,52 @@ export class OperationsService {
469495 const wire = inputs . shape ;
470496 const shapesToPassThrough : TopoDS_Shape [ ] = [ ] ;
471497 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+
472502 edges . forEach ( ( e , index ) => {
473503 const edgeStartPt = this . edgesService . startPointOnEdge ( { shape : e } ) ;
474504 const tangent = this . edgesService . tangentOnEdgeAtParam ( { shape : e , param : 0 } ) ;
475- let tangentPreviousEdgeEnd : Inputs . Base . Vector3 ;
476505 let averageTangentVec = tangent ;
477506
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+ }
482517 }
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 ;
484525 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 ) {
486529 const edgeEndPt = this . edgesService . endPointOnEdge ( { shape : e } ) ;
487530 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 ) ;
490538 }
491539 } ) ;
492540
493541 const pipe = new this . occ . BRepOffsetAPI_MakePipeShell ( wire ) ;
494542 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 ) ;
496544 } ) ;
497545
498546 pipe . Build ( new this . occ . Message_ProgressRange_1 ( ) ) ;
@@ -506,7 +554,7 @@ export class OperationsService {
506554
507555 pipeWiresCylindrical ( inputs : Inputs . OCCT . PipeWiresCylindricalDto < TopoDS_Wire > ) {
508556 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 } ) ;
510558 } ) ;
511559 }
512560
0 commit comments