@@ -264,6 +264,28 @@ def texture_coordinates() -> flask.Response:
264264 return flask .make_response ({"texture_coordinates" : texture_coordinates }, 200 )
265265
266266
267+ def attributes_metadata (manager : Any ) -> dict [str , Any ]:
268+ metadata : dict [str , Any ] = {}
269+ for name in manager .attribute_names ():
270+ attribute = manager .find_generic_attribute (name )
271+ if not attribute .is_genericable ():
272+ metadata [name ] = [- 1 , - 1 ]
273+ continue
274+ min_value = None
275+ max_value = None
276+ nb_items = attribute .nb_items ()
277+ for i in range (nb_items ):
278+ generic_value = attribute .generic_value (i )
279+ if not isinstance (generic_value , (int , float )):
280+ continue
281+ if min_value is None or generic_value < min_value :
282+ min_value = generic_value
283+ if max_value is None or generic_value > max_value :
284+ max_value = generic_value
285+ metadata [name ] = [min_value , max_value ] if min_value is not None else [- 1 , - 1 ]
286+ return metadata
287+
288+
267289@routes .route (
268290 schemas_dict ["vertex_attribute_names" ]["route" ],
269291 methods = schemas_dict ["vertex_attribute_names" ]["methods" ],
@@ -276,10 +298,11 @@ def vertex_attribute_names() -> flask.Response:
276298 geode_object = geode_functions .load_geode_object (params .id )
277299 if not isinstance (geode_object , GeodeMesh ):
278300 flask .abort (400 , f"{ params .id } is not a GeodeMesh" )
279- vertex_attribute_names = geode_object .vertex_attribute_manager (). attribute_names ()
301+ attribute_manager = geode_object .vertex_attribute_manager ()
280302 return flask .make_response (
281303 {
282- "vertex_attribute_names" : vertex_attribute_names ,
304+ "vertex_attribute_names" : attribute_manager .attribute_names (),
305+ "vertex_attribute_metadata" : attributes_metadata (attribute_manager ),
283306 },
284307 200 ,
285308 )
@@ -297,10 +320,11 @@ def cell_attribute_names() -> flask.Response:
297320 geode_object = geode_functions .load_geode_object (params .id )
298321 if not isinstance (geode_object , GeodeGrid2D | GeodeGrid3D ):
299322 flask .abort (400 , f"{ params .id } is not a GeodeGrid" )
300- cell_attribute_names = geode_object .cell_attribute_manager (). attribute_names ()
323+ attribute_manager = geode_object .cell_attribute_manager ()
301324 return flask .make_response (
302325 {
303- "cell_attribute_names" : cell_attribute_names ,
326+ "cell_attribute_names" : attribute_manager .attribute_names (),
327+ "cell_attribute_metadata" : attributes_metadata (attribute_manager ),
304328 },
305329 200 ,
306330 )
@@ -318,10 +342,11 @@ def polygon_attribute_names() -> flask.Response:
318342 geode_object = geode_functions .load_geode_object (params .id )
319343 if not isinstance (geode_object , GeodeSurfaceMesh2D | GeodeSurfaceMesh3D ):
320344 flask .abort (400 , f"{ params .id } is not a GeodeSurfaceMesh" )
321- polygon_attribute_names = geode_object .polygon_attribute_manager (). attribute_names ()
345+ attribute_manager = geode_object .polygon_attribute_manager ()
322346 return flask .make_response (
323347 {
324- "polygon_attribute_names" : polygon_attribute_names ,
348+ "polygon_attribute_names" : attribute_manager .attribute_names (),
349+ "polygon_attribute_metadata" : attributes_metadata (attribute_manager ),
325350 },
326351 200 ,
327352 )
@@ -339,12 +364,11 @@ def polyhedron_attribute_names() -> flask.Response:
339364 geode_object = geode_functions .load_geode_object (params .id )
340365 if not isinstance (geode_object , GeodeSolidMesh3D ):
341366 flask .abort (400 , f"{ params .id } is not a GeodeSolidMesh" )
342- polyhedron_attribute_names = (
343- geode_object .polyhedron_attribute_manager ().attribute_names ()
344- )
367+ attributemanager = geode_object .polyhedron_attribute_manager ()
345368 return flask .make_response (
346369 {
347- "polyhedron_attribute_names" : polyhedron_attribute_names ,
370+ "polyhedron_attribute_names" : attributemanager .attribute_names (),
371+ "polyhedron_attribute_metadata" : attributes_metadata (attributemanager ),
348372 },
349373 200 ,
350374 )
@@ -362,10 +386,11 @@ def edge_attribute_names() -> flask.Response:
362386 geode_object = geode_functions .load_geode_object (params .id )
363387 if not isinstance (geode_object , GeodeGraph ):
364388 flask .abort (400 , f"{ params .id } does not have edges" )
365- edge_attribute_names = geode_object .edge_attribute_manager (). attribute_names ()
389+ attribute_manager = geode_object .edge_attribute_manager ()
366390 return flask .make_response (
367391 {
368- "edge_attribute_names" : edge_attribute_names ,
392+ "edge_attribute_names" : attribute_manager .attribute_names (),
393+ "edge_attribute_metadata" : attributes_metadata (attribute_manager ),
369394 },
370395 200 ,
371396 )
0 commit comments