Skip to content

Commit

Permalink
fix: start and end points for edge (#1176)
Browse files Browse the repository at this point in the history
Co-authored-by: pyansys-ci-bot <pyansys.github.bot@ansys.com>
  • Loading branch information
RobPasMue and pyansys-ci-bot committed Apr 29, 2024
1 parent 9123c2f commit 5a1f6cf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changelog.d/1176.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: start and end points for edge
28 changes: 28 additions & 0 deletions src/ansys/geometry/core/designer/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def is_reversed(self) -> bool:
return self._is_reversed

@property
@protect_grpc
@ensure_design_is_active
@min_backend_version(24, 2, 0)
def shape(self) -> TrimmedCurve:
"""
Expand Down Expand Up @@ -175,3 +177,29 @@ def faces(self) -> List["Face"]:
)
for grpc_face in grpc_faces
]

@property
@protect_grpc
@ensure_design_is_active
def start(self) -> Point3D:
"""Start point of the edge."""
try:
return self.shape.start
except GeometryRuntimeError: # pragma: no cover
# Only for versions earlier than 24.2.0 (before the introduction of the shape property)
self._grpc_client.log.debug("Requesting edge start point from server.")
response = self._edges_stub.GetStartAndEndPoints(self._grpc_id)
return Point3D([response.start.x, response.start.y, response.start.z])

@property
@protect_grpc
@ensure_design_is_active
def end(self) -> Point3D:
"""End point of the edge."""
try:
return self.shape.end
except GeometryRuntimeError: # pragma: no cover
# Only for versions earlier than 24.2.0 (before the introduction of the shape property)
self._grpc_client.log.debug("Requesting edge end point from server.")
response = self._edges_stub.GetStartAndEndPoints(self._grpc_id)
return Point3D([response.end.x, response.end.y, response.end.z])
6 changes: 6 additions & 0 deletions src/ansys/geometry/core/designer/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def body(self) -> "Body":
return self._body

@property
@protect_grpc
@ensure_design_is_active
@min_backend_version(24, 2, 0)
def shape(self) -> TrimmedSurface:
"""
Expand Down Expand Up @@ -284,6 +286,7 @@ def loops(self) -> List[FaceLoop]:
return loops

@protect_grpc
@ensure_design_is_active
def normal(self, u: float = 0.5, v: float = 0.5) -> UnitVector3D:
"""
Get the normal direction to the face at certain proportional UV coordinates.
Expand Down Expand Up @@ -319,6 +322,7 @@ def normal(self, u: float = 0.5, v: float = 0.5) -> UnitVector3D:
return UnitVector3D([response.x, response.y, response.z])

@protect_grpc
@ensure_design_is_active
def point(self, u: float = 0.5, v: float = 0.5) -> Point3D:
"""
Get a point of the face evaluated at certain proportional UV coordinates.
Expand Down Expand Up @@ -381,6 +385,8 @@ def __grpc_edges_to_edges(self, edges_grpc: List[GRPCEdge]) -> List[Edge]:
)
return edges

@protect_grpc
@ensure_design_is_active
def create_isoparametric_curves(
self, use_u_param: bool, parameter: float
) -> List[TrimmedCurve]:
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/geometry/core/plotting/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def add_body_edges(self, body_plot: GeomObjectPlot, **plotting_options: Optional
"""
edge_plot_list = []
for edge in body_plot.object.edges:
line = pv.Line(edge.shape.start, edge.shape.start)
line = pv.Line(edge.start, edge.end)
edge_actor = self.scene.add_mesh(
line, line_width=10, color=EDGE_COLOR, **plotting_options
)
Expand Down

0 comments on commit 5a1f6cf

Please sign in to comment.