Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/2361.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change find split edges default
15 changes: 12 additions & 3 deletions src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ def find_split_edges(self, **kwargs) -> dict: # noqa: D102
# Create the request - assumes all inputs are valid and of the proper type
request = FindSplitEdgesRequest(
bodies_or_faces=kwargs["bodies_or_faces"],
angle=DoubleValue(value=float(from_measurement_to_server_angle(kwargs["angle"]))),
distance=DoubleValue(
value=float(from_measurement_to_server_length(kwargs["distance"]))
angle=(
DoubleValue(value=float(from_measurement_to_server_angle(kwargs["angle"])))
if kwargs["angle"] is not None
else None
),
distance=(
DoubleValue(value=float(from_measurement_to_server_length(kwargs["distance"])))
if kwargs["distance"] is not None
else None
),
)

print("distance:", request.distance)
print("angle:", request.angle)
Comment on lines +80 to +81
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobrkerstetter - these prints have to be removed.


# Call the gRPC service
response = self.stub.FindSplitEdges(request)

Expand Down
20 changes: 14 additions & 6 deletions src/ansys/geometry/core/tools/repair_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def __init__(self, grpc_client: GrpcClient, modeler: "Modeler", _internal_use: b
def find_split_edges(
self,
bodies: list["Body"],
angle: Angle | pint.Quantity | Real = 0.0,
length: Distance | pint.Quantity | Real = 0.0,
angle: Angle | pint.Quantity | Real = None,
length: Distance | pint.Quantity | Real = None,
) -> list[SplitEdgeProblemAreas]:
"""Find split edges in the given list of bodies.

Expand All @@ -112,9 +112,9 @@ def find_split_edges(
bodies : list[Body]
List of bodies that split edges are investigated on.
angle : Angle | ~pint.Quantity | Real
The maximum angle between edges.
The maximum angle between edges. By default, None.
length : Distance | ~pint.Quantity | Real
The maximum length of the edges.
The maximum length of the edges. By default, None.

Returns
-------
Expand All @@ -127,9 +127,17 @@ def find_split_edges(
body_ids = [body.id for body in bodies]

# Convert the measurement objects
angle = angle if isinstance(angle, Angle) else Angle(angle)
length = length if isinstance(length, Distance) else Distance(length)
angle = angle if isinstance(angle, Angle) else Angle(angle) if angle is not None else None
length = (
length
if isinstance(length, Distance)
else Distance(length)
if length is not None
else None
)

print("angle:", angle)
print("length:", length)
Comment on lines +139 to +140
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here..

response = self._grpc_client.services.repair_tools.find_split_edges(
bodies_or_faces=body_ids, angle=angle, distance=length
)
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/test_repair_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def test_find_split_edges(modeler: Modeler):
problem_areas = modeler.repair_tools.find_split_edges(design.bodies, 25, 150)
assert len(problem_areas) == 3

# Try with default values
problem_areas = modeler.repair_tools.find_split_edges(design.bodies)
assert len(problem_areas) == 3

# Try with values that yield no results
problem_areas = modeler.repair_tools.find_split_edges(design.bodies, 0, 0)
assert len(problem_areas) == 0


def test_find_split_edge_id(modeler: Modeler):
"""Test whether problem area has the id."""
Expand Down
Loading