Skip to content

Commit 2e1887d

Browse files
faces/edges wip - failing some tests
1 parent 6ee5a1d commit 2e1887d

File tree

4 files changed

+118
-38
lines changed

4 files changed

+118
-38
lines changed

src/ansys/geometry/core/_grpc/_services/_service.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,16 @@ def edges(self) -> GRPCEdgesService:
410410
# Import the appropriate edges service based on the version
411411
from .v0.edges import GRPCEdgesServiceV0
412412
from .v1.edges import GRPCEdgesServiceV1
413+
self._edges = GRPCEdgesServiceV1(self.channel)
413414

414-
if self.version == GeometryApiProtos.V0:
415-
self._edges = GRPCEdgesServiceV0(self.channel)
416-
elif self.version == GeometryApiProtos.V1: # pragma: no cover
417-
# V1 is not implemented yet
418-
self._edges = GRPCEdgesServiceV1(self.channel)
419-
else: # pragma: no cover
420-
# This should never happen as the version is set in the constructor
421-
raise ValueError(f"Unsupported version: {self.version}")
415+
# if self.version == GeometryApiProtos.V0:
416+
# self._edges = GRPCEdgesServiceV0(self.channel)
417+
# elif self.version == GeometryApiProtos.V1: # pragma: no cover
418+
# # V1 is not implemented yet
419+
# self._edges = GRPCEdgesServiceV1(self.channel)
420+
# else: # pragma: no cover
421+
# # This should never happen as the version is set in the constructor
422+
# raise ValueError(f"Unsupported version: {self.version}")
422423

423424
return self._edges
424425

@@ -436,15 +437,16 @@ def faces(self) -> GRPCFacesService:
436437
# Import the appropriate faces service based on the version
437438
from .v0.faces import GRPCFacesServiceV0
438439
from .v1.faces import GRPCFacesServiceV1
439-
440-
if self.version == GeometryApiProtos.V0:
441-
self._faces = GRPCFacesServiceV0(self.channel)
442-
elif self.version == GeometryApiProtos.V1: # pragma: no cover
443-
# V1 is not implemented yet
444-
self._faces = GRPCFacesServiceV1(self.channel)
445-
else: # pragma: no cover
446-
# This should never happen as the version is set in the constructor
447-
raise ValueError(f"Unsupported version: {self.version}")
440+
self._faces = GRPCFacesServiceV1(self.channel)
441+
442+
# if self.version == GeometryApiProtos.V0:
443+
# self._faces = GRPCFacesServiceV0(self.channel)
444+
# elif self.version == GeometryApiProtos.V1: # pragma: no cover
445+
# # V1 is not implemented yet
446+
# self._faces = GRPCFacesServiceV1(self.channel)
447+
# else: # pragma: no cover
448+
# # This should never happen as the version is set in the constructor
449+
# raise ValueError(f"Unsupported version: {self.version}")
448450

449451
return self._faces
450452

src/ansys/geometry/core/_grpc/_services/v1/conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ def from_grpc_curve_to_curve(curve: GRPCCurveGeometry) -> "Curve":
993993
from ansys.geometry.core.shapes.curves.ellipse import Ellipse
994994
from ansys.geometry.core.shapes.curves.line import Line
995995

996-
origin = Point3D([curve.origin.x, curve.origin.y, curve.origin.z])
996+
origin = from_grpc_point_to_point3d(curve.origin)
997997
try:
998998
reference = UnitVector3D([curve.reference.x, curve.reference.y, curve.reference.z])
999999
axis = UnitVector3D([curve.axis.x, curve.axis.y, curve.axis.z])

src/ansys/geometry/core/_grpc/_services/v1/edges.py

Lines changed: 95 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from_length_to_grpc_quantity,
3636
from_point3d_to_grpc_point,
3737
from_unit_vector_to_grpc_direction,
38+
serialize_tracked_command_response,
3839
)
3940

4041

@@ -186,7 +187,10 @@ def get_bounding_box(self, **kwargs) -> dict: # noqa: D102
186187

187188
@protect_grpc
188189
def extrude_edges(self, **kwargs) -> dict: # noqa: D102
189-
from ansys.api.geometry.v0.commands_pb2 import ExtrudeEdgesRequest
190+
from ansys.api.discovery.v1.operations.edit_pb2 import (
191+
ExtrudeEdgesRequest,
192+
ExtrudeEdgesRequestData,
193+
)
190194

191195
# Parse some optional arguments
192196
point = from_point3d_to_grpc_point(kwargs["point"]) if kwargs["point"] else None
@@ -196,34 +200,108 @@ def extrude_edges(self, **kwargs) -> dict: # noqa: D102
196200

197201
# Create the request - assumes all inputs are valid and of the proper type
198202
request = ExtrudeEdgesRequest(
199-
edges=[build_grpc_id(edge_id) for edge_id in kwargs["edge_ids"]],
200-
distance=from_length_to_grpc_quantity(kwargs["distance"]),
201-
face=build_grpc_id(kwargs["face"]),
202-
point=point,
203-
direction=direction,
204-
extrude_type=kwargs["extrude_type"].value,
205-
pull_symmetric=kwargs["pull_symmetric"],
206-
copy=kwargs["copy"],
207-
natural_extension=kwargs["natural_extension"],
203+
request_data=[
204+
ExtrudeEdgesRequestData(
205+
edge_ids=[build_grpc_id(edge_id) for edge_id in kwargs["edge_ids"]],
206+
face_id=build_grpc_id(kwargs["face"]),
207+
point=point,
208+
direction=direction,
209+
distance=from_length_to_grpc_quantity(kwargs["distance"]),
210+
extrude_type=kwargs["extrude_type"].value,
211+
pull_symmetric=kwargs["pull_symmetric"],
212+
copy=kwargs["copy"],
213+
natural_extension=kwargs["natural_extension"],
214+
)
215+
]
208216
)
209217

210-
# Call the gRPC service
211-
resp = self.EditStub.ExtrudeEdges(request)
218+
# Call the gRPC service and serialize the response
219+
response = self.EditStub.ExtrudeEdges(request)
220+
tracked_response = serialize_tracked_command_response(response.tracked_command_response)
212221

213222
# Return the response - formatted as a dictionary
214223
return {
215-
"created_bodies": [body.id for body in resp.created_bodies],
216-
"success": resp.success,
224+
"success": tracked_response.get("success"),
225+
"created_bodies": [body.get("id") for body in tracked_response.get("created_bodies")],
217226
}
218227

219228
@protect_grpc
220229
def extrude_edges_up_to(self, **kwargs) -> dict: # noqa: D102
221-
return NotImplementedError
230+
from ansys.api.discovery.v1.operations.edit_pb2 import (
231+
ExtrudeEdgesUpToRequest,
232+
ExtrudeEdgesUpToRequestData,
233+
)
234+
235+
# Create the request - assumes all inputs are valid and of the proper type
236+
request = ExtrudeEdgesUpToRequest(
237+
request_data=[
238+
ExtrudeEdgesUpToRequestData(
239+
edge_ids=[build_grpc_id(id) for id in kwargs["face_ids"]],
240+
up_to_selection_id=build_grpc_id(kwargs["up_to_selection_id"]),
241+
seed_point=from_point3d_to_grpc_point(kwargs["seed_point"]),
242+
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
243+
extrude_type=kwargs["extrude_type"].value,
244+
)
245+
]
246+
)
247+
248+
# Call the gRPC service and serialize the response
249+
response = self.EditStub.ExtrudeFacesUpTo(request=request)
250+
tracked_response = serialize_tracked_command_response(response.tracked_command_response)
251+
252+
# Return the response - formatted as a dictionary
253+
return {
254+
"success": tracked_response.get("success"),
255+
"created_bodies": [body.get("id") for body in tracked_response.get("created_bodies")],
256+
}
222257

223258
@protect_grpc
224259
def move_imprint_edges(self, **kwargs) -> dict: # noqa: D102
225-
return NotImplementedError
260+
from ansys.api.discovery.v1.operations.edit_pb2 import (
261+
MoveImprintEdgesRequest,
262+
MoveImprintEdgesRequestData,
263+
)
264+
265+
# Create the request - assumes all inputs are valid and of the proper type
266+
request = MoveImprintEdgesRequest(
267+
request_data=[
268+
MoveImprintEdgesRequestData(
269+
edge_ids=[build_grpc_id(edge_id) for edge_id in kwargs["edge_ids"]],
270+
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
271+
distance=from_length_to_grpc_quantity(kwargs["distance"]),
272+
)
273+
]
274+
)
275+
276+
# Call the gRPC service
277+
response = self.EditStub.MoveImprintEdges(request)
278+
279+
# Return the response - formatted as a dictionary
280+
return {
281+
"success": response.tracked_command_response.command_response.success,
282+
}
226283

227284
@protect_grpc
228285
def offset_edges(self, **kwargs) -> dict: # noqa: D102
229-
return NotImplementedError
286+
from ansys.api.discovery.v1.operations.edit_pb2 import (
287+
OffsetEdgesRequest,
288+
OffsetEdgesRequestData,
289+
)
290+
291+
# Create the request - assumes all inputs are valid and of the proper type
292+
request = OffsetEdgesRequest(
293+
request_data=[
294+
OffsetEdgesRequestData(
295+
edge_ids=[build_grpc_id(edge_id) for edge_id in kwargs["edge_ids"]],
296+
value=from_length_to_grpc_quantity(kwargs["offset"]),
297+
)
298+
]
299+
)
300+
301+
# Call the gRPC service
302+
response = self.EditStub.OffsetEdges(request)
303+
304+
# Return the response - formatted as a dictionary
305+
return {
306+
"success": response.tracked_command_response.command_response.success,
307+
}

src/ansys/geometry/core/_grpc/_services/v1/faces.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,15 @@ def extrude_faces_up_to(self, **kwargs) -> dict: # noqa: D102
368368
request = ExtrudeFacesUpToRequest(
369369
request_data=[
370370
ExtrudeFacesUpToRequestData(
371-
faces=[build_grpc_id(id) for id in kwargs["face_ids"]],
372-
up_to_selection=build_grpc_id(kwargs["up_to_selection_id"]),
373-
seed_point=from_point3d_to_grpc_point(kwargs["seed_point"]),
371+
ids=[build_grpc_id(id) for id in kwargs["face_ids"]],
372+
up_to_selection_id=build_grpc_id(kwargs["up_to_selection_id"]),
374373
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
375374
extrude_type=kwargs["extrude_type"].value,
376375
pull_symmetric=kwargs["pull_symmetric"],
377376
offset_mode=kwargs["offset_mode"].value,
378377
copy=kwargs["copy"],
379378
force_do_as_extrude=kwargs["force_do_as_extrude"],
379+
seed_point=from_point3d_to_grpc_point(kwargs["seed_point"]),
380380
)
381381
]
382382
)

0 commit comments

Comments
 (0)