OpenWalnut
1.4.0
|
Triangle mesh data structure allowing for convenient access of the elements. More...
#include <WTriangleMesh.h>
Public Types | |
typedef boost::shared_ptr < WTriangleMesh > | SPtr |
Shared pointer. | |
typedef boost::shared_ptr < const WTriangleMesh > | ConstSPtr |
Const shared pointer. | |
Public Member Functions | |
WTriangleMesh (size_t vertNum, size_t triangleNum) | |
constructor that already reserves space for a given number of triangles and vertexes | |
WTriangleMesh (osg::ref_ptr< osg::Vec3Array > vertices, const std::vector< size_t > &triangles) | |
Constructs a new mesh out of the given vertices and triangles. | |
virtual | ~WTriangleMesh () |
destructor | |
virtual const std::string | getName () const |
Gets the name of this prototype. | |
virtual const std::string | getDescription () const |
Gets the description for this prototype. | |
size_t | addVertex (osg::Vec3 vert) |
adds a vertex position to the mesh | |
size_t | addVertex (float x, float y, float z) |
adds a vertex position to the mesh | |
size_t | addVertex (WPosition vert) |
adds a vertex position to the mesh | |
void | addTextureCoordinate (osg::Vec3 texCoord) |
Adds a texture coordinate for the vertex. | |
void | addTextureCoordinate (float x, float y, float z) |
Adds a texture coordinate for the vertex. | |
void | addTriangle (size_t vert0, size_t vert1, size_t vert2) |
adds a tringle to the mesh | |
void | addTriangle (osg::Vec3 vert0, osg::Vec3 vert1, osg::Vec3 vert2) |
adds a tringle and its 3 vertexes to the mesh | |
void | setVertex (size_t index, osg::Vec3 vert) |
sets a vertex to a new position | |
void | setVertexNormal (size_t index, osg::Vec3 normal) |
sets the normal for a given vertex | |
void | setVertexNormal (size_t index, float x, float y, float z) |
sets the normal for a given vertex | |
void | setVertexNormal (size_t index, WPosition normal) |
sets the normal for a given vertex | |
void | setVertexColor (size_t index, osg::Vec4 color) |
sets the color for a given vertex | |
void | setTriangleColor (size_t index, osg::Vec4 color) |
sets the color for a given triangle | |
void | setTextureCoord (std::size_t index, osg::Vec3 texCoord) |
Set a texture coordinate. | |
osg::ref_ptr< osg::Vec4Array > | getTriangleColors () const |
Return triangle colors. | |
osg::ref_ptr< osg::Vec3Array > | getVertexArray () |
getter | |
osg::ref_ptr< const osg::Vec3Array > | getVertexArray () const |
Returns a const reference pointer to the vertex array. | |
osg::ref_ptr< osg::Vec3Array > | getTextureCoordinateArray () |
Returns a reference pointer to the texture coordinate array. | |
osg::ref_ptr< const osg::Vec3Array > | getTextureCoordinateArray () const |
Returns a const reference pointer to the texture coordinate array. | |
osg::ref_ptr< osg::Vec3Array > | getVertexNormalArray (bool forceRecalc=false) |
getter | |
osg::ref_ptr< osg::Vec4Array > | getVertexColorArray () |
getter | |
const std::vector< size_t > & | getTriangles () const |
Returns a const reference to the vertex ids of the triangles. | |
osg::ref_ptr< osg::Vec3Array > | getTriangleNormalArray (bool forceRecalc=false) |
getter | |
osg::Vec3 | getVertex (size_t index) const |
getter | |
osg::Vec4 | getVertColor (size_t index) const |
getter | |
osg::Vec3 | getTriVert (size_t triId, size_t vertNum) |
getter | |
WVector3d | getNormal (size_t index) |
getter | |
size_t | vertSize () const |
getter | |
size_t | triangleSize () const |
getter | |
void | doLoopSubD () |
performs a loop subdivision on the triangle mesh | |
size_t | getTriVertId0 (size_t triId) const |
returns the id of the first vertex of a triangle | |
size_t | getTriVertId1 (size_t triId) const |
returns the id of the second vertex of a triangle | |
size_t | getTriVertId2 (size_t triId) const |
return the id of the third vertex of a triangle | |
void | addMesh (boost::shared_ptr< WTriangleMesh > mesh, float xOff=0., float yOff=0., float zOff=0.) |
adds a mesh to the existing, no check for duplicate vertexes is performed, an additional vector may be specified to move the mesh to add | |
void | translateMesh (float xOff, float yOff, float zOff) |
moves the entire mesh to a new postion | |
void | zoomMesh (float zoom) |
multiplies the vertex vectors of the mesh with a given number | |
bool | operator== (const WTriangleMesh &rhs) const |
Checks if two meshes are exactly the same. | |
void | rescaleVertexColors () |
Rescale the vertex colors so that the maximum of all r, g and b values is 1. | |
void | performFeaturePreservingSmoothing (float sigmaDistance, float sigmaInfluence) |
Implements the feature-preserving mesh smoothing algorithm of Jones et al. | |
void | estimateCurvature () |
Estimates the normal curvatures and their principal directions for every vertex using the algorithm of: | |
double | getMainCurvature (std::size_t vtxId) const |
Retreive the main (maximum) curvature of a vertex. | |
double | getSecondaryCurvature (std::size_t vtxId) const |
Retreive the secondary (minimum) curvature of a vertex. | |
boost::shared_ptr< std::vector < float > > const & | getMainCurvatures () const |
Get the vector of main curvature values. | |
boost::shared_ptr< std::vector < float > > const & | getSecondaryCurvatures () const |
Get the vector of secondary curvature values. | |
osg::Vec3 | getCurvatureMainPrincipalDirection (std::size_t vtxId) const |
Retreive the 3d principal direction of curvature of a vertex. | |
osg::Vec3 | getCurvatureSecondaryPrincipalDirection (std::size_t vtxId) const |
Retreive the 3d principal direction of curvature for the minimum normal curvature of a vertex. | |
osg::ref_ptr< osg::Vec3Array > | getMainPrincipalCurvatureDirectionArray () |
Retreive the array of principal directions e.g. | |
osg::ref_ptr< osg::Vec3Array > | getSecondaryPrincipalCurvatureDirectionArray () |
Retreive the array of principal directions e.g. | |
void | recalcVertNormals () |
recalculates the vertex normals | |
void | setAutoRecalcNormals (bool autoRecalc=true) |
Set this to true to force automatic normal calculation. | |
Static Public Member Functions | |
static boost::shared_ptr < WPrototyped > | getPrototype () |
Returns a prototype instantiated with the true type of the deriving class. | |
Static Protected Attributes | |
static boost::shared_ptr < WPrototyped > | m_prototype = boost::shared_ptr< WPrototyped >() |
The prototype as singleton. | |
Private Member Functions | |
WTriangleMesh () | |
we don't allow the standard constructor | |
void | removeVertex (size_t index) |
removes a vertex from the vertex array, if any triangles still index that vertex they will be removed if forceRemoveTriangle is true | |
void | removeTriangle (size_t index) |
removes a triangle from the mesh | |
osg::Vec3 | calcTriangleNormal (size_t triangle) |
calculates a normal from the 3 points in space defining a triangle | |
osg::Vec3 | calcNormal (osg::Vec3 vert0, osg::Vec3 vert1, osg::Vec3 vert2) |
calculates a normal from the 3 points in space | |
void | updateVertsInTriangles () |
updates the list for which vertexes appear in which triangle | |
void | calcNeighbors () |
calculates neighbor information for triangles | |
size_t | getNeighbor (const size_t coVert1, const size_t coVert2, const size_t triangleNum) |
returns the triangle index of a triangle neighboring a given edge of a vertex | |
void | setTriVert0 (size_t triId, size_t vertId) |
higher level access function to the triangle vector, sets the first vertex of a triangle to a given vertex id | |
void | setTriVert1 (size_t triId, size_t vertId) |
higher level access function to the triangle vector, sets the second vertex of a triangle to a given vertex id | |
void | setTriVert2 (size_t triId, size_t vertId) |
higher level access function to the triangle vector, sets the third vertex of a triangle to a given vertex id | |
void | loopSetTriangle (size_t triId, size_t vertId1, size_t vertId2, size_t vertId3) |
changes the vertex ids of a triangle | |
void | loopEraseTriangleFromVertex (size_t triId, size_t vertId) |
erases a triangle from the vertexe's list of triangles it is part of | |
osg::Vec3 | loopCalcNewPosition (size_t vertId) |
calculates the new position of a vertex depending on it's location in the grid and number of neighbors | |
void | loopInsertCenterTriangle (size_t triId) |
inserts the center triangle in a given triangle, | |
void | loopInsertCornerTriangles (size_t triId) |
inserts the 3 corner triangles in a given triangle | |
size_t | loopCalcEdgeVert (size_t triId, size_t edgeV1, size_t edgeV2, size_t V3) |
calculates the vertex id for a given edge, inserts a new vertex of none exists yet | |
double | loopGetAlpha (int n) |
loop helper function | |
size_t | loopGetNextVertex (size_t triNum, size_t vertNum) |
returns the id of the next vertex int he triangle | |
size_t | loopGetThirdVert (size_t coVert1, size_t coVert2, size_t triangleNum) |
returns the id of the third vertex of a triangle for two given vertexes | |
void | performFeaturePreservingSmoothingMollificationPass (float sigmaDistance, float sigmaInfluence) |
Performs the first pass of the feature-preserving smoothing, only changing the triangle normals. | |
void | performFeaturePreservingSmoothingVertexPass (float sigmaDistance, float sigmaInfluence) |
Performs the second pass of the feature-preserving smoothing. | |
osg::Vec3 | estimateSmoothedVertexPosition (std::size_t vtx, float sigmaDistance, float sigmaInfluence, bool mollify) |
Calculates Eq. | |
osg::Vec3 | calcTriangleCenter (std::size_t triIdx) const |
Calculates the center position of a triangle. | |
float | calcTriangleArea (std::size_t triIdx) const |
Calculates the area of a triangle. | |
double | calcAngleBetweenNormalizedVectors (osg::Vec3 const &v1, osg::Vec3 const &v2) |
Calculates the angle between two NORMALIZED vectors. | |
Private Attributes | |
size_t | m_countVerts |
number of vertexes in the mesh | |
size_t | m_countTriangles |
number of triangles in the mesh | |
bool | m_meshDirty |
flag indicating a change took place which requires a recalculation of components | |
bool | m_autoNormal |
flag denoting whether normals should be calculated automatically. | |
bool | m_neighborsCalculated |
flag indicating whether the neighbor information has been calculated yet | |
bool | m_curvatureCalculated |
Indicates whether the curvature and its principal directions have been calculated. | |
osg::ref_ptr< osg::Vec3Array > | m_verts |
array containing the vertices | |
osg::ref_ptr< osg::Vec3Array > | m_textureCoordinates |
array containing the texture coordinates | |
osg::ref_ptr< osg::Vec3Array > | m_vertNormals |
array containing the vertex normals | |
osg::ref_ptr< osg::Vec4Array > | m_vertColors |
array containing vertex colors | |
std::vector< size_t > | m_triangles |
array containing the triangles | |
osg::ref_ptr< osg::Vec3Array > | m_triangleNormals |
array containing the triangle normals | |
osg::ref_ptr< osg::Vec4Array > | m_triangleColors |
array containing the triangle colors | |
std::vector< std::vector < size_t > > | m_vertexIsInTriangle |
for each vertex, list of triangles it is part of | |
std::vector< std::vector < size_t > > | m_triangleNeighbors |
edge neighbors for each triangle | |
boost::shared_ptr< std::vector < float > > | m_mainNormalCurvature |
Stores the maximum normal curvature (for the first principal direction) for each vertex. | |
boost::shared_ptr< std::vector < float > > | m_secondaryNormalCurvature |
Stores the minimum normal curvature (for the second principal direction) for each vertex. | |
osg::ref_ptr< osg::Vec3Array > | m_mainCurvaturePrincipalDirection |
Stores the first principal curvature direction for each vertex. | |
osg::ref_ptr< osg::Vec3Array > | m_secondaryCurvaturePrincipalDirection |
Stores the second principal curvature direction for each vertex. | |
size_t | m_numTriVerts |
stores the number of vertexes before the loop subdivion is run, needed by the loop algorithm | |
size_t | m_numTriFaces |
stores the number of triangles before the loop subdivion is run, needed by the loop algorithm | |
Friends | |
class | WTriangleMeshTest |
Triangle mesh data structure allowing for convenient access of the elements.
Definition at line 44 of file WTriangleMesh.h.
typedef boost::shared_ptr< const WTriangleMesh > WTriangleMesh::ConstSPtr |
Const shared pointer.
Definition at line 56 of file WTriangleMesh.h.
typedef boost::shared_ptr< WTriangleMesh > WTriangleMesh::SPtr |
Shared pointer.
Definition at line 51 of file WTriangleMesh.h.
WTriangleMesh::WTriangleMesh | ( | size_t | vertNum, |
size_t | triangleNum | ||
) |
constructor that already reserves space for a given number of triangles and vertexes
vertNum | |
triangleNum |
Definition at line 61 of file WTriangleMesh.cpp.
References m_textureCoordinates, m_triangleColors, m_triangleNormals, m_triangles, m_vertColors, m_vertNormals, and m_verts.
WTriangleMesh::WTriangleMesh | ( | osg::ref_ptr< osg::Vec3Array > | vertices, |
const std::vector< size_t > & | triangles | ||
) |
Constructs a new mesh out of the given vertices and triangles.
vertices | Vec3Array storing all vertices |
triangles | Vector of consecutive vertex indices where each 3 IDs are a triangle starting at 0,1,2 for first triangle 3,4,5 for the second |
Definition at line 79 of file WTriangleMesh.cpp.
WTriangleMesh::~WTriangleMesh | ( | ) | [virtual] |
destructor
Definition at line 96 of file WTriangleMesh.cpp.
WTriangleMesh::WTriangleMesh | ( | ) | [private] |
we don't allow the standard constructor
Referenced by getPrototype().
void WTriangleMesh::addMesh | ( | boost::shared_ptr< WTriangleMesh > | mesh, |
float | xOff = 0. , |
||
float | yOff = 0. , |
||
float | zOff = 0. |
||
) |
adds a mesh to the existing, no check for duplicate vertexes is performed, an additional vector may be specified to move the mesh to add
mesh | |
xOff | |
yOff | |
zOff |
Definition at line 601 of file WTriangleMesh.cpp.
References addTriangle(), addVertex(), m_countVerts, m_meshDirty, and setVertexColor().
void WTriangleMesh::addTextureCoordinate | ( | osg::Vec3 | texCoord | ) | [inline] |
Adds a texture coordinate for the vertex.
texCoord | the texture coordinate |
Definition at line 816 of file WTriangleMesh.h.
References m_countVerts.
Referenced by addTextureCoordinate().
void WTriangleMesh::addTextureCoordinate | ( | float | x, |
float | y, | ||
float | z | ||
) | [inline] |
Adds a texture coordinate for the vertex.
x | texture coordinate X |
y | texture coordinate Y |
z | texture coordinate Z |
Definition at line 821 of file WTriangleMesh.h.
References addTextureCoordinate().
void WTriangleMesh::addTriangle | ( | size_t | vert0, |
size_t | vert1, | ||
size_t | vert2 | ||
) |
adds a tringle to the mesh
vert0 | index of the first vertex |
vert1 | index of the second vertex |
vert2 | index of the third vertex |
Definition at line 115 of file WTriangleMesh.cpp.
References m_countTriangles, and m_triangles.
Referenced by addMesh(), addTriangle(), loopInsertCenterTriangle(), loopInsertCornerTriangles(), WTriangleMeshTest::testComponentDecomposition(), and WTriangleMeshTest::testEqualityOperator().
void WTriangleMesh::addTriangle | ( | osg::Vec3 | vert0, |
osg::Vec3 | vert1, | ||
osg::Vec3 | vert2 | ||
) |
adds a tringle and its 3 vertexes to the mesh
vert0 | position of the first vertex |
vert1 | position of the second vertex |
vert2 | position of the third vertex |
Definition at line 127 of file WTriangleMesh.cpp.
References addTriangle(), addVertex(), and m_countVerts.
size_t WTriangleMesh::addVertex | ( | osg::Vec3 | vert | ) | [inline] |
adds a vertex position to the mesh
vert |
Definition at line 826 of file WTriangleMesh.h.
References m_countVerts.
Referenced by addMesh(), addTriangle(), addVertex(), loopCalcEdgeVert(), WTriangleMeshTest::testComponentDecomposition(), and WTriangleMeshTest::testEqualityOperator().
size_t WTriangleMesh::addVertex | ( | float | x, |
float | y, | ||
float | z | ||
) |
adds a vertex position to the mesh
x | |
y | |
z |
Definition at line 105 of file WTriangleMesh.cpp.
References addVertex().
size_t WTriangleMesh::addVertex | ( | WPosition | vert | ) |
adds a vertex position to the mesh
vert | vertex to add |
Definition at line 110 of file WTriangleMesh.cpp.
References addVertex().
double WTriangleMesh::calcAngleBetweenNormalizedVectors | ( | osg::Vec3 const & | v1, |
osg::Vec3 const & | v2 | ||
) | [private] |
Calculates the angle between two NORMALIZED vectors.
Asserts in debug mode, in release mode when called with non-normalized vectors, results are undefined.
v1 | The first NORMALIZED vector. |
v2 | The second NORMALIZED vector. |
Definition at line 1131 of file WTriangleMesh.cpp.
Referenced by estimateCurvature().
void WTriangleMesh::calcNeighbors | ( | ) | [private] |
calculates neighbor information for triangles
Definition at line 344 of file WTriangleMesh.cpp.
References getNeighbor(), getTriVertId0(), getTriVertId1(), getTriVertId2(), m_countTriangles, m_neighborsCalculated, and m_triangleNeighbors.
Referenced by estimateCurvature(), and performFeaturePreservingSmoothing().
osg::Vec3 WTriangleMesh::calcNormal | ( | osg::Vec3 | vert0, |
osg::Vec3 | vert1, | ||
osg::Vec3 | vert2 | ||
) | [private] |
calculates a normal from the 3 points in space
vert0 | vertex 1 |
vert1 | vertex 2 |
vert2 | vertex 3 |
Definition at line 318 of file WTriangleMesh.cpp.
float WTriangleMesh::calcTriangleArea | ( | std::size_t | triIdx | ) | const [private] |
Calculates the area of a triangle.
triIdx | The id of the triangle to calculate the area of. |
Definition at line 898 of file WTriangleMesh.cpp.
References m_triangles, and m_verts.
Referenced by estimateSmoothedVertexPosition().
osg::Vec3 WTriangleMesh::calcTriangleCenter | ( | std::size_t | triIdx | ) | const [private] |
Calculates the center position of a triangle.
triIdx | The id of the triangle to calculate the center of. |
Definition at line 888 of file WTriangleMesh.cpp.
References m_triangles, and m_verts.
Referenced by estimateCurvature(), and estimateSmoothedVertexPosition().
osg::Vec3 WTriangleMesh::calcTriangleNormal | ( | size_t | triangle | ) | [private] |
calculates a normal from the 3 points in space defining a triangle
triangle |
Definition at line 302 of file WTriangleMesh.cpp.
References getTriVert().
Referenced by recalcVertNormals().
void WTriangleMesh::doLoopSubD | ( | ) |
performs a loop subdivision on the triangle mesh
Definition at line 380 of file WTriangleMesh.cpp.
References loopCalcNewPosition(), loopInsertCenterTriangle(), loopInsertCornerTriangles(), m_countTriangles, m_countVerts, m_meshDirty, m_numTriFaces, m_numTriVerts, m_triangleColors, m_triangles, m_vertColors, m_vertexIsInTriangle, m_vertNormals, m_verts, and updateVertsInTriangles().
void WTriangleMesh::estimateCurvature | ( | ) |
Estimates the normal curvatures and their principal directions for every vertex using the algorithm of:
DONG, Chen-shi; WANG, Guo-zhao. Curvatures estimation on triangular mesh. Journal of Zhejiang University SCIENCE, 2005, 6. Jg., Nr. 1, S. 128-136.
Definition at line 907 of file WTriangleMesh.cpp.
References calcAngleBetweenNormalizedVectors(), calcNeighbors(), calcTriangleCenter(), m_curvatureCalculated, m_mainCurvaturePrincipalDirection, m_mainNormalCurvature, m_secondaryCurvaturePrincipalDirection, m_secondaryNormalCurvature, m_triangleNormals, m_triangles, m_vertexIsInTriangle, m_verts, updateVertsInTriangles(), and wlog::warn().
osg::Vec3 WTriangleMesh::estimateSmoothedVertexPosition | ( | std::size_t | vtx, |
float | sigmaDistance, | ||
float | sigmaInfluence, | ||
bool | mollify | ||
) | [private] |
Calculates Eq.
3 of:
"Non-Iterative, Feature-Preserving Mesh Smoothing", Jones, T.R., Durand, F., Desbrun, M., ACM Trans. Graph. (22), 2003, 943-949
vtx | The id of the vertex to calculate the new position for. |
sigmaDistance | The standard deviation of the spatial weights. |
sigmaInfluence | The standard deviation of the influence weights. |
mollify | Whether this is a mollification pass (simple position estimates) or not. |
Definition at line 823 of file WTriangleMesh.cpp.
References calcTriangleArea(), calcTriangleCenter(), m_triangleNeighbors, m_triangleNormals, m_vertexIsInTriangle, and m_verts.
Referenced by performFeaturePreservingSmoothingMollificationPass(), and performFeaturePreservingSmoothingVertexPass().
osg::Vec3 WTriangleMesh::getCurvatureMainPrincipalDirection | ( | std::size_t | vtxId | ) | const |
Retreive the 3d principal direction of curvature of a vertex.
vtxId | The id of the vertex. |
Definition at line 1174 of file WTriangleMesh.cpp.
References m_mainCurvaturePrincipalDirection.
osg::Vec3 WTriangleMesh::getCurvatureSecondaryPrincipalDirection | ( | std::size_t | vtxId | ) | const |
Retreive the 3d principal direction of curvature for the minimum normal curvature of a vertex.
vtxId | The id of the vertex. |
Definition at line 1179 of file WTriangleMesh.cpp.
References m_secondaryCurvaturePrincipalDirection.
const std::string WTriangleMesh::getDescription | ( | ) | const [inline, virtual] |
Gets the description for this prototype.
Implements WPrototyped.
Definition at line 859 of file WTriangleMesh.h.
double WTriangleMesh::getMainCurvature | ( | std::size_t | vtxId | ) | const |
Retreive the main (maximum) curvature of a vertex.
vtxId | The id of the vertex. |
Definition at line 1154 of file WTriangleMesh.cpp.
References m_mainNormalCurvature.
boost::shared_ptr< std::vector< float > > const & WTriangleMesh::getMainCurvatures | ( | ) | const |
Get the vector of main curvature values.
Definition at line 1164 of file WTriangleMesh.cpp.
References m_mainNormalCurvature.
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::getMainPrincipalCurvatureDirectionArray | ( | ) |
Retreive the array of principal directions e.g.
for use as texture coords.
Definition at line 1189 of file WTriangleMesh.cpp.
References m_mainCurvaturePrincipalDirection.
const std::string WTriangleMesh::getName | ( | ) | const [inline, virtual] |
Gets the name of this prototype.
Implements WPrototyped.
Definition at line 854 of file WTriangleMesh.h.
size_t WTriangleMesh::getNeighbor | ( | const size_t | coVert1, |
const size_t | coVert2, | ||
const size_t | triangleNum | ||
) | [private] |
returns the triangle index of a triangle neighboring a given edge of a vertex
coVert1 | |
coVert2 | |
triangleNum |
Definition at line 362 of file WTriangleMesh.cpp.
References m_vertexIsInTriangle.
Referenced by calcNeighbors(), and loopCalcEdgeVert().
WVector3d WTriangleMesh::getNormal | ( | size_t | index | ) |
getter
index |
Definition at line 224 of file WTriangleMesh.cpp.
References m_countVerts, m_meshDirty, m_vertNormals, and recalcVertNormals().
boost::shared_ptr< WPrototyped > WTriangleMesh::getPrototype | ( | ) | [static] |
Returns a prototype instantiated with the true type of the deriving class.
Definition at line 49 of file WTriangleMesh.cpp.
References m_prototype, and WTriangleMesh().
double WTriangleMesh::getSecondaryCurvature | ( | std::size_t | vtxId | ) | const |
Retreive the secondary (minimum) curvature of a vertex.
vtxId | The id of the vertex. |
Definition at line 1159 of file WTriangleMesh.cpp.
References m_secondaryNormalCurvature.
boost::shared_ptr< std::vector< float > > const & WTriangleMesh::getSecondaryCurvatures | ( | ) | const |
Get the vector of secondary curvature values.
Definition at line 1169 of file WTriangleMesh.cpp.
References m_secondaryNormalCurvature.
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::getSecondaryPrincipalCurvatureDirectionArray | ( | ) |
Retreive the array of principal directions e.g.
for use as texture coords.
Definition at line 1194 of file WTriangleMesh.cpp.
References m_secondaryCurvaturePrincipalDirection.
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::getTextureCoordinateArray | ( | ) |
Returns a reference pointer to the texture coordinate array.
Definition at line 173 of file WTriangleMesh.cpp.
References m_textureCoordinates.
osg::ref_ptr< const osg::Vec3Array > WTriangleMesh::getTextureCoordinateArray | ( | ) | const |
Returns a const reference pointer to the texture coordinate array.
Definition at line 178 of file WTriangleMesh.cpp.
References m_textureCoordinates.
osg::ref_ptr< osg::Vec4Array > WTriangleMesh::getTriangleColors | ( | ) | const |
Return triangle colors.
Definition at line 772 of file WTriangleMesh.cpp.
References m_triangleColors.
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::getTriangleNormalArray | ( | bool | forceRecalc = false | ) |
getter
forceRecalc |
Definition at line 192 of file WTriangleMesh.cpp.
References m_autoNormal, m_meshDirty, m_triangleNormals, and recalcVertNormals().
const std::vector< size_t > & WTriangleMesh::getTriangles | ( | ) | const |
Returns a const reference to the vertex ids of the triangles.
Definition at line 207 of file WTriangleMesh.cpp.
References m_triangles.
Referenced by tm_utils::componentDecomposition(), and tm_utils::operator<<().
osg::Vec3 WTriangleMesh::getTriVert | ( | size_t | triId, |
size_t | vertNum | ||
) | [inline] |
getter
triId | |
vertNum |
Definition at line 885 of file WTriangleMesh.h.
References m_countTriangles, m_triangles, and m_verts.
Referenced by calcTriangleNormal().
size_t WTriangleMesh::getTriVertId0 | ( | size_t | triId | ) | const [inline] |
returns the id of the first vertex of a triangle
triId | id of the triangle |
Definition at line 891 of file WTriangleMesh.h.
References m_countTriangles, and m_triangles.
Referenced by calcNeighbors(), loopCalcEdgeVert(), loopGetNextVertex(), loopGetThirdVert(), loopInsertCenterTriangle(), loopInsertCornerTriangles(), and updateVertsInTriangles().
size_t WTriangleMesh::getTriVertId1 | ( | size_t | triId | ) | const [inline] |
returns the id of the second vertex of a triangle
triId | id of the triangle |
Definition at line 897 of file WTriangleMesh.h.
References m_countTriangles, and m_triangles.
Referenced by calcNeighbors(), loopCalcEdgeVert(), loopGetNextVertex(), loopGetThirdVert(), loopInsertCenterTriangle(), loopInsertCornerTriangles(), loopSetTriangle(), and updateVertsInTriangles().
size_t WTriangleMesh::getTriVertId2 | ( | size_t | triId | ) | const [inline] |
return the id of the third vertex of a triangle
triId | id of the triangle |
Definition at line 903 of file WTriangleMesh.h.
References m_countTriangles, and m_triangles.
Referenced by calcNeighbors(), loopCalcEdgeVert(), loopGetNextVertex(), loopGetThirdVert(), loopInsertCenterTriangle(), loopInsertCornerTriangles(), loopSetTriangle(), and updateVertsInTriangles().
osg::Vec4 WTriangleMesh::getVertColor | ( | size_t | index | ) | const |
getter
index |
Definition at line 218 of file WTriangleMesh.cpp.
References m_countVerts, and m_vertColors.
osg::Vec3 WTriangleMesh::getVertex | ( | size_t | index | ) | const |
getter
index |
Definition at line 212 of file WTriangleMesh.cpp.
References m_countVerts, and m_verts.
Referenced by loopCalcNewPosition().
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::getVertexArray | ( | ) |
getter
Definition at line 163 of file WTriangleMesh.cpp.
References m_verts.
Referenced by tm_utils::componentDecomposition(), and tm_utils::operator<<().
osg::ref_ptr< const osg::Vec3Array > WTriangleMesh::getVertexArray | ( | ) | const |
Returns a const reference pointer to the vertex array.
Definition at line 168 of file WTriangleMesh.cpp.
References m_verts.
osg::ref_ptr< osg::Vec4Array > WTriangleMesh::getVertexColorArray | ( | ) |
getter
Definition at line 202 of file WTriangleMesh.cpp.
References m_vertColors.
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::getVertexNormalArray | ( | bool | forceRecalc = false | ) |
getter
forceRecalc |
Definition at line 183 of file WTriangleMesh.cpp.
References m_autoNormal, m_meshDirty, m_vertNormals, and recalcVertNormals().
size_t WTriangleMesh::loopCalcEdgeVert | ( | size_t | triId, |
size_t | edgeV1, | ||
size_t | edgeV2, | ||
size_t | V3 | ||
) | [private] |
calculates the vertex id for a given edge, inserts a new vertex of none exists yet
triId | the triangle id |
edgeV1 | |
edgeV2 | |
V3 |
Definition at line 465 of file WTriangleMesh.cpp.
References addVertex(), getNeighbor(), getTriVertId0(), getTriVertId1(), getTriVertId2(), loopGetThirdVert(), m_countVerts, and m_numTriFaces.
Referenced by loopInsertCenterTriangle().
osg::Vec3 WTriangleMesh::loopCalcNewPosition | ( | size_t | vertId | ) | [private] |
calculates the new position of a vertex depending on it's location in the grid and number of neighbors
vertId | the vertex id |
Definition at line 429 of file WTriangleMesh.cpp.
References getVertex(), loopGetAlpha(), loopGetNextVertex(), and m_vertexIsInTriangle.
Referenced by doLoopSubD().
void WTriangleMesh::loopEraseTriangleFromVertex | ( | size_t | triId, |
size_t | vertId | ||
) | [private] |
erases a triangle from the vertexe's list of triangles it is part of
triId | |
vertId |
Definition at line 549 of file WTriangleMesh.cpp.
References m_vertexIsInTriangle.
Referenced by loopSetTriangle().
double WTriangleMesh::loopGetAlpha | ( | int | n | ) | [private] |
loop helper function
n |
Definition at line 560 of file WTriangleMesh.cpp.
Referenced by loopCalcNewPosition().
size_t WTriangleMesh::loopGetNextVertex | ( | size_t | triNum, |
size_t | vertNum | ||
) | [private] |
returns the id of the next vertex int he triangle
triNum | id of the triangle |
vertNum | id of the vertex |
Definition at line 575 of file WTriangleMesh.cpp.
References getTriVertId0(), getTriVertId1(), and getTriVertId2().
Referenced by loopCalcNewPosition().
size_t WTriangleMesh::loopGetThirdVert | ( | size_t | coVert1, |
size_t | coVert2, | ||
size_t | triangleNum | ||
) | [private] |
returns the id of the third vertex of a triangle for two given vertexes
coVert1 | |
coVert2 | |
triangleNum |
Definition at line 588 of file WTriangleMesh.cpp.
References getTriVertId0(), getTriVertId1(), and getTriVertId2().
Referenced by loopCalcEdgeVert().
void WTriangleMesh::loopInsertCenterTriangle | ( | size_t | triId | ) | [private] |
inserts the center triangle in a given triangle,
triId | the triangle id |
Definition at line 453 of file WTriangleMesh.cpp.
References addTriangle(), getTriVertId0(), getTriVertId1(), getTriVertId2(), and loopCalcEdgeVert().
Referenced by doLoopSubD().
void WTriangleMesh::loopInsertCornerTriangles | ( | size_t | triId | ) | [private] |
inserts the 3 corner triangles in a given triangle
triId | the triangle id |
Definition at line 514 of file WTriangleMesh.cpp.
References addTriangle(), getTriVertId0(), getTriVertId1(), getTriVertId2(), loopSetTriangle(), and m_numTriFaces.
Referenced by doLoopSubD().
void WTriangleMesh::loopSetTriangle | ( | size_t | triId, |
size_t | vertId1, | ||
size_t | vertId2, | ||
size_t | vertId3 | ||
) | [private] |
changes the vertex ids of a triangle
triId | |
vertId1 | |
vertId2 | |
vertId3 |
Definition at line 536 of file WTriangleMesh.cpp.
References getTriVertId1(), getTriVertId2(), loopEraseTriangleFromVertex(), m_vertexIsInTriangle, setTriVert0(), setTriVert1(), and setTriVert2().
Referenced by loopInsertCornerTriangles().
bool WTriangleMesh::operator== | ( | const WTriangleMesh & | rhs | ) | const [inline] |
Checks if two meshes are exactly the same.
Same number of triangles, and points, and indices as well as same ordering. Keep in mind different ordering might result in the same structure but is considered different here.
rhs | The other mesh to compare with |
Definition at line 810 of file WTriangleMesh.h.
References m_triangles, and m_verts.
void WTriangleMesh::performFeaturePreservingSmoothing | ( | float | sigmaDistance, |
float | sigmaInfluence | ||
) |
Implements the feature-preserving mesh smoothing algorithm of Jones et al.
:
"Non-Iterative, Feature-Preserving Mesh Smoothing", Jones, T.R., Durand, F., Desbrun, M., ACM Trans. Graph. (22), 2003, 943-949
sigmaDistance | The standard deviation for the spatial weight. |
sigmaInfluence | The standard deviation for the influence weight. |
Definition at line 777 of file WTriangleMesh.cpp.
References calcNeighbors(), performFeaturePreservingSmoothingMollificationPass(), performFeaturePreservingSmoothingVertexPass(), and updateVertsInTriangles().
void WTriangleMesh::performFeaturePreservingSmoothingMollificationPass | ( | float | sigmaDistance, |
float | sigmaInfluence | ||
) | [private] |
Performs the first pass of the feature-preserving smoothing, only changing the triangle normals.
sigmaDistance | The standard deviation of the spatial weights. |
sigmaInfluence | The standard deviation of the influence weights. |
Definition at line 791 of file WTriangleMesh.cpp.
References estimateSmoothedVertexPosition(), m_triangleNormals, m_triangles, and m_verts.
Referenced by performFeaturePreservingSmoothing().
void WTriangleMesh::performFeaturePreservingSmoothingVertexPass | ( | float | sigmaDistance, |
float | sigmaInfluence | ||
) | [private] |
Performs the second pass of the feature-preserving smoothing.
This calculates new smoothed vertex positions and updates the normals accordingly. Triangle information and colors stay the same.
sigmaDistance | The standard deviation of the spatial weights. |
sigmaInfluence | The standard deviation of the influence weights. |
Definition at line 813 of file WTriangleMesh.cpp.
References estimateSmoothedVertexPosition(), m_verts, and recalcVertNormals().
Referenced by performFeaturePreservingSmoothing().
void WTriangleMesh::recalcVertNormals | ( | ) |
recalculates the vertex normals
Definition at line 260 of file WTriangleMesh.cpp.
References calcTriangleNormal(), m_countTriangles, m_countVerts, m_meshDirty, m_vertexIsInTriangle, and updateVertsInTriangles().
Referenced by getNormal(), getTriangleNormalArray(), getVertexNormalArray(), and performFeaturePreservingSmoothingVertexPass().
void WTriangleMesh::removeTriangle | ( | size_t | index | ) | [private] |
removes a triangle from the mesh
index | the triangle to remove |
Definition at line 253 of file WTriangleMesh.cpp.
References m_countTriangles, m_meshDirty, and m_triangles.
void WTriangleMesh::removeVertex | ( | size_t | index | ) | [private] |
removes a vertex from the vertex array, if any triangles still index that vertex they will be removed if forceRemoveTriangle is true
index | the index of the vertex to remove |
Definition at line 234 of file WTriangleMesh.cpp.
References m_countTriangles, m_countVerts, m_meshDirty, m_triangles, and m_vertexIsInTriangle.
void WTriangleMesh::rescaleVertexColors | ( | ) |
Rescale the vertex colors so that the maximum of all r, g and b values is 1.
Definition at line 639 of file WTriangleMesh.cpp.
References m_vertColors.
void WTriangleMesh::setAutoRecalcNormals | ( | bool | autoRecalc = true | ) |
Set this to true to force automatic normal calculation.
Set it to false if you specify your own normals.
autoRecalc | auto normal calculation. |
Definition at line 100 of file WTriangleMesh.cpp.
References m_autoNormal.
void WTriangleMesh::setTextureCoord | ( | std::size_t | index, |
osg::Vec3 | texCoord | ||
) |
Set a texture coordinate.
index | The id of the vertex to set the texture coord of. |
texCoord | The texture coordinate to use. |
Definition at line 1184 of file WTriangleMesh.cpp.
References m_textureCoordinates.
void WTriangleMesh::setTriangleColor | ( | size_t | index, |
osg::Vec4 | color | ||
) |
sets the color for a given triangle
index | |
color |
Definition at line 157 of file WTriangleMesh.cpp.
References m_countTriangles.
void WTriangleMesh::setTriVert0 | ( | size_t | triId, |
size_t | vertId | ||
) | [inline, private] |
higher level access function to the triangle vector, sets the first vertex of a triangle to a given vertex id
triId | the id of the triangle to modify |
vertId | new id of the first vertex |
Definition at line 864 of file WTriangleMesh.h.
References m_countTriangles, m_countVerts, and m_triangles.
Referenced by loopSetTriangle().
void WTriangleMesh::setTriVert1 | ( | size_t | triId, |
size_t | vertId | ||
) | [inline, private] |
higher level access function to the triangle vector, sets the second vertex of a triangle to a given vertex id
triId | the id of the triangle to modify |
vertId | new id of the second vertex |
Definition at line 871 of file WTriangleMesh.h.
References m_countTriangles, m_countVerts, and m_triangles.
Referenced by loopSetTriangle().
void WTriangleMesh::setTriVert2 | ( | size_t | triId, |
size_t | vertId | ||
) | [inline, private] |
higher level access function to the triangle vector, sets the third vertex of a triangle to a given vertex id
triId | the id of the triangle to modify |
vertId | new id of the third vertex |
Definition at line 878 of file WTriangleMesh.h.
References m_countTriangles, m_countVerts, and m_triangles.
Referenced by loopSetTriangle().
void WTriangleMesh::setVertex | ( | size_t | index, |
osg::Vec3 | vert | ||
) | [inline] |
sets a vertex to a new position
index | |
vert |
Definition at line 909 of file WTriangleMesh.h.
void WTriangleMesh::setVertexColor | ( | size_t | index, |
osg::Vec4 | color | ||
) |
sets the color for a given vertex
index | |
color |
Definition at line 151 of file WTriangleMesh.cpp.
References m_countVerts.
Referenced by addMesh().
void WTriangleMesh::setVertexNormal | ( | size_t | index, |
osg::Vec3 | normal | ||
) |
sets the normal for a given vertex
index | |
normal |
Definition at line 135 of file WTriangleMesh.cpp.
References m_countVerts.
Referenced by setVertexNormal().
void WTriangleMesh::setVertexNormal | ( | size_t | index, |
float | x, | ||
float | y, | ||
float | z | ||
) |
sets the normal for a given vertex
index | |
x | x coordinate |
y | y coordinate |
z | z coordinate |
Definition at line 146 of file WTriangleMesh.cpp.
References setVertexNormal().
void WTriangleMesh::setVertexNormal | ( | size_t | index, |
WPosition | normal | ||
) |
sets the normal for a given vertex
index | |
normal |
Definition at line 141 of file WTriangleMesh.cpp.
References setVertexNormal().
void WTriangleMesh::translateMesh | ( | float | xOff, |
float | yOff, | ||
float | zOff | ||
) |
moves the entire mesh to a new postion
xOff | |
yOff | |
zOff |
Definition at line 622 of file WTriangleMesh.cpp.
size_t WTriangleMesh::triangleSize | ( | ) | const |
getter
Definition at line 339 of file WTriangleMesh.cpp.
References m_countTriangles.
Referenced by tm_utils::componentDecomposition(), and tm_utils::operator<<().
void WTriangleMesh::updateVertsInTriangles | ( | ) | [private] |
updates the list for which vertexes appear in which triangle
Definition at line 288 of file WTriangleMesh.cpp.
References getTriVertId0(), getTriVertId1(), getTriVertId2(), m_countTriangles, and m_vertexIsInTriangle.
Referenced by doLoopSubD(), estimateCurvature(), performFeaturePreservingSmoothing(), and recalcVertNormals().
size_t WTriangleMesh::vertSize | ( | ) | const |
getter
Definition at line 334 of file WTriangleMesh.cpp.
References m_countVerts.
Referenced by tm_utils::componentDecomposition(), and tm_utils::operator<<().
void WTriangleMesh::zoomMesh | ( | float | zoom | ) |
multiplies the vertex vectors of the mesh with a given number
zoom |
Definition at line 631 of file WTriangleMesh.cpp.
bool WTriangleMesh::m_autoNormal [private] |
flag denoting whether normals should be calculated automatically.
Definition at line 742 of file WTriangleMesh.h.
Referenced by getTriangleNormalArray(), getVertexNormalArray(), and setAutoRecalcNormals().
size_t WTriangleMesh::m_countTriangles [private] |
number of triangles in the mesh
Definition at line 738 of file WTriangleMesh.h.
Referenced by addTriangle(), calcNeighbors(), doLoopSubD(), getTriVert(), getTriVertId0(), getTriVertId1(), getTriVertId2(), recalcVertNormals(), removeTriangle(), removeVertex(), setTriangleColor(), setTriVert0(), setTriVert1(), setTriVert2(), triangleSize(), and updateVertsInTriangles().
size_t WTriangleMesh::m_countVerts [private] |
number of vertexes in the mesh
Definition at line 736 of file WTriangleMesh.h.
Referenced by addMesh(), addTextureCoordinate(), addTriangle(), addVertex(), doLoopSubD(), getNormal(), getVertColor(), getVertex(), loopCalcEdgeVert(), recalcVertNormals(), removeVertex(), setTriVert0(), setTriVert1(), setTriVert2(), setVertexColor(), setVertexNormal(), and vertSize().
bool WTriangleMesh::m_curvatureCalculated [private] |
Indicates whether the curvature and its principal directions have been calculated.
Definition at line 747 of file WTriangleMesh.h.
Referenced by estimateCurvature().
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::m_mainCurvaturePrincipalDirection [private] |
Stores the first principal curvature direction for each vertex.
Definition at line 775 of file WTriangleMesh.h.
Referenced by estimateCurvature(), getCurvatureMainPrincipalDirection(), and getMainPrincipalCurvatureDirectionArray().
boost::shared_ptr< std::vector< float > > WTriangleMesh::m_mainNormalCurvature [private] |
Stores the maximum normal curvature (for the first principal direction) for each vertex.
Definition at line 769 of file WTriangleMesh.h.
Referenced by estimateCurvature(), getMainCurvature(), and getMainCurvatures().
bool WTriangleMesh::m_meshDirty [private] |
flag indicating a change took place which requires a recalculation of components
Definition at line 740 of file WTriangleMesh.h.
Referenced by addMesh(), doLoopSubD(), getNormal(), getTriangleNormalArray(), getVertexNormalArray(), recalcVertNormals(), removeTriangle(), and removeVertex().
bool WTriangleMesh::m_neighborsCalculated [private] |
flag indicating whether the neighbor information has been calculated yet
Definition at line 744 of file WTriangleMesh.h.
Referenced by calcNeighbors().
size_t WTriangleMesh::m_numTriFaces [private] |
stores the number of triangles before the loop subdivion is run, needed by the loop algorithm
Definition at line 782 of file WTriangleMesh.h.
Referenced by doLoopSubD(), loopCalcEdgeVert(), and loopInsertCornerTriangles().
size_t WTriangleMesh::m_numTriVerts [private] |
stores the number of vertexes before the loop subdivion is run, needed by the loop algorithm
Definition at line 780 of file WTriangleMesh.h.
Referenced by doLoopSubD().
boost::shared_ptr< WPrototyped > WTriangleMesh::m_prototype = boost::shared_ptr< WPrototyped >() [static, protected] |
The prototype as singleton.
Definition at line 501 of file WTriangleMesh.h.
Referenced by getPrototype().
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::m_secondaryCurvaturePrincipalDirection [private] |
Stores the second principal curvature direction for each vertex.
Definition at line 778 of file WTriangleMesh.h.
Referenced by estimateCurvature(), getCurvatureSecondaryPrincipalDirection(), and getSecondaryPrincipalCurvatureDirectionArray().
boost::shared_ptr< std::vector< float > > WTriangleMesh::m_secondaryNormalCurvature [private] |
Stores the minimum normal curvature (for the second principal direction) for each vertex.
Definition at line 772 of file WTriangleMesh.h.
Referenced by estimateCurvature(), getSecondaryCurvature(), and getSecondaryCurvatures().
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::m_textureCoordinates [private] |
array containing the texture coordinates
Definition at line 751 of file WTriangleMesh.h.
Referenced by getTextureCoordinateArray(), setTextureCoord(), and WTriangleMesh().
osg::ref_ptr< osg::Vec4Array > WTriangleMesh::m_triangleColors [private] |
array containing the triangle colors
Definition at line 761 of file WTriangleMesh.h.
Referenced by doLoopSubD(), getTriangleColors(), and WTriangleMesh().
std::vector< std::vector< size_t > > WTriangleMesh::m_triangleNeighbors [private] |
edge neighbors for each triangle
Definition at line 766 of file WTriangleMesh.h.
Referenced by calcNeighbors(), and estimateSmoothedVertexPosition().
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::m_triangleNormals [private] |
array containing the triangle normals
Definition at line 759 of file WTriangleMesh.h.
Referenced by estimateCurvature(), estimateSmoothedVertexPosition(), getTriangleNormalArray(), performFeaturePreservingSmoothingMollificationPass(), and WTriangleMesh().
std::vector< size_t > WTriangleMesh::m_triangles [private] |
array containing the triangles
Definition at line 757 of file WTriangleMesh.h.
Referenced by addTriangle(), calcTriangleArea(), calcTriangleCenter(), doLoopSubD(), estimateCurvature(), getTriangles(), getTriVert(), getTriVertId0(), getTriVertId1(), getTriVertId2(), operator==(), performFeaturePreservingSmoothingMollificationPass(), removeTriangle(), removeVertex(), setTriVert0(), setTriVert1(), setTriVert2(), WTriangleMeshTest::testEqualityOperator(), and WTriangleMesh().
osg::ref_ptr< osg::Vec4Array > WTriangleMesh::m_vertColors [private] |
array containing vertex colors
Definition at line 755 of file WTriangleMesh.h.
Referenced by doLoopSubD(), getVertColor(), getVertexColorArray(), rescaleVertexColors(), and WTriangleMesh().
std::vector< std::vector< size_t > > WTriangleMesh::m_vertexIsInTriangle [private] |
for each vertex, list of triangles it is part of
Definition at line 764 of file WTriangleMesh.h.
Referenced by doLoopSubD(), estimateCurvature(), estimateSmoothedVertexPosition(), getNeighbor(), loopCalcNewPosition(), loopEraseTriangleFromVertex(), loopSetTriangle(), recalcVertNormals(), removeVertex(), and updateVertsInTriangles().
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::m_vertNormals [private] |
array containing the vertex normals
Definition at line 753 of file WTriangleMesh.h.
Referenced by doLoopSubD(), getNormal(), getVertexNormalArray(), and WTriangleMesh().
osg::ref_ptr< osg::Vec3Array > WTriangleMesh::m_verts [private] |
array containing the vertices
Definition at line 749 of file WTriangleMesh.h.
Referenced by calcTriangleArea(), calcTriangleCenter(), doLoopSubD(), estimateCurvature(), estimateSmoothedVertexPosition(), getTriVert(), getVertex(), getVertexArray(), operator==(), performFeaturePreservingSmoothingMollificationPass(), performFeaturePreservingSmoothingVertexPass(), and WTriangleMesh().