Skip to content

Commit 50ff2c9

Browse files
Merge pull request #1114 from Geode-solutions/feat/anisotropic_distance_to_tetrahedron
Feat/anisotropic_distance_to_tetrahedron
2 parents 9d692bf + 5137bfe commit 50ff2c9

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

include/geode/mesh/builder/hybrid_solid_builder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace geode
5858
index_t create_tetrahedron( const std::array< index_t, 4 >& vertices );
5959

6060
/*!
61-
* Create a new hexahedron from four vertices.
61+
* Create a new hexahedron from eight vertices.
6262
* @param[in] vertices The eight vertices defining the hexahedron to
6363
* create
6464
* @return the index of the created hexahedron

include/geode/mesh/helpers/aabb_solid_helpers.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace geode
3131
FORWARD_DECLARATION_DIMENSION_CLASS( AABBTree );
3232
FORWARD_DECLARATION_DIMENSION_CLASS( SolidMesh );
3333
FORWARD_DECLARATION_DIMENSION_CLASS( TetrahedralSolid );
34+
FORWARD_DECLARATION_DIMENSION_CLASS( CoordinateSystem );
35+
ALIAS_3D( CoordinateSystem );
3436
template < typename T >
3537
class GenericMeshAABB;
3638
} // namespace geode
@@ -59,6 +61,26 @@ namespace geode
5961
};
6062
ALIAS_3D( DistanceToTetrahedron );
6163

64+
template < index_t dimension >
65+
class AnisotropicDistanceToTetrahedron
66+
{
67+
public:
68+
explicit AnisotropicDistanceToTetrahedron(
69+
const TetrahedralSolid< dimension >& mesh,
70+
const CoordinateSystem< dimension >& coordinate_system )
71+
: mesh_( mesh ), coordinate_system_( coordinate_system )
72+
{
73+
}
74+
75+
[[nodiscard]] double operator()(
76+
const Point< dimension >& query, index_t cur_box ) const;
77+
78+
private:
79+
const TetrahedralSolid< dimension >& mesh_;
80+
const CoordinateSystem< dimension >& coordinate_system_;
81+
};
82+
ALIAS_3D( AnisotropicDistanceToTetrahedron );
83+
6284
template < index_t dimension >
6385
class GenericMeshAABB< SolidMesh< dimension > >
6486
{

src/geode/mesh/helpers/aabb_solid_helpers.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,31 @@ namespace geode
6060
point_tetrahedron_distance( query, mesh_.tetrahedron( cur_box ) ) );
6161
}
6262

63+
template < index_t dimension >
64+
double AnisotropicDistanceToTetrahedron< dimension >::operator()(
65+
const Point< dimension >& query, index_t cur_box ) const
66+
{
67+
const auto tetrahedron_vertices =
68+
mesh_.tetrahedron( cur_box ).vertices();
69+
const auto p0 =
70+
coordinate_system_.coordinates( tetrahedron_vertices[0] );
71+
const auto p1 =
72+
coordinate_system_.coordinates( tetrahedron_vertices[1] );
73+
const auto p2 =
74+
coordinate_system_.coordinates( tetrahedron_vertices[2] );
75+
const auto p3 =
76+
coordinate_system_.coordinates( tetrahedron_vertices[3] );
77+
const Tetrahedron tetrahedron_in_metric_space{ p0, p1, p2, p3 };
78+
const auto query_in_metric_space =
79+
coordinate_system_.coordinates( query );
80+
return std::get< 0 >( point_tetrahedron_distance(
81+
query_in_metric_space, tetrahedron_in_metric_space ) );
82+
}
83+
6384
template opengeode_mesh_api AABBTree3D create_aabb_tree< 3 >(
6485
const SolidMesh3D& );
6586

6687
template class opengeode_mesh_api DistanceToTetrahedron< 3 >;
88+
template class opengeode_mesh_api AnisotropicDistanceToTetrahedron< 3 >;
6789

6890
} // namespace geode

0 commit comments

Comments
 (0)