def test_extruded_shape_volume(self): """creates an extruded shape with multiple placement angles using straight \ connections and checks the volume is correct""" test_shape = ExtrudeStraightShape(points=[(5, 0), (5, 20), (15, 20), (15, 0)], distance=10) test_shape.azimuth_placement_angle = 0 assert test_shape.volume == pytest.approx(10 * 20 * 10 * 1) test_shape.azimuth_placement_angle = [0, 90, 180, 270] assert test_shape.volume == pytest.approx(10 * 20 * 10 * 4)
def test_extruded_shape_relative_volume(self): """creates two extruded shapes at different placement angles using straight connections and checks that their relative volumes are correct""" test_shape = ExtrudeStraightShape(points=[(5, 0), (5, 20), (15, 20), (15, 0)], distance=10) test_shape.azimuth_placement_angle = 0 assert test_shape.volume == pytest.approx(10 * 20 * 10 * 1) test_shape.azimuth_placement_angle = [0, 90, 180, 270] assert test_shape.volume == pytest.approx(10 * 20 * 10 * 4)
def test_extruded_shape_with_overlap_volume(self): """creates two overlapping extruded shapes at different placement angles using straight connections and checks that their volume is correct""" test_shape = ExtrudeStraightShape(points=[(0, 0), (0, 20), (10, 20), (10, 0)], distance=10) test_shape.azimuth_placement_angle = [0, 90, 180, 270] assert test_shape.volume == pytest.approx((10 * 20 * 10 * 4) - (5 * 20 * 5 * 4))
def test_conditional_solid_reconstruction_parameters(self): """tests that a new cadquery solid with a new unique hash is created when the shape properties of points, distance, workplane, name, color, material_tag, stp_filename, azimuth_placement_angle or cut are changed""" # points test_shape = ExtrudeStraightShape(points=[(0, 0), (0, 20), (20, 20)], distance=20) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.points = [(0, 0), (10, 30), (15, 50), (25, 5), (15, 0)] test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # distance test_shape = ExtrudeStraightShape(points=[(0, 0), (0, 20), (20, 20)], distance=20) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.distance = 30 test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # workplane test_shape = ExtrudeStraightShape( points=[(0, 0), (0, 20), (20, 20)], distance=20, workplane="XZ", ) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.workplane = "YZ" test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # name test_shape = ExtrudeStraightShape( points=[(0, 0), (0, 20), (20, 20)], distance=20, name='test_name', ) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.name = 'new_name' test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # color test_shape = ExtrudeStraightShape( points=[(0, 0), (0, 20), (20, 20)], distance=20, color=[0.5, 0.5, 0.5], ) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.color = [0.1, 0.2, 0.8] test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # material_tag test_shape = ExtrudeStraightShape( points=[(0, 0), (0, 20), (20, 20)], distance=20, material_tag='test_material', ) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.material_tag = 'new_material' test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # stp_filename test_shape = ExtrudeStraightShape( points=[(0, 0), (0, 20), (20, 20)], distance=20, stp_filename='test_filename.stp', ) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.stp_filename = 'new_filename.stp' test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # azimuth_placement_angle test_shape = ExtrudeStraightShape( points=[(0, 0), (0, 20), (20, 20)], distance=20, azimuth_placement_angle=0, ) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.azimuth_placement_angle = 180 test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value # cut cut_shape = ExtrudeStraightShape(points=[(5, 5), (5, 15), (15, 15)], distance=5) test_shape = ExtrudeStraightShape( points=[(0, 0), (0, 20), (20, 20)], distance=20, ) test_shape.solid initial_hash_value = test_shape.hash_value test_shape.cut = cut_shape test_shape.solid assert test_shape.solid is not None assert test_shape.hash_value != initial_hash_value