Skip to content

Commit

Permalink
Merge pull request #898 from Geode-solutions/fix/point_and_vertices_a…
Browse files Browse the repository at this point in the history
…round_vertex_for_light_grid

fix(LightRegularGrid): Added point and vertices_around_vertex methods…
  • Loading branch information
panquez authored Feb 26, 2024
2 parents 6fa7f83 + a5fc0b2 commit 6ec812c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/geode/mesh/core/light_regular_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace geode
static constexpr auto dim = dimension;
using CellIndices = typename Grid< dimension >::CellIndices;
using VertexIndices = typename Grid< dimension >::VertexIndices;
using VerticesAroundVertex =
absl::InlinedVector< index_t, 2 * dimension >;

LightRegularGrid( Point< dimension > origin,
std::array< index_t, dimension > cells_number,
Expand Down Expand Up @@ -75,6 +77,10 @@ namespace geode

CellIndices cell_indices( index_t index ) const override;

Point< dimension > point( index_t vertex_id ) const;

VerticesAroundVertex vertices_around_vertex( index_t vertex_id ) const;

AttributeManager& cell_attribute_manager() const override;

AttributeManager& grid_vertex_attribute_manager() const override;
Expand Down
27 changes: 27 additions & 0 deletions src/geode/mesh/core/light_regular_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,33 @@ namespace geode
return impl_->cell_indices( *this, index );
}

template < index_t dimension >
Point< dimension > LightRegularGrid< dimension >::point(
index_t vertex_id ) const
{
return this->grid_point( vertex_indices( vertex_id ) );
}

template < index_t dimension >
auto LightRegularGrid< dimension >::vertices_around_vertex(
index_t vertex_id ) const -> VerticesAroundVertex
{
VerticesAroundVertex result;
const auto indices = this->vertex_indices( vertex_id );
for( const auto d : LRange{ 2 } )
{
if( const auto next = this->next_vertex( indices, d ) )
{
result.push_back( this->vertex_index( next.value() ) );
}
if( const auto previous = this->previous_vertex( indices, d ) )
{
result.push_back( this->vertex_index( previous.value() ) );
}
}
return result;
}

template < index_t dimension >
AttributeManager&
LightRegularGrid< dimension >::cell_attribute_manager() const
Expand Down

0 comments on commit 6ec812c

Please sign in to comment.