1212
1313
1414@routes .route (
15- schemas_dict ["mesh_components " ]["route" ],
16- methods = schemas_dict ["mesh_components " ]["methods" ],
15+ schemas_dict ["model_components " ]["route" ],
16+ methods = schemas_dict ["model_components " ]["methods" ],
1717)
18- def mesh_components () -> flask .Response :
18+ def model_components () -> flask .Response :
1919 json_data = utils_functions .validate_request (
20- flask .request , schemas_dict ["mesh_components " ]
20+ flask .request , schemas_dict ["model_components " ]
2121 )
22- params = schemas .MeshComponents .from_dict (json_data )
22+ params = schemas .ModelComponents .from_dict (json_data )
2323 model = geode_functions .load_geode_object (params .id )
2424 if not isinstance (model , GeodeModel ):
2525 flask .abort (400 , f"{ params .id } is not a GeodeModel" )
@@ -44,14 +44,40 @@ def mesh_components() -> flask.Response:
4444 geode_id = id .string ()
4545 component_name = geode_id
4646 viewer_id = uuid_to_flat_index [geode_id ]
47-
47+ boundaries = model .boundaries (id )
48+ boundaries_uuid = [boundary .id ().string () for boundary in boundaries ]
49+ internals = model .internals (id )
50+ internals_uuid = [internal .id ().string () for internal in internals ]
4851 mesh_component_object = {
49- "id" : params .id ,
5052 "viewer_id" : viewer_id ,
5153 "geode_id" : geode_id ,
5254 "name" : component_name ,
5355 "type" : component_type ,
56+ "boundaries" : boundaries_uuid ,
57+ "internals" : internals_uuid ,
5458 }
5559 mesh_components .append (mesh_component_object )
5660
57- return flask .make_response ({"mesh_components" : mesh_components }, 200 )
61+ model_collection_components = model .collection_components ()
62+ collection_components = []
63+ for collection_component , ids in model_collection_components .items ():
64+ component_type = collection_component .get ()
65+ for id in ids :
66+ geode_id = id .string ()
67+ items = model .items (id )
68+ items_uuid = [item .id ().string () for item in items ]
69+ collection_component_object = {
70+ "geode_id" : geode_id ,
71+ "name" : geode_id ,
72+ "type" : component_type ,
73+ "items" : items_uuid ,
74+ }
75+ collection_components .append (collection_component_object )
76+
77+ return flask .make_response (
78+ {
79+ "mesh_components" : mesh_components ,
80+ "collection_components" : collection_components ,
81+ },
82+ 200 ,
83+ )
0 commit comments