52#ifndef _SO_NORMAL_GENERATOR_
53#define _SO_NORMAL_GENERATOR_
59#include <Inventor/STL/vector>
60#include <Inventor/STL/utility>
111 const int approxNumVertices=16,
112 const int approxNumFaces=6,
113 const float creaseAngle =0.0f,
170 void triangle(
const int32_t index1,
const int32_t index2,
const int32_t index3);
193 {
return vertNormals; }
200 {
return vertNormals[i]; }
219 {
return m_numNormalCrack; };
227 void setNormalBuffer(int32_t numNormals,
const SbVec3f *normals);
232 bool isIndexedMode()
const
233 {
return m_isIndexedMode; }
236 void endPolygon_( int32_t numVertices );
238 inline void addPolygonNormal(
const SbVec3f &vec1,
const SbVec3f &vec2 )
239 { polygonSum += (vec1).cross(vec2); }
249 SbVec3f *points, *faceNormals, *vertNormals;
250 int32_t *pointIndexes;
251 int32_t numPoints, numVertNormals;
252 int32_t maxPoints, maxFaceNormals, maxVertNormals;
258 float m_toleranceFactor;
260 int32_t m_approxNumVertices;
261 int32_t m_approxNumFaces;
263 int32_t m_pointIndex;
266 int32_t beginPolygonIndex;
270 int m_numNormalCrack;
271 bool m_isIndexedMode;
272 int32_t *m_userConnectivity;
275 void growPointsArray(
const int requestedMaxPoints);
277 void growNormalFaceArray(
const int requestedNormalFaceArraySize);
280 inline bool needToComputeConnectivity( )
const
281 {
return (( m_creaseAngle != 0.0f ) && ( m_userConnectivity == NULL )); }
286 int32_t* computeConnectivity( std::vector < std::pair< int, size_t > > &indicesClasses );
289 void evalConnectedVerticesIndicesClasses( int32_t* indirect,
size_t numPoints,
290 std::vector < std::pair< int, size_t > > &indicesClasses )
const;
295 static SbBool s_useOldTolerance;
~SoNormalGenerator()
Surface normal generator.
void setNormal(int32_t index, const SbVec3f &newNormal)
Add or modify a normal vector.
void generate()
Calculate the normals once all vertices have been sent.
const SbVec3f & getNormal(int32_t i) const
Returns the i'th normal in the array.
int getNumNormals() const
Returns number of normals generated.
void beginPolygon()
Send a polygon's worth of vertices.
void triangle(const SbVec3f &p1, const SbVec3f &p2, const SbVec3f &p3)
Send a triangle.
int32_t numNormalCrack() const
Returns the number of connected points that have different normals.
const SbVec3f * getNormals() const
Returns a pointer to the array of normals.
void setNumNormals(int newNum)
Truncate the array so there are only the given number of normals.
void setupIndexedConnectivity(const int32_t *connectivityArray)
Specifies a per-vertex connectivity array.
void polygonVertex(const SbVec3f &point)
void setupIndexedVertexArray(const SbVec3f *pointArray)
Specifies a pointer to the array of points that will be used in subsequent calls to polygonVertex(ind...
void setupApproxShapeSize(const int32_t approxNumVertices, const int32_t approxNumFaces)
Resets the approximative number of vertices and faces that we have to generate normals for.
static float getDefault()
Returns the default tolerance factor value.