Skip to content

feat: Find and Fix Stitch Faces/Missing Faces Enhancements #1953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
38ba56a
added model for testing stitching many faces
May 1, 2025
ade4c4a
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] May 1, 2025
c9bc1c1
chore: adding changelog file 1953.added.md [dependabot-skip]
pyansys-ci-bot May 1, 2025
0547a59
wip - discrepancy in scripting and core service result of find small …
May 1, 2025
065c075
adding max distance to standard find method
May 1, 2025
e70a95c
put default max distance for find stitch to 0.0001
May 1, 2025
785233a
Merge branch 'feat/find_fix_stitch_faces_enhancement' of https://gith…
May 1, 2025
83aebb6
adding options for find missing faces
May 1, 2025
cad60df
Merge branch 'feat/find_missing_faces_enhancement' of https://github.…
May 1, 2025
d54cc0c
changing all angles/distances to proper classes and defaults
May 1, 2025
1edcbc7
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] May 1, 2025
ae6aedf
chore: adding changelog file 1953.added.md [dependabot-skip]
pyansys-ci-bot May 1, 2025
d9baa72
Merge branch 'main' into feat/find_fix_stitch_faces_enhancement
jacobrkerstetter May 6, 2025
8006873
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
May 7, 2025
6960d45
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
May 7, 2025
7034aaf
wip refactoring
May 7, 2025
b8e7251
refactor to match new grpc architecture
May 7, 2025
571fe02
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] May 7, 2025
e00d092
Merge branch 'main' into feat/find_fix_stitch_faces_enhancement
jacobrkerstetter May 7, 2025
981890b
Merge branch 'main' into feat/find_fix_stitch_faces_enhancement
RobPasMue May 8, 2025
750f9a0
chore: general improvements
RobPasMue May 8, 2025
9c98e1b
chore: refactoring
RobPasMue May 8, 2025
dd9e74c
fix: enhancements
RobPasMue May 8, 2025
93290e6
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
May 14, 2025
13c885f
wip, changing signature
May 14, 2025
cf45567
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
May 14, 2025
f9e2cdb
Merge branch 'feat/find_small_faces_enhancements' of https://github.c…
May 14, 2025
45f8d6f
adding small faces options
May 15, 2025
f321646
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] May 15, 2025
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/1953.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Find and Fix Stitch Faces/Missing Faces Enhancements
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GRPCRepairToolsService(ABC):

def __init__(self, channel: grpc.Channel):
"""Initialize the gRPC repair tools service."""
pass # pragma: no cover

@abstractmethod
def find_split_edges(self, **kwargs) -> dict:
Expand Down Expand Up @@ -113,6 +114,11 @@ def find_and_fix_simplify(self, **kwargs) -> dict:
"""Identify and simplify areas in the geometry."""
pass # pragma: no cover

@abstractmethod
def find_and_fix_stitch_faces(self, **kwargs) -> dict:
"""Identify and stitch faces in the geometry."""
pass # pragma: no cover

@abstractmethod
def inspect_geometry(self, **kwargs) -> dict:
"""Inspect the geometry for issues."""
Expand Down
107 changes: 99 additions & 8 deletions src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def find_split_edges(self, **kwargs) -> dict: # noqa: D102

from ansys.api.geometry.v0.repairtools_pb2 import FindSplitEdgesRequest

# Create the gRPC request
# 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(kwargs["angle"])),
Expand Down Expand Up @@ -104,6 +104,7 @@ def find_extra_edges(self, **kwargs) -> dict: # noqa: D102
def find_inexact_edges(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindInexactEdgesRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindInexactEdgesRequest(selection=kwargs["selection"])

# Call the gRPC service
Expand Down Expand Up @@ -150,6 +151,7 @@ def find_short_edges(self, **kwargs) -> dict: # noqa: D102
def find_duplicate_faces(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindDuplicateFacesRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindDuplicateFacesRequest(faces=kwargs["faces"])

# Call the gRPC service
Expand All @@ -168,9 +170,26 @@ def find_duplicate_faces(self, **kwargs) -> dict: # noqa: D102

@protect_grpc
def find_missing_faces(self, **kwargs) -> dict: # noqa: D102
from google.protobuf.wrappers_pb2 import DoubleValue

from ansys.api.geometry.v0.repairtools_pb2 import FindMissingFacesRequest

request = FindMissingFacesRequest(faces=kwargs["faces"])
from ..base.conversions import (
from_measurement_to_server_angle,
from_measurement_to_server_length,
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindMissingFacesRequest(
faces=kwargs["faces"],
angle=DoubleValue(value=from_measurement_to_server_angle(kwargs["angle"]))
if kwargs["angle"] is not None
else None,
distance=DoubleValue(value=from_measurement_to_server_length(kwargs["distance"]))
if kwargs["distance"] is not None
else None,
)

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

Expand All @@ -187,9 +206,26 @@ def find_missing_faces(self, **kwargs) -> dict: # noqa: D102

@protect_grpc
def find_small_faces(self, **kwargs) -> dict: # noqa: D102
from google.protobuf.wrappers_pb2 import DoubleValue

from ansys.api.geometry.v0.repairtools_pb2 import FindSmallFacesRequest

request = FindSmallFacesRequest(selection=kwargs["selection"])
from ..base.conversions import (
from_measurement_to_server_angle,
from_measurement_to_server_length,
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindSmallFacesRequest(
selection=kwargs["selection"],
area=DoubleValue(value=from_measurement_to_server_angle(kwargs["area"]))
if kwargs["area"] is not None
else None,
width=DoubleValue(value=from_measurement_to_server_length(kwargs["width"]))
if kwargs["width"] is not None
else None,
)

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

Expand All @@ -206,11 +242,25 @@ def find_small_faces(self, **kwargs) -> dict: # noqa: D102

@protect_grpc
def find_stitch_faces(self, **kwargs) -> dict: # noqa: D102
from google.protobuf.wrappers_pb2 import DoubleValue

from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest

request = FindStitchFacesRequest(faces=kwargs["faces"])
from ..base.conversions import from_measurement_to_server_length

# Create the request - assumes all inputs are valid and of the proper type
request = FindStitchFacesRequest(
faces=kwargs["faces"],
maximum_distance=DoubleValue(
value=from_measurement_to_server_length(kwargs["distance"])
)
if kwargs["distance"] is not None
else None,
)

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

# Return the response - formatted as a dictionary
return {
"problems": [
Expand All @@ -226,10 +276,12 @@ def find_stitch_faces(self, **kwargs) -> dict: # noqa: D102
def find_simplify(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindAdjustSimplifyRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindAdjustSimplifyRequest(selection=kwargs["selection"])

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

# Return the response - formatted as a dictionary
return {
"problems": [
Expand All @@ -245,12 +297,15 @@ def find_simplify(self, **kwargs) -> dict: # noqa: D102
def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindAdjustSimplifyRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindAdjustSimplifyRequest(
selection=kwargs["selection"],
comprehensive=kwargs["comprehensive_result"],
)

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

# Return the response - formatted as a dictionary
return {
"success": response.success,
Expand All @@ -260,23 +315,54 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102
"modified_bodies_monikers": [],
}

@protect_grpc
def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102
from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue

from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindStitchFacesRequest(
faces=kwargs["body_ids"],
maximum_distance=DoubleValue(value=kwargs["max_distance"])
if kwargs["max_distance"] is not None
else None,
allow_multiple_bodies=BoolValue(value=kwargs["allow_multiple_bodies"]),
maintain_components=BoolValue(value=kwargs["maintain_components"]),
check_for_coincidence=BoolValue(value=kwargs["check_for_coincidence"]),
comprehensive=kwargs["comprehensive_result"],
)

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

# Return the response - formatted as a dictionary
return {
"success": response.success,
"created_bodies_monikers": response.created_bodies_monikers,
"modified_bodies_monikers": response.modified_bodies_monikers,
"found": response.found,
"repaired": response.repaired,
}

@protect_grpc
def inspect_geometry(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import InspectGeometryRequest

# Create the gRPC request
# Create the request - assumes all inputs are valid and of the proper type
request = InspectGeometryRequest(bodies=kwargs.get("bodies", []))

# Call the gRPC service
inspect_result_response = self.stub.InspectGeometry(request)

# Serialize and return the response
return self.serialize_inspect_result_response(inspect_result_response)
return self.__serialize_inspect_result_response(inspect_result_response)

@protect_grpc
def repair_geometry(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import RepairGeometryRequest

# Create the request - assumes all inputs are valid and of the proper type
request = RepairGeometryRequest(bodies=kwargs.get("bodies", []))

# Call the gRPC service
Expand All @@ -293,6 +379,7 @@ def find_interferences(self, **kwargs) -> dict: # noqa: D102

from ansys.api.geometry.v0.repairtools_pb2 import FindInterferenceRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindInterferenceRequest(
bodies=kwargs["bodies"],
cut_smaller_body=BoolValue(value=kwargs["cut_smaller_body"]),
Expand All @@ -318,11 +405,13 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102

from ansys.api.geometry.v0.repairtools_pb2 import FindShortEdgesRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindShortEdgesRequest(
selection=kwargs["selection"],
max_edge_length=DoubleValue(value=kwargs["length"]),
comprehensive=kwargs["comprehensive_result"],
)

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

Expand All @@ -339,10 +428,12 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102
def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindExtraEdgesRequest

# Create the request - assumes all inputs are valid and of the proper type
request = FindExtraEdgesRequest(
selection=kwargs["selection"],
comprehensive=kwargs["comprehensive_result"],
)

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

Expand All @@ -361,6 +452,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102

from ansys.api.geometry.v0.repairtools_pb2 import FindSplitEdgesRequest

# 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(kwargs["angle"])),
Expand All @@ -380,8 +472,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102
"modified_bodies_monikers": [],
}

@staticmethod
def serialize_inspect_result_response(response) -> dict: # noqa: D102
def __serialize_inspect_result_response(self, response) -> dict: # noqa: D102
def serialize_body(body):
return {
"id": body.id,
Expand Down
11 changes: 8 additions & 3 deletions src/ansys/geometry/core/_grpc/_services/v1/repair_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Module containing the repair tools service implementation."""
"""Module containing the repair tools service implementation for v1."""

from abc import ABC

import grpc


class GRPCRepairToolsServiceV1(ABC):
class GRPCRepairToolsServiceV1(ABC): # pragma: no cover
"""Repair tools service for gRPC communication with the Geometry server.

Parameters
Expand All @@ -36,7 +36,9 @@ class GRPCRepairToolsServiceV1(ABC):
"""

def __init__(self, channel: grpc.Channel):
"""Initialize the MeasurementToolsService class."""
from ansys.api.geometry.v1.repairtools_pb2_grpc import RepairToolsStub

self.stub = RepairToolsStub(channel)

def find_split_edges(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError
Expand Down Expand Up @@ -80,6 +82,9 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102
def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

def inspect_geometry(self, **kwargs) -> dict: # noqa: D102
raise NotImplementedError

Expand Down
Loading
Loading