Adds information required to compute signed distances from a point to a triangle.
The class adds vertex, edge and face normals to mesh. The normals are calculated according to [2] to allow for a numerically stable sign computation. To compute the point<->triangle distance, we use the rotation method described in [16]. Some data is precomputed to allow for faster computations and is stored at each face in an object of class DistanceProperties. The numbering of vertices, edges and voronoi regions in the rotated triangles are shown here:
The class offers multiple methods to get the signed squared distance from a point to a single triangle or the whole mesh. Please note that the distance computation for whole meshes is rather inefficient. Instead you should an object of this class into a mesh::DistanceOctree reduce the computational complexity from \(\mathcal O(n)\) to \(\mathcal O(\log n)\), where \(\mathcal O(n)\) where \(n\) is the number triangles.
Additionally to the signed squared distance you can also retrieve the closest point on the triangle or mesh to your point of inquiry. You may also retrieve the corresponding normal and the closest voronoi region.
#include <DistanceComputations.h>
Public Types | |
typedef MeshType::Scalar | Scalar |
typedef MeshType::Point | Point |
typedef MeshType::Normal | Normal |
typedef MeshType::FaceHandle | FaceHandle |
typedef math::Vector3< Scalar > | Vec3 |
typedef math::GenericAABB< Scalar > | BoundingBox |
Public Member Functions | |
TriangleDistance (const shared_ptr< MeshType > &mesh) | |
Scalar | sqDistance (const FaceHandle fh, const Point &p) const |
Scalar | sqSignedDistance (const FaceHandle fh, const Point &p) const |
Scalar | distance (const FaceHandle fh, const Point &p) const |
Scalar | signedDistance (const FaceHandle fh, const Point &p) const |
Scalar | sqDistance (const FaceHandle fh, const Point &p, Point &closestPoint) const |
Scalar | sqSignedDistance (const FaceHandle fh, const Point &p, Point &closestPoint) const |
Scalar | distance (const FaceHandle fh, const Point &p, Point &closestPoint) const |
Scalar | signedDistance (const FaceHandle fh, const Point &p, Point &closestPoint) const |
Scalar | sqDistance (const FaceHandle fh, const Point &p, Point &closestPoint, Normal &normal) const |
Scalar | sqSignedDistance (const FaceHandle fh, const Point &p, Point &closestPoint, Normal &normal) const |
Scalar | distance (const FaceHandle fh, const Point &p, Point &closestPoint, Normal &normal) const |
Scalar | signedDistance (const FaceHandle fh, const Point &p, Point &closestPoint, Normal &normal) const |
Scalar | sqDistance (const Point &p) const |
Scalar | sqSignedDistance (const Point &p) const |
Scalar | distance (const Point &p) const |
Scalar | signedDistance (const Point &p) const |
Scalar | sqDistance (const Point &p, FaceHandle &closestTriangle) const |
Scalar | sqSignedDistance (const Point &p, FaceHandle &closestTriangle) const |
Scalar | distance (const Point &p, FaceHandle &closestTriangle) const |
Scalar | signedDistance (const Point &p, FaceHandle &closestTriangle) const |
Scalar | sqDistance (const Point &p, Point &closestPoint) const |
Scalar | sqSignedDistance (const Point &p, Point &closestPoint) const |
Scalar | distance (const Point &p, Point &closestPoint) const |
Scalar | signedDistance (const Point &p, Point &closestPoint) const |
Scalar | sqDistance (const Point &p, Point &closestPoint, Normal &normal) const |
Scalar | sqSignedDistance (const Point &p, Point &closestPoint, Normal &normal) const |
Scalar | distance (const Point &p, Point &closestPoint, Normal &normal) const |
Scalar | signedDistance (const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator > | |
Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator > | |
Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator > | |
Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator > | |
Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator , typename OutputIterator > | |
void | filterTrianglesForAABB (const BoundingBox &aabb, const InputIterator fhInBegin, const InputIterator fhInEnd, OutputIterator fhOutBegin) const |
const MeshType & | getMesh () const |
shared_ptr< MeshType > | getMeshPtr () |
const BoundingBox & | getAabb (FaceHandle fh) const |
void | triangleToStream (const FaceHandle fh, std::ostream &os) const |
template<typename InputIterator > | |
MeshType::Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, int ®ion, Point &closestPoint, FaceHandle &fh) const |
template<typename InputIterator > | |
MeshType::Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
MeshType::Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
MeshType::Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
MeshType::Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p) const |
template<typename InputIterator > | |
MeshType::Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
MeshType::Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
MeshType::Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
MeshType::Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, FaceHandle &closestTriangle) const |
template<typename InputIterator > | |
MeshType::Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
MeshType::Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
MeshType::Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
MeshType::Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint) const |
template<typename InputIterator > | |
MeshType::Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator > | |
MeshType::Scalar | sqSignedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator > | |
MeshType::Scalar | distance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
template<typename InputIterator > | |
MeshType::Scalar | signedDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, Point &closestPoint, Normal &normal) const |
Protected Types | |
typedef OpenMesh::FPropHandleT< DistanceProperties< MeshType > > | DistancePropertyHandle |
Protected Member Functions | |
void | computeNormals () |
void | computeDistanceProperties () |
Scalar | sqDistance (const FaceHandle fh, const Point &p, int ®ion, Point &closestPoint) const |
template<typename InputIterator > | |
Scalar | sqDistance (InputIterator fhBegin, InputIterator fhEnd, const Point &p, int ®ion, Point &closestPoint, FaceHandle &fh) const |
Scalar | toSignedDistance (const Scalar &d, const FaceHandle fh, const Point &p, const int region, Point &closestPoint) const |
Scalar | toSignedDistance (const Scalar &d, const Point &p, Point &closestPoint, const Normal &normal) const |
const Normal & | getNormal (const FaceHandle fh, const int region) const |
Protected Attributes | |
shared_ptr< MeshType > | mesh_ |
OpenMesh::PropertyManager< DistancePropertyHandle, MeshType > | distanceProperties_ |
typedef math::GenericAABB<Scalar> walberla::mesh::TriangleDistance< MeshType >::BoundingBox |
|
protected |
typedef MeshType::FaceHandle walberla::mesh::TriangleDistance< MeshType >::FaceHandle |
typedef MeshType::Normal walberla::mesh::TriangleDistance< MeshType >::Normal |
typedef MeshType::Point walberla::mesh::TriangleDistance< MeshType >::Point |
typedef MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::Scalar |
typedef math::Vector3<Scalar> walberla::mesh::TriangleDistance< MeshType >::Vec3 |
|
inline |
|
protected |
|
protected |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | const FaceHandle | fh, |
const Point & | p | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | const Point & | p | ) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | const Point & | p, |
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | const Point & | p, |
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | const Point & | p, |
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::distance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
void walberla::mesh::TriangleDistance< MeshType >::filterTrianglesForAABB | ( | const BoundingBox & | aabb, |
const InputIterator | fhInBegin, | ||
const InputIterator | fhInEnd, | ||
OutputIterator | fhOutBegin | ||
) | const |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | const FaceHandle | fh, |
const Point & | p | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | const Point & | p | ) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | const Point & | p, |
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | const Point & | p, |
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | const Point & | p, |
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::signedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | const FaceHandle | fh, |
const Point & | p | ||
) | const |
|
protected |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | const Point & | p | ) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | const Point & | p, |
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | const Point & | p, |
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | const Point & | p, |
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
|
protected |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
int & | region, | ||
Point & | closestPoint, | ||
FaceHandle & | fh | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | const FaceHandle | fh, |
const Point & | p | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | const FaceHandle | fh, |
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | const Point & | p | ) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | const Point & | p, |
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | const Point & | p, |
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | const Point & | p, |
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
FaceHandle & | closestTriangle | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint | ||
) | const |
Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
MeshType::Scalar walberla::mesh::TriangleDistance< MeshType >::sqSignedDistance | ( | InputIterator | fhBegin, |
InputIterator | fhEnd, | ||
const Point & | p, | ||
Point & | closestPoint, | ||
Normal & | normal | ||
) | const |
|
inlineprotected |
|
inlineprotected |
void walberla::mesh::TriangleDistance< MeshType >::triangleToStream | ( | const FaceHandle | fh, |
std::ostream & | os | ||
) | const |
|
protected |
|
protected |