OpenGeodeWeb-Back 5.10.4__py3-none-any.whl → 5.14.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opengeodeweb_back/app.py +20 -14
- opengeodeweb_back/geode_functions.py +44 -283
- opengeodeweb_back/geode_objects/__init__.py +61 -0
- opengeodeweb_back/geode_objects/geode_brep.py +102 -0
- opengeodeweb_back/geode_objects/geode_cross_section.py +75 -0
- opengeodeweb_back/geode_objects/geode_edged_curve2d.py +107 -0
- opengeodeweb_back/geode_objects/geode_edged_curve3d.py +107 -0
- opengeodeweb_back/geode_objects/geode_graph.py +76 -0
- opengeodeweb_back/geode_objects/geode_grid2d.py +30 -0
- opengeodeweb_back/geode_objects/geode_grid3d.py +30 -0
- opengeodeweb_back/geode_objects/geode_hybrid_solid3d.py +71 -0
- opengeodeweb_back/geode_objects/geode_implicit_cross_section.py +81 -0
- opengeodeweb_back/geode_objects/geode_implicit_structural_model.py +85 -0
- opengeodeweb_back/geode_objects/geode_light_regular_grid2d.py +72 -0
- opengeodeweb_back/geode_objects/geode_light_regular_grid3d.py +72 -0
- opengeodeweb_back/geode_objects/geode_mesh.py +19 -0
- opengeodeweb_back/geode_objects/geode_model.py +22 -0
- opengeodeweb_back/geode_objects/geode_object.py +78 -0
- opengeodeweb_back/geode_objects/geode_point_set2d.py +105 -0
- opengeodeweb_back/geode_objects/geode_point_set3d.py +105 -0
- opengeodeweb_back/geode_objects/geode_polygonal_surface2d.py +73 -0
- opengeodeweb_back/geode_objects/geode_polygonal_surface3d.py +73 -0
- opengeodeweb_back/geode_objects/geode_polyhedral_solid3d.py +73 -0
- opengeodeweb_back/geode_objects/geode_raster_image2d.py +83 -0
- opengeodeweb_back/geode_objects/geode_raster_image3d.py +83 -0
- opengeodeweb_back/geode_objects/geode_regular_grid2d.py +78 -0
- opengeodeweb_back/geode_objects/geode_regular_grid3d.py +78 -0
- opengeodeweb_back/geode_objects/geode_section.py +106 -0
- opengeodeweb_back/geode_objects/geode_solid_mesh3d.py +61 -0
- opengeodeweb_back/geode_objects/geode_structural_model.py +78 -0
- opengeodeweb_back/geode_objects/geode_surface_mesh2d.py +66 -0
- opengeodeweb_back/geode_objects/geode_surface_mesh3d.py +66 -0
- opengeodeweb_back/geode_objects/geode_tetrahedral_solid3d.py +73 -0
- opengeodeweb_back/geode_objects/geode_triangulated_surface2d.py +77 -0
- opengeodeweb_back/geode_objects/geode_triangulated_surface3d.py +77 -0
- opengeodeweb_back/geode_objects/geode_vertex_set.py +81 -0
- opengeodeweb_back/geode_objects/types.py +75 -0
- opengeodeweb_back/routes/blueprint_routes.py +346 -225
- opengeodeweb_back/routes/create/blueprint_create.py +121 -0
- opengeodeweb_back/routes/create/schemas/__init__.py +3 -0
- opengeodeweb_back/routes/create/schemas/create_aoi.json +45 -0
- opengeodeweb_back/routes/create/schemas/create_aoi.py +25 -0
- opengeodeweb_back/routes/create/schemas/create_point.json +29 -0
- opengeodeweb_back/routes/create/schemas/create_point.py +13 -0
- opengeodeweb_back/routes/create/schemas/create_voi.json +36 -0
- opengeodeweb_back/routes/create/schemas/create_voi.py +24 -0
- opengeodeweb_back/routes/models/blueprint_models.py +27 -27
- opengeodeweb_back/routes/models/schemas/__init__.py +2 -0
- opengeodeweb_back/routes/models/schemas/mesh_components.py +10 -0
- opengeodeweb_back/routes/models/schemas/vtm_component_indices.py +10 -0
- opengeodeweb_back/routes/schemas/__init__.py +17 -0
- opengeodeweb_back/routes/schemas/allowed_files.json +6 -8
- opengeodeweb_back/routes/schemas/allowed_files.py +10 -0
- opengeodeweb_back/routes/schemas/allowed_objects.json +1 -8
- opengeodeweb_back/routes/schemas/allowed_objects.py +10 -0
- opengeodeweb_back/routes/schemas/cell_attribute_names.json +13 -0
- opengeodeweb_back/routes/schemas/cell_attribute_names.py +10 -0
- opengeodeweb_back/routes/schemas/export_project.json +21 -0
- opengeodeweb_back/routes/schemas/export_project.py +12 -0
- opengeodeweb_back/routes/schemas/geode_objects_and_output_extensions.json +2 -2
- opengeodeweb_back/routes/schemas/geode_objects_and_output_extensions.py +11 -0
- opengeodeweb_back/routes/schemas/geographic_coordinate_systems.json +2 -2
- opengeodeweb_back/routes/schemas/geographic_coordinate_systems.py +10 -0
- opengeodeweb_back/routes/schemas/import_project.json +10 -0
- opengeodeweb_back/routes/schemas/import_project.py +10 -0
- opengeodeweb_back/routes/schemas/inspect_file.json +2 -2
- opengeodeweb_back/routes/schemas/inspect_file.py +11 -0
- opengeodeweb_back/routes/schemas/kill.py +10 -0
- opengeodeweb_back/routes/schemas/missing_files.json +2 -2
- opengeodeweb_back/routes/schemas/missing_files.py +11 -0
- opengeodeweb_back/routes/schemas/ping.py +10 -0
- opengeodeweb_back/routes/schemas/polygon_attribute_names.py +10 -0
- opengeodeweb_back/routes/schemas/polyhedron_attribute_names.py +10 -0
- opengeodeweb_back/routes/schemas/save_viewable_file.json +2 -2
- opengeodeweb_back/routes/schemas/save_viewable_file.py +11 -0
- opengeodeweb_back/routes/schemas/texture_coordinates.py +10 -0
- opengeodeweb_back/routes/schemas/upload_file.py +11 -0
- opengeodeweb_back/routes/schemas/vertex_attribute_names.py +10 -0
- opengeodeweb_back/test_utils.py +9 -3
- opengeodeweb_back/utils_functions.py +77 -74
- {opengeodeweb_back-5.10.4.dist-info → opengeodeweb_back-5.14.1.dist-info}/METADATA +9 -9
- opengeodeweb_back-5.14.1.dist-info/RECORD +98 -0
- opengeodeweb_back/geode_objects.py +0 -570
- opengeodeweb_back/routes/schemas/create_point.json +0 -29
- opengeodeweb_back-5.10.4.dist-info/RECORD +0 -33
- {opengeodeweb_back-5.10.4.dist-info → opengeodeweb_back-5.14.1.dist-info}/WHEEL +0 -0
- {opengeodeweb_back-5.10.4.dist-info → opengeodeweb_back-5.14.1.dist-info}/entry_points.txt +0 -0
- {opengeodeweb_back-5.10.4.dist-info → opengeodeweb_back-5.14.1.dist-info}/licenses/LICENSE +0 -0
- {opengeodeweb_back-5.10.4.dist-info → opengeodeweb_back-5.14.1.dist-info}/top_level.txt +0 -0
opengeodeweb_back/app.py
CHANGED
|
@@ -2,32 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
4
|
import os
|
|
5
|
-
import time
|
|
6
5
|
from typing import Any
|
|
7
|
-
|
|
8
6
|
import flask
|
|
9
7
|
import flask_cors # type: ignore
|
|
10
8
|
from flask import Flask, Response
|
|
11
9
|
from flask_cors import cross_origin
|
|
12
10
|
from werkzeug.exceptions import HTTPException
|
|
13
|
-
|
|
14
11
|
from opengeodeweb_back import utils_functions, app_config
|
|
15
12
|
from opengeodeweb_back.routes import blueprint_routes
|
|
16
13
|
from opengeodeweb_back.routes.models import blueprint_models
|
|
14
|
+
from opengeodeweb_back.routes.create import blueprint_create
|
|
17
15
|
from opengeodeweb_microservice.database import connection
|
|
18
16
|
|
|
19
|
-
|
|
20
17
|
""" Global config """
|
|
21
18
|
app: Flask = flask.Flask(__name__)
|
|
22
19
|
|
|
23
20
|
""" Config variables """
|
|
24
21
|
FLASK_DEBUG = True if os.environ.get("FLASK_DEBUG", default=None) == "True" else False
|
|
25
|
-
|
|
26
22
|
if FLASK_DEBUG == False:
|
|
27
23
|
app.config.from_object(app_config.ProdConfig)
|
|
28
24
|
else:
|
|
29
25
|
app.config.from_object(app_config.DevConfig)
|
|
30
|
-
|
|
31
26
|
DEFAULT_HOST: str = app.config.get("DEFAULT_HOST") or "localhost"
|
|
32
27
|
DEFAULT_PORT: int = int(app.config.get("DEFAULT_PORT") or 5000)
|
|
33
28
|
DEFAULT_DATA_FOLDER_PATH: str = app.config.get("DEFAULT_DATA_FOLDER_PATH") or "./data"
|
|
@@ -40,8 +35,13 @@ SECONDS_BETWEEN_SHUTDOWNS: float = float(
|
|
|
40
35
|
|
|
41
36
|
|
|
42
37
|
@app.before_request
|
|
43
|
-
def before_request() -> None:
|
|
38
|
+
def before_request() -> flask.Response | None:
|
|
39
|
+
if flask.request.method == "OPTIONS":
|
|
40
|
+
response = flask.make_response()
|
|
41
|
+
response.headers["Access-Control-Allow-Methods"] = "GET,POST,PUT,DELETE,OPTIONS"
|
|
42
|
+
return response
|
|
44
43
|
utils_functions.before_request(flask.current_app)
|
|
44
|
+
return None
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
@app.teardown_request
|
|
@@ -54,12 +54,16 @@ app.register_blueprint(
|
|
|
54
54
|
url_prefix="/opengeodeweb_back",
|
|
55
55
|
name="opengeodeweb_back",
|
|
56
56
|
)
|
|
57
|
-
|
|
58
57
|
app.register_blueprint(
|
|
59
58
|
blueprint_models.routes,
|
|
60
59
|
url_prefix="/opengeodeweb_back/models",
|
|
61
60
|
name="opengeodeweb_models",
|
|
62
61
|
)
|
|
62
|
+
app.register_blueprint(
|
|
63
|
+
blueprint_create.routes,
|
|
64
|
+
url_prefix="/opengeodeweb_back/create",
|
|
65
|
+
name="opengeodeweb_create",
|
|
66
|
+
)
|
|
63
67
|
|
|
64
68
|
if FLASK_DEBUG == False:
|
|
65
69
|
utils_functions.set_interval(
|
|
@@ -68,8 +72,14 @@ if FLASK_DEBUG == False:
|
|
|
68
72
|
|
|
69
73
|
|
|
70
74
|
@app.errorhandler(HTTPException)
|
|
71
|
-
def errorhandler(
|
|
72
|
-
return utils_functions.handle_exception(
|
|
75
|
+
def errorhandler(exception: HTTPException) -> tuple[dict[str, Any], int] | Response:
|
|
76
|
+
return utils_functions.handle_exception(exception)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@app.errorhandler(Exception)
|
|
80
|
+
def handle_generic_exception(exception: Exception) -> Response:
|
|
81
|
+
print("\033[91mError:\033[0m \033[91m" + str(exception) + "\033[0m", flush=True)
|
|
82
|
+
return flask.make_response({"description": str(exception)}, 500)
|
|
73
83
|
|
|
74
84
|
|
|
75
85
|
@app.route(
|
|
@@ -136,13 +146,10 @@ def run_server() -> None:
|
|
|
136
146
|
help="Number of minutes before the server times out",
|
|
137
147
|
)
|
|
138
148
|
args = parser.parse_args()
|
|
139
|
-
|
|
140
149
|
app.config.update(DATA_FOLDER_PATH=args.data_folder_path)
|
|
141
150
|
app.config.update(UPLOAD_FOLDER=args.upload_folder_path)
|
|
142
151
|
app.config.update(MINUTES_BEFORE_TIMEOUT=args.timeout)
|
|
143
|
-
|
|
144
152
|
flask_cors.CORS(app, origins=args.allowed_origins)
|
|
145
|
-
|
|
146
153
|
print(
|
|
147
154
|
f"Host: {args.host}, Port: {args.port}, Debug: {args.debug}, "
|
|
148
155
|
f"Data folder path: {args.data_folder_path}, Timeout: {args.timeout}, "
|
|
@@ -158,7 +165,6 @@ def run_server() -> None:
|
|
|
158
165
|
|
|
159
166
|
connection.init_database(db_path)
|
|
160
167
|
print(f"Database initialized at: {db_path}", flush=True)
|
|
161
|
-
|
|
162
168
|
app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL)
|
|
163
169
|
|
|
164
170
|
|
|
@@ -2,75 +2,47 @@
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
# Third party imports
|
|
5
|
-
import opengeode_geosciences as og_gs # type: ignore
|
|
6
|
-
import opengeode as og # type: ignore
|
|
7
5
|
import werkzeug
|
|
8
6
|
import flask
|
|
9
|
-
from typing import Any
|
|
10
7
|
|
|
11
8
|
# Local application imports
|
|
12
|
-
from .geode_objects import
|
|
13
|
-
from . import
|
|
9
|
+
from .geode_objects import geode_objects
|
|
10
|
+
from .geode_objects.types import (
|
|
11
|
+
GeodeObjectType,
|
|
12
|
+
geode_object_type,
|
|
13
|
+
)
|
|
14
|
+
from .geode_objects.geode_object import GeodeObject
|
|
14
15
|
from opengeodeweb_microservice.database.data import Data
|
|
15
|
-
from opengeodeweb_microservice.database.connection import get_session
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def input_factory(geode_object: str):
|
|
27
|
-
return geode_object_value(geode_object)["input_factory"]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def output_factory(geode_object: str):
|
|
31
|
-
return geode_object_value(geode_object)["output_factory"]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def additional_files(geode_object: str, file_absolute_path: str):
|
|
35
|
-
return geode_object_value(geode_object)["additional_files"](file_absolute_path)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def is_loadable(geode_object: str, file_absolute_path: str) -> float:
|
|
39
|
-
percentage = geode_object_value(geode_object)["is_loadable"](file_absolute_path)
|
|
40
|
-
return percentage.value()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def object_priority(geode_object: str, file_absolute_path: str) -> int:
|
|
44
|
-
return geode_object_value(geode_object)["object_priority"](file_absolute_path)
|
|
45
|
-
|
|
18
|
+
def data_file_path(data_id: str, filename: str | None = None) -> str:
|
|
19
|
+
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
|
|
20
|
+
data_path = os.path.join(data_folder_path, data_id)
|
|
21
|
+
if filename is not None:
|
|
22
|
+
return os.path.join(data_path, filename)
|
|
23
|
+
return data_path
|
|
46
24
|
|
|
47
|
-
def load(geode_object: str, file_absolute_path: str):
|
|
48
|
-
return geode_object_value(geode_object)["load"](file_absolute_path)
|
|
49
25
|
|
|
26
|
+
def geode_object_from_string(value: str) -> type[GeodeObject]:
|
|
27
|
+
return geode_objects[geode_object_type(value)]
|
|
50
28
|
|
|
51
|
-
def data_file_path(data_id: str, filename: str = "") -> str:
|
|
52
|
-
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
|
|
53
|
-
if filename:
|
|
54
|
-
return os.path.join(data_folder_path, data_id, filename)
|
|
55
|
-
return os.path.join(data_folder_path, data_id)
|
|
56
29
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if not data_entry:
|
|
30
|
+
def load_geode_object(data_id: str) -> GeodeObject:
|
|
31
|
+
data = Data.get(data_id)
|
|
32
|
+
if not data:
|
|
61
33
|
flask.abort(404, f"Data with id {data_id} not found")
|
|
62
34
|
|
|
63
|
-
file_absolute_path = data_file_path(data_id,
|
|
35
|
+
file_absolute_path = data_file_path(data_id, data.native_file)
|
|
64
36
|
print("Loading file: ", file_absolute_path)
|
|
65
37
|
print("File exists: ", os.path.exists(file_absolute_path))
|
|
66
|
-
return
|
|
38
|
+
return geode_object_from_string(data.geode_object).load(file_absolute_path)
|
|
67
39
|
|
|
68
40
|
|
|
69
41
|
def get_data_info(data_id: str) -> Data:
|
|
70
|
-
|
|
71
|
-
if not
|
|
42
|
+
data = Data.get(data_id)
|
|
43
|
+
if not data:
|
|
72
44
|
flask.abort(404, f"Data with id {data_id} not found")
|
|
73
|
-
return
|
|
45
|
+
return data
|
|
74
46
|
|
|
75
47
|
|
|
76
48
|
def upload_file_path(filename: str) -> str:
|
|
@@ -79,237 +51,26 @@ def upload_file_path(filename: str) -> str:
|
|
|
79
51
|
return os.path.abspath(os.path.join(upload_folder, secure_filename))
|
|
80
52
|
|
|
81
53
|
|
|
82
|
-
def
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def create_builder(geode_object: str, data):
|
|
93
|
-
return geode_object_value(geode_object)["builder"](data)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def assign_crs(geode_object: str, data, crs_name: str, info):
|
|
97
|
-
builder = create_builder(geode_object, data)
|
|
98
|
-
geode_object_value(geode_object)["crs"]["assign"](data, builder, crs_name, info)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def convert_crs(geode_object: str, data, crs_name: str, info):
|
|
102
|
-
builder = create_builder(geode_object, data)
|
|
103
|
-
geode_object_value(geode_object)["crs"]["convert"](data, builder, crs_name, info)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def create_crs(
|
|
107
|
-
geode_object: str,
|
|
108
|
-
data,
|
|
109
|
-
name: str,
|
|
110
|
-
input_coordiante_system,
|
|
111
|
-
output_coordiante_system,
|
|
112
|
-
):
|
|
113
|
-
builder = create_builder(geode_object, data)
|
|
114
|
-
geode_object_value(geode_object)["crs"]["create"](
|
|
115
|
-
data, builder, name, input_coordiante_system, output_coordiante_system
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def get_object_type(geode_object: str):
|
|
120
|
-
return geode_object_value(geode_object)["object_type"]
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def get_elements(geode_object: str):
|
|
124
|
-
return geode_object_value(geode_object)["elements"]
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def is_3D(geode_object: str):
|
|
128
|
-
return geode_object_value(geode_object)["is_3D"]
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def is_viewable(geode_object: str):
|
|
132
|
-
return geode_object_value(geode_object)["is_viewable"]
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def inspect(geode_object: str, data):
|
|
136
|
-
return geode_object_value(geode_object)["inspector"](data)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def save_viewable(geode_object: str, data, folder_absolute_path: str, id: str):
|
|
140
|
-
return geode_object_value(geode_object)["save_viewable"](
|
|
141
|
-
data, os.path.join(folder_absolute_path, id)
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def save_light_viewable(geode_object: str, data, folder_absolute_path: str, id: str):
|
|
146
|
-
return geode_object_value(geode_object)["save_light_viewable"](
|
|
147
|
-
data, os.path.join(folder_absolute_path, id)
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
def geode_object_input_extensions(geode_object: str):
|
|
152
|
-
geode_object_input_list_creators = input_factory(geode_object).list_creators()
|
|
153
|
-
geode_object_input_list_creators.sort()
|
|
154
|
-
return geode_object_input_list_creators
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def geode_object_output_extensions(geode_object: str):
|
|
158
|
-
geode_object_output_list_creators = output_factory(geode_object).list_creators()
|
|
159
|
-
geode_object_output_list_creators.sort()
|
|
160
|
-
return geode_object_output_list_creators
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def filter_geode_objects(key: str = None):
|
|
164
|
-
geode_objects_filtered_list = []
|
|
165
|
-
for geode_object, value in geode_objects_dict().items():
|
|
166
|
-
if key != None and key != "":
|
|
167
|
-
if key in value:
|
|
168
|
-
if type(value[key]) == bool:
|
|
169
|
-
geode_objects_filtered_list.append(geode_object)
|
|
170
|
-
else:
|
|
171
|
-
geode_objects_filtered_list.append(geode_object)
|
|
172
|
-
else:
|
|
173
|
-
geode_objects_filtered_list.append(geode_object)
|
|
174
|
-
geode_objects_filtered_list.sort()
|
|
175
|
-
return geode_objects_filtered_list
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
def list_input_extensions(key: str = None):
|
|
179
|
-
extensions_list = []
|
|
180
|
-
geode_objects_filtered_list = filter_geode_objects(key)
|
|
181
|
-
for geode_object in geode_objects_filtered_list:
|
|
182
|
-
extensions_list += geode_object_input_extensions(geode_object)
|
|
183
|
-
|
|
184
|
-
extensions_list = list(set(extensions_list))
|
|
185
|
-
extensions_list.sort()
|
|
186
|
-
return extensions_list
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
def has_creator(geode_object: str, extension: str):
|
|
190
|
-
return input_factory(geode_object).has_creator(extension)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def list_geode_objects(
|
|
194
|
-
file_absolute_path: str,
|
|
195
|
-
key: str = None,
|
|
196
|
-
):
|
|
197
|
-
return_dict = {}
|
|
198
|
-
file_extension = utils_functions.extension_from_filename(
|
|
199
|
-
os.path.basename(file_absolute_path)
|
|
200
|
-
)
|
|
201
|
-
geode_objects_filtered_list = filter_geode_objects(key)
|
|
202
|
-
for geode_object in geode_objects_filtered_list:
|
|
203
|
-
if has_creator(geode_object, file_extension):
|
|
204
|
-
loadability_score = is_loadable(geode_object, file_absolute_path)
|
|
205
|
-
priority_score = object_priority(geode_object, file_absolute_path)
|
|
206
|
-
return_dict[geode_object] = {
|
|
207
|
-
"is_loadable": loadability_score,
|
|
208
|
-
"object_priority": priority_score,
|
|
209
|
-
}
|
|
210
|
-
return return_dict
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
def geode_objects_output_extensions(geode_object: str, data):
|
|
214
|
-
geode_objects_output_extensions_dict = {}
|
|
215
|
-
output_extensions = geode_object_output_extensions(geode_object)
|
|
216
|
-
extensions_dict = {}
|
|
217
|
-
for output_extension in output_extensions:
|
|
218
|
-
bool_is_saveable = is_saveable(geode_object, data, f"test.{output_extension}")
|
|
219
|
-
extensions_dict[output_extension] = {"is_saveable": bool_is_saveable}
|
|
220
|
-
geode_objects_output_extensions_dict[geode_object] = extensions_dict
|
|
221
|
-
|
|
222
|
-
if "parent" in geode_object_value(geode_object).keys():
|
|
223
|
-
parent_geode_object = geode_object_value(geode_object)["parent"]
|
|
224
|
-
geode_objects_output_extensions_dict.update(
|
|
225
|
-
geode_objects_output_extensions(parent_geode_object, data)
|
|
226
|
-
)
|
|
227
|
-
return geode_objects_output_extensions_dict
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
def get_inspector_children(obj):
|
|
231
|
-
new_object = {}
|
|
232
|
-
|
|
233
|
-
if "inspection_type" in dir(obj):
|
|
234
|
-
new_object["title"] = obj.inspection_type()
|
|
235
|
-
new_object["nb_issues"] = 0
|
|
236
|
-
new_object["children"] = []
|
|
237
|
-
for child in dir(obj):
|
|
238
|
-
if not child.startswith("__") and not child in [
|
|
239
|
-
"inspection_type",
|
|
240
|
-
"string",
|
|
241
|
-
]:
|
|
242
|
-
child_instance = obj.__getattribute__(child)
|
|
243
|
-
child_object = get_inspector_children(child_instance)
|
|
244
|
-
new_object["children"].append(child_object)
|
|
245
|
-
new_object["nb_issues"] += child_object["nb_issues"]
|
|
246
|
-
else:
|
|
247
|
-
new_object["title"] = obj.description()
|
|
248
|
-
nb_issues = obj.nb_issues()
|
|
249
|
-
new_object["nb_issues"] = nb_issues
|
|
250
|
-
if nb_issues > 0:
|
|
251
|
-
issues = obj.string().split("\n")
|
|
252
|
-
new_object["issues"] = issues
|
|
253
|
-
return new_object
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
def geographic_coordinate_systems(geode_object: str):
|
|
257
|
-
if is_3D(geode_object):
|
|
258
|
-
return og_gs.GeographicCoordinateSystem3D.geographic_coordinate_systems()
|
|
259
|
-
else:
|
|
260
|
-
return og_gs.GeographicCoordinateSystem2D.geographic_coordinate_systems()
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
def geographic_coordinate_systems_info(geode_object: str, crs):
|
|
264
|
-
if is_3D(geode_object):
|
|
265
|
-
return og_gs.GeographicCoordinateSystemInfo3D(
|
|
266
|
-
crs["authority"], crs["code"], crs["name"]
|
|
54
|
+
def geode_object_output_extensions(
|
|
55
|
+
geode_object: GeodeObject,
|
|
56
|
+
) -> dict[GeodeObjectType, dict[str, bool]]:
|
|
57
|
+
results: dict[GeodeObjectType, dict[str, bool]] = {}
|
|
58
|
+
for mixin_geode_object in geode_objects[geode_object.geode_object_type()].__mro__:
|
|
59
|
+
output_extensions_method = getattr(
|
|
60
|
+
mixin_geode_object, "output_extensions", None
|
|
267
61
|
)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
),
|
|
284
|
-
),
|
|
285
|
-
og.Vector2D(
|
|
286
|
-
og.Point2D(
|
|
287
|
-
[coordinate_system["origin_x"], coordinate_system["origin_y"]]
|
|
288
|
-
),
|
|
289
|
-
og.Point2D(
|
|
290
|
-
[coordinate_system["point_2_x"], coordinate_system["point_2_y"]]
|
|
291
|
-
),
|
|
292
|
-
),
|
|
293
|
-
],
|
|
294
|
-
og.Point2D([coordinate_system["origin_x"], coordinate_system["origin_y"]]),
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
def assign_geographic_coordinate_system_info(geode_object: str, data, input_crs):
|
|
299
|
-
info = geographic_coordinate_systems_info(geode_object, input_crs)
|
|
300
|
-
assign_crs(geode_object, data, input_crs["name"], info)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
def convert_geographic_coordinate_system_info(geode_object: str, data, output_crs):
|
|
304
|
-
info = geographic_coordinate_systems_info(geode_object, output_crs)
|
|
305
|
-
convert_crs(geode_object, data, output_crs["name"], info)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
def create_coordinate_system(
|
|
309
|
-
geode_object: str, data, name, input_coordinate_points, output_coordinate_points
|
|
310
|
-
):
|
|
311
|
-
input_coordiante_system = coordinate_system(geode_object, input_coordinate_points)
|
|
312
|
-
output_coordiante_system = coordinate_system(geode_object, output_coordinate_points)
|
|
313
|
-
create_crs(
|
|
314
|
-
geode_object, data, name, input_coordiante_system, output_coordiante_system
|
|
315
|
-
)
|
|
62
|
+
if output_extensions_method is None:
|
|
63
|
+
continue
|
|
64
|
+
output_extensions = output_extensions_method.__func__(mixin_geode_object)
|
|
65
|
+
if output_extensions is None:
|
|
66
|
+
continue
|
|
67
|
+
object_output_extensions: dict[str, bool] = {}
|
|
68
|
+
is_saveable_method = getattr(mixin_geode_object, "is_saveable")
|
|
69
|
+
for output_extension in output_extensions:
|
|
70
|
+
bool_is_saveable = is_saveable_method(
|
|
71
|
+
geode_object, f"test.{output_extension}"
|
|
72
|
+
)
|
|
73
|
+
object_output_extensions[output_extension] = bool_is_saveable
|
|
74
|
+
if hasattr(mixin_geode_object, "geode_object_type"):
|
|
75
|
+
results[mixin_geode_object.geode_object_type()] = object_output_extensions
|
|
76
|
+
return results
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Standard library imports
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
# Third party imports
|
|
5
|
+
|
|
6
|
+
# Local application imports
|
|
7
|
+
from .types import GeodeObjectType
|
|
8
|
+
from .geode_object import GeodeObject
|
|
9
|
+
from .geode_brep import GeodeBRep
|
|
10
|
+
from .geode_vertex_set import GeodeVertexSet
|
|
11
|
+
from .geode_graph import GeodeGraph
|
|
12
|
+
from .geode_point_set2d import GeodePointSet2D
|
|
13
|
+
from .geode_point_set3d import GeodePointSet3D
|
|
14
|
+
from .geode_edged_curve2d import GeodeEdgedCurve2D
|
|
15
|
+
from .geode_edged_curve3d import GeodeEdgedCurve3D
|
|
16
|
+
from .geode_raster_image2d import GeodeRasterImage2D
|
|
17
|
+
from .geode_raster_image3d import GeodeRasterImage3D
|
|
18
|
+
from .geode_polygonal_surface2d import GeodePolygonalSurface2D
|
|
19
|
+
from .geode_polygonal_surface3d import GeodePolygonalSurface3D
|
|
20
|
+
from .geode_triangulated_surface2d import GeodeTriangulatedSurface2D
|
|
21
|
+
from .geode_triangulated_surface3d import GeodeTriangulatedSurface3D
|
|
22
|
+
from .geode_regular_grid2d import GeodeRegularGrid2D
|
|
23
|
+
from .geode_polyhedral_solid3d import GeodePolyhedralSolid3D
|
|
24
|
+
from .geode_tetrahedral_solid3d import GeodeTetrahedralSolid3D
|
|
25
|
+
from .geode_hybrid_solid3d import GeodeHybridSolid3D
|
|
26
|
+
from .geode_regular_grid3d import GeodeRegularGrid3D
|
|
27
|
+
from .geode_light_regular_grid2d import GeodeLightRegularGrid2D
|
|
28
|
+
from .geode_light_regular_grid3d import GeodeLightRegularGrid3D
|
|
29
|
+
from .geode_section import GeodeSection
|
|
30
|
+
from .geode_structural_model import GeodeStructuralModel
|
|
31
|
+
from .geode_cross_section import GeodeCrossSection
|
|
32
|
+
from .geode_implicit_structural_model import GeodeImplicitStructuralModel
|
|
33
|
+
from .geode_implicit_cross_section import GeodeImplicitCrossSection
|
|
34
|
+
|
|
35
|
+
geode_objects: dict[GeodeObjectType, type[GeodeObject]] = {
|
|
36
|
+
"VertexSet": GeodeVertexSet,
|
|
37
|
+
"Graph": GeodeGraph,
|
|
38
|
+
"PointSet2D": GeodePointSet2D,
|
|
39
|
+
"PointSet3D": GeodePointSet3D,
|
|
40
|
+
"EdgedCurve2D": GeodeEdgedCurve2D,
|
|
41
|
+
"EdgedCurve3D": GeodeEdgedCurve3D,
|
|
42
|
+
"RasterImage2D": GeodeRasterImage2D,
|
|
43
|
+
"RasterImage3D": GeodeRasterImage3D,
|
|
44
|
+
"PolygonalSurface2D": GeodePolygonalSurface2D,
|
|
45
|
+
"PolygonalSurface3D": GeodePolygonalSurface3D,
|
|
46
|
+
"TriangulatedSurface2D": GeodeTriangulatedSurface2D,
|
|
47
|
+
"TriangulatedSurface3D": GeodeTriangulatedSurface3D,
|
|
48
|
+
"RegularGrid2D": GeodeRegularGrid2D,
|
|
49
|
+
"PolyhedralSolid3D": GeodePolyhedralSolid3D,
|
|
50
|
+
"TetrahedralSolid3D": GeodeTetrahedralSolid3D,
|
|
51
|
+
"HybridSolid3D": GeodeHybridSolid3D,
|
|
52
|
+
"RegularGrid3D": GeodeRegularGrid3D,
|
|
53
|
+
"LightRegularGrid2D": GeodeLightRegularGrid2D,
|
|
54
|
+
"LightRegularGrid3D": GeodeLightRegularGrid3D,
|
|
55
|
+
"BRep": GeodeBRep,
|
|
56
|
+
"Section": GeodeSection,
|
|
57
|
+
"StructuralModel": GeodeStructuralModel,
|
|
58
|
+
"CrossSection": GeodeCrossSection,
|
|
59
|
+
"ImplicitStructuralModel": GeodeImplicitStructuralModel,
|
|
60
|
+
"ImplicitCrossSection": GeodeImplicitCrossSection,
|
|
61
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Standard library imports
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
# Third party imports
|
|
5
|
+
import opengeode as og
|
|
6
|
+
import opengeode_geosciences as og_geosciences
|
|
7
|
+
import opengeode_inspector as og_inspector
|
|
8
|
+
import geode_viewables as viewables
|
|
9
|
+
|
|
10
|
+
# Local application imports
|
|
11
|
+
from .types import GeodeModelType
|
|
12
|
+
from .geode_model import GeodeModel, ComponentRegistry
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class GeodeBRep(GeodeModel):
|
|
16
|
+
brep: og.BRep
|
|
17
|
+
|
|
18
|
+
def __init__(self, brep: og.BRep | None = None) -> None:
|
|
19
|
+
self.brep = brep if brep is not None else og.BRep()
|
|
20
|
+
super().__init__(self.brep)
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def geode_object_type(cls) -> GeodeModelType:
|
|
24
|
+
return "BRep"
|
|
25
|
+
|
|
26
|
+
def native_extension(self) -> str:
|
|
27
|
+
return self.brep.native_extension()
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def is_3D(cls) -> bool:
|
|
31
|
+
return True
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def is_viewable(cls) -> bool:
|
|
35
|
+
return True
|
|
36
|
+
|
|
37
|
+
def builder(self) -> og.BRepBuilder:
|
|
38
|
+
return og.BRepBuilder(self.brep)
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def load(cls, filename: str) -> GeodeBRep:
|
|
42
|
+
return GeodeBRep(og.load_brep(filename))
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def additional_files(cls, filename: str) -> og.AdditionalFiles:
|
|
46
|
+
return og.brep_additional_files(filename)
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def is_loadable(cls, filename: str) -> og.Percentage:
|
|
50
|
+
return og.is_brep_loadable(filename)
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def input_extensions(cls) -> list[str]:
|
|
54
|
+
return og.BRepInputFactory.list_creators()
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def output_extensions(cls) -> list[str]:
|
|
58
|
+
return og.BRepOutputFactory.list_creators()
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def object_priority(cls, filename: str) -> int:
|
|
62
|
+
return og.brep_object_priority(filename)
|
|
63
|
+
|
|
64
|
+
def is_saveable(self, filename: str) -> bool:
|
|
65
|
+
return og.is_brep_saveable(self.brep, filename)
|
|
66
|
+
|
|
67
|
+
def save(self, filename: str) -> list[str]:
|
|
68
|
+
return og.save_brep(self.brep, filename)
|
|
69
|
+
|
|
70
|
+
def save_viewable(self, filename_without_extension: str) -> str:
|
|
71
|
+
return viewables.save_viewable_brep(self.brep, filename_without_extension)
|
|
72
|
+
|
|
73
|
+
def save_light_viewable(self, filename_without_extension: str) -> str:
|
|
74
|
+
return viewables.save_light_viewable_brep(self.brep, filename_without_extension)
|
|
75
|
+
|
|
76
|
+
def mesh_components(self) -> ComponentRegistry:
|
|
77
|
+
return self.brep.mesh_components()
|
|
78
|
+
|
|
79
|
+
def inspect(self) -> og_inspector.BRepInspectionResult:
|
|
80
|
+
return og_inspector.inspect_brep(self.brep)
|
|
81
|
+
|
|
82
|
+
def assign_crs(
|
|
83
|
+
self, crs_name: str, info: og_geosciences.GeographicCoordinateSystemInfo
|
|
84
|
+
) -> None:
|
|
85
|
+
builder = self.builder()
|
|
86
|
+
og_geosciences.assign_brep_geographic_coordinate_system_info(
|
|
87
|
+
self.brep, builder, crs_name, info
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def convert_crs(
|
|
91
|
+
self, crs_name: str, info: og_geosciences.GeographicCoordinateSystemInfo
|
|
92
|
+
) -> None:
|
|
93
|
+
builder = self.builder()
|
|
94
|
+
og_geosciences.convert_brep_coordinate_reference_system(
|
|
95
|
+
self.brep, builder, crs_name, info
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def create_crs(
|
|
99
|
+
self, crs_name: str, input: og.CoordinateSystem2D, output: og.CoordinateSystem2D
|
|
100
|
+
) -> None:
|
|
101
|
+
builder = self.builder()
|
|
102
|
+
og.create_brep_coordinate_system(self.brep, builder, crs_name, input, output)
|