]> gerrit.simantics Code Review - simantics/3d.git/blob - org.jcae.opencascade/src-java-test/org/jcae/opencascade/jni/Explorer.java
Reversing pipe runs was never implemented properly
[simantics/3d.git] / org.jcae.opencascade / src-java-test / org / jcae / opencascade / jni / Explorer.java
1 package org.jcae.opencascade.jni;
2
3 import static org.junit.Assert.*;
4 import org.junit.Test;
5
6 import java.util.HashSet;
7
8 public class Explorer
9 {
10         @Test public void explorer()
11         {
12                 // Create a cube
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();
16                 
17                 // The created shape is a solid.
18                 assertTrue(box instanceof TopoDS_Solid);
19                 
20                 // Display the child of our box
21                 TopoDS_Iterator it=new TopoDS_Iterator(box);
22                 
23                 // The first (and only) child is a shell
24                 TopoDS_Shell shell=(TopoDS_Shell) it.value();
25                 it.next();
26                 assertFalse(it.more());
27                 
28                 // Children of the shell are faces
29                 it=new TopoDS_Iterator(shell);
30                 while(it.more())
31                 {
32                         assertTrue(it.value() instanceof TopoDS_Face);
33                         it.next();
34                 }
35                 
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);
39                 int counter=0;
40                 HashSet<TopoDS_Shape> set=new HashSet<TopoDS_Shape>();
41                 while(exp.more())
42                 {
43                         //Just to show that the type is TopoDS_Edge
44                         assertTrue(exp.current() instanceof TopoDS_Edge);
45                         set.add(exp.current());
46                         
47                         counter++;
48                         exp.next();
49                 }
50                 
51                 // the number of edges is 24 because each edge is shared by 2
52                 // faces.
53                 assertTrue(counter == 24);
54
55                 // the number of edges is 12
56                 assertTrue(12 == set.size());
57         }
58 }