Skip to content

Commit 90ae694

Browse files
authored
Merge pull request #236 from Geode-solutions/feat/is_active
Feat/is active
2 parents 432ce28 + fd7d32d commit 90ae694

9 files changed

Lines changed: 23 additions & 19 deletions

File tree

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
opengeode-core==16.3.0
1+
opengeode-core==16.3.2
22
opengeode-io==7.4.9
33
opengeode-inspector==6.8.18
44
opengeode-geosciences==9.5.11

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ markupsafe>=3
3131
# flask
3232
# jinja2
3333
# werkzeug
34-
opengeode-core==16.3.0
34+
opengeode-core==16.3.2
3535
# via
3636
# -r requirements.in
3737
# geode-common
@@ -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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +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()
91+
def component(self, id: og.uuid) -> og.Component3D:
92+
return self.brep.brep_component(id)
9393

9494
def inspect(self) -> og_inspector.BRepInspectionResult:
9595
return og_inspector.inspect_brep(self.brep)

src/opengeodeweb_back/geode_objects/geode_cross_section.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ def save_light_viewable(self, filename_without_extension: str) -> str:
7676

7777
def component_name(self, id: og.uuid) -> str | None:
7878
return self.cross_section.cross_section_component(id).name()
79+
80+
def component(self, id: og.uuid) -> og.Component2D:
81+
return self.cross_section.cross_section_component(id)

src/opengeodeweb_back/geode_objects/geode_model.py

Lines changed: 2 additions & 1 deletion
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,4 +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+
def component(self, id: og.uuid) -> og.Component2D | og.Component3D: ...

src/opengeodeweb_back/geode_objects/geode_section.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +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()
93+
def component(self, id: og.uuid) -> og.Component2D:
94+
return self.section.section_component(id)
9595

9696
def inspect(self) -> og_inspector.SectionInspectionResult:
9797
return og_inspector.inspect_section(self.section)

src/opengeodeweb_back/geode_objects/geode_structural_model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ def save_light_viewable(self, filename_without_extension: str) -> str:
7878

7979
def component_name(self, id: og.uuid) -> str | None:
8080
return self.structural_model.structural_model_component(id).name()
81+
82+
def component(self, id: og.uuid) -> og.Component3D:
83+
return self.structural_model.structural_model_component(id)

src/opengeodeweb_back/utils_functions.py

Lines changed: 6 additions & 2 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,6 +230,7 @@ def model_components(
229230
"type": component_type,
230231
"boundaries": boundaries_uuid,
231232
"internals": internals_uuid,
233+
"is_active": component.is_active(),
232234
}
233235
mesh_components.append(mesh_component_object)
234236

@@ -237,8 +239,9 @@ def model_components(
237239
for collection_component, ids in model_collection_components.items():
238240
component_type = collection_component.get()
239241
for id in ids:
242+
component = model.component(id)
240243
geode_id = id.string()
241-
component_name = model.component_name(id)
244+
component_name = component.name()
242245
if not component_name:
243246
component_name = geode_id
244247
items = model.items(id)
@@ -248,6 +251,7 @@ def model_components(
248251
"name": component_name,
249252
"type": component_type,
250253
"items": items_uuid,
254+
"is_active": component.is_active(),
251255
}
252256
collection_components.append(collection_component_object)
253257
return {

tests/test_routes.py

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

432432
def test_model_components(client: FlaskClient) -> None:
433433
geode_object_type = "BRep"
434-
filename = "LS2.og_brep"
434+
filename = "cube.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
443441
for mesh_component in mesh_components:
444442
assert isinstance(mesh_component, object)
445443
assert isinstance(mesh_component["geode_id"], str)
446444
assert isinstance(mesh_component["viewer_id"], int)
447445
assert isinstance(mesh_component["name"], str)
448446
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
453447
assert isinstance(mesh_component["boundaries"], list)
454448
for boundary_uuid in mesh_component["boundaries"]:
455449
assert isinstance(boundary_uuid, str)
456450
assert isinstance(mesh_component["internals"], list)
457451
for internal_uuid in mesh_component["internals"]:
458452
assert isinstance(internal_uuid, str)
459-
assert name_is_uuid is True
460-
assert name_is_not_uuid is True
453+
assert isinstance(mesh_component["is_active"], bool)
461454
assert "collection_components" in response.get_json()
462455
collection_components = response.get_json()["collection_components"]
463456
assert isinstance(collection_components, list)
@@ -468,6 +461,7 @@ def test_model_components(client: FlaskClient) -> None:
468461
assert isinstance(collection_component["items"], list)
469462
for item_uuid in collection_component["items"]:
470463
assert isinstance(item_uuid, str)
464+
assert isinstance(collection_component["is_active"], bool)
471465

472466

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

0 commit comments

Comments
 (0)