@@ -687,11 +687,115 @@ describe("OCCT operations unit tests", () => {
687687 const squareWire = wire . createSquareWire ( { center : [ 0.5 , 0 , 0 ] , size : 1 , direction : [ 0 , 1 , 0 ] } ) ;
688688 const res = operations . rotatedExtrude ( { shape : squareWire , angle : 360 , height : 10 , makeSolid : true } ) ;
689689 const vol = solid . getSolidVolume ( { shape : res } ) ;
690- expect ( vol ) . toEqual ( 9.999989383137159 ) ;
690+ expect ( vol ) . toEqual ( 9.999989483139538 ) ;
691691 squareWire . delete ( ) ;
692692 res . delete ( ) ;
693693 } ) ;
694694
695+ it ( "should create rotated extrusion with shape positioned above Y=0" , ( ) => {
696+ // Test with a shape positioned at Y=5
697+ const squareWire = wire . createSquareWire ( { center : [ 0.5 , 5 , 0 ] , size : 1 , direction : [ 0 , 1 , 0 ] } ) ;
698+ const res = operations . rotatedExtrude ( { shape : squareWire , angle : 360 , height : 10 , makeSolid : true } ) ;
699+ const vol = solid . getSolidVolume ( { shape : res } ) ;
700+ // Volume should be the same as the ground-level test since the algorithm should work correctly now
701+ expect ( vol ) . toBeCloseTo ( 9.999989483139538 , 5 ) ;
702+
703+ // Check bounding box to ensure the result is positioned correctly
704+ const bbox = operations . boundingBoxOfShape ( { shape : res } ) ;
705+ expect ( bbox . min [ 1 ] ) . toBeCloseTo ( 5 , 1 ) ; // Bottom should be at Y=5
706+ expect ( bbox . max [ 1 ] ) . toBeCloseTo ( 15 , 1 ) ; // Top should be at Y=15
707+
708+ squareWire . delete ( ) ;
709+ res . delete ( ) ;
710+ } ) ;
711+
712+ it ( "should create rotated extrusion with shape positioned below Y=0" , ( ) => {
713+ // Test with a shape positioned at Y=-3
714+ const squareWire = wire . createSquareWire ( { center : [ 0.5 , - 3 , 0 ] , size : 1 , direction : [ 0 , 1 , 0 ] } ) ;
715+ const res = operations . rotatedExtrude ( { shape : squareWire , angle : 360 , height : 10 , makeSolid : true } ) ;
716+ const vol = solid . getSolidVolume ( { shape : res } ) ;
717+ // Volume should be the same as the ground-level test
718+ expect ( vol ) . toBeCloseTo ( 9.999989483139538 , 5 ) ;
719+
720+ // Check bounding box to ensure the result is positioned correctly
721+ const bbox = operations . boundingBoxOfShape ( { shape : res } ) ;
722+ expect ( bbox . min [ 1 ] ) . toBeCloseTo ( - 3 , 1 ) ; // Bottom should be at Y=-3
723+ expect ( bbox . max [ 1 ] ) . toBeCloseTo ( 7 , 1 ) ; // Top should be at Y=7
724+
725+ squareWire . delete ( ) ;
726+ res . delete ( ) ;
727+ } ) ;
728+
729+ it ( "should create rotated extrusion with shape at arbitrary Y position" , ( ) => {
730+ // Test with a shape positioned at Y=25.7 (arbitrary high position)
731+ const squareWire = wire . createSquareWire ( { center : [ 0.5 , 25.7 , 0 ] , size : 1 , direction : [ 0 , 1 , 0 ] } ) ;
732+ const res = operations . rotatedExtrude ( { shape : squareWire , angle : 360 , height : 5 , makeSolid : true } ) ;
733+ const vol = solid . getSolidVolume ( { shape : res } ) ;
734+ // Volume should be proportional to height (5 instead of 10)
735+ expect ( vol ) . toBeCloseTo ( 5.0 , 1 ) ;
736+
737+ // Check bounding box to ensure the result is positioned correctly
738+ const bbox = operations . boundingBoxOfShape ( { shape : res } ) ;
739+ expect ( bbox . min [ 1 ] ) . toBeCloseTo ( 25.7 , 1 ) ; // Bottom should be at Y=25.7
740+ expect ( bbox . max [ 1 ] ) . toBeCloseTo ( 30.7 , 1 ) ; // Top should be at Y=30.7
741+
742+ squareWire . delete ( ) ;
743+ res . delete ( ) ;
744+ } ) ;
745+
746+ it ( "should create rotated extrusion with partial rotation at elevated position" , ( ) => {
747+ // Test with partial rotation (180 degrees) at Y=10
748+ const squareWire = wire . createSquareWire ( { center : [ 0.5 , 10 , 0 ] , size : 1 , direction : [ 0 , 1 , 0 ] } ) ;
749+ const res = operations . rotatedExtrude ( { shape : squareWire , angle : 180 , height : 8 , makeSolid : true } ) ;
750+ const vol = solid . getSolidVolume ( { shape : res } ) ;
751+ // Volume should be half of a full rotation
752+ expect ( vol ) . toBeCloseTo ( 7.999990663583383 , 1 ) ;
753+
754+ // Check bounding box to ensure the result is positioned correctly
755+ const bbox = operations . boundingBoxOfShape ( { shape : res } ) ;
756+ expect ( bbox . min [ 1 ] ) . toBeCloseTo ( 10 , 1 ) ; // Bottom should be at Y=10
757+ expect ( bbox . max [ 1 ] ) . toBeCloseTo ( 18 , 1 ) ; // Top should be at Y=18
758+
759+ squareWire . delete ( ) ;
760+ res . delete ( ) ;
761+ } ) ;
762+
763+ it ( "should create rotated extrusion as surface (not solid) at elevated position" , ( ) => {
764+ // Test with makeSolid=false at Y=7
765+ const squareWire = wire . createSquareWire ( { center : [ 0.5 , 7 , 0 ] , size : 1 , direction : [ 0 , 1 , 0 ] } ) ;
766+ const res = operations . rotatedExtrude ( { shape : squareWire , angle : 360 , height : 6 , makeSolid : false } ) ;
767+
768+ // Check that it's not a solid but a shell/surface
769+ const faces = face . getFaces ( { shape : res } ) ;
770+ expect ( faces . length ) . toBeGreaterThan ( 0 ) ;
771+
772+ // Check bounding box to ensure the result is positioned correctly
773+ const bbox = operations . boundingBoxOfShape ( { shape : res } ) ;
774+ expect ( bbox . min [ 1 ] ) . toBeCloseTo ( 7 , 1 ) ; // Bottom should be at Y=7
775+ expect ( bbox . max [ 1 ] ) . toBeCloseTo ( 13 , 1 ) ; // Top should be at Y=13
776+
777+ squareWire . delete ( ) ;
778+ res . delete ( ) ;
779+ faces . forEach ( f => f . delete ( ) ) ;
780+ } ) ;
781+
782+ it ( "should create rotated extrusion with circle wire at negative Y position" , ( ) => {
783+ // Test with a different shape type (circle) at Y=-8
784+ const circleWire = wire . createCircleWire ( { center : [ 2 , - 8 , 0 ] , radius : 0.5 , direction : [ 0 , 1 , 0 ] } ) ;
785+ const res = operations . rotatedExtrude ( { shape : circleWire , angle : 270 , height : 12 , makeSolid : true } ) ;
786+ const vol = solid . getSolidVolume ( { shape : res } ) ;
787+ // Volume should be proportional to the circle area and 3/4 rotation
788+ expect ( vol ) . toBeCloseTo ( 9.424769481063818 , 1 ) ;
789+
790+ // Check bounding box to ensure the result is positioned correctly
791+ const bbox = operations . boundingBoxOfShape ( { shape : res } ) ;
792+ expect ( bbox . min [ 1 ] ) . toBeCloseTo ( - 8 , 1 ) ; // Bottom should be at Y=-8
793+ expect ( bbox . max [ 1 ] ) . toBeCloseTo ( 4 , 1 ) ; // Top should be at Y=4
794+
795+ circleWire . delete ( ) ;
796+ res . delete ( ) ;
797+ } ) ;
798+
695799 it ( "should pipe a single profile along the backbone wire" , ( ) => {
696800 const interpolatedWire = wire . interpolatePoints ( {
697801 points : [
0 commit comments