TTK
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
Geometry.h File Reference
#include <Debug.h>
#include <VisitedMask.h>
#include <array>
#include <cmath>
#include <stack>

Go to the source code of this file.

Classes

struct  ttk::Geometry::ProjectionResult
 Stores the findProjection() result. More...
 
struct  ttk::Geometry::ProjectionInput
 Stores the findProjection() input. More...
 

Namespaces

namespace  ttk
 The Topology ToolKit.
 
namespace  ttk::Geometry
 

Macros

#define TTK_POW_LAMBDA(CALLEXPR, TYPE, EXPN, ...)
 Optimized Power function with lambdas.
 

Functions

template<typename T >
ttk::Geometry::angle (const T *vA0, const T *vA1, const T *vB0, const T *vB1)
 
template<typename T >
ttk::Geometry::angle2D (const T *vA0, const T *vA1, const T *vB0, const T *vB1)
 
template<typename T >
double ttk::Geometry::angle2DUndirected (const T *vA, const T *vB, const T *vC)
 
template<typename T >
bool ttk::Geometry::areVectorsColinear (const T *vA0, const T *vA1, const T *vB0, const T *vB1, std::array< T, 3 > *coefficients=nullptr, const T *tolerance=NULL)
 
template<typename T >
bool ttk::Geometry::isTriangleColinear2D (const T *pptA, const T *pptB, const T *pptC, const T tolerance)
 
template<typename T >
int ttk::Geometry::computeBarycentricCoordinates (const T *p0, const T *p1, const T *p, std::array< T, 2 > &baryCentrics, const int &dimension=3)
 
template<typename T >
int ttk::Geometry::computeBarycentricCoordinates (const T *p0, const T *p1, const T *p2, const T *p, std::array< T, 3 > &baryCentrics)
 
template<typename T >
bool ttk::Geometry::computeSegmentIntersection (const T &xA, const T &yA, const T &xB, const T &yB, const T &xC, const T &yC, const T &xD, const T &yD, T &x, T &y)
 
template<typename T >
int ttk::Geometry::computeTriangleAngles (const T *p0, const T *p1, const T *p2, std::array< T, 3 > &angles)
 
template<typename T >
int ttk::Geometry::computeTriangleAngleFromSides (const T s0, const T s1, const T s2, T &angle)
 
template<typename T >
int ttk::Geometry::computeTriangleArea (const T *p0, const T *p1, const T *p2, T &area)
 
template<typename T >
int ttk::Geometry::computeTriangleAreaFromSides (const T s0, const T s1, const T s2, T &area)
 
template<typename T >
int ttk::Geometry::crossProduct (const T *vA0, const T *vA1, const T *vB0, const T *vB1, std::array< T, 3 > &crossProduct)
 
template<typename T >
int ttk::Geometry::crossProduct (const T *vA, const T *vB, T *crossProduct)
 
template<typename T >
ttk::Geometry::distance (const T *p0, const T *p1, const int &dimension=3)
 
template<typename T >
ttk::Geometry::distance (const std::vector< T > &p0, const std::vector< T > &p1)
 
template<typename T >
ttk::Geometry::distance2D (const T *p0, const T *p1)
 
template<typename T >
ttk::Geometry::distanceFlatten (const std::vector< std::vector< T > > &p0, const std::vector< std::vector< T > > &p1)
 
template<typename T >
ttk::Geometry::dotProduct (const T *vA0, const T *vA1, const T *vB0, const T *vB1)
 
template<typename T >
ttk::Geometry::dotProduct (const T *vA, const T *vB, const int &dimension=3)
 
template<typename T >
ttk::Geometry::dotProduct (const std::vector< T > &vA, const std::vector< T > &vB)
 
template<typename T >
ttk::Geometry::dotProductFlatten (const std::vector< std::vector< T > > &vA, const std::vector< std::vector< T > > &vB)
 
template<typename T , typename Container , size_t dim>
int ttk::Geometry::getBoundingBox (const Container &points, std::array< std::pair< T, T >, dim > &bBox)
 
template<typename T >
bool ttk::Geometry::isPointInTriangle (const T *p0, const T *p1, const T *p2, const T *p)
 
template<typename T >
bool ttk::Geometry::isPointOnSegment (const T &x, const T &y, const T &xA, const T &yA, const T &xB, const T &yB)
 
template<typename T >
bool ttk::Geometry::isPointOnSegment (const T *p, const T *pA, const T *pB, const int &dimension=3)
 
template<typename T >
bool ttk::Geometry::isTriangleColinear (const T *p0, const T *p1, const T *p2, const T *tolerance=nullptr)
 
template<typename T >
ttk::Geometry::magnitude (const T *v, const int &dimension=3)
 
template<typename T >
ttk::Geometry::magnitude (const std::vector< T > &v)
 
template<typename T >
ttk::Geometry::magnitudeFlatten (const std::vector< std::vector< T > > &v)
 
template<typename T >
ttk::Geometry::magnitude (const T *o, const T *d)
 
template<typename T >
ttk::Geometry::powInt (const T val, const int n)
 
template<typename T = double>
ttk::Geometry::powIntTen (const int n)
 Compute the nth power of ten.
 
template<typename T1 , typename T2 >
T1 ttk::Geometry::pow (const T1 val, const T2 n)
 
template<typename T >
void ttk::Geometry::projectOnTrianglePlane (const T *p, const T *a, const T *normTri, T *out)
 Compute euclidean projection in a triangle plane.
 
template<typename T >
void ttk::Geometry::projectOnEdge (const T *p, const T *a, const T *b, T *out)
 Compute euclidean projection on a 3D segment.
 
template<typename T >
void ttk::Geometry::computeTriangleNormal (const T *a, const T *b, const T *c, T *out)
 Compute normal vector to triangle.
 
template<typename T , typename triangulationType >
SimplexId ttk::Geometry::getNearestSurfaceVertex (const T *pa, std::vector< T > &dists, const triangulationType &triangulation)
 Find nearest vertex on the surface.
 
template<typename T >
int ttk::Geometry::subtractVectors (const T *a, const T *b, T *out, const int &dimension=3)
 
template<typename T >
int ttk::Geometry::subtractVectors (const std::vector< T > &a, const std::vector< T > &b, std::vector< T > &out)
 
template<typename T >
int ttk::Geometry::addVectors (const T *a, const T *b, T *out, const int &dimension=3)
 
template<typename T >
int ttk::Geometry::addVectors (const std::vector< T > &a, const std::vector< T > &b, std::vector< T > &out)
 
template<typename T >
int ttk::Geometry::multiAddVectors (const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
 
template<typename T >
int ttk::Geometry::multiAddVectorsFlatten (const std::vector< std::vector< std::vector< T > > > &a, const std::vector< std::vector< std::vector< T > > > &b, std::vector< std::vector< T > > &out)
 
template<typename T >
int ttk::Geometry::scaleVector (const T *a, const T factor, T *out, const int &dimension=3)
 
template<typename T >
int ttk::Geometry::scaleVector (const std::vector< T > &a, const T factor, std::vector< T > &out)
 
template<typename T >
int ttk::Geometry::vectorProjection (const T *a, const T *b, T *out, const int &dimension=3)
 
template<typename T >
int ttk::Geometry::vectorProjection (const std::vector< T > &a, const std::vector< T > &b, std::vector< T > &out)
 
template<typename T >
void ttk::Geometry::addVectorsProjection (const std::vector< T > &a, const std::vector< T > &b, std::vector< T > &a_out, std::vector< T > &b_out)
 
template<typename T >
void ttk::Geometry::gramSchmidt (const std::vector< std::vector< T > > &a, std::vector< std::vector< T > > &out)
 
template<typename T >
bool ttk::Geometry::isVectorUniform (const std::vector< T > &a)
 
template<typename T >
bool ttk::Geometry::isVectorNull (const std::vector< T > &a)
 
template<typename T >
bool ttk::Geometry::isVectorNullFlatten (const std::vector< std::vector< T > > &a)
 
template<typename T >
int ttk::Geometry::flattenMultiDimensionalVector (const std::vector< std::vector< T > > &a, std::vector< T > &out)
 
template<typename T >
int ttk::Geometry::multiFlattenMultiDimensionalVector (const std::vector< std::vector< std::vector< T > > > &a, std::vector< std::vector< T > > &out)
 
template<typename T >
int ttk::Geometry::unflattenMultiDimensionalVector (const std::vector< T > &a, std::vector< std::vector< T > > &out, const int &no_columns=2)
 
template<typename T >
void ttk::Geometry::matrixMultiplication (const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
 
template<typename T >
void ttk::Geometry::subtractMatrices (const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
 
template<typename T >
void ttk::Geometry::addMatrices (const std::vector< std::vector< T > > &a, const std::vector< std::vector< T > > &b, std::vector< std::vector< T > > &out)
 
template<typename T >
void ttk::Geometry::scaleMatrix (const std::vector< std::vector< T > > &a, const T factor, std::vector< std::vector< T > > &out)
 
template<typename T >
void ttk::Geometry::transposeMatrix (const std::vector< std::vector< T > > &a, std::vector< std::vector< T > > &out)
 
template<typename triangulationType >
std::array< float, 3 > ttk::Geometry::computeSurfaceNormalAtPoint (const SimplexId a, const triangulationType &triangulation)
 Compute (mean) surface normal at given surface vertex.
 
template<typename triangulationType0 , typename triangulationType1 >
ProjectionResult ttk::Geometry::findProjection (const ProjectionInput &pi, VisitedMask &trianglesTested, std::vector< float > &dists, std::stack< SimplexId > &trianglesToTest, const bool reverseProjection, const triangulationType0 &triangulationToSmooth, const triangulationType1 &triangulation)
 

Macro Definition Documentation

◆ TTK_POW_LAMBDA

#define TTK_POW_LAMBDA (   CALLEXPR,
  TYPE,
  EXPN,
  ... 
)
Value:
{ \
const auto one = [](const TYPE ttkNotUsed(a)) { return TYPE{1}; }; \
const auto id = [](const TYPE a) { return a; }; \
const auto square = [](const TYPE a) { return a * a; }; \
const auto cube = [](const TYPE a) { return a * a * a; }; \
const auto powInt \
= [EXPN](const TYPE a) { return Geometry::powInt(a, EXPN); }; \
\
if(EXPN == 0) { \
CALLEXPR(__VA_ARGS__, one); \
} else if(EXPN == 1) { \
CALLEXPR(__VA_ARGS__, id); \
} else if(EXPN == 2) { \
CALLEXPR(__VA_ARGS__, square); \
} else if(EXPN == 3) { \
CALLEXPR(__VA_ARGS__, cube); \
} else { \
CALLEXPR(__VA_ARGS__, powInt); \
} \
}
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
Definition BaseClass.h:47
T powInt(const T val, const int n)
Definition Geometry.h:383

Optimized Power function with lambdas.

If ttk::Geometry::powInt, the integer power function, is called in a hot path, the if statements on the integer exponent can limit the performance. This macro helps by extracting the specialized computations for a given integer exponent into lambdas. These lambdas can be passed as arguments to a templated function outside the hot path to bypass the if statements.

Parameters
[in]CALLEXPRExpression containing the call to a templated function/method. This templated function should take one of the lambdas as last parameter.
[in]TYPEData type (template parameter).
[in]EXPNLocal variable containing the integer exponent.
[in]...List of CALLEXPR arguments before the lambda placeholder.

c.f. ttk::LDistance or ttk::KDTree for example uses.

Definition at line 430 of file Geometry.h.