1 package org.jcae.opencascade.jni;
3 import static org.junit.Assert.*;
6 import java.util.HashSet;
10 @Test public void explorer()
13 double[] pt1=new double[]{0,0,0};
14 double[] pt2=new double[]{1,3,2};
15 TopoDS_Shape box = new BRepPrimAPI_MakeBox(pt1, pt2).shape();
17 // The created shape is a solid.
18 assertTrue(box instanceof TopoDS_Solid);
20 // Display the child of our box
21 TopoDS_Iterator it=new TopoDS_Iterator(box);
23 // The first (and only) child is a shell
24 TopoDS_Shell shell=(TopoDS_Shell) it.value();
26 assertFalse(it.more());
28 // Children of the shell are faces
29 it=new TopoDS_Iterator(shell);
32 assertTrue(it.value() instanceof TopoDS_Face);
36 // TopExp_Explorer is easier to use if you are looking for shapes
37 // of a give type. Let's count the number of edges in the box
38 TopExp_Explorer exp=new TopExp_Explorer(box, TopAbs_ShapeEnum.EDGE);
40 HashSet<TopoDS_Shape> set=new HashSet<TopoDS_Shape>();
43 //Just to show that the type is TopoDS_Edge
44 assertTrue(exp.current() instanceof TopoDS_Edge);
45 set.add(exp.current());
51 // the number of edges is 24 because each edge is shared by 2
53 assertTrue(counter == 24);
55 // the number of edges is 12
56 assertTrue(12 == set.size());