31
31
FindStitchFacesRequest ,
32
32
)
33
33
from ansys .api .geometry .v0 .repairtools_pb2_grpc import RepairToolsStub
34
- from beartype .typing import List
34
+ from beartype .typing import TYPE_CHECKING , List
35
+
36
+ if TYPE_CHECKING : # pragma: no cover
37
+ from ansys .geometry .core .designer .body import Body
38
+
35
39
from google .protobuf .wrappers_pb2 import DoubleValue
36
40
37
41
from ansys .geometry .core .connection import GrpcClient
@@ -56,7 +60,7 @@ def __init__(self, grpc_client: GrpcClient):
56
60
self ._repair_stub = RepairToolsStub (self ._grpc_client .channel )
57
61
58
62
def find_split_edges (
59
- self , ids : List [str ], angle : Real = 0.0 , length : Real = 0.0
63
+ self , bodies : List ["Body" ], angle : Real = 0.0 , length : Real = 0.0
60
64
) -> List [SplitEdgeProblemAreas ]:
61
65
"""
62
66
Find split edges in the given list of bodies.
@@ -66,8 +70,8 @@ def find_split_edges(
66
70
67
71
Parameters
68
72
----------
69
- ids : List[str ]
70
- Server-defined ID for the bodies .
73
+ bodies : List[Body ]
74
+ List of bodies that split edges are investigated on .
71
75
angle : Real
72
76
The maximum angle between edges.
73
77
length : Real
@@ -80,21 +84,21 @@ def find_split_edges(
80
84
"""
81
85
angle_value = DoubleValue (value = float (angle ))
82
86
length_value = DoubleValue (value = float (length ))
87
+ body_ids = [body .id for body in bodies ]
88
+
83
89
problem_areas_response = self ._repair_stub .FindSplitEdges (
84
- FindSplitEdgesRequest (bodies_or_faces = ids , angle = angle_value , distance = length_value )
90
+ FindSplitEdgesRequest (
91
+ bodies_or_faces = body_ids , angle = angle_value , distance = length_value
92
+ )
85
93
)
86
94
87
- problem_areas = []
88
- for res in problem_areas_response .result :
89
- connected_edges = []
90
- for edge_moniker in res .edge_monikers :
91
- connected_edges .append (edge_moniker )
92
- problem_area = SplitEdgeProblemAreas (res .id , connected_edges , self ._grpc_client )
93
- problem_areas .append (problem_area )
94
-
95
+ problem_areas = [
96
+ SplitEdgeProblemAreas (res .id , list (res .edge_monikers ), self ._grpc_client )
97
+ for res in problem_areas_response .result
98
+ ]
95
99
return problem_areas
96
100
97
- def find_extra_edges (self , ids : List [str ]) -> List [ExtraEdgeProblemAreas ]:
101
+ def find_extra_edges (self , bodies : List ["Body" ]) -> List [ExtraEdgeProblemAreas ]:
98
102
"""
99
103
Find the extra edges in the given list of bodies.
100
104
@@ -103,28 +107,25 @@ def find_extra_edges(self, ids: List[str]) -> List[ExtraEdgeProblemAreas]:
103
107
104
108
Parameters
105
109
----------
106
- ids : List[str ]
107
- Server-defined ID for the bodies .
110
+ bodies : List[Body ]
111
+ List of bodies that extra edges are investigated on .
108
112
109
113
Returns
110
114
----------
111
115
List[ExtraEdgeProblemArea]
112
116
List of objects representing extra edge problem areas.
113
117
"""
118
+ body_ids = [body .id for body in bodies ]
114
119
problem_areas_response = self ._repair_stub .FindExtraEdges (
115
- FindExtraEdgesRequest (selection = ids )
120
+ FindExtraEdgesRequest (selection = body_ids )
116
121
)
117
- problem_areas = []
118
- for res in problem_areas_response .result :
119
- connected_edges = []
120
- for edge_moniker in res .edge_monikers :
121
- connected_edges .append (edge_moniker )
122
- problem_area = ExtraEdgeProblemAreas (res .id , connected_edges , self ._grpc_client )
123
- problem_areas .append (problem_area )
124
-
122
+ problem_areas = [
123
+ ExtraEdgeProblemAreas (res .id , list (res .edge_monikers ), self ._grpc_client )
124
+ for res in problem_areas_response .result
125
+ ]
125
126
return problem_areas
126
127
127
- def find_inexact_edges (self , ids ) -> List [InexactEdgeProblemAreas ]:
128
+ def find_inexact_edges (self , bodies : List [ "Body" ] ) -> List [InexactEdgeProblemAreas ]:
128
129
"""
129
130
Find inexact edges in the given list of bodies.
130
131
@@ -133,28 +134,25 @@ def find_inexact_edges(self, ids) -> List[InexactEdgeProblemAreas]:
133
134
134
135
Parameters
135
136
----------
136
- ids : List[str ]
137
- Server-defined ID for the bodies .
137
+ bodies : List[Body ]
138
+ List of bodies that inexact edges are investigated on .
138
139
139
140
Returns
140
141
-------
141
142
List[InExactEdgeProblemArea]
142
143
List of objects representing inexact edge problem areas.
143
144
"""
145
+ body_ids = [body .id for body in bodies ]
144
146
problem_areas_response = self ._repair_stub .FindInexactEdges (
145
- FindInexactEdgesRequest (selection = ids )
147
+ FindInexactEdgesRequest (selection = body_ids )
146
148
)
147
- problem_areas = []
148
- for res in problem_areas_response .result :
149
- connected_edges = []
150
- for edge_moniker in res .edge_monikers :
151
- connected_edges .append (edge_moniker )
152
- problem_area = InexactEdgeProblemAreas (res .id , connected_edges , self ._grpc_client )
153
- problem_areas .append (problem_area )
154
-
149
+ problem_areas = [
150
+ InexactEdgeProblemAreas (res .id , list (res .edge_monikers ), self ._grpc_client )
151
+ for res in problem_areas_response .result
152
+ ]
155
153
return problem_areas
156
154
157
- def find_duplicate_faces (self , ids ) -> List [DuplicateFaceProblemAreas ]:
155
+ def find_duplicate_faces (self , bodies : List [ "Body" ] ) -> List [DuplicateFaceProblemAreas ]:
158
156
"""
159
157
Find the duplicate face problem areas.
160
158
@@ -163,28 +161,25 @@ def find_duplicate_faces(self, ids) -> List[DuplicateFaceProblemAreas]:
163
161
164
162
Parameters
165
163
----------
166
- ids : List[str ]
167
- Server-defined ID for the bodies .
164
+ bodies : List[Body ]
165
+ List of bodies that duplicate faces are investigated on .
168
166
169
167
Returns
170
168
-------
171
169
List[DuplicateFaceProblemAreas]
172
170
List of objects representing duplicate face problem areas.
173
171
"""
172
+ body_ids = [body .id for body in bodies ]
174
173
problem_areas_response = self ._repair_stub .FindDuplicateFaces (
175
- FindDuplicateFacesRequest (faces = ids )
174
+ FindDuplicateFacesRequest (faces = body_ids )
176
175
)
177
- problem_areas = []
178
- for res in problem_areas_response .result :
179
- connected_edges = []
180
- for face_moniker in res .face_monikers :
181
- connected_edges .append (face_moniker )
182
- problem_area = DuplicateFaceProblemAreas (res .id , connected_edges , self ._grpc_client )
183
- problem_areas .append (problem_area )
184
-
176
+ problem_areas = [
177
+ DuplicateFaceProblemAreas (res .id , list (res .face_monikers ), self ._grpc_client )
178
+ for res in problem_areas_response .result
179
+ ]
185
180
return problem_areas
186
181
187
- def find_missing_faces (self , ids ) -> List [MissingFaceProblemAreas ]:
182
+ def find_missing_faces (self , bodies : List [ "Body" ] ) -> List [MissingFaceProblemAreas ]:
188
183
"""
189
184
Find the missing faces.
190
185
@@ -193,28 +188,25 @@ def find_missing_faces(self, ids) -> List[MissingFaceProblemAreas]:
193
188
194
189
Parameters
195
190
----------
196
- ids : List[str ]
197
- Server-defined ID for the bodies .
191
+ bodies : List[Body ]
192
+ List of bodies that missing faces are investigated on .
198
193
199
194
Returns
200
195
-------
201
196
List[MissingFaceProblemAreas]
202
197
List of objects representing missing face problem areas.
203
198
"""
199
+ body_ids = [body .id for body in bodies ]
204
200
problem_areas_response = self ._repair_stub .FindMissingFaces (
205
- FindMissingFacesRequest (faces = ids )
201
+ FindMissingFacesRequest (faces = body_ids )
206
202
)
207
- problem_areas = []
208
- for res in problem_areas_response .result :
209
- connected_edges = []
210
- for edge_moniker in res .edge_monikers :
211
- connected_edges .append (edge_moniker )
212
- problem_area = MissingFaceProblemAreas (res .id , connected_edges , self ._grpc_client )
213
- problem_areas .append (problem_area )
214
-
203
+ problem_areas = [
204
+ MissingFaceProblemAreas (res .id , list (res .edge_monikers ), self ._grpc_client )
205
+ for res in problem_areas_response .result
206
+ ]
215
207
return problem_areas
216
208
217
- def find_small_faces (self , ids ) -> List [SmallFaceProblemAreas ]:
209
+ def find_small_faces (self , bodies : List [ "Body" ] ) -> List [SmallFaceProblemAreas ]:
218
210
"""
219
211
Find the small face problem areas.
220
212
@@ -223,28 +215,25 @@ def find_small_faces(self, ids) -> List[SmallFaceProblemAreas]:
223
215
224
216
Parameters
225
217
----------
226
- ids : List[str ]
227
- Server-defined ID for the bodies .
218
+ bodies : List[Body ]
219
+ List of bodies that small faces are investigated on .
228
220
229
221
Returns
230
222
-------
231
223
List[SmallFaceProblemAreas]
232
224
List of objects representing small face problem areas.
233
225
"""
226
+ body_ids = [body .id for body in bodies ]
234
227
problem_areas_response = self ._repair_stub .FindSmallFaces (
235
- FindSmallFacesRequest (selection = ids )
228
+ FindSmallFacesRequest (selection = body_ids )
236
229
)
237
- problem_areas = []
238
- for res in problem_areas_response .result :
239
- connected_edges = []
240
- for face_moniker in res .face_monikers :
241
- connected_edges .append (face_moniker )
242
- problem_area = SmallFaceProblemAreas (res .id , connected_edges , self ._grpc_client )
243
- problem_areas .append (problem_area )
244
-
230
+ problem_areas = [
231
+ SmallFaceProblemAreas (res .id , list (res .face_monikers ), self ._grpc_client )
232
+ for res in problem_areas_response .result
233
+ ]
245
234
return problem_areas
246
235
247
- def find_stitch_faces (self , ids ) -> List [StitchFaceProblemAreas ]:
236
+ def find_stitch_faces (self , bodies : List [ "Body" ] ) -> List [StitchFaceProblemAreas ]:
248
237
"""
249
238
Return the list of stitch face problem areas.
250
239
@@ -253,23 +242,20 @@ def find_stitch_faces(self, ids) -> List[StitchFaceProblemAreas]:
253
242
254
243
Parameters
255
244
----------
256
- ids : List[str ]
257
- Server-defined ID for the bodies .
245
+ bodies : List[Body ]
246
+ List of bodies that stitchable faces are investigated on .
258
247
259
248
Returns
260
249
-------
261
250
List[StitchFaceProblemAreas]
262
251
List of objects representing stitch face problem areas.
263
252
"""
253
+ body_ids = [body .id for body in bodies ]
264
254
problem_areas_response = self ._repair_stub .FindStitchFaces (
265
- FindStitchFacesRequest (faces = ids )
255
+ FindStitchFacesRequest (faces = body_ids )
266
256
)
267
- problem_areas = []
268
- for res in problem_areas_response .result :
269
- connected_edges = []
270
- for face_moniker in res .body_monikers :
271
- connected_edges .append (face_moniker )
272
- problem_area = StitchFaceProblemAreas (res .id , connected_edges , self ._grpc_client )
273
- problem_areas .append (problem_area )
274
-
257
+ problem_areas = [
258
+ StitchFaceProblemAreas (res .id , list (res .body_monikers ), self ._grpc_client )
259
+ for res in problem_areas_response .result
260
+ ]
275
261
return problem_areas
0 commit comments