CMS 3D CMS Logo

IgSurfaceOperation.cc File Reference

#include "Iguana/Inventor/interface/IgSurfaceOperation.h"
#include "Iguana/Inventor/interface/IgBSPTriangle.h"
#include "Iguana/Inventor/interface/IgBSPTree.h"
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoVertexProperty.h>
#include <Inventor/nodes/SoShape.h>
#include <Inventor/nodes/SoNode.h>
#include <Inventor/SbLinear.h>
#include <cassert>
#include <map>

Go to the source code of this file.

Classes

struct  SbVec3fPtrComparison

Functions

static SoIndexedFaceSet * listToNode (IgBSPTriangle::List *list)


Function Documentation

static SoIndexedFaceSet* listToNode ( IgBSPTriangle::List list  )  [static]

Definition at line 42 of file IgSurfaceOperation.cc.

References end, i, j, and k.

Referenced by IgSurfaceOperation::apply().

00043 {
00044     SoIndexedFaceSet *indexedFaceSet = new SoIndexedFaceSet;
00045     SoVertexProperty *vertexProperty = new SoVertexProperty;
00046             
00047     int lastIndex = 0;
00048     int j = 0;
00049     
00050     std::map <const SbVec3f, int, SbVec3fPtrComparison> indicesMap;
00051     
00052     int vertexIndices[4] = {0, 0, 0, -1};
00053     IgBSPTriangle::List::iterator end (list->end ());
00054     for (IgBSPTriangle::List::iterator i = list->begin ();
00055         i != end;
00056         i++)
00057     {
00058         // Updates the vertexMap with the vertices from the new
00059         // triangle.
00060         for (int k = 0; k < 3; k++)
00061         {
00062             const SbVec3f &vertex = (*i)->v (k);
00063             if (indicesMap.find (vertex) == indicesMap.end ())
00064             {
00065                 vertexProperty->vertex.setValues (lastIndex, 1, &vertex);
00066                 indicesMap[vertex] = lastIndex++;
00067             }
00068             vertexIndices[k] = indicesMap[vertex];          
00069         }
00070     
00071         indexedFaceSet->coordIndex.setValues (j, 4, vertexIndices);
00072         j += 4;    
00073     }
00074 
00075     //    std::cerr << "Num of vertexes: " << lastIndex
00076     //        << "Num of faces: " << j/4 << std::endl;
00077     
00078     indexedFaceSet->vertexProperty = vertexProperty;
00079             
00080     return indexedFaceSet;
00081 }


Generated on Tue Jun 9 17:54:15 2009 for CMSSW by  doxygen 1.5.4