1 package org.jcae.opencascade.jni;
3 import org.jcae.opencascade.jni.*;
5 import static org.junit.Assert.*;
9 * Show how to use brep builder
10 * @author Jerome Robert
12 public class BRepBuilder
14 @Test public void sample()
16 // Create a shape for the example (an half cone)
17 double[] axis=new double[]{
21 TopoDS_Shape cone=new BRepPrimAPI_MakeCone(axis, 2, 1, 1, Math.PI).shape();
23 // Now we will remove one face of the shape. We need first to find
24 // the direct parent of this face.
25 TopoDS_Iterator it=new TopoDS_Iterator(cone);
27 // The children of solids are shells
28 TopoDS_Shell shell = (TopoDS_Shell) it.value();
30 // Get a handle on the face to remove
31 TopExp_Explorer exp=new TopExp_Explorer(cone, TopAbs_ShapeEnum.FACE);
32 TopoDS_Face toRemove = (TopoDS_Face) exp.current();
34 TopoDS_Face anotherFace = (TopoDS_Face) exp.current();
37 BRep_Builder bb=new BRep_Builder();
38 bb.remove(shell, toRemove);
40 // Let's revert the face and readd it to the cube
41 bb.add(shell, toRemove.reversed());
43 // We can also create a compound containing only the 2 first faces of
45 TopoDS_Compound compound=new TopoDS_Compound();
46 bb.makeCompound(compound);
47 bb.add(compound, toRemove);
48 bb.add(compound, anotherFace);