def test_absolute_shape_volume(self): """creates a rotated shape using straight and spline connections and \ checks the volume is correct""" test_shape = RotateMixedShape( points=[(0, 0, "straight"), (0, 20, "spline"), (20, 20, "spline"), (20, 0, "spline")]) test_shape.rotation_angle = 360 test_shape.create_solid() assert test_shape.solid is not None assert test_shape.volume > 100 test_shape2 = RotateMixedShape( points=[(0, 0, "straight"), (0, 20, "spline"), (20, 20, "spline"), (20, 0, "spline")]) test_shape2.rotation_angle = 180 test_shape2.create_solid() assert test_shape2.solid is not None assert 2 * test_shape2.volume == test_shape.volume
def test_shape_volume_with_multiple_azimuth_placement_angles(self): """creates rotated shapes at multiple placement angles using mixed connections and checks the volumes are correct""" test_shape = RotateMixedShape( points=[ (1, 1, "straight"), (1, 20, "spline"), (20, 20, "spline"), (20, 1, "spline"), ] ) test_shape.rotation_angle = 10 test_shape.azimuth_placement_angle = [0, 90, 180, 270] test_shape.create_solid() assert test_shape.solid is not None assert test_shape.volume > 100 test_shape2 = RotateMixedShape( points=[ (1, 1, "straight"), (1, 20, "spline"), (20, 20, "spline"), (20, 1, "spline"), ] ) test_shape2.rotation_angle = 5 test_shape2.azimuth_placement_angle = [0, 90, 180, 270] test_shape2.create_solid() assert test_shape2.solid is not None assert 2 * test_shape2.volume == pytest.approx(test_shape.volume) test_shape3 = RotateMixedShape( points=[ (1, 1, "straight"), (1, 20, "spline"), (20, 20, "spline"), (20, 1, "spline"), ] ) test_shape3.rotation_angle = 20 test_shape3.azimuth_placement_angle = [0, 180] test_shape3.create_solid() assert test_shape3.solid is not None assert test_shape3.volume == pytest.approx(test_shape.volume)
def main(): blanket = RotateMixedShape(points=[ (538, 305, "straight"), (538, -305, "straight"), (322, -305, "spline"), (470, 0, "spline"), (322, 305, "straight"), ]) blanket.rotation_angle = 180 blanket.export_stp("blanket_from_points.stp")
def test_hash_value_update(self): """tests that the hash_value of the shape is not updated until a new solid has been created""" test_shape = RotateMixedShape(points=[ (0, 0, "straight"), (0, 20, "spline"), (20, 20, "spline"), ], rotation_angle=360) test_shape.solid assert test_shape.hash_value is not None initial_hash_value = test_shape.hash_value test_shape.rotation_angle = 180 assert test_shape.hash_value == initial_hash_value test_shape.solid assert test_shape.hash_value != initial_hash_value
def test_conditional_solid_reconstruction(self): """tests that a new cadquery solid with a new unique hash is constructed when .solid is called again after changes have been made to the shape""" test_shape = RotateMixedShape(points=[ (0, 0, "straight"), (0, 20, "spline"), (20, 20, "spline"), ], rotation_angle=360) assert test_shape.solid is not None assert test_shape.hash_value is not None initial_hash_value = test_shape.hash_value test_shape.rotation_angle = 180 assert test_shape.solid is not None assert test_shape.hash_value is not None assert initial_hash_value != test_shape.hash_value