mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-05 18:20:46 -08:00
Making project_to_viewport a proper method
Some checks failed
benchmarks / benchmarks (macos-14, 3.12) (push) Has been cancelled
benchmarks / benchmarks (macos-15-intel, 3.12) (push) Has been cancelled
benchmarks / benchmarks (ubuntu-latest, 3.12) (push) Has been cancelled
benchmarks / benchmarks (windows-latest, 3.12) (push) Has been cancelled
Upload coverage reports to Codecov / run (push) Has been cancelled
pylint / lint (3.10) (push) Has been cancelled
Run type checker / typecheck (3.10) (push) Has been cancelled
Run type checker / typecheck (3.13) (push) Has been cancelled
Wheel building and publishing / Build wheel on ubuntu-latest (push) Has been cancelled
tests / tests (macos-14, 3.10) (push) Has been cancelled
tests / tests (macos-14, 3.13) (push) Has been cancelled
tests / tests (macos-15-intel, 3.10) (push) Has been cancelled
tests / tests (macos-15-intel, 3.13) (push) Has been cancelled
tests / tests (ubuntu-latest, 3.10) (push) Has been cancelled
tests / tests (ubuntu-latest, 3.13) (push) Has been cancelled
tests / tests (windows-latest, 3.10) (push) Has been cancelled
tests / tests (windows-latest, 3.13) (push) Has been cancelled
Wheel building and publishing / upload_pypi (push) Has been cancelled
Some checks failed
benchmarks / benchmarks (macos-14, 3.12) (push) Has been cancelled
benchmarks / benchmarks (macos-15-intel, 3.12) (push) Has been cancelled
benchmarks / benchmarks (ubuntu-latest, 3.12) (push) Has been cancelled
benchmarks / benchmarks (windows-latest, 3.12) (push) Has been cancelled
Upload coverage reports to Codecov / run (push) Has been cancelled
pylint / lint (3.10) (push) Has been cancelled
Run type checker / typecheck (3.10) (push) Has been cancelled
Run type checker / typecheck (3.13) (push) Has been cancelled
Wheel building and publishing / Build wheel on ubuntu-latest (push) Has been cancelled
tests / tests (macos-14, 3.10) (push) Has been cancelled
tests / tests (macos-14, 3.13) (push) Has been cancelled
tests / tests (macos-15-intel, 3.10) (push) Has been cancelled
tests / tests (macos-15-intel, 3.13) (push) Has been cancelled
tests / tests (ubuntu-latest, 3.10) (push) Has been cancelled
tests / tests (ubuntu-latest, 3.13) (push) Has been cancelled
tests / tests (windows-latest, 3.10) (push) Has been cancelled
tests / tests (windows-latest, 3.13) (push) Has been cancelled
Wheel building and publishing / upload_pypi (push) Has been cancelled
This commit is contained in:
parent
726a72a20b
commit
a971cbbad6
3 changed files with 78 additions and 15 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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]):
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue