]> gerrit.simantics Code Review - simantics/3d.git/blob - org.jcae.opencascade/src-java-test/org/jcae/opencascade/jni/BRepBuilder.java
Reversing pipe runs was never implemented properly
[simantics/3d.git] / org.jcae.opencascade / src-java-test / org / jcae / opencascade / jni / BRepBuilder.java
1 package org.jcae.opencascade.jni;
2
3 import org.jcae.opencascade.jni.*;
4
5 import static org.junit.Assert.*;
6 import org.junit.Test;
7
8 /**
9  * Show how to use brep builder
10  * @author Jerome Robert
11  */
12 public class BRepBuilder
13 {
14         @Test public void sample()
15         {
16                 // Create a shape for the example (an half cone)
17                 double[] axis=new double[]{
18                         0,0,0, // position
19                         0,0,1  // direction
20                 };
21                 TopoDS_Shape cone=new BRepPrimAPI_MakeCone(axis, 2, 1, 1, Math.PI).shape();
22                 
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);
26                 
27                 // The children of solids are shells
28                 TopoDS_Shell shell = (TopoDS_Shell) it.value();
29                 
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();
33                 exp.next();
34                 TopoDS_Face anotherFace = (TopoDS_Face) exp.current();
35                 
36                 // Remove the face
37                 BRep_Builder bb=new BRep_Builder();
38                 bb.remove(shell, toRemove);
39                 
40                 // Let's revert the face and readd it to the cube
41                 bb.add(shell, toRemove.reversed());
42                 
43                 // We can also create a compound containing only the 2 first faces of
44                 // the cone
45                 TopoDS_Compound compound=new TopoDS_Compound();
46                 bb.makeCompound(compound);
47                 bb.add(compound, toRemove);
48                 bb.add(compound, anotherFace);
49         }
50 }