Skip to content

Commit 707872c

Browse files
authored
Merge pull request #233 from Geode-solutions/fix/model_components_name
Fix/model components name
2 parents 7e6a419 + e9be67d commit 707872c

7 files changed

Lines changed: 25 additions & 4 deletions

File tree

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,3 @@ werkzeug==3.1.2
6060
# flask
6161
# flask-cors
6262

63-
opengeodeweb-microservice==1.*,>=1.1.1

src/opengeodeweb_back/geode_objects/geode_brep.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ 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+
9194
def inspect(self) -> og_inspector.BRepInspectionResult:
9295
return og_inspector.inspect_brep(self.brep)
9396

src/opengeodeweb_back/geode_objects/geode_model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ def internals(self, id: og.uuid) -> list[og.ComponentID]: ...
3535

3636
@abstractmethod
3737
def items(self, id: og.uuid) -> list[og.ComponentID]: ...
38+
39+
@abstractmethod
40+
def component_name(self, id: og.uuid) -> str | None: ...

src/opengeodeweb_back/geode_objects/geode_section.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ 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+
9396
def inspect(self) -> og_inspector.SectionInspectionResult:
9497
return og_inspector.inspect_section(self.section)
9598

src/opengeodeweb_back/utils_functions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ def model_components(
214214
component_type = mesh_component.get()
215215
for id in ids:
216216
geode_id = id.string()
217-
component_name = geode_id
217+
component_name = model.component_name(id)
218+
if not component_name:
219+
component_name = geode_id
218220
viewer_id = uuid_to_flat_index[geode_id]
219221
boundaries = model.boundaries(id)
220222
boundaries_uuid = [boundary.id().string() for boundary in boundaries]
@@ -236,11 +238,14 @@ def model_components(
236238
component_type = collection_component.get()
237239
for id in ids:
238240
geode_id = id.string()
241+
component_name = model.component_name(id)
242+
if not component_name:
243+
component_name = geode_id
239244
items = model.items(id)
240245
items_uuid = [item.id().string() for item in items]
241246
collection_component_object = {
242247
"geode_id": geode_id,
243-
"name": geode_id,
248+
"name": component_name,
244249
"type": component_type,
245250
"items": items_uuid,
246251
}

tests/data/LS2.og_brep

109 KB
Binary file not shown.

tests/test_routes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,25 +431,33 @@ def get_full_data() -> test_utils.JsonData:
431431

432432
def test_model_components(client: FlaskClient) -> None:
433433
geode_object_type = "BRep"
434-
filename = "cube.og_brep"
434+
filename = "LS2.og_brep"
435435
response = test_save_viewable_file(client, geode_object_type, filename)
436436
assert response.status_code == 200
437437
assert "mesh_components" in response.get_json()
438438
mesh_components = response.get_json()["mesh_components"]
439439
assert isinstance(mesh_components, list)
440440
assert len(mesh_components) > 0
441+
name_is_uuid = False
442+
name_is_not_uuid = False
441443
for mesh_component in mesh_components:
442444
assert isinstance(mesh_component, object)
443445
assert isinstance(mesh_component["geode_id"], str)
444446
assert isinstance(mesh_component["viewer_id"], int)
445447
assert isinstance(mesh_component["name"], str)
446448
assert isinstance(mesh_component["type"], str)
449+
if mesh_component["name"] == mesh_component["geode_id"]:
450+
name_is_uuid = True
451+
else:
452+
name_is_not_uuid = True
447453
assert isinstance(mesh_component["boundaries"], list)
448454
for boundary_uuid in mesh_component["boundaries"]:
449455
assert isinstance(boundary_uuid, str)
450456
assert isinstance(mesh_component["internals"], list)
451457
for internal_uuid in mesh_component["internals"]:
452458
assert isinstance(internal_uuid, str)
459+
assert name_is_uuid is True
460+
assert name_is_not_uuid is True
453461
assert "collection_components" in response.get_json()
454462
collection_components = response.get_json()["collection_components"]
455463
assert isinstance(collection_components, list)

0 commit comments

Comments
 (0)