コード例 #1
0
    def test_eq(self) -> None:
        self.assertEqual(
            cylinder.Cylinder(diameter=15.0, height=7.5, center=True),
            cylinder.Cylinder(diameter=15.0, height=7.5, center=True),
            msg="Equivalent cylinders should be equal",
        )

        self.assertNotEqual(
            cylinder.Cylinder(diameter=15.0, height=7.5, center=True),
            frustum.CircularFrustum(bottom_diameter=15.0,
                                    height=7.5,
                                    center=True),
            msg="A cylinder & equivalent circular frustum should not be equal",
        )
コード例 #2
0
    def _arm(self, axis: vector.Vector,
             color: component.Color) -> component.Component:
        """Construct an arm for representing the frame's alignment

        Args:
            axis: The axis with which the arm should be aligned
            color: The color the arm should have
        """
        arm_cylinder = cylinder.Cylinder(diameter=0.2, height=2.0)
        tip_cone = cone.Cone(bottom_diameter=0.3, height=0.3)

        # Put the cone on top of the cylinder and construct a container for them
        tip_cone.transform(
            tip_cone.bottom_anchor.align(arm_cylinder.top_anchor))
        arm = component.Component(children=[arm_cylinder, tip_cone],
                                  color=color)

        # Align the arm with the desired axis
        arm.transform(
            arm_cylinder.bottom_anchor.align(
                connector.Connector.from_components(axis_x=axis.x,
                                                    axis_y=axis.y,
                                                    axis_z=axis.z)))

        return arm
コード例 #3
0
 def test_body(self) -> None:
     self.assertTrue(
         utils.compare_openscad_objects(
             cylinder.Cylinder(diameter=15.0, height=7.5, center=True).body,
             solid.cylinder(d1=15.0, d2=15.0, h=7.5, center=True),
         ),
         msg="Should produce the expected OpenSCAD object",
     )
コード例 #4
0
    def test_diameter_modification(self) -> None:
        test_cylinder = cylinder.Cylinder(diameter=15.0,
                                          height=7.5,
                                          center=True)
        test_cylinder.diameter = 30.0

        self.assertEqual(
            test_cylinder.diameter,
            30.0,
            msg="Should be able to modify the diameter of an existing cylinder",
        )
コード例 #5
0
    def test_copy(self) -> None:
        test_cylinder = cylinder.Cylinder(diameter=15.0,
                                          height=7.5,
                                          center=True)
        copy_cylinder = test_cylinder.copy()

        self.assertEqual(
            test_cylinder,
            copy_cylinder,
            msg="Copied cylinders should be equivalent to the originals",
        )