Skip to content

Commit 837a3e1

Browse files
committed
feat(GeodeObject): new design using OpenGeode types
1 parent 53a5187 commit 837a3e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+230
-863
lines changed

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
opengeode-core==15.30.3
1+
opengeode-core==15.30.4
22
opengeode-io==7.4.6
33
opengeode-inspector==6.8.6
44
opengeode-geosciences==9.5.5

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ markupsafe>=3
3131
# flask
3232
# jinja2
3333
# werkzeug
34-
opengeode-core==15.30.3
34+
opengeode-core==15.30.4
3535
# via
3636
# -r requirements.in
3737
# geode-common

src/opengeodeweb_back/geode_functions.py

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@
99
from typing import Any
1010

1111
# Local application imports
12-
from .geode_objects import geode_objects, geode_meshes, geode_models
12+
from .geode_objects import geode_objects
1313
from .geode_objects.types import (
1414
GeodeObjectType,
1515
geode_object_type,
16-
GeodeMeshType,
17-
geode_mesh_type,
18-
GeodeModelType,
19-
geode_model_type,
2016
)
2117
from .geode_objects.geode_object import GeodeObject
22-
from .geode_objects.geode_mesh import GeodeMesh
23-
from .geode_objects.geode_model import GeodeModel
2418
from . import utils_functions
2519
from opengeodeweb_microservice.database.data import Data
2620
from opengeodeweb_microservice.database.connection import get_session
@@ -38,15 +32,7 @@ def geode_object_from_string(value: str) -> type[GeodeObject]:
3832
return geode_objects[geode_object_type(value)]
3933

4034

41-
def geode_mesh_from_string(value: str) -> type[GeodeMesh]:
42-
return geode_meshes[geode_mesh_type(value)]
43-
44-
45-
def geode_model_from_string(value: str) -> type[GeodeModel]:
46-
return geode_models[geode_model_type(value)]
47-
48-
49-
def load_object_data(data_id: str) -> GeodeObject:
35+
def load_geode_object(data_id: str) -> GeodeObject:
5036
data = Data.get(data_id)
5137
if not data:
5238
flask.abort(404, f"Data with id {data_id} not found")
@@ -57,28 +43,6 @@ def load_object_data(data_id: str) -> GeodeObject:
5743
return geode_object_from_string(data.geode_object).load(file_absolute_path)
5844

5945

60-
def load_mesh_data(data_id: str) -> GeodeMesh:
61-
data = Data.get(data_id)
62-
if not data:
63-
flask.abort(404, f"Data with id {data_id} not found")
64-
65-
file_absolute_path = data_file_path(data_id, data.native_file_name)
66-
print("Loading file: ", file_absolute_path)
67-
print("File exists: ", os.path.exists(file_absolute_path))
68-
return geode_mesh_from_string(data.geode_object).load_mesh(file_absolute_path)
69-
70-
71-
def load_model_data(data_id: str) -> GeodeModel:
72-
data = Data.get(data_id)
73-
if not data:
74-
flask.abort(404, f"Data with id {data_id} not found")
75-
76-
file_absolute_path = data_file_path(data_id, data.native_file_name)
77-
print("Loading file: ", file_absolute_path)
78-
print("File exists: ", os.path.exists(file_absolute_path))
79-
return geode_model_from_string(data.geode_object).load_model(file_absolute_path)
80-
81-
8246
def get_data_info(data_id: str) -> Data:
8347
data = Data.get(data_id)
8448
if not data:

src/opengeodeweb_back/geode_objects/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from .geode_implicit_structural_model import GeodeImplicitStructuralModel
4343
from .geode_implicit_cross_section import GeodeImplicitCrossSection
4444

45-
geode_meshes: dict[GeodeMeshType, type[GeodeMesh]] = {
45+
geode_objects: dict[GeodeObjectType, type[GeodeObject]] = {
4646
"VertexSet": GeodeVertexSet,
4747
"Graph": GeodeGraph,
4848
"PointSet2D": GeodePointSet2D,
@@ -62,17 +62,10 @@
6262
"RegularGrid3D": GeodeRegularGrid3D,
6363
"LightRegularGrid2D": GeodeLightRegularGrid2D,
6464
"LightRegularGrid3D": GeodeLightRegularGrid3D,
65-
}
66-
geode_models: dict[GeodeModelType, type[GeodeModel]] = {
6765
"BRep": GeodeBRep,
6866
"Section": GeodeSection,
6967
"StructuralModel": GeodeStructuralModel,
7068
"CrossSection": GeodeCrossSection,
7169
"ImplicitStructuralModel": GeodeImplicitStructuralModel,
7270
"ImplicitCrossSection": GeodeImplicitCrossSection,
7371
}
74-
75-
GeodeObjectsDict = dict[GeodeObjectType, type[GeodeObject]]
76-
geode_objects: GeodeObjectsDict = {}
77-
geode_objects.update(cast(GeodeObjectsDict, geode_meshes))
78-
geode_objects.update(cast(GeodeObjectsDict, geode_models))

src/opengeodeweb_back/geode_objects/geode_brep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, brep: og.BRep | None = None) -> None:
2020
super().__init__(self.brep)
2121

2222
@classmethod
23-
def geode_model_type(cls) -> GeodeModelType:
23+
def geode_object_type(cls) -> GeodeModelType:
2424
return "BRep"
2525

2626
def native_extension(self) -> str:
@@ -38,7 +38,7 @@ def builder(self) -> og.BRepBuilder:
3838
return og.BRepBuilder(self.brep)
3939

4040
@classmethod
41-
def load_model(cls, filename: str) -> GeodeBRep:
41+
def load(cls, filename: str) -> GeodeBRep:
4242
return GeodeBRep(og.load_brep(filename))
4343

4444
@classmethod

src/opengeodeweb_back/geode_objects/geode_cross_section.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(
2525
super().__init__(self.cross_section)
2626

2727
@classmethod
28-
def geode_model_type(cls) -> GeodeModelType:
28+
def geode_object_type(cls) -> GeodeModelType:
2929
return "CrossSection"
3030

3131
def native_extension(self) -> str:
@@ -35,7 +35,7 @@ def builder(self) -> og_geosciences.CrossSectionBuilder:
3535
return og_geosciences.CrossSectionBuilder(self.cross_section)
3636

3737
@classmethod
38-
def load_model(cls, filename: str) -> GeodeCrossSection:
38+
def load(cls, filename: str) -> GeodeCrossSection:
3939
return GeodeCrossSection(og_geosciences.load_cross_section(filename))
4040

4141
@classmethod

src/opengeodeweb_back/geode_objects/geode_edged_curve2d.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ class GeodeEdgedCurve2D(GeodeGraph):
1616
edged_curve: og.EdgedCurve2D
1717

1818
def __init__(self, edged_curve: og.EdgedCurve2D | None = None) -> None:
19-
self.edged_curve = edged_curve if edged_curve is not None else og.EdgedCurve2D()
19+
self.edged_curve = (
20+
edged_curve if edged_curve is not None else og.EdgedCurve2D.create()
21+
)
2022
super().__init__(self.edged_curve)
2123

2224
@classmethod
23-
def geode_mesh_type(cls) -> GeodeMeshType:
25+
def geode_object_type(cls) -> GeodeMeshType:
2426
return "EdgedCurve2D"
2527

2628
def native_extension(self) -> str:
@@ -35,10 +37,10 @@ def is_viewable(cls) -> bool:
3537
return False
3638

3739
def builder(self) -> og.EdgedCurveBuilder2D:
38-
return og.EdgedCurveBuilder2D(self.edged_curve)
40+
return og.EdgedCurveBuilder2D.create(self.edged_curve)
3941

4042
@classmethod
41-
def load_mesh(cls, filename: str) -> GeodeEdgedCurve2D:
43+
def load(cls, filename: str) -> GeodeEdgedCurve2D:
4244
return GeodeEdgedCurve2D(og.load_edged_curve2D(filename))
4345

4446
@classmethod

src/opengeodeweb_back/geode_objects/geode_edged_curve3d.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ class GeodeEdgedCurve3D(GeodeGraph):
1616
edged_curve: og.EdgedCurve3D
1717

1818
def __init__(self, edged_curve: og.EdgedCurve3D | None = None) -> None:
19-
self.edged_curve = edged_curve if edged_curve is not None else og.EdgedCurve3D()
19+
self.edged_curve = (
20+
edged_curve if edged_curve is not None else og.EdgedCurve3D.create()
21+
)
2022
super().__init__(self.edged_curve)
2123

2224
@classmethod
23-
def geode_mesh_type(cls) -> GeodeMeshType:
25+
def geode_object_type(cls) -> GeodeMeshType:
2426
return "EdgedCurve3D"
2527

2628
def native_extension(self) -> str:
@@ -35,10 +37,10 @@ def is_viewable(cls) -> bool:
3537
return False
3638

3739
def builder(self) -> og.EdgedCurveBuilder3D:
38-
return og.EdgedCurveBuilder3D(self.edged_curve)
40+
return og.EdgedCurveBuilder3D.create(self.edged_curve)
3941

4042
@classmethod
41-
def load_mesh(cls, filename: str) -> GeodeEdgedCurve3D:
43+
def load(cls, filename: str) -> GeodeEdgedCurve3D:
4244
return GeodeEdgedCurve3D(og.load_edged_curve3D(filename))
4345

4446
@classmethod

src/opengeodeweb_back/geode_objects/geode_graph.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class GeodeGraph(GeodeVertexSet):
1515
graph: og.Graph
1616

1717
def __init__(self, graph: og.Graph | None = None) -> None:
18-
self.graph = graph if graph is not None else og.Graph()
18+
self.graph = graph if graph is not None else og.Graph.create()
1919
super().__init__(self.graph)
2020

2121
@classmethod
22-
def geode_mesh_type(cls) -> GeodeMeshType:
22+
def geode_object_type(cls) -> GeodeMeshType:
2323
return "Graph"
2424

2525
def native_extension(self) -> str:
@@ -34,10 +34,10 @@ def is_viewable(cls) -> bool:
3434
return False
3535

3636
def builder(self) -> og.GraphBuilder:
37-
return og.GraphBuilder(self.graph)
37+
return og.GraphBuilder.create(self.graph)
3838

3939
@classmethod
40-
def load_mesh(cls, filename: str) -> GeodeGraph:
40+
def load(cls, filename: str) -> GeodeGraph:
4141
return GeodeGraph(og.load_graph(filename))
4242

4343
@classmethod

src/opengeodeweb_back/geode_objects/geode_hybrid_solid3d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ class GeodeHybridSolid3D(GeodeSolidMesh3D):
1616

1717
def __init__(self, hybrid_solid: og.HybridSolid3D | None = None) -> None:
1818
self.hybrid_solid = (
19-
hybrid_solid if hybrid_solid is not None else og.HybridSolid3D()
19+
hybrid_solid if hybrid_solid is not None else og.HybridSolid3D.create()
2020
)
2121
super().__init__(self.hybrid_solid)
2222

2323
@classmethod
24-
def geode_mesh_type(cls) -> GeodeMeshType:
24+
def geode_object_type(cls) -> GeodeMeshType:
2525
return "HybridSolid3D"
2626

2727
def native_extension(self) -> str:
2828
return self.hybrid_solid.native_extension()
2929

3030
def builder(self) -> og.HybridSolidBuilder3D:
31-
return og.HybridSolidBuilder3D(self.hybrid_solid)
31+
return og.HybridSolidBuilder3D.create(self.hybrid_solid)
3232

3333
@classmethod
34-
def load_mesh(cls, filename: str) -> GeodeHybridSolid3D:
34+
def load(cls, filename: str) -> GeodeHybridSolid3D:
3535
return GeodeHybridSolid3D(og.load_hybrid_solid3D(filename))
3636

3737
@classmethod

0 commit comments

Comments
 (0)