@@ -64,6 +64,60 @@ describe("OCCT io unit tests", () => {
6464 cone . delete ( ) ;
6565 } ) ;
6666
67+ it ( "should save shape as step file with adjustYtoZ and fromRightHanded (no mirroring)" , ( ) => {
68+ const box = solid . createBox ( { width : 4 , length : 6 , height : 8 , center : [ 0 , 0 , 0 ] } ) ;
69+
70+ // Save with fromRightHanded=true (skips mirroring)
71+ const stepRightHanded = io . saveShapeSTEP ( {
72+ shape : box ,
73+ adjustYtoZ : true ,
74+ fromRightHanded : true ,
75+ fileName : "box.step"
76+ } ) ;
77+
78+ // Save with fromRightHanded=false (default, applies mirroring)
79+ const stepLeftHanded = io . saveShapeSTEP ( {
80+ shape : box ,
81+ adjustYtoZ : true ,
82+ fromRightHanded : false ,
83+ fileName : "box.step"
84+ } ) ;
85+
86+ // Both should be valid STEP files
87+ expect ( stepRightHanded ) . toContain ( "ISO-10303-21;" ) ;
88+ expect ( stepRightHanded ) . toContain ( "END-ISO-10303-21;" ) ;
89+ expect ( stepLeftHanded ) . toContain ( "ISO-10303-21;" ) ;
90+ expect ( stepLeftHanded ) . toContain ( "END-ISO-10303-21;" ) ;
91+
92+ // The content should differ because mirroring changes the geometry
93+ expect ( stepRightHanded ) . not . toEqual ( stepLeftHanded ) ;
94+
95+ box . delete ( ) ;
96+ } ) ;
97+
98+ it ( "should save shape as step file with fromRightHanded true and preserve roundtrip" , ( ) => {
99+ const cylinder = solid . createCylinder ( { radius : 5 , height : 10 , direction : [ 0 , 1 , 0 ] , center : [ 0 , 0 , 0 ] } ) ;
100+
101+ const stepText = io . saveShapeSTEP ( {
102+ shape : cylinder ,
103+ adjustYtoZ : true ,
104+ fromRightHanded : true ,
105+ fileName : "cylinder.step"
106+ } ) ;
107+
108+ // Load it back (adjustZtoY should reverse the rotation)
109+ const loaded = io . loadSTEPorIGES ( { filetext : stepText , fileName : "cylinder.step" , adjustZtoY : true } ) ;
110+
111+ const volumeOriginal = solid . getSolidVolume ( { shape : cylinder } ) ;
112+ const volumeLoaded = solid . getSolidVolume ( { shape : loaded } ) ;
113+
114+ // Volume should be preserved
115+ expect ( volumeOriginal ) . toBeCloseTo ( volumeLoaded ) ;
116+
117+ cylinder . delete ( ) ;
118+ loaded . delete ( ) ;
119+ } ) ;
120+
67121 it ( "should load cube shape from step file" , ( ) => {
68122 const cube = solid . createCube ( { size : 10 , center : [ 0 , 0 , 0 ] } ) ;
69123 const stepText = io . saveShapeSTEP ( { shape : cube , adjustYtoZ : false , fileName : "cube.step" } ) ;
0 commit comments