Skip to content

Commit 536bbf5

Browse files
committed
add boundaries, internal and items logic for mesh_components' relations table
1 parent c68ad9e commit 536bbf5

5 files changed

Lines changed: 45 additions & 1 deletion

File tree

src/opengeodeweb_back/geode_objects/geode_brep.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ def mesh_components(self) -> ComponentRegistry:
7979
def collection_components(self) -> ComponentRegistry:
8080
return self.brep.collection_components()
8181

82+
def boundaries(self, id: og.uuid) -> list[og.ComponentID]:
83+
return self.brep.boundaries(id)
84+
85+
def internals(self, id: og.uuid) -> list[og.ComponentID]:
86+
return self.brep.internals(id)
87+
88+
def items(self, id: og.uuid) -> list[og.ComponentID]:
89+
return self.brep.items(id)
90+
8291
def inspect(self) -> og_inspector.BRepInspectionResult:
8392
return og_inspector.inspect_brep(self.brep)
8493

src/opengeodeweb_back/geode_objects/geode_model.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,12 @@ def mesh_components(self) -> ComponentRegistry: ...
2626

2727
@abstractmethod
2828
def collection_components(self) -> ComponentRegistry: ...
29+
30+
@abstractmethod
31+
def boundaries(self, id: og.uuid) -> list[og.ComponentID]: ...
32+
33+
@abstractmethod
34+
def internals(self, id: og.uuid) -> list[og.ComponentID]: ...
35+
36+
@abstractmethod
37+
def items(self, id: og.uuid) -> list[og.ComponentID]: ...

src/opengeodeweb_back/geode_objects/geode_section.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ def mesh_components(self) -> ComponentRegistry:
8181
def collection_components(self) -> ComponentRegistry:
8282
return self.section.collection_components()
8383

84+
def boundaries(self, id: og.uuid) -> list[og.ComponentID]:
85+
return self.section.boundaries(id)
86+
87+
def internals(self, id: og.uuid) -> list[og.ComponentID]:
88+
return self.section.internals(id)
89+
90+
def items(self, id: og.uuid) -> list[og.ComponentID]:
91+
return self.section.items(id)
92+
8493
def inspect(self) -> og_inspector.SectionInspectionResult:
8594
return og_inspector.inspect_section(self.section)
8695

src/opengeodeweb_back/routes/models/blueprint_models.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@ def model_components() -> flask.Response:
4444
geode_id = id.string()
4545
component_name = geode_id
4646
viewer_id = uuid_to_flat_index[geode_id]
47-
47+
boundaries = model.boundaries(id)
48+
boundaries_uuid = [boundary.id().string() for boundary in boundaries]
49+
internals = model.internals(id)
50+
internals_uuid = [internal.id().string() for internal in internals]
4851
mesh_component_object = {
4952
"viewer_id": viewer_id,
5053
"geode_id": geode_id,
5154
"name": component_name,
5255
"type": component_type,
56+
"boundaries": boundaries_uuid,
57+
"internals": internals_uuid,
5358
}
5459
mesh_components.append(mesh_component_object)
5560

@@ -59,10 +64,13 @@ def model_components() -> flask.Response:
5964
component_type = collection_component.get()
6065
for id in ids:
6166
geode_id = id.string()
67+
items = model.items(id)
68+
items_uuid = [item.id().string() for item in items]
6269
collection_component_object = {
6370
"geode_id": geode_id,
6471
"name": geode_id,
6572
"type": component_type,
73+
"items": items_uuid,
6674
}
6775
collection_components.append(collection_component_object)
6876

tests/test_models_routes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@ def test_model_components(client: FlaskClient) -> None:
3838
assert isinstance(mesh_component["viewer_id"], int)
3939
assert isinstance(mesh_component["name"], str)
4040
assert isinstance(mesh_component["type"], str)
41+
assert isinstance(mesh_component["boundaries"], list)
42+
for boundary_uuid in mesh_component["boundaries"]:
43+
assert isinstance(boundary_uuid, str)
44+
assert isinstance(mesh_component["internals"], list)
45+
for internal_uuid in mesh_component["internals"]:
46+
assert isinstance(internal_uuid, str)
4147
assert "collection_components" in response.get_json()
4248
collection_components = response.get_json()["collection_components"]
4349
assert isinstance(collection_components, list)
4450
for collection_component in collection_components:
4551
assert isinstance(collection_component, object)
4652
assert isinstance(collection_component["geode_id"], str)
4753
assert isinstance(collection_component["name"], str)
54+
assert isinstance(collection_component["items"], list)
55+
for item_uuid in collection_component["items"]:
56+
assert isinstance(item_uuid, str)
4857

4958

5059
def test_export_project_route(client: FlaskClient, tmp_path: Path) -> None:

0 commit comments

Comments
 (0)