Skip to content

Commit 78a7186

Browse files
unit test io with fromRightHanded STEP and fillets with defined solution value
1 parent 7cbf067 commit 78a7186

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

packages/dev/occt/lib/services/fillets.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,4 +769,12 @@ describe("OCCT fillets unit tests", () => {
769769
const wireLength = occHelper.wiresService.getWireLength({ shape: filletRes });
770770
expect(wireLength).toBeCloseTo(1.3424777993634651);
771771
});
772+
773+
it("should fillet two edges into a wire with explicit solution parameter", () => {
774+
const edge1 = edge.line({ start: [0, 0, 0], end: [1, 0, 0] });
775+
const edge2 = edge.line({ start: [1, 0, 0], end: [1, 1, 0] });
776+
const filletRes = fillets.filletTwoEdgesInPlaneIntoAWire({ edge1, edge2, radius: 0.2, planeDirection: [0, 0, 1], planeOrigin: [1, 0, 0], solution: 0 });
777+
const wireLength = occHelper.wiresService.getWireLength({ shape: filletRes });
778+
expect(wireLength).toBeCloseTo(1.9141592620724523);
779+
});
772780
});

packages/dev/occt/lib/services/io.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)