Ignore:
Timestamp:
02/19/07 02:51:22 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp

    r2072 r2124  
    77#include "Triangle3.h" 
    88#include "Polygon3.h" 
     9#include "TraversalTree.h" 
    910 
    1011 
     
    305306 
    306307 
    307  
    308 } 
     308bool Exporter::ExportTraversalTree(const TraversalTree &tree,  
     309                                                                          const bool exportGeometry) 
     310{ 
     311        stack<TraversalNode *> tStack; 
     312 
     313        tStack.push(tree.GetRoot()); 
     314 
     315        Mesh *mesh = new Mesh; 
     316 
     317        SetWireframe(); 
     318 
     319        while (!tStack.empty())  
     320        { 
     321                TraversalNode *node = tStack.top(); 
     322                tStack.pop(); 
     323                const AxisAlignedBox3 box = tree.GetBox(node); 
     324 
     325                // add 6 vertices of the box 
     326                const int index = (int)mesh->mVertices.size(); 
     327 
     328                SetForcedMaterial(RandomMaterial()); 
     329 
     330                for (int i=0; i < 8; i++)  
     331                { 
     332                        Vector3 v; 
     333                        box.GetVertex(i, v); 
     334                        mesh->mVertices.push_back(v); 
     335                } 
     336 
     337                mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 
     338                mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 
     339                mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 
     340 
     341                mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 
     342                mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 
     343                mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 
     344 
     345                if (!node->IsLeaf())  
     346                { 
     347                        TraversalInterior *interior = static_cast<TraversalInterior *>(node); 
     348 
     349                        tStack.push(interior->mFront); 
     350                        tStack.push(interior->mBack); 
     351                } 
     352                else if (exportGeometry) 
     353                { 
     354                        SetFilled(); 
     355                        SetForcedMaterial(RandomMaterial()); 
     356 
     357                        ExportViewCells(static_cast<TraversalLeaf *>(node)->mViewCells);         
     358                        SetWireframe(); 
     359                } 
     360        } 
     361 
     362        ExportMesh(mesh); 
     363        delete mesh; 
     364 
     365        return true; 
     366} 
     367 
     368 
     369} 
Note: See TracChangeset for help on using the changeset viewer.