Skip to content

Commit ebdccf1

Browse files
jacobrkerstetterpre-commit-ci[bot]pyansys-ci-botRobPasMue
authored
feat: vertex references (#2083)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com>
1 parent e88fafd commit ebdccf1

File tree

23 files changed

+378
-4
lines changed

23 files changed

+378
-4
lines changed

doc/changelog.d/2083.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Vertex references

src/ansys/geometry/core/_grpc/_services/base/bodies.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def get_edges(self, **kwargs) -> dict:
119119
"""Get the edges of a body."""
120120
pass
121121

122+
@abstractmethod
123+
def get_vertices(self, **kwargs) -> dict:
124+
"""Get the vertices of a body."""
125+
pass
126+
122127
@abstractmethod
123128
def get_volume(self, **kwargs) -> dict:
124129
"""Get the volume of a body."""

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def get_faces(self, **kwargs) -> dict:
6969
"""Get the faces that are connected to the edge."""
7070
pass
7171

72+
@abstractmethod
73+
def get_vertices(self, **kwargs) -> dict:
74+
"""Get the vertices that are connected to the edge."""
75+
pass
76+
7277
@abstractmethod
7378
def get_bounding_box(self, **kwargs) -> dict:
7479
"""Get the bounding box of the edge."""

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def get_edges(self, **kwargs) -> dict:
5959
"""Get the edges of a face."""
6060
pass
6161

62+
@abstractmethod
63+
def get_vertices(self, **kwargs) -> dict:
64+
"""Get the vertices of a face."""
65+
pass
66+
6267
@abstractmethod
6368
def get_loops(self, **kwargs) -> dict:
6469
"""Get the loops of a face."""

src/ansys/geometry/core/_grpc/_services/v0/bodies.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,22 @@ def get_edges(self, **kwargs) -> dict: # noqa: D102
383383
]
384384
}
385385

386+
@protect_grpc
387+
def get_vertices(self, **kwargs) -> dict: # noqa: D102
388+
# Call the gRPC service
389+
resp = self.stub.GetVertices(request=build_grpc_id(kwargs["id"]))
390+
391+
# Return the response - formatted as a dictionary
392+
return {
393+
"vertices": [
394+
{
395+
"id": vertex.id.id,
396+
"position": from_grpc_point_to_point3d(vertex.position),
397+
}
398+
for vertex in resp.vertices
399+
]
400+
}
401+
386402
@protect_grpc
387403
def get_volume(self, **kwargs) -> dict: # noqa: D102
388404
# Call the gRPC service

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,27 @@ def get_faces(self, **kwargs) -> dict: # noqa: D102
138138
],
139139
}
140140

141+
@protect_grpc
142+
def get_vertices(self, **kwargs) -> dict: # noqa: D102
143+
from ansys.api.geometry.v0.edges_pb2 import GetVerticesRequest
144+
145+
# Create the request - assumes all inputs are valid and of proper type
146+
request = GetVerticesRequest(edge=build_grpc_id(kwargs["id"]))
147+
148+
# Call the gRPC service
149+
response = self.stub.GetVertices(request=request)
150+
151+
# Return the response - formatted as a dictionary
152+
return {
153+
"vertices": [
154+
{
155+
"id": vertex.id.id,
156+
"position": from_grpc_point_to_point3d(vertex.position),
157+
}
158+
for vertex in response.vertices
159+
],
160+
}
161+
141162
@protect_grpc
142163
def get_bounding_box(self, **kwargs) -> dict: # noqa: D102
143164
# Create the request - assumes all inputs are valid and of the proper type

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,27 @@ def get_edges(self, **kwargs) -> dict: # noqa: D102
114114
]
115115
}
116116

117+
@protect_grpc
118+
def get_vertices(self, **kwargs) -> dict: # noqa: D102
119+
# Create the request - assumes all inputs are valid and of the proper type
120+
from ansys.api.geometry.v0.faces_pb2 import GetVerticesRequest
121+
122+
request = GetVerticesRequest(face_id=build_grpc_id(kwargs["id"]))
123+
124+
# Call the gRPC service
125+
response = self.stub.GetVertices(request=request)
126+
127+
# Return the response - formatted as a dictionary
128+
return {
129+
"vertices": [
130+
{
131+
"id": vertex.id.id,
132+
"position": from_grpc_point_to_point3d(vertex.position),
133+
}
134+
for vertex in response.vertices
135+
]
136+
}
137+
117138
@protect_grpc
118139
def get_loops(self, **kwargs) -> dict: # noqa: D102
119140
# Create the request - assumes all inputs are valid and of the proper type

src/ansys/geometry/core/_grpc/_services/v0/named_selection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def get_named_selection(self, **kwargs): # noqa: D102
6767
"beams": [beam.id.id for beam in response.beams],
6868
"design_points": [(dp.id, dp.points[0]) for dp in response.design_points],
6969
"components": [comp.id for comp in response.components],
70+
"vertices": [vertex.id.id for vertex in response.vertices],
7071
}
7172

7273
@protect_grpc
@@ -92,6 +93,7 @@ def create_named_selection(self, **kwargs): # noqa: D102
9293
"beams": [beam.id.id for beam in response.beams],
9394
"design_points": [dp.id for dp in response.design_points],
9495
"components": [comp.id for comp in response.components],
96+
"vertices": [vertex.id.id for vertex in response.vertices],
9597
}
9698

9799
@protect_grpc

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def get_faces(self, **kwargs) -> dict: # noqa: D102
112112
def get_edges(self, **kwargs) -> dict: # noqa: D102
113113
raise NotImplementedError
114114

115+
@protect_grpc
116+
def get_vertices(self, **kwargs) -> dict: # noqa: D102
117+
raise NotImplementedError
118+
115119
@protect_grpc
116120
def get_volume(self, **kwargs) -> dict: # noqa: D102
117121
raise NotImplementedError

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def get_interval(self, **kwargs) -> dict: # noqa: D102
7171
def get_faces(self, **kwargs) -> dict: # noqa: D102
7272
return NotImplementedError
7373

74+
@protect_grpc
75+
def get_vertices(self, **kwargs) -> dict: # noqa: D102
76+
return NotImplementedError
77+
7478
@protect_grpc
7579
def get_bounding_box(self, **kwargs) -> dict: # noqa: D102
7680
return NotImplementedError

0 commit comments

Comments
 (0)