|
22 | 22 |
|
23 | 23 | sys.path.append('../OCCUtils') |
24 | 24 |
|
25 | | -from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox |
| 25 | +from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox, BRepPrimAPI_MakeSphere |
26 | 26 | from OCC.TopoDS import TopoDS_Face, TopoDS_Edge |
27 | 27 |
|
28 | 28 | from Topology import Topo |
29 | 29 | from edge import Edge |
| 30 | +from face import Face |
| 31 | +from wire import Wire |
| 32 | +from vertex import Vertex |
| 33 | +from shell import Shell |
| 34 | +from solid import Solid |
30 | 35 |
|
31 | 36 |
|
32 | 37 | def get_test_box_shape(): |
33 | 38 | return BRepPrimAPI_MakeBox(10, 20, 30).Shape() |
34 | 39 |
|
35 | 40 |
|
| 41 | +def get_test_sphere_shape(): |
| 42 | + return BRepPrimAPI_MakeSphere(10.).Shape() |
| 43 | + |
| 44 | + |
36 | 45 | class TestTopo(unittest.TestCase): |
37 | 46 | def test_init(self): |
38 | 47 | b = get_test_box_shape() |
@@ -79,15 +88,58 @@ def test_creat_edge(self): |
79 | 88 | edge_0 = t.edges().next() # it's a TopoDS_Edge |
80 | 89 | assert not edge_0.IsNull() |
81 | 90 | # then create an edge |
82 | | - my_Edge = Edge(edge_0) |
83 | | - assert not my_Edge.IsNull() |
84 | | - assert my_Edge.tolerance == 1e-06 |
| 91 | + my_edge = Edge(edge_0) |
| 92 | + assert not my_edge.IsNull() |
| 93 | + assert my_edge.tolerance == 1e-06 |
| 94 | + assert my_edge.type == 'line' |
| 95 | + assert my_edge.length() == 30. |
| 96 | + |
| 97 | + |
| 98 | +class TestFace(unittest.TestCase): |
| 99 | + def test_creat_face(self): |
| 100 | + # create a box |
| 101 | + my_face = Face(BRepPrimAPI_MakeSphere(1., 1.).Face()) |
| 102 | + assert not my_face.IsNull() |
| 103 | + assert my_face.tolerance == 1e-06 |
| 104 | + assert not my_face.is_planar() |
| 105 | + assert my_face.is_trimmed() |
| 106 | + |
| 107 | + |
| 108 | +class TestWire(unittest.TestCase): |
| 109 | + def test_creat_face(self): |
| 110 | + # create a box |
| 111 | + b = get_test_box_shape() |
| 112 | + # take the first edge |
| 113 | + t = Topo(b) |
| 114 | + wire = t.wires().next() |
| 115 | + my_wire = Wire(wire) |
| 116 | + assert not my_wire.IsNull() |
| 117 | + assert my_wire.tolerance == 1e-06 |
| 118 | + |
| 119 | + |
| 120 | +class TestVertex(unittest.TestCase): |
| 121 | + def test_creat_vertex(self): |
| 122 | + my_vertex = Vertex(1., 2., -2.6) |
| 123 | + assert my_vertex.tolerance == 1e-06 |
| 124 | + assert my_vertex.x == 1. |
| 125 | + assert my_vertex.y == 2. |
| 126 | + assert my_vertex.z == -2.6 |
| 127 | + |
| 128 | + |
| 129 | +class TestShell(unittest.TestCase): |
| 130 | + def test_creat_shell(self): |
| 131 | + my_shell = Shell(BRepPrimAPI_MakeBox(10, 20, 30).Shell()) |
| 132 | + assert my_shell.tolerance == 1e-06 |
| 133 | + |
| 134 | + |
| 135 | +class TestSolid(unittest.TestCase): |
| 136 | + def test_creat_solid(self): |
| 137 | + my_solid = Solid(BRepPrimAPI_MakeBox(10, 20, 30).Solid()) |
| 138 | + assert my_solid.tolerance == 1e-06 |
85 | 139 |
|
86 | 140 |
|
87 | 141 | def suite(): |
88 | 142 | test_suite = unittest.TestSuite() |
89 | | - test_suite.addTest(unittest.makeSuite(TestTopo)) |
90 | | - test_suite.addTest(unittest.makeSuite(TestEdge)) |
91 | 143 | return test_suite |
92 | 144 |
|
93 | 145 | if __name__ == "__main__": |
|
0 commit comments