Skip to content

Commit 3065203

Browse files
committed
fix(LightRegularGrid): Give access in python to the attribute managers with same name than meshes.
1 parent 0cfb3d1 commit 3065203

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

bindings/python/src/mesh/core/light_regular_grid.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
.def( pybind11::init< Point< dimension >, \
4242
std::array< index_t, dimension >, \
4343
std::array< Vector< dimension >, dimension > >() ) \
44+
.def( "vertex_attribute_manager", \
45+
&Grid##dimension##D::grid_vertex_attribute_manager, \
46+
pybind11::return_value_policy::reference ) \
4447
.def( "native_extension", \
4548
&LightRegularGrid##dimension##D::native_extension )
4649

bindings/python/tests/mesh/test-py-light-regular-grid.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@ def test_attribute( grid ):
249249
raise ValueError( "[Test] Wrong attribute value" )
250250
if attribute.value( grid.nb_cells() - 1 ) != -1:
251251
raise ValueError( "[Test] Wrong attribute value" )
252+
attribute = grid.vertex_attribute_manager().find_or_create_attribute_variable_double( "toto_vertex", 1 )
253+
attribute.set_value( 10, 10 )
254+
if attribute.value( 0 ) != 1:
255+
raise ValueError( "[Test] Wrong attribute value" )
256+
if attribute.value( 10 ) != 10:
257+
raise ValueError( "[Test] Wrong attribute value" )
258+
if attribute.value( grid.nb_cells() - 1 ) != 1:
259+
raise ValueError( "[Test] Wrong attribute value" )
252260

253261
def test_io(grid, filename):
254262
mesh.save_light_regular_grid3D(grid, filename)

include/geode/basic/attribute_manager.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ namespace geode
7979
std::dynamic_pointer_cast< ReadOnlyAttribute< T > >(
8080
find_attribute_base( name ) );
8181
OPENGEODE_EXCEPTION( attribute.get(),
82-
"[AttributeManager::find_attribute] You have to create an "
83-
"attribute before using it. "
84-
"See find_or_create_attribute method and "
85-
"derived classes of ReadOnlyAttribute." );
82+
"[AttributeManager::find_attribute] Could not find attribute '",
83+
name,
84+
"'. You have to create an attribute before using it. See "
85+
"find_or_create_attribute method and derived classes of "
86+
"ReadOnlyAttribute." );
8687
return attribute;
8788
}
8889

0 commit comments

Comments
 (0)