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
6 changes: 6 additions & 0 deletions include/geode/io/image/detail/vtk_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

#include <geode/basic/attribute_manager.hpp>

namespace geode

Check warning on line 34 in include/geode/io/image/detail/vtk_output.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/image/detail/vtk_output.hpp:34:1 [modernize-concat-nested-namespaces]

nested namespaces can be concatenated
{
namespace detail
{
template < typename Mesh >
class VTKOutputImpl

Check warning on line 39 in include/geode/io/image/detail/vtk_output.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/image/detail/vtk_output.hpp:39:15 [cppcoreguidelines-special-member-functions]

class 'VTKOutputImpl' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
{
public:
void write_file()
Expand All @@ -59,7 +59,7 @@
"[VTKOutput] Error while writing file: ", filename );
}

virtual ~VTKOutputImpl() {}

Check warning on line 62 in include/geode/io/image/detail/vtk_output.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/image/detail/vtk_output.hpp:62:21 [hicpp-use-equals-default]

use '= default' to define a trivial destructor

const Mesh& mesh() const
{
Expand All @@ -79,11 +79,11 @@
write_attributes( attribute_node, manager, elements );
}

void write_attributes( pugi::xml_node& attribute_node,

Check warning on line 82 in include/geode/io/image/detail/vtk_output.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/image/detail/vtk_output.hpp:82:18 [readability-function-cognitive-complexity]

function 'write_attributes' has cognitive complexity of 13 (threshold 10)
const AttributeManager& manager,
absl::Span< const index_t > elements ) const
{
for( const auto& id : manager.attribute_ids() )

Check warning on line 86 in include/geode/io/image/detail/vtk_output.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/image/detail/vtk_output.hpp:86:34 [readability-identifier-length]

variable name 'id' is too short, expected at least 3 characters
{
const auto attribute = manager.find_generic_attribute( id );
if( !attribute || !attribute->is_genericable() )
Expand All @@ -99,6 +99,12 @@
{
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, " " );
Expand Down
18 changes: 16 additions & 2 deletions include/geode/io/mesh/detail/vtk_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@

#include <geode/geometry/point.hpp>

namespace geode

Check warning on line 42 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:42:1 [modernize-concat-nested-namespaces]

nested namespaces can be concatenated
{
namespace detail
{
template < typename Mesh >
class VTKInputImpl

Check warning on line 47 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:47:15 [cppcoreguidelines-special-member-functions]

class 'VTKInputImpl' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
{
public:
virtual ~VTKInputImpl() = default;
Expand All @@ -59,17 +59,17 @@
return std::move( mesh_ );
}

Percentage is_loadable()

Check failure on line 62 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:62:13 [clang-diagnostic-error]

unknown type name 'Percentage'
{
read_common_data();
std::vector< Percentage > percentages;

Check failure on line 65 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:65:30 [clang-diagnostic-error]

use of undeclared identifier 'Percentage'
for( const auto& vtk_object : root_.children( type_ ) )
{
is_vtk_object_loadable( vtk_object, percentages );
}
if( percentages.empty() )
{
return Percentage{ 0 };

Check failure on line 72 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:72:38 [clang-diagnostic-error]

expected ';' after return statement

Check failure on line 72 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:72:28 [clang-diagnostic-error]

use of undeclared identifier 'Percentage'
}
const auto nb_percentages = percentages.size();
double value{ 0 };
Expand All @@ -77,7 +77,7 @@
{
value += percentage.value();
}
return Percentage{ value / nb_percentages };

Check failure on line 80 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:80:34 [clang-diagnostic-error]

expected ';' after return statement

Check failure on line 80 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:80:24 [clang-diagnostic-error]

use of undeclared identifier 'Percentage'
}

protected:
Expand All @@ -97,7 +97,7 @@

virtual void is_vtk_object_loadable(
const pugi::xml_node& vtk_object,
std::vector< Percentage >& percentages ) const = 0;

Check failure on line 100 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:100:30 [clang-diagnostic-error]

use of undeclared identifier 'Percentage'

void read_common_data()
{
Expand All @@ -124,20 +124,20 @@
index_t read_attribute(
const pugi::xml_node& piece, std::string_view attribute ) const
{
return string_to_index(

Check failure on line 127 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:127:24 [clang-diagnostic-error]

use of undeclared identifier 'string_to_index'
piece.attribute( attribute.data() ).value() );

Check warning on line 128 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:128:48 [bugprone-suspicious-stringview-data-usage]

result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues
}

template < typename T >
std::vector< T > read_integer_data_array(
const pugi::xml_node& data ) const
{
const auto format = data.attribute( "format" ).value();

Check warning on line 135 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:135:17 [llvm-qualified-auto]

'const auto format' can be declared as 'const auto *const format'
if( match( format, "appended" ) )
{
return decode< T >( read_appended_data( data ) );
}
else

Check warning on line 140 in include/geode/io/mesh/detail/vtk_input.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/io/mesh/detail/vtk_input.hpp:140:17 [llvm-else-after-return]

do not use 'else' after 'return'
{
const auto data_string =
absl::StripAsciiWhitespace( data.child_value() );
Expand Down Expand Up @@ -222,9 +222,16 @@
"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 );
Expand Down Expand Up @@ -372,9 +379,16 @@
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 );
Expand Down
9 changes: 8 additions & 1 deletion src/geode/io/mesh/csv_input_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 >(
Expand Down
11 changes: 9 additions & 2 deletions tests/mesh/test-vti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 >(
Expand Down
11 changes: 9 additions & 2 deletions tests/model/test-gid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,21 @@ 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();
[[maybe_unused]] auto material_attribute =
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() )
{
Expand All @@ -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" );
Expand Down
Loading