Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@
const auto translate_name##mesh##dimension = absl::StrCat( \
"translate_", mesh_name, std::to_string( dimension ), "D" ); \
module.def( translate_name##mesh##dimension.c_str(), \
&translate_mesh< mesh, mesh##Builder, dimension > )
&translate_mesh< mesh##dimension##D > )

#define PYTHON_RESCALE( mesh, mesh_name, dimension ) \
const auto rescale_name##mesh##dimension = absl::StrCat( \
"rescale_", mesh_name, std::to_string( dimension ), "D" ); \
module.def( rescale_name##mesh##dimension.c_str(), \
&rescale_mesh< mesh, mesh##Builder, dimension > )
&rescale_mesh< mesh##dimension##D > )

namespace geode
{
void define_geometrical_operations_on_mesh( pybind11::module& module )

Check warning on line 56 in bindings/python/src/mesh/helpers/geometrical_operations_on_mesh.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/mesh/helpers/geometrical_operations_on_mesh.cpp:56:10 [misc-use-internal-linkage]

function 'define_geometrical_operations_on_mesh' can be made static or moved into an anonymous namespace to enforce internal linkage
{
PYTHON_TRANSLATE( PointSet, "point_set", 2 );
PYTHON_TRANSLATE( PointSet, "point_set", 3 );
Expand Down
22 changes: 9 additions & 13 deletions include/geode/mesh/helpers/geometrical_operations_on_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,26 @@

namespace geode
{
template < template < index_t > class Mesh,
template < index_t > class MeshBuilder,
index_t dimension >
void translate_mesh( Mesh< dimension >& mesh,
MeshBuilder< dimension >& builder,
const Vector< dimension >& translation )
template < class Mesh >
void translate_mesh( Mesh& mesh,
typename Mesh::Builder& builder,
const Vector< Mesh::dim >& translation )
{
for( const auto v : Range{ mesh.nb_vertices() } )
{
builder.set_point( v, mesh.point( v ) + translation );
}
}

template < template < index_t > class Mesh,
template < index_t > class MeshBuilder,
index_t dimension >
void rescale_mesh( Mesh< dimension >& mesh,
MeshBuilder< dimension >& builder,
const std::array< double, dimension >& scale )
template < class Mesh >
void rescale_mesh( Mesh& mesh,
typename Mesh::Builder& builder,
const std::array< double, Mesh::dim >& scale )
{
for( const auto v : Range{ mesh.nb_vertices() } )
{
auto point = mesh.point( v );
for( const auto d : LRange{ dimension } )
for( const auto d : LRange{ Mesh::dim } )
{
point.set_value( d, point.value( d ) * scale[d] );
}
Expand Down
Loading