Ignore:
Timestamp:
07/10/06 01:57:41 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1020 r1106  
    99#include "Polygon3.h" 
    1010#include "VssRay.h" 
    11 //#include "VspOspTree.h" 
     11#include "VspOspTree.h" 
    1212#include "VssTree.h" 
    1313#include "VspBspTree.h" 
     
    538538} 
    539539 
    540 #if 0 
    541 bool X3dExporter::ExportVspOspTree(const VspOspTree &tree, const int maxPvs) 
    542 { 
    543         stack<VspKdNode *> tStack; 
    544  
    545         tStack.push(tree.GetRoot()); 
    546  
    547         //Mesh *mesh = new Mesh; 
    548    
    549         if (maxPvs > 0) 
    550                 mUseForcedMaterial = true; 
    551  
    552         while (!tStack.empty())  
    553         { 
    554                 VspKdNode *node = tStack.top(); 
    555      
    556                 tStack.pop(); 
    557  
    558                 if (node->IsLeaf()) 
    559                 { 
    560                         AxisAlignedBox3 box = tree.GetBBox(node); 
    561  
    562                         Mesh *mesh = new Mesh; 
    563  
    564                         // add 6 vertices of the box 
    565                         int index = (int)mesh->mVertices.size(); 
    566  
    567                         for (int i=0; i < 8; ++ i)  
    568                         { 
    569                                 Vector3 v; 
    570                                 box.GetVertex(i, v); 
    571                                 mesh->mVertices.push_back(v); 
    572                         } 
    573  
    574                         mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 
    575                         mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 
    576                         mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 
    577  
    578                         mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 
    579                         mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 
    580                         mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 
    581  
    582                         if (maxPvs > 0) 
    583                         { 
    584                                 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node); 
    585  
    586                                 mForcedMaterial.mDiffuseColor.b = 1.0f; 
    587                                  
    588                                 leaf->UpdatePvsSize(); 
    589                          
    590                                 const float importance = (float)leaf->GetPvsSize() / (float)maxPvs; 
    591                                 mForcedMaterial.mDiffuseColor.r = importance; 
    592                                 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 
    593                         } 
    594  
    595                         ExportMesh(mesh); 
    596                         DEL_PTR(mesh); 
    597                 } 
    598                 else   
    599                 { 
    600                         VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node); 
    601                         tStack.push(interior->GetFront()); 
    602                         tStack.push(interior->GetBack()); 
    603                 } 
    604         } 
    605    
    606         //ExportMesh(mesh); 
    607         //DEL_PTR(mesh); 
    608  
    609         return true; 
    610 } 
    611 #endif 
    612540 
    613541bool X3dExporter::ExportKdTree(const KdTree &tree) 
     
    13091237} 
    13101238 
    1311 } 
     1239 
     1240bool X3dExporter::ExportOspTree(const OspTree &ospTree) 
     1241{ 
     1242        vector<KdLeaf *> leaves; 
     1243        ospTree.CollectLeaves(leaves); 
     1244 
     1245        vector<KdLeaf *>::const_iterator it, it_end = leaves.end(); 
     1246 
     1247        for (it = leaves.begin(); it != it_end; ++ it) 
     1248        { 
     1249                ExportBox(ospTree.GetBBox(*it)); 
     1250        } 
     1251 
     1252        return true; 
     1253} 
     1254 
     1255 
     1256} 
Note: See TracChangeset for help on using the changeset viewer.