Пример #1
0
    def test_shape_volume(self):
        box1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), gp_Pnt(10, 10, 10))
        box2 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), gp_Pnt(10, 10, 10))
        fuse = BRepAlgoAPI_Fuse(box1.Shape(), box2.Shape())
        fused_shape = fuse.Shape()

        from skdb.geom import shape_volume
        box1_volume = shape_volume(box1.Shape())
        box2_volume = shape_volume(box2.Shape())
        fused_volume = shape_volume(fused_shape)

        self.assertEqual(box1_volume, box2_volume)
        self.assertEqual(box1_volume, fused_volume)

        #change box size
        box2 = BRepPrimAPI_MakeBox(gp_Pnt(5, 5, 5), gp_Pnt(10, 10, 10))
        fuse = BRepAlgoAPI_Fuse(box1.Shape(), box2.Shape())
        fused_shape = fuse.Shape()
        box2_volume = shape_volume(box2.Shape())
        fused_volume = shape_volume(fused_shape)
        self.assertTrue(close_enough(box1_volume / 8, box2_volume))
        #self.assertTrue(close_enough(box2_volume, fused_volume)) #fused_volume should be 1000

        #now move the other box over a bit
        box2 = BRepPrimAPI_MakeBox(gp_Pnt(10, 10, 10), gp_Pnt(20, 20, 20))
        fuse = BRepAlgoAPI_Fuse(box1.Shape(), box2.Shape())
        fused_shape = fuse.Shape()
        box2_volume = shape_volume(box2.Shape())
        fused_volume = shape_volume(fused_shape)
        self.assertTrue(close_enough(fused_volume / 2, box1_volume))
Пример #2
0
    def test_shape_volume(self):
        box1 = BRepPrimAPI_MakeBox(gp_Pnt(0,0,0), gp_Pnt(10,10,10))
        box2 = BRepPrimAPI_MakeBox(gp_Pnt(0,0,0), gp_Pnt(10,10,10))
        fuse = BRepAlgoAPI_Fuse(box1.Shape(), box2.Shape())
        fused_shape = fuse.Shape()

        from skdb.geom import shape_volume
        box1_volume = shape_volume(box1.Shape())
        box2_volume = shape_volume(box2.Shape())
        fused_volume = shape_volume(fused_shape)

        self.assertEqual(box1_volume, box2_volume)
        self.assertEqual(box1_volume, fused_volume)

        #change box size
        box2 = BRepPrimAPI_MakeBox(gp_Pnt(5,5,5), gp_Pnt(10,10,10))
        fuse = BRepAlgoAPI_Fuse(box1.Shape(), box2.Shape())
        fused_shape = fuse.Shape()
        box2_volume = shape_volume(box2.Shape())
        fused_volume = shape_volume(fused_shape)
        self.assertTrue(close_enough(box1_volume/8, box2_volume))
        #self.assertTrue(close_enough(box2_volume, fused_volume)) #fused_volume should be 1000

        #now move the other box over a bit
        box2 = BRepPrimAPI_MakeBox(gp_Pnt(10,10,10), gp_Pnt(20,20,20))
        fuse = BRepAlgoAPI_Fuse(box1.Shape(), box2.Shape())
        fused_shape = fuse.Shape()
        box2_volume = shape_volume(box2.Shape())
        fused_volume = shape_volume(fused_shape)
        self.assertTrue(close_enough(fused_volume/2, box1_volume))
Пример #3
0
 def test_boundingbox(self):
     len_x, len_y, len_z = 10, 11, 12
     box_shape = BRepPrimAPI_MakeBox(Point(0,0,0), Point(len_x, len_y, len_z)).Shape()
     box = BoundingBox(shape=box_shape)
     #max on x, y, z should be len_x, len_y, len_z .. especially for a box.
     #OCC adds Precision().Confusion() to the box on purpose
     self.assertTrue(close_enough(box.x_max, len_x))
     self.assertTrue(close_enough(box.y_max, len_y))
     self.assertTrue(close_enough(box.z_max, len_z))
     
     #this could get filled out more but who cares
     self.assertTrue(box.contains(gp_Pnt(len_x, len_y, len_z)))
     
     #what about a more complicated shape?
     how_about_not_right_now='''
Пример #4
0
    def test_boundingbox(self):
        len_x, len_y, len_z = 10, 11, 12
        box_shape = BRepPrimAPI_MakeBox(Point(0, 0, 0),
                                        Point(len_x, len_y, len_z)).Shape()
        box = BoundingBox(shape=box_shape)
        #max on x, y, z should be len_x, len_y, len_z .. especially for a box.
        #OCC adds Precision().Confusion() to the box on purpose
        self.assertTrue(close_enough(box.x_max, len_x))
        self.assertTrue(close_enough(box.y_max, len_y))
        self.assertTrue(close_enough(box.z_max, len_z))

        #this could get filled out more but who cares
        self.assertTrue(box.contains(gp_Pnt(len_x, len_y, len_z)))

        #what about a more complicated shape?
        how_about_not_right_now = '''