mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -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
|
order = 4.0
|
||||||
|
|
||||||
project_to_viewport = Mixin1D.project_to_viewport
|
|
||||||
# ---- Constructor ----
|
# ---- Constructor ----
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -858,6 +857,33 @@ class Compound(Mixin3D[TopoDS_Compound]):
|
||||||
|
|
||||||
return ShapeList(common_set)
|
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:
|
def unwrap(self, fully: bool = True) -> Self | Shape:
|
||||||
"""Strip unnecessary Compound wrappers
|
"""Strip unnecessary Compound wrappers
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,6 @@ if TYPE_CHECKING: # pragma: no cover
|
||||||
class Mixin3D(Shape[TOPODS]):
|
class Mixin3D(Shape[TOPODS]):
|
||||||
"""Additional methods to add to 3D Shape classes"""
|
"""Additional methods to add to 3D Shape classes"""
|
||||||
|
|
||||||
project_to_viewport = Mixin1D.project_to_viewport
|
|
||||||
find_intersection_points = Mixin2D.find_intersection_points
|
find_intersection_points = Mixin2D.find_intersection_points
|
||||||
|
|
||||||
# ---- Properties ----
|
# ---- Properties ----
|
||||||
|
|
@ -715,13 +714,32 @@ class Mixin3D(Shape[TOPODS]):
|
||||||
|
|
||||||
return offset_solid
|
return offset_solid
|
||||||
|
|
||||||
# def solid(self) -> Solid | None:
|
def project_to_viewport(
|
||||||
# """Return the Solid"""
|
self,
|
||||||
# return Shape.get_single_shape(self, "Solid")
|
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]:
|
Project a shape onto a viewport returning visible and hidden Edges.
|
||||||
# """solids - all the solids in this Shape"""
|
|
||||||
# return Shape.get_shape_list(self, "Solid")
|
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]):
|
class Solid(Mixin3D[TopoDS_Solid]):
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ T = TypeVar("T", Edge, Wire, "Face")
|
||||||
class Mixin2D(ABC, Shape[TOPODS]):
|
class Mixin2D(ABC, Shape[TOPODS]):
|
||||||
"""Additional methods to add to Face and Shell class"""
|
"""Additional methods to add to Face and Shell class"""
|
||||||
|
|
||||||
project_to_viewport = Mixin1D.project_to_viewport
|
# project_to_viewport = Mixin1D.project_to_viewport
|
||||||
|
|
||||||
# ---- Properties ----
|
# ---- Properties ----
|
||||||
|
|
||||||
|
|
@ -407,13 +407,32 @@ class Mixin2D(ABC, Shape[TOPODS]):
|
||||||
"""Return a copy of self moved along the normal by amount"""
|
"""Return a copy of self moved along the normal by amount"""
|
||||||
return copy.deepcopy(self).moved(Location(self.normal_at() * amount))
|
return copy.deepcopy(self).moved(Location(self.normal_at() * amount))
|
||||||
|
|
||||||
# def shell(self) -> Shell | None:
|
def project_to_viewport(
|
||||||
# """Return the Shell"""
|
self,
|
||||||
# return Shape.get_single_shape(self, "Shell")
|
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]:
|
Project a shape onto a viewport returning visible and hidden Edges.
|
||||||
# """shells - all the shells in this Shape"""
|
|
||||||
# return Shape.get_shape_list(self, "Shell")
|
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(
|
def _wrap_edge(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue