]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Support for fillets and chamfers 21/3021/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 16 Jul 2019 16:07:54 +0000 (19:07 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 16 Jul 2019 16:07:54 +0000 (19:07 +0300)
gitlab #9

Change-Id: I69c0ec1c538d9eb2dfa83c8f88bf6a0faa881fb8

org.simantics.opencascade/src/org/simantics/opencascade/OccTriangulator.java

index 5226eb8329836784002b1018445074ca843b31ca..aca1f43805274ab74f929cb7621f17e061cf0b1d 100644 (file)
@@ -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) {