diff --git a/include/geode/io/image/detail/vtk_output.hpp b/include/geode/io/image/detail/vtk_output.hpp index 21a08cf..244cfca 100644 --- a/include/geode/io/image/detail/vtk_output.hpp +++ b/include/geode/io/image/detail/vtk_output.hpp @@ -99,6 +99,12 @@ namespace geode { for( const auto i : LRange{ attribute->nb_items() } ) { + if( !attribute->has_value( e ) ) + { + absl::StrAppend( + &values, std::nanf( " " ), " " ); + continue; + } const auto value = attribute->generic_item_value( e, i ); absl::StrAppend( &values, value, " " ); diff --git a/include/geode/io/mesh/detail/vtk_input.hpp b/include/geode/io/mesh/detail/vtk_input.hpp index 557aa4c..73be104 100644 --- a/include/geode/io/mesh/detail/vtk_input.hpp +++ b/include/geode/io/mesh/detail/vtk_input.hpp @@ -222,9 +222,16 @@ namespace geode "values is not a multiple of number of components" ); if( nb_components == 1 ) { + AttributeValues< T > default_values; + default_values.default_value = T{}; + default_values.no_value = T{}; + AttributeProperties properties; + properties.assignable = false; + properties.interpolable = false; + properties.transferable = true; auto attribute_id = manager.create_attribute< VariableAttribute, T >( - name, T{}, geode::AttributeProperties{} ); + name, default_values, properties ); auto attribute = manager.find_attribute< VariableAttribute, T >( attribute_id ); @@ -372,9 +379,16 @@ namespace geode std::string_view name, index_t offset ) { + AttributeValues< Container > default_values; + default_values.default_value = default_value; + default_values.no_value = default_value; + AttributeProperties properties; + properties.assignable = false; + properties.interpolable = false; + properties.transferable = true; const auto attribute_id = manager.create_attribute< VariableAttribute, Container >( - name, default_value, geode::AttributeProperties{} ); + name, default_values, properties ); auto attribute = manager.find_attribute< VariableAttribute, Container >( attribute_id ); diff --git a/src/geode/io/mesh/csv_input_helpers.cpp b/src/geode/io/mesh/csv_input_helpers.cpp index 47ce7e8..40dafae 100644 --- a/src/geode/io/mesh/csv_input_helpers.cpp +++ b/src/geode/io/mesh/csv_input_helpers.cpp @@ -154,10 +154,17 @@ namespace geode { continue; } + AttributeValues< double > default_values; + default_values.default_value = value; + default_values.no_value = value; + AttributeProperties properties; + properties.assignable = false; + properties.interpolable = false; + properties.transferable = true; const auto attribute_id = attribute_manager .create_attribute< VariableAttribute, double >( - attribute_name, value, AttributeProperties{} ); + attribute_name, default_values, properties ); double_attrs[col] = attribute_manager .find_attribute< VariableAttribute, double >( diff --git a/tests/mesh/test-vti.cpp b/tests/mesh/test-vti.cpp index 66d83fd..3bf3c00 100644 --- a/tests/mesh/test-vti.cpp +++ b/tests/mesh/test-vti.cpp @@ -43,10 +43,17 @@ void put_attributes_on_grid( const geode::Grid3D& grid ) { + geode::AttributeValues< geode::index_t > default_values; + default_values.default_value = geode::NO_ID; + default_values.no_value = geode::NO_ID; + geode::AttributeProperties properties; + properties.assignable = false; + properties.interpolable = false; + properties.transferable = true; const auto cell_attribute_id = grid.cell_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "id", geode::NO_ID, geode::AttributeProperties{} ); + "id", default_values, properties ); auto att = grid.cell_attribute_manager() .find_attribute< geode::VariableAttribute, geode::index_t >( cell_attribute_id ); @@ -57,7 +64,7 @@ void put_attributes_on_grid( const geode::Grid3D& grid ) const auto vertex_attribute_id = grid.grid_vertex_attribute_manager() .create_attribute< geode::VariableAttribute, geode::index_t >( - "id_vertex", geode::NO_ID, geode::AttributeProperties{} ); + "id_vertex", default_values, properties ); auto att_vertex = grid.grid_vertex_attribute_manager() .find_attribute< geode::VariableAttribute, geode::index_t >( diff --git a/tests/model/test-gid.cpp b/tests/model/test-gid.cpp index b97a0be..668ed8a 100644 --- a/tests/model/test-gid.cpp +++ b/tests/model/test-gid.cpp @@ -179,6 +179,13 @@ namespace auto brep = geode::load_brep( absl::StrCat( geode::DATA_PATH, short_filename, ".og_brep" ) ); test( brep ); + geode::AttributeValues< geode::index_t > default_values; + default_values.default_value = 1; + default_values.no_value = geode::NO_ID; + geode::AttributeProperties properties; + properties.assignable = false; + properties.interpolable = true; + properties.transferable = true; for( const auto& block : brep.blocks() ) { const auto& mesh = block.mesh(); @@ -186,7 +193,7 @@ namespace mesh.polyhedron_attribute_manager() .create_attribute< geode::ConstantAttribute, geode::index_t >( - "material_number", 1, { false, true, true } ); + "material_number", default_values, properties ); } for( const auto& surface : brep.surfaces() ) { @@ -195,7 +202,7 @@ namespace mesh.polygon_attribute_manager() .create_attribute< geode::ConstantAttribute, geode::index_t >( - "material_number", 1, { false, true, true } ); + "material_number", default_values, properties ); } const auto filename_gid = absl::StrCat( short_filename, "_output.gid_msh" );