Skip to content

Commit 3ee5c1e

Browse files
Merge pull request #49 from Geode-solutions/feat/is_loadable
Feat/is loadable
2 parents 1b16b59 + 9c9ab87 commit 3ee5c1e

File tree

4 files changed

+114
-71
lines changed

4 files changed

+114
-71
lines changed

requirements.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ colorama==0.4.6
1818
# via click
1919
flask[async]==3.0.0
2020
# via -r requirements.in
21-
geode-background==7.4.8
21+
geode-background==7.4.9
2222
# via
2323
# geode-explicit
2424
# geode-implicit
2525
# geode-simplex
26-
geode-common==30.0.4
26+
geode-common==30.0.5
2727
# via
2828
# -r requirements.in
2929
# geode-background
@@ -32,24 +32,24 @@ geode-common==30.0.4
3232
# geode-numerics
3333
# geode-simplex
3434
# geode-viewables
35-
geode-conversion==5.1.6
35+
geode-conversion==5.1.7
3636
# via
3737
# geode-explicit
3838
# geode-implicit
39-
geode-explicit==4.3.9
39+
geode-explicit==4.3.10
4040
# via
4141
# -r requirements.in
4242
# geode-implicit
43-
geode-implicit==2.5.3
43+
geode-implicit==2.5.4
4444
# via -r requirements.in
45-
geode-numerics==4.2.2
45+
geode-numerics==4.2.3
4646
# via
4747
# -r requirements.in
4848
# geode-implicit
4949
# geode-simplex
50-
geode-simplex==6.2.9
50+
geode-simplex==6.3.0
5151
# via -r requirements.in
52-
geode-viewables==2.1.7
52+
geode-viewables==2.1.8
5353
# via -r requirements.in
5454
importlib-metadata==7.0.0
5555
# via flask
@@ -65,7 +65,7 @@ markupsafe==2.1.3
6565
# via
6666
# jinja2
6767
# werkzeug
68-
opengeode-core==14.10.2
68+
opengeode-core==14.10.3
6969
# via
7070
# -r requirements.in
7171
# geode-background
@@ -80,22 +80,22 @@ opengeode-core==14.10.2
8080
# opengeode-geosciencesio
8181
# opengeode-inspector
8282
# opengeode-io
83-
opengeode-geosciences==7.3.2
83+
opengeode-geosciences==7.3.3
8484
# via
8585
# -r requirements.in
8686
# geode-implicit
8787
# geode-viewables
8888
# opengeode-geosciencesio
89-
opengeode-geosciencesio==4.5.4
89+
opengeode-geosciencesio==4.5.5
9090
# via
9191
# -r requirements.in
9292
# geode-implicit
93-
opengeode-inspector==4.0.4
93+
opengeode-inspector==4.0.5
9494
# via
9595
# -r requirements.in
9696
# geode-explicit
9797
# geode-implicit
98-
opengeode-io==6.2.4
98+
opengeode-io==6.2.5
9999
# via
100100
# -r requirements.in
101101
# geode-implicit

src/opengeodeweb_back/geode_functions.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def missing_files(geode_object: str, file_absolute_path: str):
3434
return geode_object_value(geode_object)["missing_files"](file_absolute_path)
3535

3636

37+
def is_loadable(geode_object: str, file_absolute_path: str):
38+
return geode_object_value(geode_object)["is_loadable"](file_absolute_path)
39+
40+
3741
def load(geode_object: str, file_absolute_path: str):
3842
return geode_object_value(geode_object)["load"](file_absolute_path)
3943

@@ -131,23 +135,28 @@ def has_creator(geode_object: str, extension: str):
131135
return input_factory(geode_object).has_creator(extension)
132136

133137

134-
def list_geode_objects(extension: str, key: str = None):
135-
geode_objects_list = []
136-
for geode_object, value in geode_objects_dict().items():
137-
if key != None:
138-
if key in value:
139-
if type(value[key]) == bool:
140-
if value[key] == True:
141-
if has_creator(geode_object, extension):
142-
geode_objects_list.append(geode_object)
143-
elif has_creator(geode_object, extension):
144-
geode_objects_list.append(geode_object)
145-
else:
146-
if has_creator(geode_object, extension):
147-
geode_objects_list.append(geode_object)
138+
def list_geode_objects(
139+
file_absolute_path: str,
140+
key: str = None,
141+
):
142+
return_dict = {}
143+
file_extension = extension_from_filename(os.path.basename(file_absolute_path))
148144

149-
geode_objects_list.sort()
150-
return geode_objects_list
145+
for geode_object, value in geode_objects_dict().items():
146+
if has_creator(geode_object, file_extension):
147+
file_is_loadable = is_loadable(geode_object, file_absolute_path)
148+
if key != None:
149+
if key in value:
150+
if type(value[key]) == bool:
151+
if value[key] == True:
152+
return_dict[geode_object] = {
153+
"is_loadable": file_is_loadable
154+
}
155+
else:
156+
return_dict[geode_object] = {"is_loadable": file_is_loadable}
157+
else:
158+
return_dict[geode_object] = {"is_loadable": file_is_loadable}
159+
return return_dict
151160

152161

153162
def geode_objects_output_extensions(geode_object: str, data):

src/opengeodeweb_back/geode_objects.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def geode_objects_dict():
1212
"input_factory": og.BRepInputFactory,
1313
"output_factory": og.BRepOutputFactory,
1414
"missing_files": og.check_brep_missing_files,
15+
"is_loadable": og.is_brep_loadable,
1516
"load": og.load_brep,
1617
"is_saveable": og.is_brep_saveable,
1718
"save": og.save_brep,
@@ -32,6 +33,7 @@ def geode_objects_dict():
3233
"input_factory": og_gs.CrossSectionInputFactory,
3334
"output_factory": og_gs.CrossSectionOutputFactory,
3435
"missing_files": og_gs.check_cross_section_missing_files,
36+
"is_loadable": og_gs.is_cross_section_loadable,
3537
"load": og_gs.load_cross_section,
3638
"is_saveable": og_gs.is_cross_section_saveable,
3739
"save": og_gs.save_cross_section,
@@ -51,6 +53,7 @@ def geode_objects_dict():
5153
"input_factory": og.EdgedCurveInputFactory2D,
5254
"output_factory": og.EdgedCurveOutputFactory2D,
5355
"missing_files": og.check_edged_curve_missing_files2D,
56+
"is_loadable": og.is_edged_curve_loadable2D,
5457
"load": og.load_edged_curve2D,
5558
"is_saveable": og.is_edged_curve_saveable2D,
5659
"save": og.save_edged_curve2D,
@@ -70,6 +73,7 @@ def geode_objects_dict():
7073
"input_factory": og.EdgedCurveInputFactory3D,
7174
"output_factory": og.EdgedCurveOutputFactory3D,
7275
"missing_files": og.check_edged_curve_missing_files3D,
76+
"is_loadable": og.is_edged_curve_loadable3D,
7377
"load": og.load_edged_curve3D,
7478
"is_saveable": og.is_edged_curve_saveable3D,
7579
"save": og.save_edged_curve3D,
@@ -89,6 +93,7 @@ def geode_objects_dict():
8993
"input_factory": og.GraphInputFactory,
9094
"output_factory": og.GraphOutputFactory,
9195
"missing_files": og.check_graph_missing_files,
96+
"is_loadable": og.is_graph_loadable,
9297
"load": og.load_graph,
9398
"is_saveable": og.is_graph_saveable,
9499
"save": og.save_graph,
@@ -101,6 +106,7 @@ def geode_objects_dict():
101106
"input_factory": og.HybridSolidInputFactory3D,
102107
"output_factory": og.HybridSolidOutputFactory3D,
103108
"missing_files": og.check_hybrid_solid_missing_files3D,
109+
"is_loadable": og.is_hybrid_solid_loadable3D,
104110
"load": og.load_hybrid_solid3D,
105111
"is_saveable": og.is_hybrid_solid_saveable3D,
106112
"save": og.save_hybrid_solid3D,
@@ -120,6 +126,7 @@ def geode_objects_dict():
120126
"input_factory": og.PointSetInputFactory2D,
121127
"output_factory": og.PointSetOutputFactory2D,
122128
"missing_files": og.check_point_set_missing_files2D,
129+
"is_loadable": og.is_point_set_loadable2D,
123130
"load": og.load_point_set2D,
124131
"is_saveable": og.is_point_set_saveable2D,
125132
"save": og.save_point_set2D,
@@ -139,6 +146,7 @@ def geode_objects_dict():
139146
"input_factory": og.PointSetInputFactory3D,
140147
"output_factory": og.PointSetOutputFactory3D,
141148
"missing_files": og.check_point_set_missing_files3D,
149+
"is_loadable": og.is_point_set_loadable3D,
142150
"load": og.load_point_set3D,
143151
"is_saveable": og.is_point_set_saveable3D,
144152
"save": og.save_point_set3D,
@@ -158,6 +166,7 @@ def geode_objects_dict():
158166
"input_factory": og.PolygonalSurfaceInputFactory2D,
159167
"output_factory": og.PolygonalSurfaceOutputFactory2D,
160168
"missing_files": og.check_polygonal_surface_missing_files2D,
169+
"is_loadable": og.is_polygonal_surface_loadable2D,
161170
"load": og.load_polygonal_surface2D,
162171
"is_saveable": og.is_polygonal_surface_saveable2D,
163172
"save": og.save_polygonal_surface2D,
@@ -177,6 +186,7 @@ def geode_objects_dict():
177186
"input_factory": og.PolygonalSurfaceInputFactory3D,
178187
"output_factory": og.PolygonalSurfaceOutputFactory3D,
179188
"missing_files": og.check_polygonal_surface_missing_files3D,
189+
"is_loadable": og.is_polygonal_surface_loadable3D,
180190
"load": og.load_polygonal_surface3D,
181191
"is_saveable": og.is_polygonal_surface_saveable3D,
182192
"save": og.save_polygonal_surface3D,
@@ -196,6 +206,7 @@ def geode_objects_dict():
196206
"input_factory": og.PolyhedralSolidInputFactory3D,
197207
"output_factory": og.PolyhedralSolidOutputFactory3D,
198208
"missing_files": og.check_polyhedral_solid_missing_files3D,
209+
"is_loadable": og.is_polyhedral_solid_loadable3D,
199210
"load": og.load_polyhedral_solid3D,
200211
"is_saveable": og.is_polyhedral_solid_saveable3D,
201212
"save": og.save_polyhedral_solid3D,
@@ -215,6 +226,7 @@ def geode_objects_dict():
215226
"input_factory": og.RasterImageInputFactory2D,
216227
"output_factory": og.RasterImageOutputFactory2D,
217228
"missing_files": og.check_raster_image_missing_files2D,
229+
"is_loadable": og.is_raster_image_loadable2D,
218230
"load": og.load_raster_image2D,
219231
"is_saveable": og.is_raster_image_saveable2D,
220232
"save": og.save_raster_image2D,
@@ -227,6 +239,7 @@ def geode_objects_dict():
227239
"input_factory": og.RasterImageInputFactory3D,
228240
"output_factory": og.RasterImageOutputFactory3D,
229241
"missing_files": og.check_raster_image_missing_files3D,
242+
"is_loadable": og.is_raster_image_loadable3D,
230243
"load": og.load_raster_image3D,
231244
"is_saveable": og.is_raster_image_saveable3D,
232245
"save": og.save_raster_image3D,
@@ -239,6 +252,7 @@ def geode_objects_dict():
239252
"input_factory": og.RegularGridInputFactory2D,
240253
"output_factory": og.RegularGridOutputFactory2D,
241254
"missing_files": og.check_regular_grid_missing_files2D,
255+
"is_loadable": og.is_regular_grid_loadable2D,
242256
"load": og.load_regular_grid2D,
243257
"is_saveable": og.is_regular_grid_saveable2D,
244258
"save": og.save_regular_grid2D,
@@ -257,6 +271,7 @@ def geode_objects_dict():
257271
"input_factory": og.RegularGridInputFactory3D,
258272
"output_factory": og.RegularGridOutputFactory3D,
259273
"missing_files": og.check_regular_grid_missing_files3D,
274+
"is_loadable": og.is_regular_grid_loadable3D,
260275
"load": og.load_regular_grid3D,
261276
"is_saveable": og.is_regular_grid_saveable3D,
262277
"save": og.save_regular_grid3D,
@@ -275,6 +290,7 @@ def geode_objects_dict():
275290
"input_factory": og.SectionInputFactory,
276291
"output_factory": og.SectionOutputFactory,
277292
"missing_files": og.check_section_missing_files,
293+
"is_loadable": og.is_section_loadable,
278294
"load": og.load_section,
279295
"is_saveable": og.is_section_saveable,
280296
"save": og.save_section,
@@ -295,6 +311,7 @@ def geode_objects_dict():
295311
"input_factory": og_gs.StructuralModelInputFactory,
296312
"output_factory": og_gs.StructuralModelOutputFactory,
297313
"missing_files": og_gs.check_structural_model_missing_files,
314+
"is_loadable": og_gs.is_structural_model_loadable,
298315
"load": og_gs.load_structural_model,
299316
"is_saveable": og_gs.is_structural_model_saveable,
300317
"save": og_gs.save_structural_model,
@@ -314,6 +331,7 @@ def geode_objects_dict():
314331
"input_factory": og.TetrahedralSolidInputFactory3D,
315332
"output_factory": og.TetrahedralSolidOutputFactory3D,
316333
"missing_files": og.check_tetrahedral_solid_missing_files3D,
334+
"is_loadable": og.is_tetrahedral_solid_loadable3D,
317335
"load": og.load_tetrahedral_solid3D,
318336
"is_saveable": og.is_tetrahedral_solid_saveable3D,
319337
"save": og.save_tetrahedral_solid3D,
@@ -333,6 +351,7 @@ def geode_objects_dict():
333351
"input_factory": og.TriangulatedSurfaceInputFactory2D,
334352
"output_factory": og.TriangulatedSurfaceOutputFactory2D,
335353
"missing_files": og.check_triangulated_surface_missing_files2D,
354+
"is_loadable": og.is_triangulated_surface_loadable2D,
336355
"load": og.load_triangulated_surface2D,
337356
"is_saveable": og.is_triangulated_surface_saveable2D,
338357
"save": og.save_triangulated_surface2D,
@@ -352,6 +371,7 @@ def geode_objects_dict():
352371
"input_factory": og.TriangulatedSurfaceInputFactory3D,
353372
"output_factory": og.TriangulatedSurfaceOutputFactory3D,
354373
"missing_files": og.check_triangulated_surface_missing_files3D,
374+
"is_loadable": og.is_triangulated_surface_loadable3D,
355375
"load": og.load_triangulated_surface3D,
356376
"is_saveable": og.is_triangulated_surface_saveable3D,
357377
"save": og.save_triangulated_surface3D,
@@ -371,6 +391,7 @@ def geode_objects_dict():
371391
"input_factory": og.VertexSetInputFactory,
372392
"output_factory": og.VertexSetOutputFactory,
373393
"missing_files": og.check_vertex_set_missing_files,
394+
"is_loadable": og.is_vertex_set_loadable,
374395
"load": og.load_vertex_set,
375396
"is_saveable": og.is_vertex_set_saveable,
376397
"save": og.save_vertex_set,

0 commit comments

Comments
 (0)