diff --git a/src/build123d/topology/composite.py b/src/build123d/topology/composite.py index 365808d..0919312 100644 --- a/src/build123d/topology/composite.py +++ b/src/build123d/topology/composite.py @@ -141,7 +141,6 @@ class Compound(Mixin3D[TopoDS_Compound]): order = 4.0 - project_to_viewport = Mixin1D.project_to_viewport # ---- Constructor ---- def __init__( @@ -858,6 +857,33 @@ class Compound(Mixin3D[TopoDS_Compound]): return ShapeList(common_set) + def project_to_viewport( + self, + viewport_origin: VectorLike, + viewport_up: VectorLike = (0, 0, 1), + look_at: VectorLike | None = None, + focus: float | None = None, + ) -> tuple[ShapeList[Edge], ShapeList[Edge]]: + """project_to_viewport + + Project a shape onto a viewport returning visible and hidden Edges. + + Args: + viewport_origin (VectorLike): location of viewport + viewport_up (VectorLike, optional): direction of the viewport y axis. + Defaults to (0, 0, 1). + look_at (VectorLike, optional): point to look at. + Defaults to None (center of shape). + focus (float, optional): the focal length for perspective projection + Defaults to None (orthographic projection) + + Returns: + tuple[ShapeList[Edge],ShapeList[Edge]]: visible & hidden Edges + """ + return Mixin1D.project_to_viewport( + self, viewport_origin, viewport_up, look_at, focus + ) + def unwrap(self, fully: bool = True) -> Self | Shape: """Strip unnecessary Compound wrappers diff --git a/src/build123d/topology/three_d.py b/src/build123d/topology/three_d.py index e6a7c38..5b0fb30 100644 --- a/src/build123d/topology/three_d.py +++ b/src/build123d/topology/three_d.py @@ -141,7 +141,6 @@ if TYPE_CHECKING: # pragma: no cover class Mixin3D(Shape[TOPODS]): """Additional methods to add to 3D Shape classes""" - project_to_viewport = Mixin1D.project_to_viewport find_intersection_points = Mixin2D.find_intersection_points # ---- Properties ---- @@ -715,13 +714,32 @@ class Mixin3D(Shape[TOPODS]): return offset_solid - # def solid(self) -> Solid | None: - # """Return the Solid""" - # return Shape.get_single_shape(self, "Solid") + def project_to_viewport( + self, + viewport_origin: VectorLike, + viewport_up: VectorLike = (0, 0, 1), + look_at: VectorLike | None = None, + focus: float | None = None, + ) -> tuple[ShapeList[Edge], ShapeList[Edge]]: + """project_to_viewport - # def solids(self) -> ShapeList[Solid]: - # """solids - all the solids in this Shape""" - # return Shape.get_shape_list(self, "Solid") + Project a shape onto a viewport returning visible and hidden Edges. + + Args: + viewport_origin (VectorLike): location of viewport + viewport_up (VectorLike, optional): direction of the viewport y axis. + Defaults to (0, 0, 1). + look_at (VectorLike, optional): point to look at. + Defaults to None (center of shape). + focus (float, optional): the focal length for perspective projection + Defaults to None (orthographic projection) + + Returns: + tuple[ShapeList[Edge],ShapeList[Edge]]: visible & hidden Edges + """ + return Mixin1D.project_to_viewport( + self, viewport_origin, viewport_up, look_at, focus + ) class Solid(Mixin3D[TopoDS_Solid]): diff --git a/src/build123d/topology/two_d.py b/src/build123d/topology/two_d.py index 5c3e35c..279eb5c 100644 --- a/src/build123d/topology/two_d.py +++ b/src/build123d/topology/two_d.py @@ -172,7 +172,7 @@ T = TypeVar("T", Edge, Wire, "Face") class Mixin2D(ABC, Shape[TOPODS]): """Additional methods to add to Face and Shell class""" - project_to_viewport = Mixin1D.project_to_viewport + # project_to_viewport = Mixin1D.project_to_viewport # ---- Properties ---- @@ -407,13 +407,32 @@ class Mixin2D(ABC, Shape[TOPODS]): """Return a copy of self moved along the normal by amount""" return copy.deepcopy(self).moved(Location(self.normal_at() * amount)) - # def shell(self) -> Shell | None: - # """Return the Shell""" - # return Shape.get_single_shape(self, "Shell") + def project_to_viewport( + self, + viewport_origin: VectorLike, + viewport_up: VectorLike = (0, 0, 1), + look_at: VectorLike | None = None, + focus: float | None = None, + ) -> tuple[ShapeList[Edge], ShapeList[Edge]]: + """project_to_viewport - # def shells(self) -> ShapeList[Shell]: - # """shells - all the shells in this Shape""" - # return Shape.get_shape_list(self, "Shell") + Project a shape onto a viewport returning visible and hidden Edges. + + Args: + viewport_origin (VectorLike): location of viewport + viewport_up (VectorLike, optional): direction of the viewport y axis. + Defaults to (0, 0, 1). + look_at (VectorLike, optional): point to look at. + Defaults to None (center of shape). + focus (float, optional): the focal length for perspective projection + Defaults to None (orthographic projection) + + Returns: + tuple[ShapeList[Edge],ShapeList[Edge]]: visible & hidden Edges + """ + return Mixin1D.project_to_viewport( + self, viewport_origin, viewport_up, look_at, focus + ) def _wrap_edge( self,