Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions opengeodeweb_back_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,6 @@
"additionalProperties": false
}
},
"models": {
"model_components": {
"$id": "opengeodeweb_back/models/model_components",
"route": "/model_components",
"methods": [
"POST"
],
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
}
},
"required": [
"id"
],
"additionalProperties": false
}
},
"vertex_attribute_names": {
"$id": "opengeodeweb_back/vertex_attribute_names",
"route": "/vertex_attribute_names",
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ werkzeug==3.1.2
# flask
# flask-cors

opengeodeweb-microservice==1.*,>=1.0.16rc1
6 changes: 0 additions & 6 deletions src/opengeodeweb_back/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from werkzeug.exceptions import HTTPException
from opengeodeweb_back import utils_functions, app_config
from opengeodeweb_back.routes import blueprint_routes
from opengeodeweb_back.routes.models import blueprint_models
from opengeodeweb_back.routes.create import blueprint_create
from opengeodeweb_microservice.database import connection

Expand Down Expand Up @@ -85,11 +84,6 @@ def register_ogw_back_blueprints(app: flask.Flask) -> None:
url_prefix="/opengeodeweb_back",
name="opengeodeweb_back",
)
app.register_blueprint(
blueprint_models.routes,
url_prefix="/opengeodeweb_back/models",
name="opengeodeweb_models",
)
app.register_blueprint(
blueprint_create.routes,
url_prefix="/opengeodeweb_back/create",
Expand Down
8 changes: 0 additions & 8 deletions src/opengeodeweb_back/routes/blueprint_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# Local application imports
from opengeodeweb_back import geode_functions, utils_functions
from opengeodeweb_back.routes import schemas
from opengeodeweb_back.routes.models import blueprint_models
from opengeodeweb_back.geode_objects import geode_objects
from opengeodeweb_back.geode_objects.geode_mesh import GeodeMesh
from opengeodeweb_back.geode_objects.geode_graph import GeodeGraph
Expand All @@ -34,13 +33,6 @@

routes = flask.Blueprint("routes", __name__, url_prefix="/opengeodeweb_back")


routes.register_blueprint(
blueprint_models.routes,
url_prefix=blueprint_models.routes.url_prefix,
name=blueprint_models.routes.name,
)

schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))


Expand Down
83 changes: 0 additions & 83 deletions src/opengeodeweb_back/routes/models/blueprint_models.py

This file was deleted.

1 change: 0 additions & 1 deletion src/opengeodeweb_back/routes/models/schemas/__init__.py

This file was deleted.

17 changes: 0 additions & 17 deletions src/opengeodeweb_back/routes/models/schemas/model_components.json

This file was deleted.

10 changes: 0 additions & 10 deletions src/opengeodeweb_back/routes/models/schemas/model_components.py

This file was deleted.

72 changes: 68 additions & 4 deletions src/opengeodeweb_back/utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import threading
import time
import xml.etree.ElementTree as ET
import zipfile
from collections.abc import Callable
from concurrent.futures import ThreadPoolExecutor
Expand All @@ -22,6 +23,7 @@
# Local application imports
from . import geode_functions
from .geode_objects import geode_objects
from .geode_objects.geode_model import GeodeModel
from .geode_objects.geode_object import GeodeObject


Expand Down Expand Up @@ -191,11 +193,69 @@ def create_data_folder_from_id(data_id: str) -> str:
return data_path


def model_components(
data_id: str, model: GeodeModel, viewable_file: str
) -> dict[str, Any]:
vtm_file_path = geode_functions.data_file_path(data_id, viewable_file)
tree = ET.parse(vtm_file_path)
root = tree.find("vtkMultiBlockDataSet")
if root is None:
flask.abort(500, "Failed to read viewable file")
uuid_to_flat_index = {}
current_index = 0
assert root is not None
for elem in root.iter():
if "uuid" in elem.attrib and elem.tag == "DataSet":
uuid_to_flat_index[elem.attrib["uuid"]] = current_index
current_index += 1
model_mesh_components = model.mesh_components()
mesh_components = []
for mesh_component, ids in model_mesh_components.items():
component_type = mesh_component.get()
for id in ids:
geode_id = id.string()
component_name = geode_id
viewer_id = uuid_to_flat_index[geode_id]
boundaries = model.boundaries(id)
boundaries_uuid = [boundary.id().string() for boundary in boundaries]
internals = model.internals(id)
internals_uuid = [internal.id().string() for internal in internals]
mesh_component_object = {
"viewer_id": viewer_id,
"geode_id": geode_id,
"name": component_name,
"type": component_type,
"boundaries": boundaries_uuid,
"internals": internals_uuid,
}
mesh_components.append(mesh_component_object)

model_collection_components = model.collection_components()
collection_components = []
for collection_component, ids in model_collection_components.items():
component_type = collection_component.get()
for id in ids:
geode_id = id.string()
items = model.items(id)
items_uuid = [item.id().string() for item in items]
collection_component_object = {
"geode_id": geode_id,
"name": geode_id,
"type": component_type,
"items": items_uuid,
}
collection_components.append(collection_component_object)
return {
"mesh_components": mesh_components,
"collection_components": collection_components,
}


def save_all_viewables_and_return_info(
geode_object: GeodeObject,
data: Data,
data_path: str,
) -> dict[str, str | list[str]]:
) -> dict[str, Any]:
with ThreadPoolExecutor() as executor:
native_files, viewable_path, light_path = executor.map(
lambda args: args[0](args[1]),
Expand Down Expand Up @@ -225,7 +285,8 @@ def save_all_viewables_and_return_info(
name = geode_object.identifier.name()
if not name:
flask.abort(400, "Geode object has no name defined.")
return {

response: dict[str, Any] = {
"native_file": data.native_file,
"viewable_file": data.viewable_file,
"id": data.id,
Expand All @@ -234,11 +295,14 @@ def save_all_viewables_and_return_info(
"binary_light_viewable": binary_light_viewable.decode("utf-8"),
"geode_object_type": data.geode_object,
}
if isinstance(geode_object, GeodeModel):
response |= model_components(data.id, geode_object, data.viewable_file)
return response


def generate_native_viewable_and_light_viewable_from_object(
geode_object: GeodeObject,
) -> dict[str, str | list[str]]:
) -> dict[str, Any]:
data = Data.create(
geode_object=geode_object.geode_object_type(),
viewer_object=geode_object.viewer_type(),
Expand All @@ -250,7 +314,7 @@ def generate_native_viewable_and_light_viewable_from_object(

def generate_native_viewable_and_light_viewable_from_file(
geode_object_type: GeodeObjectType, input_file: str
) -> dict[str, str | list[str]]:
) -> dict[str, Any]:
generic_geode_object = geode_objects[geode_object_type]
data = Data.create(
geode_object=geode_object_type,
Expand Down
Loading