Skip to content

Commit b1f4b85

Browse files
committed
refacto geode_objects classes for model_components
1 parent dc7485e commit b1f4b85

4 files changed

Lines changed: 12 additions & 18 deletions

File tree

src/opengeodeweb_back/geode_objects/geode_brep.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ def internals(self, id: og.uuid) -> list[og.ComponentID]:
8888
def items(self, id: og.uuid) -> list[og.ComponentID]:
8989
return self.brep.items(id)
9090

91-
def component_name(self, id: og.uuid) -> str | None:
92-
return self.brep.brep_component(id).name()
93-
94-
def is_active(self, id: og.uuid) -> bool:
95-
return self.brep.brep_component(id).is_active()
91+
def component(self, id: og.uuid) -> og.Component3D:
92+
return self.brep.brep_component(id)
9693

9794
def inspect(self) -> og_inspector.BRepInspectionResult:
9895
return og_inspector.inspect_brep(self.brep)

src/opengeodeweb_back/geode_objects/geode_model.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Standard library imports
22
from __future__ import annotations
33
from abc import abstractmethod
4+
from typing import Union
45

56
# Third party imports
67
import opengeode as og
@@ -37,7 +38,4 @@ def internals(self, id: og.uuid) -> list[og.ComponentID]: ...
3738
def items(self, id: og.uuid) -> list[og.ComponentID]: ...
3839

3940
@abstractmethod
40-
def component_name(self, id: og.uuid) -> str | None: ...
41-
42-
@abstractmethod
43-
def is_active(self, id: og.uuid) -> bool: ...
41+
def component(self, id: og.uuid) -> og.Component2D | og.Component3D: ...

src/opengeodeweb_back/geode_objects/geode_section.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,8 @@ def internals(self, id: og.uuid) -> list[og.ComponentID]:
9090
def items(self, id: og.uuid) -> list[og.ComponentID]:
9191
return self.section.items(id)
9292

93-
def component_name(self, id: og.uuid) -> str | None:
94-
return self.section.section_component(id).name()
95-
96-
def is_active(self, id: og.uuid) -> bool:
97-
return self.section.section_component(id).is_active()
93+
def component(self, id: og.uuid) -> og.Component2D:
94+
return self.section.section_component(id)
9895

9996
def inspect(self) -> og_inspector.SectionInspectionResult:
10097
return og_inspector.inspect_section(self.section)

src/opengeodeweb_back/utils_functions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ def model_components(
213213
for mesh_component, ids in model_mesh_components.items():
214214
component_type = mesh_component.get()
215215
for id in ids:
216+
component = model.component(id)
216217
geode_id = id.string()
217-
component_name = model.component_name(id)
218+
component_name = component.name()
218219
if not component_name:
219220
component_name = geode_id
220221
viewer_id = uuid_to_flat_index[geode_id]
@@ -229,7 +230,7 @@ def model_components(
229230
"type": component_type,
230231
"boundaries": boundaries_uuid,
231232
"internals": internals_uuid,
232-
"is_active": model.is_active(id),
233+
"is_active": component.is_active(),
233234
}
234235
mesh_components.append(mesh_component_object)
235236

@@ -238,8 +239,9 @@ def model_components(
238239
for collection_component, ids in model_collection_components.items():
239240
component_type = collection_component.get()
240241
for id in ids:
242+
component = model.component(id)
241243
geode_id = id.string()
242-
component_name = model.component_name(id)
244+
component_name = component.name()
243245
if not component_name:
244246
component_name = geode_id
245247
items = model.items(id)
@@ -249,7 +251,7 @@ def model_components(
249251
"name": component_name,
250252
"type": component_type,
251253
"items": items_uuid,
252-
"is_active": model.is_active(id),
254+
"is_active": component.is_active(),
253255
}
254256
collection_components.append(collection_component_object)
255257
return {

0 commit comments

Comments
 (0)