MCPcopy
hub / github.com/CadQuery/cadquery / mirror

Method mirror

cadquery/occ_impl/shapes.py:694–727  ·  view source on GitHub ↗

Applies a mirror transform to this Shape. Does not duplicate objects about the plane. :param mirrorPlane: The direction of the plane to mirror about - one of 'XY', 'XZ' or 'YZ' :param basePointVector: The origin of the plane to mirror about :retu

(
        self,
        mirrorPlane: Literal["XY", "YX", "XZ", "ZX", "YZ", "ZY"] | VectorLike = "XY",
        basePointVector: VectorLike = (0, 0, 0),
    )

Source from the content-addressed store, hash-verified

692 return BoundBox._fromTopoDS(self.wrapped, tol=tolerance)
693
694 def mirror(
695 self,
696 mirrorPlane: Literal["XY", "YX", "XZ", "ZX", "YZ", "ZY"] | VectorLike = "XY",
697 basePointVector: VectorLike = (0, 0, 0),
698 ) -> Shape:
699 """
700 Applies a mirror transform to this Shape. Does not duplicate objects
701 about the plane.
702
703 :param mirrorPlane: The direction of the plane to mirror about - one of
704 'XY', 'XZ' or 'YZ'
705 :param basePointVector: The origin of the plane to mirror about
706 :returns: The mirrored shape
707 """
708 if isinstance(mirrorPlane, str):
709 if mirrorPlane == "XY" or mirrorPlane == "YX":
710 mirrorPlaneNormalVector = gp_Dir(0, 0, 1)
711 elif mirrorPlane == "XZ" or mirrorPlane == "ZX":
712 mirrorPlaneNormalVector = gp_Dir(0, 1, 0)
713 elif mirrorPlane == "YZ" or mirrorPlane == "ZY":
714 mirrorPlaneNormalVector = gp_Dir(1, 0, 0)
715 else:
716 if isinstance(mirrorPlane, tuple):
717 mirrorPlaneNormalVector = gp_Dir(*mirrorPlane)
718 elif isinstance(mirrorPlane, Vector):
719 mirrorPlaneNormalVector = mirrorPlane.toDir()
720
721 if isinstance(basePointVector, tuple):
722 basePointVector = Vector(basePointVector)
723
724 T = gp_Trsf()
725 T.SetMirror(gp_Ax2(gp_Pnt(*basePointVector.toTuple()), mirrorPlaneNormalVector))
726
727 return self._apply_transform(T)
728
729 @staticmethod
730 def _center_of_mass(shape: Shape) -> Vector:

Callers

nothing calls this directly

Calls 4

toTupleMethod · 0.95
_apply_transformMethod · 0.95
VectorClass · 0.85
toDirMethod · 0.80

Tested by

no test coverage detected