Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
97eb31a
chore: update CHANGELOG for v0.9.0 (#1753)
pyansys-ci-bot Feb 17, 2025
1547839
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Mar 10, 2025
5a48878
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Mar 27, 2025
4109456
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Apr 8, 2025
e00316b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu May 20, 2025
1afa37a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jun 11, 2025
7c595bb
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jun 24, 2025
6a23076
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jul 7, 2025
62ca792
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jul 9, 2025
40c19c1
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Jul 28, 2025
40a13e2
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 3, 2025
269ec5b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 22, 2025
6217f4a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 24, 2025
7a728c4
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 25, 2025
6c462de
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Sep 30, 2025
3611a99
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Oct 8, 2025
c5a4e86
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Oct 11, 2025
ecd7567
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Oct 13, 2025
8b628a2
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 18, 2025
f55daa8
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 21, 2025
38324c1
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 24, 2025
18f6686
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Nov 25, 2025
6147028
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Dec 1, 2025
85a9d0b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Dec 1, 2025
a3de5c0
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu Dec 2, 2025
f80402b
v1 implementation of repair tools
smereu Dec 3, 2025
5b3aaa5
chore: adding changelog file 2441.maintenance.md [dependabot-skip]
pyansys-ci-bot Dec 3, 2025
b032622
Merge branch 'main' into ci/v1-implementation-of-repair-stub
jacobrkerstetter Dec 3, 2025
68dacd8
chore: adding changelog file 2441.maintenance.md [dependabot-skip]
pyansys-ci-bot Dec 3, 2025
659dc43
code review
smereu Dec 3, 2025
3f13da1
clean_up from copilot
smereu Dec 3, 2025
7082ad7
fix error
smereu Dec 4, 2025
c596a69
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Dec 4, 2025
bc61363
fix typos
smereu Dec 4, 2025
10ee4ee
Merge branch 'ci/v1-implementation-of-repair-stub' of https://github.…
smereu Dec 4, 2025
dcc902c
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Dec 4, 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/1753.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update CHANGELOG for v0.9.0
1 change: 1 addition & 0 deletions doc/changelog.d/2441.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Chore: v1 implementation of repair stubs
105 changes: 36 additions & 69 deletions src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
# 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 for v0.

This module defines an abstract base class for a gRPC-based repair tools service.
The class provides a set of abstract methods for identifying and repairing various
geometry issues, such as split edges, extra edges, duplicate faces etc.
"""
"""Module containing the repair tools service implementation for v0."""

from google.protobuf.wrappers_pb2 import Int32Value
import grpc
Expand Down Expand Up @@ -184,27 +179,11 @@ def find_missing_faces(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindMissingFacesRequest
from google.protobuf.wrappers_pb2 import DoubleValue

from ansys.geometry.core.logger import LOG

from ..base.conversions import (
from_measurement_to_server_angle,
from_measurement_to_server_length,
)

# Check the backend version to set optional parameters
if kwargs["backend_version"] < (26, 1, 0) and (
kwargs["angle"] is not None or kwargs["distance"] is not None
):
# If the backend version is less than 26.1.0, set angle and distance to None
kwargs["angle"] = None
kwargs["distance"] = None

# Log a warning
LOG.warning(
"The backend version is less than 26.1.0, so angle and distance parameters will be"
"ignored. Please update the backend to use these parameters."
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindMissingFacesRequest(
faces=kwargs["faces"],
Expand Down Expand Up @@ -235,27 +214,11 @@ def find_small_faces(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindSmallFacesRequest
from google.protobuf.wrappers_pb2 import DoubleValue

from ansys.geometry.core.logger import LOG

from ..base.conversions import (
from_measurement_to_server_area,
from_measurement_to_server_length,
)

# Check the backend version to set optional parameters
if kwargs["backend_version"] < (26, 1, 0) and (
kwargs["area"] is not None or kwargs["width"] is not None
):
# If the backend version is less than 26.1.0, set area and width to None
kwargs["area"] = None
kwargs["width"] = None

# Log a warning
LOG.warning(
"The backend version is less than 26.1.0, so area and width parameters will be"
"ignored. Please update the backend to use these parameters."
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindSmallFacesRequest(
selection=kwargs["selection"],
Expand Down Expand Up @@ -286,17 +249,8 @@ def find_stitch_faces(self, **kwargs) -> dict: # noqa: D102
from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest
from google.protobuf.wrappers_pb2 import DoubleValue

from ansys.geometry.core.logger import LOG

from ..base.conversions import from_measurement_to_server_length

if kwargs["backend_version"] < (26, 1, 0) and kwargs["distance"] is not None:
# If the backend version is less than 26.1.0, set distance to None and log warning
kwargs["distance"] = None
LOG.warning(
"The backend version is less than 26.1.0, so distance parameter will be ignored. "
)

# Create the request - assumes all inputs are valid and of the proper type
request = FindStitchFacesRequest(
faces=kwargs["faces"],
Expand Down Expand Up @@ -393,7 +347,7 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102
"repaired": response.repaired,
"created_bodies_monikers": [],
"modified_bodies_monikers": [],
"complete_command_response": serialized_tracker_response,
"tracker_response": serialized_tracker_response,
}

@protect_grpc
Expand All @@ -420,7 +374,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102
"repaired": response.repaired,
"created_bodies_monikers": response.created_bodies_monikers,
"modified_bodies_monikers": response.modified_bodies_monikers,
"complete_command_response": serialized_tracker_response,
"tracker_response": serialized_tracker_response,
}

@protect_grpc
Expand Down Expand Up @@ -449,7 +403,7 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102
"repaired": response.repaired,
"created_bodies_monikers": [],
"modified_bodies_monikers": [],
"complete_command_response": serialized_tracker_response,
"tracker_response": serialized_tracker_response,
}

@protect_grpc
Expand All @@ -476,7 +430,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102
"repaired": response.repaired,
"created_bodies_monikers": [],
"modified_bodies_monikers": [],
"complete_command_response": serialized_tracker_response,
"tracker_response": serialized_tracker_response,
}

@protect_grpc
Expand Down Expand Up @@ -514,7 +468,7 @@ def find_and_fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102
"modified_bodies_monikers": response.modified_bodies_monikers,
"found": response.found,
"repaired": response.repaired,
"complete_command_response": serialized_tracker_response,
"tracker_response": serialized_tracker_response,
}

@protect_grpc
Expand Down Expand Up @@ -566,7 +520,9 @@ def fix_duplicate_faces(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -590,7 +546,9 @@ def fix_missing_faces(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -614,7 +572,9 @@ def fix_inexact_edges(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -636,7 +596,9 @@ def fix_extra_edges(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -658,7 +620,9 @@ def fix_short_edges(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -680,7 +644,9 @@ def fix_small_faces(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -702,7 +668,9 @@ def fix_split_edges(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -726,7 +694,9 @@ def fix_stitch_faces(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -750,7 +720,9 @@ def fix_unsimplified_faces(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

@protect_grpc
Expand All @@ -774,7 +746,9 @@ def fix_interference(self, **kwargs) -> dict: # noqa: D102
# Return the response - formatted as a dictionary
return {
"tracker_response": serialized_tracker_response,
"repair_tracker_response": self.__serialize_message_response(response),
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}

def __serialize_inspect_result_response(self, response) -> dict: # noqa: D102
Expand Down Expand Up @@ -830,10 +804,3 @@ def serialize_issue(issue):
for body_issues in response.issues_by_body
]
}

def __serialize_message_response(self, response):
return {
"success": response.result.success,
"created_bodies_monikers": response.result.created_bodies_monikers,
"modified_bodies_monikers": response.result.modified_bodies_monikers,
}
114 changes: 114 additions & 0 deletions src/ansys/geometry/core/_grpc/_services/v1/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
CurveGeometry as GRPCCurveGeometry,
DrivingDimensionEntity as GRPCDrivingDimension,
EdgeTessellation as GRPCEdgeTessellation,
EnhancedRepairToolMessage as GRPCEnhancedRepairToolResponse,
Geometries as GRPCGeometries,
Knot as GRPCKnot,
MaterialEntity as GRPCMaterial,
Expand Down Expand Up @@ -1349,6 +1350,38 @@ def from_angle_to_grpc_quantity(input: "Measurement") -> GRPCQuantity:
return GRPCQuantity(value_in_geometry_units=input.value.m_as(DEFAULT_UNITS.SERVER_ANGLE))


def from_area_to_grpc_quantity(input: "Measurement") -> GRPCQuantity:
"""Convert a ``Measurement`` containing an area to a gRPC quantity.
Parameters
----------
input : Measurement
Source measurement data.
Returns
-------
GRPCQuantity
Converted gRPC quantity.
"""
return GRPCQuantity(value_in_geometry_units=input.value.m_as(DEFAULT_UNITS.SERVER_AREA))


def from_volume_to_grpc_quantity(input: "Measurement") -> GRPCQuantity:
"""Convert a ``Measurement`` containing a volume to a gRPC quantity.
Parameters
----------
input : Measurement
Source measurement data.
Returns
-------
GRPCQuantity
Converted gRPC quantity.
"""
return GRPCQuantity(value_in_geometry_units=input.value.m_as(DEFAULT_UNITS.SERVER_VOLUME))


def _nurbs_curves_compatibility(backend_version: "semver.Version", grpc_geometries: GRPCGeometries):
"""Check if the backend version is compatible with NURBS curves in sketches.
Expand Down Expand Up @@ -1568,3 +1601,84 @@ def get_tracker_response_with_created_bodies(response) -> dict:
"created_bodies", []
)
return serialized_response


def serialize_repair_command_response(response: GRPCEnhancedRepairToolResponse) -> dict:
"""Serialize a EnhancedRepairToolResponse object into a dictionary.
Parameters
----------
response : GRPCEnhancedRepairToolResponse
The gRPC EnhancedRepairToolResponse object to serialize.
A dictionary representation of the EnhancedRepairToolResponse object.
"""
return {
"success": response.tracked_changes.command_response.success,
"found": response.found,
"repaired": response.repaired,
"complete_command_response": serialize_tracked_command_response(response.tracked_changes),
"created_bodies_monikers": [
created_body.id for created_body in response.tracked_changes.get("created_bodies", [])
],
"modified_bodies_monikers": [
modified_body.id
for modified_body in response.tracked_changes.get("modified_bodies", [])
],
"deleted_bodies_monikers": [
deleted_body.id for deleted_body in response.tracked_changes.get("deleted_bodies", [])
],
}


def response_problem_area_for_body(response) -> dict:
"""Get a dictionary response from problem areas for a body.
Parameters
----------
response
The response to convert.
Returns
-------
dict
A dictionary representation of the ProblemAreaForBody object.
"""
return {
"problems": [{"id": res.problem_area_id, "bodies": res.body_ids} for res in response.result]
}


def response_problem_area_for_face(response) -> dict:
"""Get a dictionary response from problem areas for a face.
Parameters
----------
response
The response to convert.
Returns
-------
dict
A dictionary representation of the ProblemAreaForFace object.
"""
return {
"problems": [{"id": res.problem_area_id, "faces": res.face_ids} for res in response.result]
Copy link
Contributor

Choose a reason for hiding this comment

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

call .id on each face_id

}


def response_problem_area_for_edge(response) -> dict:
"""Get a dictionary response from problem areas for an edge.
Parameters
----------
response
The response to convert.
Returns
-------
dict
A dictionary representation of the ProblemAreaForEdge object.
"""
return {
"problems": [{"id": res.problem_area_id, "edges": res.edge_ids} for res in response.result]
}
Loading
Loading