Skip to content

Commit 227cefb

Browse files
switch to use MakePipe instead of MakePipeShell as it is more stable. New approach does not work well for sharp corners, but previous solution also did not work well for those situations. It's better to always provide rounded wires to this operation to succeed.
1 parent a43f2c5 commit 227cefb

1 file changed

Lines changed: 9 additions & 54 deletions

File tree

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

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("OCCT operations unit tests", () => {
3131
});
3232

3333
it("should get two closest points between two shapes", async () => {
34-
34+
3535
const sph1 = occHelper.entitiesService.bRepPrimAPIMakeSphere([0, 0, 0], [0, 1, 0], 1);
3636
const sph2 = occHelper.entitiesService.bRepPrimAPIMakeSphere([3, 3, 3], [0, 1, 0], 1);
3737
const res = operations.closestPointsBetweenTwoShapes({ shape1: sph1, shape2: sph2 });
@@ -686,7 +686,7 @@ describe("OCCT operations unit tests", () => {
686686

687687
it("should create rotated extrusion", () => {
688688
const squareWire = wire.createSquareWire({ center: [0.5, 0, 0], size: 1, direction: [0, 1, 0] });
689-
const res = operations.rotatedExtrude({ shape: squareWire, angle: 360, height: 10 });
689+
const res = operations.rotatedExtrude({ shape: squareWire, angle: 360, height: 10, makeSolid: true });
690690
const vol = solid.getSolidVolume({ shape: res });
691691
expect(vol).toEqual(9.999989383137159);
692692
squareWire.delete();
@@ -752,30 +752,13 @@ describe("OCCT operations unit tests", () => {
752752
tolerance: 1e-7,
753753
periodic: false
754754
});
755-
const res = operations.pipePolylineWireNGon({ shape: interpolatedWire, nrCorners: 6, radius: 0.2, withContact: false, withCorrection: false });
755+
const res = operations.pipePolylineWireNGon({ shape: interpolatedWire, nrCorners: 6, radius: 0.2, makeSolid: true, forceApproxC1: false, trihedronEnum: Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal });
756756
const vol = solid.getSolidVolume({ shape: res });
757-
expect(vol).toEqual(0.518460713602639);
757+
expect(vol).toEqual(0.5184607136026386);
758758
interpolatedWire.delete();
759759
res.delete();
760760
});
761761

762-
it("should pipe polyline wire with ngon through square wire", () => {
763-
const polyline = wire.createPolylineWire({
764-
points: [
765-
[0, 0, 0],
766-
[0, 1, 0],
767-
[1, 2, 0],
768-
[1, 3, 0],
769-
[0, 4, 0],
770-
]
771-
});
772-
const res = operations.pipePolylineWireNGon({ shape: polyline, nrCorners: 6, radius: 0.2, withContact: false, withCorrection: false });
773-
const vol = solid.getSolidVolume({ shape: res });
774-
expect(vol).toEqual(0.5099367481546556);
775-
polyline.delete();
776-
res.delete();
777-
});
778-
779762
it("should pipe interpolated wire with circular profile", () => {
780763
const interpolatedWire = wire.interpolatePoints({
781764
points: [
@@ -788,41 +771,14 @@ describe("OCCT operations unit tests", () => {
788771
tolerance: 1e-7,
789772
periodic: false
790773
});
791-
const res = operations.pipeWireCylindrical({ shape: interpolatedWire, radius: 0.2, withContact: false, withCorrection: false });
774+
const res = operations.pipeWireCylindrical({ shape: interpolatedWire, radius: 0.2, makeSolid: true, forceApproxC1: false, trihedronEnum: Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal });
792775
const vol = solid.getSolidVolume({ shape: res });
793-
expect(vol).toEqual(0.6269224771598202);
776+
expect(vol).toEqual(0.6269086976927102);
794777
interpolatedWire.delete();
795778
res.delete();
796779
});
797780

798-
it("should pipe polyline wire with circular profile", () => {
799-
const polyline = wire.createPolylineWire({
800-
points: [
801-
[0, 0, 0],
802-
[0, 1, 0],
803-
[1, 2, 0],
804-
[1, 3, 0],
805-
[0, 4, 0],
806-
]
807-
});
808-
const res = operations.pipeWireCylindrical({ shape: polyline, radius: 0.2, withContact: false, withCorrection: false });
809-
const vol = solid.getSolidVolume({ shape: res });
810-
expect(vol).toEqual(0.6178829238950824);
811-
polyline.delete();
812-
res.delete();
813-
});
814-
815-
it("should pipe multiple wires wire with circular profile", () => {
816-
const polyline = wire.createPolylineWire({
817-
points: [
818-
[0, 0, 0],
819-
[0, 1, 0],
820-
[1, 2, 0],
821-
[1, 3, 0],
822-
[0, 4, 0],
823-
]
824-
});
825-
781+
it("should pipe interpolated profile", () => {
826782
const interpolatedWire = wire.interpolatePoints({
827783
points: [
828784
[0, 0, 4],
@@ -834,10 +790,9 @@ describe("OCCT operations unit tests", () => {
834790
tolerance: 1e-7,
835791
periodic: false
836792
});
837-
const res = operations.pipeWiresCylindrical({ shapes: [polyline, interpolatedWire], radius: 0.2, withContact: false, withCorrection: false });
793+
const res = operations.pipeWiresCylindrical({ shapes: [interpolatedWire], radius: 0.2, makeSolid: true, forceApproxC1: false, trihedronEnum: Inputs.OCCT.geomFillTrihedronEnum.isConstantNormal });
838794
const vols = res.map(s => solid.getSolidVolume({ shape: s }));
839-
expect(vols).toEqual([0.6178829238950824, 0.62692247715982,]);
840-
polyline.delete();
795+
expect(vols).toEqual([0.626908697692709]);
841796
res.forEach(s => s.delete());
842797
});
843798

0 commit comments

Comments
 (0)