7 #ifndef __FWMATH_MESHFUNCTIONS_HPP__ 8 #define __FWMATH_MESHFUNCTIONS_HPP__ 10 #include "fwMath/IntrasecTypes.hpp" 11 #include "fwMath/config.hpp" 13 #include <fwCore/base.hpp> 15 #include <boost/unordered_map.hpp> 26 FWMATH_API
bool IsInclosedVolume(
const fwVertexPosition &_vertex,
const fwVertexIndex &_vertexIndex,
38 FWMATH_API
bool intersect_triangle(fwVec3d _orig, fwVec3d _dir, fwVec3d _vert0, fwVec3d _vert1, fwVec3d _vert2,
39 double &_t,
double &_u,
double &_v);
44 FWMATH_API
void findBorderEdges(
const fwVertexIndex &_vertexIndex, std::vector< std::vector< std::pair<
int,
51 FWMATH_API
bool closeSurface( fwVertexPosition &_vertex, fwVertexIndex &_vertexIndex );
60 template <
typename T,
typename U>
61 std::pair< T, U > makeOrderedPair(
const T first,
const U second)
65 return std::pair< T, U >(first, second);
69 return std::pair< T, U >(second, first);
75 template <
typename T,
typename U,
typename V>
76 bool isBorderlessSurface(T* cellDataBegin, T* cellDataEnd, U* cellDataOffsetsBegin, U* cellDataOffsetsEnd,
79 typedef std::pair< T, T > Edge;
80 typedef ::boost::unordered_map< Edge, int > EdgeHistogram;
81 EdgeHistogram edgesHistogram;
82 bool isBorderless =
true;
85 U* iter = cellDataOffsetsBegin;
86 U* iter2 = cellDataOffsetsBegin + 1;
87 const U* iterEnd = cellDataOffsetsEnd - 1;
88 V* iterTypes = cellTypesBegin;
90 dataLen = *iter2 - *iter;
93 iter < iterEnd || ( iter < cellDataOffsetsEnd && (dataLen = (cellDataEnd - cellDataBegin) - *iter) );
94 dataLen = *++iter2 - *++iter, ++iterTypes
101 T* iterCell = cellDataBegin + *iter;
102 T* iterCell2 = iterCell + 1;
103 T* beginCell = iterCell;
104 const T* iterCellEnd = beginCell + dataLen - 1;
107 iterCell < iterCellEnd || ( iterCell < (beginCell + dataLen) && (iterCell2 = beginCell) );
108 ++iterCell, ++iterCell2
111 ++edgesHistogram[makeOrderedPair(*iterCell, *(iterCell2))];
115 for(
const typename EdgeHistogram::value_type &histo : edgesHistogram)
117 if (histo.second != 2)
119 isBorderless =
false;
FWMATH_API bool removeOrphanVertices(fwVertexPosition &_vertex, fwVertexIndex &_vertexIndex)
FWMATH_API bool closeSurface(fwVertexPosition &_vertex, fwVertexIndex &_vertexIndex)
Closes the surface if necessary.
FWMATH_API bool intersect_triangle(fwVec3d _orig, fwVec3d _dir, fwVec3d _vert0, fwVec3d _vert1, fwVec3d _vert2, double &_t, double &_u, double &_v)
Compute the intersection between triangle(define by threes vertex vert1, vert2, vert3) and the Oz par...
The namespace fwMath contains classes which provide the implementation of several mathematic function...
FWMATH_API bool isBorderlessSurface(const fwVertexIndex &_vertexIndex)
test whatever a vertex is duplicated or not