From 8204a7a5250e06c7afc114d4bfedf5af1f4b0ba9 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Tue, 16 Jul 2019 19:07:54 +0300 Subject: [PATCH] Support for fillets and chamfers gitlab #9 Change-Id: I69c0ec1c538d9eb2dfa83c8f88bf6a0faa881fb8 --- .../opencascade/OccTriangulator.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java b/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java index 5226eb83..aca1f438 100644 --- a/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java +++ b/org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java @@ -17,11 +17,15 @@ import org.jcae.opencascade.jni.BRepBuilderAPI_MakeEdge; import org.jcae.opencascade.jni.BRepBuilderAPI_MakeFace; import org.jcae.opencascade.jni.BRepBuilderAPI_MakeWire; import org.jcae.opencascade.jni.BRepBuilderAPI_Transform; +import org.jcae.opencascade.jni.BRepFilletAPI_MakeChamfer; +import org.jcae.opencascade.jni.BRepFilletAPI_MakeFillet; import org.jcae.opencascade.jni.BRepPrimAPI_MakePrism; import org.jcae.opencascade.jni.BRepPrimAPI_MakeTorus; import org.jcae.opencascade.jni.BRep_Builder; import org.jcae.opencascade.jni.GP_Elips; import org.jcae.opencascade.jni.GP_Trsf; +import org.jcae.opencascade.jni.TopAbs_ShapeEnum; +import org.jcae.opencascade.jni.TopExp_Explorer; import org.jcae.opencascade.jni.TopoDS_Edge; import org.jcae.opencascade.jni.TopoDS_Face; import org.jcae.opencascade.jni.TopoDS_Shape; @@ -317,6 +321,49 @@ public class OccTriangulator { F.delete(); return shape; } + + public static TopoDS_Shape makeFillet(TopoDS_Shape shape, double r) { + BRepFilletAPI_MakeFillet fillet = new BRepFilletAPI_MakeFillet(shape); + + TopExp_Explorer exp = new TopExp_Explorer(shape, TopAbs_ShapeEnum.EDGE); + while (exp.more()) { + TopoDS_Edge e = (TopoDS_Edge) exp.current(); + fillet.add(r, e); + e.delete(); + exp.next(); + } + TopoDS_Shape result = fillet.shape(); + exp.delete(); + shape.delete(); + fillet.delete(); + return result; + + } + + public static TopoDS_Shape makeChamfer(TopoDS_Shape shape, double d) { + BRepFilletAPI_MakeChamfer fillet = new BRepFilletAPI_MakeChamfer(shape); + + TopExp_Explorer exp = new TopExp_Explorer(shape, TopAbs_ShapeEnum.FACE); + while (exp.more()) { + TopoDS_Face f = (TopoDS_Face) exp.current(); + TopExp_Explorer exp2 = new TopExp_Explorer(f, TopAbs_ShapeEnum.EDGE); + while (exp2.more()) { + TopoDS_Edge e = (TopoDS_Edge) exp2.current(); + fillet.add(d, e, f); + exp2.next(); + e.delete(); + } + exp2.delete(); + f.delete(); + exp.next(); + } + TopoDS_Shape result = fillet.shape(); + exp.delete(); + shape.delete(); + fillet.delete(); + return result; + + } public static void exportBREP(TopoDS_Shape shape, String filename) { -- 2.47.1