Changeset 1233


Ignore:
Timestamp:
08/20/06 22:48:01 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
29 edited

Legend:

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

    r1181 r1233  
    11#include "X3dExporter.h" 
    22#include "VrmlExporter.h" 
    3 #include "VspOspTree.h" 
     3#include "OspTree.h" 
    44#include "KdTree.h" 
    55#include "KdIntersectable.h" 
     
    7676void Exporter::ExportKdIntersectable(const KdIntersectable &kdObj) 
    7777{ 
    78         KdNode *node = kdObj.GetNode(); 
     78        KdNode *node = kdObj.GetItem(); 
    7979         
    8080        Intersectable::NewMail(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h

    r1106 r1233  
    226226} 
    227227 
    228  
    229228} 
    230229 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1193 r1233  
    1111struct VssRayContainer; 
    1212class KdLeaf; 
     13class BvhLeaf; 
     14 
    1315 
    1416class Intersectable { 
     
    3234  ViewCellPvs mViewCellPvs; 
    3335 
    34   /// kd leaves that this intersectable belongs to 
    35   //set<KdLeaf *> mKdLeaves; 
     36  /// pointer to the container bvh leaf 
     37  BvhLeaf *mBvhLeaf; 
     38 
    3639  VssRayContainer mVssRays; 
    3740 
    38   /// # of object references 
     41  /// # of references to this instance 
    3942  int mReferences; 
    4043 
     
    4447                 VIEW_CELL,  
    4548                 OGRE_MESH_INSTANCE, 
    46                  KD_INTERSECTABLE 
     49                 KD_INTERSECTABLE, 
     50                 BVH_INTERSECTABLE 
    4751                }; 
    4852   
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.cpp

    r1199 r1233  
    55 
    66 
    7 KdIntersectable::KdIntersectable(KdNode *node): 
    8 Intersectable(), mNode(node) 
    9 { 
    10 } 
    117 
    12  
    13 void KdIntersectable::SetNode(KdNode *node) 
    14 { 
    15         mNode = node; 
    16 } 
    17  
    18  
    19 KdNode *KdIntersectable::GetNode() const 
    20 {  
    21         return mNode;  
    22 } 
    23          
    24  
    25 AxisAlignedBox3 KdIntersectable::GetBox() const 
    26 {       // TODO matt 
    27         return AxisAlignedBox3(); 
    28 } 
    29  
    30  
    31 int KdIntersectable::CastRay(Ray &ray) 
    32 {       // TODO matt 
    33         return 0; 
    34 } 
    35          
    36  
    37 bool KdIntersectable::IsConvex() const 
    38 { 
    39         return true; 
    40 } 
    41  
    42  
    43 bool KdIntersectable::IsWatertight() const 
    44 { 
    45         return true; 
    46 } 
    47  
    48  
    49 float KdIntersectable::IntersectionComplexity() 
    50 { 
    51         return 1.0f; 
    52 } 
    53  
    54  
    55 int KdIntersectable::NumberOfFaces() const 
    56 { 
    57         return 0; 
    58 } 
    59  
    60  
    61 int KdIntersectable::Type() const 
    62 { 
    63         return Intersectable::KD_INTERSECTABLE; 
    64 } 
    65  
    66  
    67 int KdIntersectable::GetRandomSurfacePoint(Vector3 &point, 
    68                                                                                    Vector3 &normal) 
    69 { 
    70         return 0; 
    71 } 
    72  
    73  
    74 int KdIntersectable::GetRandomVisibleSurfacePoint(Vector3 &point, 
    75                                                                                                   Vector3 &normal, 
    76                                                                                                   const Vector3 &viewpoint, 
    77                                                                                                   const int maxTries) 
    78 { 
    79         return 0; 
    80 } 
    81    
    82  
    83 ostream &KdIntersectable::Describe(ostream &s) 
    84 { 
    85         s << mNode; 
    86         return s; 
    87 } 
    888         
    899} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h

    r1139 r1233  
    1010struct VssRayContainer; 
    1111class KdNode; 
     12class BvhNode; 
    1213 
    1314/** 
    14         Wrapper for Kd nodes for use in a PVS. 
     15        Wrapper used for creating a PVS compliant intersectable. 
    1516*/ 
    16 class KdIntersectable: public Intersectable 
     17template<typename T> 
     18class IntersectableWrapper: public Intersectable 
    1719{ 
    1820public: 
    19         KdIntersectable(KdNode *node); 
     21        IntersectableWrapper(T *item); 
    2022 
    21         /** Returns 'mesh' associated with this instance.  
     23        /** Returns node associated with this instance.  
    2224        */ 
    23         KdNode *GetNode() const; 
     25        T *GetItem() const; 
    2426 
    2527        /** See get. 
    2628        */ 
    27         void SetNode(KdNode *node); 
    28  
     29        void SetItem(T *item); 
    2930 
    3031        //-- inherited functions from Intersectable 
     
    3940   
    4041        int NumberOfFaces() const; 
    41         int Type() const; 
     42        //int Type() const; 
    4243 
    4344        int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,  
     
    5253         
    5354 
    54         /** Pointer to kd leaf object that was hit during ray casting. 
    55         */ 
    56         Intersectable *mHitObject; 
    57  
    5855protected: 
    5956         
    60         KdNode *mNode; 
     57        T *mItem; 
    6158}; 
    6259 
     60template<typename T> 
     61IntersectableWrapper<T>::IntersectableWrapper(T *item): 
     62Intersectable(), mItem(item) 
     63{ 
     64} 
     65 
     66template<typename T> 
     67void IntersectableWrapper<T>::SetItem(T *item) 
     68{ 
     69        mItem = item; 
     70} 
     71 
     72template<typename T> 
     73T *IntersectableWrapper<T>::GetItem() const 
     74{  
     75        return mItem;  
     76} 
     77         
     78template<typename T> 
     79AxisAlignedBox3 IntersectableWrapper<T>::GetBox() const 
     80{       // TODO matt 
     81        return AxisAlignedBox3(); 
     82} 
     83 
     84template<typename T> 
     85int IntersectableWrapper<T>::CastRay(Ray &ray) 
     86{       // TODO matt 
     87        return 0; 
     88} 
     89         
     90template<typename T> 
     91bool IntersectableWrapper<T>::IsConvex() const 
     92{ 
     93        return true; 
     94} 
     95 
     96template<typename T> 
     97bool IntersectableWrapper<T>::IsWatertight() const 
     98{ 
     99        return true; 
     100} 
     101 
     102template<typename T> 
     103float IntersectableWrapper<T>::IntersectionComplexity() 
     104{ 
     105        return 1.0f; 
     106} 
     107 
     108template<typename T> 
     109int IntersectableWrapper<T>::NumberOfFaces() const 
     110{ 
     111        return 0; 
     112} 
     113 
     114template<typename T> 
     115int IntersectableWrapper<T>::GetRandomSurfacePoint(Vector3 &point, 
     116                                                                                                Vector3 &normal) 
     117{ 
     118        return 0; 
     119} 
     120 
     121template<typename T> 
     122int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point, 
     123                                                                                                           Vector3 &normal, 
     124                                                                                                           const Vector3 &viewpoint, 
     125                                                                                                           const int maxTries) 
     126{ 
     127        return 0; 
     128} 
     129   
     130template<typename T> 
     131ostream &IntersectableWrapper<T>::Describe(ostream &s) 
     132{ 
     133        s << mItem; 
     134        return s; 
     135} 
     136 
     137 
     138class KdIntersectable: public IntersectableWrapper<KdNode> 
     139{ 
     140public: 
     141        KdIntersectable(KdNode *item): 
     142        IntersectableWrapper<KdNode>(item) {} 
     143 
     144        int Type() const 
     145        { 
     146                return Intersectable::KD_INTERSECTABLE; 
     147        } 
     148}; 
     149 
     150 
     151class BvhIntersectable: public IntersectableWrapper<BvhNode> 
     152{ 
     153public: 
     154        BvhIntersectable(BvhNode *item): 
     155        IntersectableWrapper<BvhNode>(item) {} 
     156 
     157        int Type() const 
     158        { 
     159                return Intersectable::BVH_INTERSECTABLE; 
     160        } 
     161}; 
    63162 
    64163} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r1201 r1233  
    435435 
    436436void 
    437 KdTree::SortSplitCandidates( 
     437KdTree::SortSubdivisionCandidates( 
    438438                            KdLeaf *node, 
    439439                            const int axis 
     
    485485{ 
    486486 
    487   SortSplitCandidates(node, axis); 
     487  SortSubdivisionCandidates(node, axis); 
    488488   
    489489  // go through the lists, count the number of objects left and right 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r1201 r1233  
    2020  class KdInterior; 
    2121  class Intersectable; 
    22   //class KdViewCell; 
    2322  class Beam; 
    2423 
     
    174173}; 
    175174   
    176 class SplitCandidate; 
     175class SubdivisionCandidate; 
    177176   
    178177/** Implementation of the kd-tree leaf node */ 
     
    213212 
    214213  /// pvs of view cells seeing this node. 
    215   SplitCandidate *mSplitCandidate; 
     214  SubdivisionCandidate *mSubdivisionCandidate; 
    216215 
    217216  /// pointer to view cell. 
     
    227226}; 
    228227 
    229    
    230228 
    231229/** KdTree for indexing scene entities - occluders/occludees/viewcells */ 
     
    528526 
    529527  void 
    530   SortSplitCandidates( 
     528  SortSubdivisionCandidates( 
    531529                      KdLeaf *node, 
    532530                      const int axis 
  • GTP/trunk/Lib/Vis/Preprocessing/src/MeshKdTree.cpp

    r1004 r1233  
    1919{ 
    2020  mRoot = new MeshKdLeaf; 
    21   mSplitCandidates = NULL; 
     21  mSubdivisionCandidates = NULL; 
    2222} 
    2323 
     
    177177 
    178178void 
    179 MeshKdTree::SortSplitCandidates( 
     179MeshKdTree::SortSubdivisionCandidates( 
    180180                            MeshKdLeaf *node, 
    181181                            const int axis 
    182182                            ) 
    183183{ 
    184   mSplitCandidates->clear(); 
     184  mSubdivisionCandidates->clear(); 
    185185   
    186186  int requestedSize = 2*(int)node->mFaces.size(); 
    187187  // creates a sorted split candidates array 
    188   if (mSplitCandidates->capacity() > 500000 && 
    189       requestedSize < (int)(mSplitCandidates->capacity()/10) ) { 
    190     delete mSplitCandidates; 
    191     mSplitCandidates = new vector<SortableEntry>; 
    192   } 
    193    
    194   mSplitCandidates->reserve(requestedSize); 
     188  if (mSubdivisionCandidates->capacity() > 500000 && 
     189      requestedSize < (int)(mSubdivisionCandidates->capacity()/10) ) { 
     190    delete mSubdivisionCandidates; 
     191    mSubdivisionCandidates = new vector<SortableEntry>; 
     192  } 
     193   
     194  mSubdivisionCandidates->reserve(requestedSize); 
    195195   
    196196  vector<int>::const_iterator fi; 
     
    202202    AxisAlignedBox3 box = mMesh->GetFaceBox(*fi); 
    203203     
    204     mSplitCandidates->push_back(SortableEntry(SortableEntry::FACE_MIN, 
     204    mSubdivisionCandidates->push_back(SortableEntry(SortableEntry::FACE_MIN, 
    205205                                             box.Min(axis), 
    206206                                             *fi) 
     
    208208     
    209209     
    210     mSplitCandidates->push_back(SortableEntry(SortableEntry::FACE_MAX, 
     210    mSubdivisionCandidates->push_back(SortableEntry(SortableEntry::FACE_MAX, 
    211211                                             box.Max(axis), 
    212212                                             *fi) 
     
    214214  } 
    215215   
    216   stable_sort(mSplitCandidates->begin(), mSplitCandidates->end()); 
     216  stable_sort(mSubdivisionCandidates->begin(), mSubdivisionCandidates->end()); 
    217217} 
    218218 
     
    229229{ 
    230230 
    231   SortSplitCandidates(node, axis); 
     231  SortSubdivisionCandidates(node, axis); 
    232232   
    233233  // go through the lists, count the number of objects left and right 
     
    247247  vector<SortableEntry>::const_iterator ci; 
    248248 
    249   for(ci = mSplitCandidates->begin(); 
    250       ci != mSplitCandidates->end(); 
     249  for(ci = mSubdivisionCandidates->begin(); 
     250      ci != mSubdivisionCandidates->end(); 
    251251      ci++) { 
    252252    switch ((*ci).type) { 
     
    409409MeshKdTree::Construct() 
    410410{ 
    411   if (!mSplitCandidates) 
    412     mSplitCandidates = new vector<SortableEntry>; 
     411  if (!mSubdivisionCandidates) 
     412    mSubdivisionCandidates = new vector<SortableEntry>; 
    413413   
    414414  // first construct a leaf that will get subdivide 
     
    418418   
    419419  // remove the allocated array 
    420   delete mSplitCandidates; 
    421   mSplitCandidates = NULL; 
     420  delete mSubdivisionCandidates; 
     421  mSubdivisionCandidates = NULL; 
    422422   
    423423  return true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/MeshKdTree.h

    r860 r1233  
    134134  MeshKdTree(Mesh *mesh); 
    135135  ~MeshKdTree() { 
    136     if (mSplitCandidates) 
    137       delete mSplitCandidates; 
     136    if (mSubdivisionCandidates) 
     137      delete mSubdivisionCandidates; 
    138138     
    139139    if (mRoot) 
     
    220220 
    221221  void 
    222   SortSplitCandidates( 
     222  SortSubdivisionCandidates( 
    223223                      MeshKdLeaf *node, 
    224224                      const int axis 
     
    251251   
    252252  /// reusable array of split candidates 
    253   vector<SortableEntry> *mSplitCandidates; 
     253  vector<SortableEntry> *mSubdivisionCandidates; 
    254254 
    255255public: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp

    r1221 r1233  
    1 #include  <stdlib.h> 
     1#include <stdlib.h> 
    22#include <iostream> 
    33#include <list> 
     
    155155        char str[100]; 
    156156         
    157         float x,y,z; 
    158         int i; 
    159  
    160157        SceneGraphNode *root = new SceneGraphNode; 
    161158         
     
    168165                { 
    169166                case 'v': 
    170                         cout << "v"; 
    171  
    172                         // vertex  
    173                         sscanf(str + 1, "%f %f %f", &x, &y, &z); 
    174                         vertices.push_back(Vector3(x,y,z)); 
    175                          
    176                         //Debug << "vertex: " << vertices.back() << endl; 
    177                         break; 
    178  
     167                        { 
     168                                float x,y,z; 
     169                                cout << "v"; 
     170 
     171                                // vertex  
     172                                sscanf(str + 1, "%f %f %f", &x, &y, &z); 
     173                                vertices.push_back(Vector3(x,y,z)); 
     174                                //Debug << "vertex: " << vertices.back() << endl; 
     175                                break; 
     176                        } 
    179177                case 'f':  
    180178                        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1232 r1233  
    1313#include "PlyParser.h" 
    1414#include "SamplingStrategy.h" 
    15 #include "VspOspTree.h" 
     15#include "VspTree.h" 
     16#include "OspTree.h" 
    1617#include "ObjParser.h" 
    1718#ifdef INTEL_COMPILER 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp

    r1189 r1233  
    66#include "KdTree.h" 
    77#include "common.h" 
     8#include "BvHierarchy.h" 
    89 
    910 
     
    1920} 
    2021 
     22/** the pvs is the number of different objects in the node leaves 
     23        We eliminate already accounted kd nodes and objects using mailboxing.  
     24*/ 
     25static int CountNewObjectsInKdNode(KdIntersectable *kdobj) 
     26{ 
     27        int pvs = 0; 
     28        stack<KdNode *> tStack; 
     29 
     30        tStack.push(kdobj->GetItem()); 
     31 
     32        while (!tStack.empty()) 
     33        { 
     34                KdNode *node = tStack.top(); 
     35                tStack.pop(); 
     36 
     37                // already processed node (=> objects already in pvs)? 
     38                if (!node->Mailed()) 
     39                { 
     40                        node->Mail(); 
     41 
     42                        if (node->IsLeaf()) 
     43                        { 
     44                                KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 
     45                        
     46                                // add #objects exclusivly in this node 
     47                                pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
     48 
     49                                // Objects already accounted for can only be found among those 
     50                                // which are referenced in more than one leaf 
     51                                ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
     52                                                 
     53                                for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
     54                                { 
     55                                        Intersectable *object = *oit;                                            
     56                             
     57                                        if (!object->Mailed()) 
     58                                        { 
     59                                                object->Mail(); 
     60                                                ++ pvs; 
     61                                        } 
     62                                } 
     63                        } 
     64                        else // traverse tree 
     65                        { 
     66                                KdInterior *interior = dynamic_cast<KdInterior *>(node); 
     67 
     68                                tStack.push(interior->mFront); 
     69                                tStack.push(interior->mBack); 
     70                        } 
     71                } 
     72        } 
     73 
     74        return pvs; 
     75} 
     76 
     77 
     78/** the pvs is the number of different objects in the node leaves 
     79        We eliminate already accounted kd nodes and objects using mailboxing.  
     80*/ 
     81static int CountNewObjectsInBvhNode(BvhIntersectable *bvhobj) 
     82{ 
     83        BvhNode *node= bvhobj->GetItem(); 
     84 
     85        // early exit 
     86        if (node->IsLeaf())      
     87        { 
     88                if (!node->Mailed()) 
     89                { 
     90                        node->Mail(); 
     91                        return (int)(((BvhLeaf *)node)->mObjects.size()); 
     92                } 
     93                else 
     94                { 
     95                        return 0; 
     96                } 
     97        } 
     98                                  
     99 
     100        // compute leaf pvs 
     101        int pvs = 0; 
     102 
     103        stack<BvhNode *> tStack; 
     104 
     105        tStack.push(bvhobj->GetItem()); 
     106 
     107        while (!tStack.empty()) 
     108        { 
     109                BvhNode *node = tStack.top(); 
     110                tStack.pop(); 
     111 
     112                // already processed node (=> objects already in pvs)? 
     113                if (!node->Mailed()) 
     114                { 
     115                        node->Mail(); 
     116 
     117                        if (node->IsLeaf()) 
     118                        { 
     119                                BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(node); 
     120                        
     121                                // add #objects exclusivly in this node 
     122                                pvs += leaf->mObjects.size(); 
     123                        } 
     124                        else // traverse tree 
     125                        { 
     126                                BvhInterior *interior = dynamic_cast<BvhInterior *>(node); 
     127 
     128                                tStack.push(interior->GetFront()); 
     129                                tStack.push(interior->GetBack()); 
     130                        } 
     131                } 
     132        } 
     133        return pvs; 
     134} 
     135 
     136 
    21137 
    22138int ObjectPvs::CountObjectsInPvs() const 
     
    26142        Intersectable::NewMail(); 
    27143        KdLeaf::NewMail(); 
     144        BvhLeaf::NewMail(); 
    28145 
    29146        ObjectPvsMap::const_iterator it, it_end = mEntries.end(); 
     
    33150                Intersectable *obj = (*it).first; 
    34151 
    35                 // found kd node 
    36                 // the pvs is the number od different objects in the node leaves 
    37                 // We eliminate already accounted kd nodes and objects using mailboxing.  
    38                 if (obj->Type() == Intersectable::KD_INTERSECTABLE) 
     152                switch (obj->Type()) 
    39153                { 
    40                         KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj); 
    41  
    42                         stack<KdNode *> tStack; 
    43  
    44                         tStack.push(kdObj->GetNode()); 
    45  
    46                         while (!tStack.empty()) 
    47                         { 
    48                                 KdNode *node = tStack.top(); 
    49                                 tStack.pop(); 
    50  
    51                                 // already processed node (= objects in pvs)? 
    52                                 if (0 ||!node->Mailed()) 
     154                        case Intersectable::KD_INTERSECTABLE: 
    53155                                { 
    54                                         node->Mail(); 
    55  
    56                                         if (node->IsLeaf()) 
    57                                         { 
    58                                                 KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 
    59 #if 1                         
    60                                                 // add #objects exclusivly in this node 
    61                                                 pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
    62  
    63                                                 // Objects already accounted for can only be found among those 
    64                                                 // which are referenced in more than one leaf 
    65                                                 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
    66                                                  
    67                                                 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 
    68                                                 { 
    69                                                         Intersectable *object = *oit;                                            
    70                              
    71                                                         if (!object->Mailed()) 
    72                                                         { 
    73                                                                 object->Mail(); 
    74                                                                 ++ pvs; 
    75                                                         } 
    76                                                 } 
    77 #else    
    78                                                 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
    79                                                  
    80                                                 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 
    81                                                 { 
    82                                                         Intersectable *object = *oit;                                            
    83                              
    84                                                         if (!object->Mailed()) 
    85                                                         { 
    86                                                                 object->Mail(); 
    87                                                                 ++ pvs; 
    88                                                         } 
    89                                                 } 
    90 #endif 
    91                                         } 
    92                                         else // traverse tree 
    93                                         { 
    94                                                 KdInterior *interior = dynamic_cast<KdInterior *>(node); 
    95  
    96                                                 tStack.push(interior->mFront); 
    97                                                 tStack.push(interior->mBack); 
    98                                         } 
     156                                        // found kd node 
     157                                        KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj); 
     158                                        pvs += CountNewObjectsInKdNode(kdObj);   
     159                                        break; 
    99160                                } 
    100                         } 
    101                 } 
    102                 else 
    103                 { 
    104                         ++ pvs; 
     161                        case Intersectable::BVH_INTERSECTABLE: 
     162                                { 
     163                                        BvhIntersectable *bvhObj = dynamic_cast<BvhIntersectable *>(obj); 
     164                                        pvs += CountNewObjectsInBvhNode(bvhObj); 
     165                                        break; 
     166                                } 
     167                        default: 
     168                                ++ pvs; 
     169                                break; 
    105170                } 
    106171        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1199 r1233  
    938938  } 
    939939         
    940   SortSplitCandidates(leaf, info.axis); 
     940  SortSubdivisionCandidates(leaf, info.axis); 
    941941   
    942942  // go through the lists, count the number of objects left and right 
     
    11111111 
    11121112void 
    1113 RssTree::SortSplitCandidates( 
     1113RssTree::SortSubdivisionCandidates( 
    11141114                                                         RssTreeLeaf *node, 
    11151115                                                         const int axis 
     
    26422642  else  
    26432643        switch (passDiff) { 
    2644           //    case 0: 
     2644          case 0: 
    26452645          //      weight = 1.0f; 
    26462646          //      break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.h

    r1199 r1233  
    761761 
    762762  void 
    763   SortSplitCandidates( 
     763  SortSubdivisionCandidates( 
    764764                                          RssTreeLeaf *node, 
    765765                                          const int axis 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1221 r1233  
    3636 
    3737 
    38 //int upperPvsLimit = 120; 
    39 //int lowerPvsLimit = 5; 
    40  
    4138float MergeCandidate::sRenderCostWeight = 0; 
    4239 
     
    7370        return count; 
    7471} 
     72 
    7573 
    7674/// Fast computation of merged pvs size 
     
    418416                { 
    419417                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     418 
    420419                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     420                         
    421421                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     422                        { 
    422423                                tstack.push(*it); 
     424                        } 
    423425                         
    424426                } 
     
    18331835        while (root->GetParent()) 
    18341836        { 
    1835 // <<<<<<< .mine 
    1836 //      case PVS_IN_LEAVES: //-- store pvs only in leaves 
    1837 //              {                        
    1838 //                      // pvs is always stored directly in leaves 
    1839 //                      if (vc->IsLeaf()) 
    1840 //                      { 
    1841 //                              if (!countKdPvs) 
    1842 //                                      pvsSize = vc->GetPvs().GetSize(); 
    1843 //                              else 
    1844 //                                      pvsSize = CountKdPvs(dynamic_cast<ViewCellLeaf *>(vc)); 
    1845 //                              break; 
    1846 //                      } 
    18471837                root = root->GetParent(); 
    18481838         
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1168 r1233  
    11701170 
    11711171 
    1172 void BspTree::SortSplitCandidates(const PolygonContainer &polys,  
     1172void BspTree::SortSubdivisionCandidates(const PolygonContainer &polys,  
    11731173                                                                  const int axis,  
    11741174                                                                  vector<SortableEntry> &splitCandidates) const 
     
    12071207        vector<SortableEntry> splitCandidates; 
    12081208 
    1209         SortSplitCandidates(polys, axis, splitCandidates); 
     1209        SortSubdivisionCandidates(polys, axis, splitCandidates); 
    12101210         
    12111211        // go through the lists, count the number of objects left and right 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r1121 r1233  
    890890                @param splitCandidates returns sorted list of split candidates 
    891891        */ 
    892         void SortSplitCandidates(const PolygonContainer &polys,  
     892        void SortSubdivisionCandidates(const PolygonContainer &polys,  
    893893                                                         const int axis,  
    894894                                                         vector<SortableEntry> &splitCandidates) const; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1221 r1233  
    88#include "ViewCellBsp.h" 
    99#include "KdTree.h" 
    10 #include "VspOspTree.h" 
     10#include "HierarchyManager.h" 
    1111#include "Exporter.h" 
    1212#include "VspBspTree.h" 
     
    1919#include "ResourceManager.h" 
    2020#include "KdIntersectable.h" 
     21#include "VspTree.h" 
     22#include "OspTree.h" 
     23 
    2124 
    2225// should not count origin object for sampling because it disturbs heuristics 
     
    34723475                        exporter->SetWireframe(); 
    34733476 
    3474                         KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 
     3477                        KdPvsMap::iterator kit = object->mKdPvs.mEntries.begin(); 
    34753478                        Intersectable::NewMail(); 
    34763479 
     
    34793482                        ObjectContainer visibleObjects; 
    34803483 
    3481                         for (; i != object->mKdPvs.mEntries.end(); i++) 
     3484                        for (; kit != object->mKdPvs.mEntries.end(); i++) 
    34823485                        { 
    3483                                 KdNode *node = (*i).first; 
     3486                                KdNode *node = (*kit).first; 
    34843487                                exporter->ExportBox(mKdTree->GetBox(node)); 
    34853488 
     
    54105413                                        // export bounding box of node 
    54115414                                        KdIntersectable *kdObj  = dynamic_cast<KdIntersectable *>(obj); 
    5412                                         AxisAlignedBox3 box = mOspTree->GetBoundingBox(kdObj->GetNode()); 
     5415                                        AxisAlignedBox3 box = mOspTree->GetBoundingBox(kdObj->GetItem()); 
    54135416                                         
    54145417                                        exporter->SetWireframe(); 
     
    55095512         
    55105513        // the type of the view space partition 
    5511         stream << "<ViewSpacePartition>" << endl; 
     5514        stream << "<ViewSpaceHierarchy>" << endl; 
    55125515        mVspTree->Export(stream); 
    55135516        stream << endl << "</ViewSpacePartitioin>" << endl; 
     
    55175520         
    55185521        // the type of the view cells hierarchy 
    5519         stream << "<ObjectSpacePartition>" << endl; 
     5522        stream << "<ObjectSpaceHierarchy>" << endl; 
    55205523        mOspTree->Export(stream); 
    5521         stream << endl << "</ObjectSpacePartition>" << endl; 
     5524        stream << endl << "</ObjectSpaceHierarchy>" << endl; 
    55225525 
    55235526 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r1221 r1233  
    3030#include "ViewCellsManager.h" 
    3131#include "GzFileInputSource.h" 
    32 #include "VspOspTree.h" 
     32#include "OspTree.h" 
     33#include "VspTree.h" 
    3334#include "KdTree.h" 
    3435 
     
    260261} 
    261262 
    262 void ViewCellsParseHandlers::StartViewSpacePartitionElement(const std::string &element, 
     263void ViewCellsParseHandlers::StartViewSpaceHierarchyElement(const std::string &element, 
    263264                                                                                                                        AttributeList& attributes) 
    264265{ 
     
    283284 
    284285 
    285 void ViewCellsParseHandlers::StartObjectSpacePartitionElement(const std::string &element, 
     286void ViewCellsParseHandlers::StartObjectSpaceHierarchyElement(const std::string &element, 
    286287                                                                                                                          AttributeList& attributes) 
    287288{ 
     
    340341 
    341342        // decides about the view cell hierarchy 
    342         if (element == "ViewSpacePartition") 
    343         { 
    344                 //StartViewSpacePartition(attributes); 
     343        if (element == "ViewSpaceHierarchy") 
     344        { 
     345                //StartViewSpaceHierarchy(attributes); 
    345346                cout << "parsing view space partition" << endl; 
    346347                mCurrentTask = PARSE_VSP; 
     
    348349 
    349350        // decides about the view cell hierarchy 
    350         if (element == "ObjectSpacePartition") 
    351         { 
    352                 //StartObjectSpacePartition(attributes); 
     351        if (element == "ObjectSpaceHierarchy") 
     352        { 
     353                //StartObjectSpaceHierarchy(attributes); 
    353354                cout << "parsing object space partition" << endl; 
    354355                mCurrentTask = PARSE_OSP; 
     
    373374        { 
    374375        case PARSE_VSP: 
    375                 StartViewSpacePartitionElement(element, attributes); 
     376                StartViewSpaceHierarchyElement(element, attributes); 
    376377                break; 
    377378        case PARSE_OSP: 
    378                 StartObjectSpacePartitionElement(element, attributes); 
     379                StartObjectSpaceHierarchyElement(element, attributes); 
    379380                break; 
    380381        case PARSE_VIEWCELLS: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r1201 r1233  
    121121  void EndViewCellInterior(); 
    122122 
    123   void StartViewSpacePartitionElement(const std::string &element, AttributeList& attributes); 
    124   void StartObjectSpacePartitionElement(const std::string &element, AttributeList& attributes); 
     123  void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes); 
     124  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes); 
    125125  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes); 
    126126 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp

    r1197 r1233  
    1111#include "VssTree.h" 
    1212#include "VspBspTree.h" 
    13 #include "VspOspTree.h" 
     13#include "HierarchyManager.h" 
    1414#include "RssTree.h" 
    1515#include "Beam.h" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1201 r1233  
    196196 
    197197 
    198         mLocalSplitCandidates = new vector<SortableEntry>; 
     198        mLocalSubdivisionCandidates = new vector<SortableEntry>; 
    199199 
    200200        Debug << endl; 
     
    230230{ 
    231231        DEL_PTR(mRoot); 
    232         DEL_PTR(mLocalSplitCandidates); 
     232        DEL_PTR(mLocalSubdivisionCandidates); 
    233233} 
    234234 
     
    639639 
    640640        // compute first split candidate 
    641         VspBspSplitCandidate splitCandidate; 
     641        VspBspSubdivisionCandidate splitCandidate; 
    642642        splitCandidate.mParentData = tData; 
    643643 
    644         EvalSplitCandidate(splitCandidate); 
     644        EvalSubdivisionCandidate(splitCandidate); 
    645645 
    646646        tQueue.push(splitCandidate); 
     
    742742                        << "#ViewCells\n" << viewCells << endl 
    743743                        << "#RenderCostDecrease\n" << renderCostDecr << endl  
    744                         << "#SplitCandidateCost\n" << splitCandidateCost << endl 
     744                        << "#SubdivisionCandidateCost\n" << splitCandidateCost << endl 
    745745                        << "#TotalRenderCost\n" << totalRenderCost << endl 
    746746                        << "#AvgRenderCost\n" << avgRenderCost << endl; 
     
    895895// subdivide node using a split plane queue 
    896896BspNode *VspBspTree::Subdivide(VspBspSplitQueue &tQueue, 
    897                                                            VspBspSplitCandidate &splitCandidate) 
     897                                                           VspBspSubdivisionCandidate &splitCandidate) 
    898898{ 
    899899        VspBspTraversalData &tData = splitCandidate.mParentData; 
     
    953953         
    954954                //-- push the new split candidates on the stack 
    955                 VspBspSplitCandidate frontCandidate; 
     955                VspBspSubdivisionCandidate frontCandidate; 
    956956                frontCandidate.mParentData = tFrontData; 
    957957 
    958                 VspBspSplitCandidate backCandidate; 
     958                VspBspSubdivisionCandidate backCandidate; 
    959959                backCandidate.mParentData = tBackData; 
    960960 
    961                 EvalSplitCandidate(frontCandidate); 
    962                 EvalSplitCandidate(backCandidate); 
     961                EvalSubdivisionCandidate(frontCandidate); 
     962                EvalSubdivisionCandidate(backCandidate); 
    963963         
    964964                tQueue.push(frontCandidate); 
     
    10421042 
    10431043/* 
    1044 void VspBspTree::EvalSplitCandidate(VspBspTraversalData &tData, 
    1045                                                                         VspBspSplitCandidate &splitData) 
     1044void VspBspTree::EvalSubdivisionCandidate(VspBspTraversalData &tData, 
     1045                                                                        VspBspSubdivisionCandidate &splitData) 
    10461046{ 
    10471047        VspBspTraversalData frontData; 
     
    10651065*/ 
    10661066 
    1067 void VspBspTree::EvalSplitCandidate(VspBspSplitCandidate &splitCandidate) 
     1067void VspBspTree::EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitCandidate) 
    10681068{ 
    10691069        VspBspTraversalData frontData; 
     
    13061306 
    13071307 
    1308 void VspBspTree::SortSplitCandidates(const RayInfoContainer &rays,  
     1308void VspBspTree::SortSubdivisionCandidates(const RayInfoContainer &rays,  
    13091309                                                                         const int axis,  
    13101310                                                                         float minBand,  
    13111311                                                                         float maxBand) 
    13121312{ 
    1313         mLocalSplitCandidates->clear(); 
     1313        mLocalSubdivisionCandidates->clear(); 
    13141314 
    13151315        int requestedSize = 2 * (int)(rays.size()); 
    13161316        // creates a sorted split candidates array 
    1317         if (mLocalSplitCandidates->capacity() > 500000 && 
    1318                 requestedSize < (int)(mLocalSplitCandidates->capacity() / 10) ) 
    1319         { 
    1320         delete mLocalSplitCandidates; 
    1321                 mLocalSplitCandidates = new vector<SortableEntry>; 
    1322         } 
    1323  
    1324         mLocalSplitCandidates->reserve(requestedSize); 
     1317        if (mLocalSubdivisionCandidates->capacity() > 500000 && 
     1318                requestedSize < (int)(mLocalSubdivisionCandidates->capacity() / 10) ) 
     1319        { 
     1320        delete mLocalSubdivisionCandidates; 
     1321                mLocalSubdivisionCandidates = new vector<SortableEntry>; 
     1322        } 
     1323 
     1324        mLocalSubdivisionCandidates->reserve(requestedSize); 
    13251325 
    13261326        if (0) 
     
    13391339                if (0) ClipValue(pos, minBand, maxBand); 
    13401340                 
    1341                 mLocalSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,  
     1341                mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,  
    13421342                                                                        pos, (*ri).mRay)); 
    13431343 
     
    13471347                if (0) ClipValue(pos, minBand, maxBand); 
    13481348 
    1349                 mLocalSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,  
     1349                mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,  
    13501350                                                                        pos, (*ri).mRay)); 
    13511351        } 
    13521352 
    1353         stable_sort(mLocalSplitCandidates->begin(), mLocalSplitCandidates->end()); 
     1353        stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 
    13541354} 
    13551355 
     
    13801380        const float maxBand = minBox + mMaxBand * sizeBox; 
    13811381 
    1382         SortSplitCandidates(usedRays, axis, minBand, maxBand); 
     1382        SortSubdivisionCandidates(usedRays, axis, minBand, maxBand); 
    13831383 
    13841384        // go through the lists, count the number of objects left and right 
     
    14421442        Intersectable::NewMail(); 
    14431443 
    1444         vector<SortableEntry>::const_iterator ci, ci_end = mLocalSplitCandidates->end(); 
    1445  
    1446         for (ci = mLocalSplitCandidates->begin(); ci != ci_end; ++ ci) 
     1444        vector<SortableEntry>::const_iterator ci, ci_end = mLocalSubdivisionCandidates->end(); 
     1445 
     1446        for (ci = mLocalSubdivisionCandidates->begin(); ci != ci_end; ++ ci) 
    14471447        { 
    14481448                VssRay *ray; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r1201 r1233  
    156156         
    157157         
    158         struct VspBspSplitCandidate 
     158        struct VspBspSubdivisionCandidate 
    159159        {   
    160160                /// the current split plane 
     
    172172                float mRenderCostDecr; 
    173173 
    174                 VspBspSplitCandidate(): mPriority(0), mRenderCostDecr(0)  
     174                VspBspSubdivisionCandidate(): mPriority(0), mRenderCostDecr(0)  
    175175                {}; 
    176176 
    177                 VspBspSplitCandidate(const Plane3 &plane, const VspBspTraversalData &tData):  
     177                VspBspSubdivisionCandidate(const Plane3 &plane, const VspBspTraversalData &tData):  
    178178                mSplitPlane(plane), mParentData(tData), mPriority(0), mRenderCostDecr(0)  
    179179                {} 
     
    190190                } 
    191191 
    192                 friend bool operator<(const VspBspSplitCandidate &a, const VspBspSplitCandidate &b) 
     192                friend bool operator<(const VspBspSubdivisionCandidate &a, const VspBspSubdivisionCandidate &b) 
    193193                { 
    194194                        return a.GetPriority() < b.GetPriority(); 
     
    196196    }; 
    197197 
    198         typedef std::priority_queue<VspBspSplitCandidate> VspBspSplitQueue; 
     198        typedef std::priority_queue<VspBspSubdivisionCandidate> VspBspSplitQueue; 
    199199 
    200200        /** Default constructor creating an empty tree. 
     
    402402        /** Evaluates candidate for splitting. 
    403403        */ 
    404         void EvalSplitCandidate(VspBspSplitCandidate &splitData); 
     404        void EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitData); 
    405405 
    406406        /** Computes priority of the traversal data and stores it in tData. 
     
    461461        */ 
    462462        BspNode *Subdivide(VspBspSplitQueue &tQueue, 
    463                                            VspBspSplitCandidate &splitCandidate); 
     463                                           VspBspSubdivisionCandidate &splitCandidate); 
    464464 
    465465        /** Constructs the tree from the given traversal data. 
     
    563563                @param splitCandidates returns sorted list of split candidates 
    564564        */ 
    565         void SortSplitCandidates(const RayInfoContainer &rays,  
     565        void SortSubdivisionCandidates(const RayInfoContainer &rays,  
    566566                                                         const int axis,  
    567567                                                         float minBand,  
     
    732732 
    733733        /// sorted split candidates used for sweep-heuristics 
    734         vector<SortableEntry> *mLocalSplitCandidates; 
     734        vector<SortableEntry> *mLocalSubdivisionCandidates; 
    735735 
    736736        /// box around the whole view domain 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1221 r1233  
    28812881                { 
    28822882                        leaf->Mail(); 
    2883                         dirtyList.push_back(leaf->mSplitCandidate); 
     2883                        dirtyList.push_back(leaf->mSubdivisionCandidate); 
    28842884                } 
    28852885                 
     
    28892889                { 
    28902890                        leaf->Mail(); 
    2891                         dirtyList.push_back(leaf->mSplitCandidate); 
     2891                        dirtyList.push_back(leaf->mSubdivisionCandidate); 
    28922892                } 
    28932893        } 
     
    59725972         
    59735973        //-- reevaluate the dirty list 
    5974         vector<SplitCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 
     5974        vector<SubdivisionCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 
    59755975 
    59765976        for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1221 r1233  
    1616 
    1717class ViewCellLeaf; 
    18 //class VspViewCell; 
    1918class Plane3; 
    2019class AxisAlignedBox3; 
     
    4847                return c1->GetPriority() < c2->GetPriority(); 
    4948        } 
    50 }; 
    51  
    52  
    53 /** Candidate for a view space / object space split. 
    54 */ 
    55 class SplitCandidate: public Heapable 
    56  
    57 public: 
    58  
    59         enum {OBJECT_SPACE, VIEW_SPACE}; 
    60  
    61         /// the current split plane 
    62         AxisAlignedPlane mSplitPlane; 
    63         /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) 
    64         int mSplitAxis; 
    65         /// the number of misses of max cost ratio until this split 
    66         int mMaxCostMisses; 
    67  
    68         SplitCandidate(): mRenderCostDecrease(0) 
    69         {}; 
    70  
    71         SplitCandidate(const AxisAlignedPlane &plane): mSplitPlane(plane), mRenderCostDecrease(0) 
    72         {} 
    73  
    74         virtual void EvalPriority() = 0; 
    75         virtual int Type() const = 0; 
    76         virtual bool GlobalTerminationCriteriaMet() const = 0; 
    77  
    78         /** Set render cost decrease achieved through this split. 
    79         */ 
    80         void SetRenderCostDecrease(const float renderCostDecr) 
    81         { 
    82                 mRenderCostDecrease = renderCostDecr; 
    83         } 
    84          
    85         float GetRenderCostDecrease() const 
    86         { 
    87                 return mRenderCostDecrease; 
    88         } 
    89  
    90 protected: 
    91  
    92         /// render cost decrease achieved through this split 
    93         float mRenderCostDecrease; 
    94          
    9549}; 
    9650 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r1221 r1233  
    1313#include "Beam.h" 
    1414#include "GlRenderer.h" 
    15 #include "ArchModeler2MLRT.hxx" 
     15//#include "ArchModeler2MLRT.hxx" 
    1616#include "Intersectable.h" 
    1717 
     
    191191 
    192192        float dist = 0; 
    193         const int hittriangle = mlrtaIntersectAS(pforg, pfdir, pfnorm, dist); 
     193        const int hittriangle = -1//mlrtaIntersectAS(pforg, pfdir, pfnorm, dist); 
    194194 
    195195        if (hittriangle == -1) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp

    r1004 r1233  
    794794  } 
    795795         
    796   SortSplitCandidates(leaf, axis); 
     796  SortSubdivisionCandidates(leaf, axis); 
    797797   
    798798  // go through the lists, count the number of objects left and right 
     
    892892 
    893893void 
    894 VssTree::SortSplitCandidates( 
     894VssTree::SortSubdivisionCandidates( 
    895895                                                         VssTreeLeaf *node, 
    896896                                                         const int axis 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.h

    r863 r1233  
    727727 
    728728  void 
    729   SortSplitCandidates( 
     729  SortSubdivisionCandidates( 
    730730                                          VssTreeLeaf *node, 
    731731                                          const int axis 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r1197 r1233  
    99#include "Polygon3.h" 
    1010#include "VssRay.h" 
    11 #include "VspOspTree.h" 
     11#include "HierarchyManager.h" 
    1212#include "VssTree.h" 
    1313#include "VspBspTree.h" 
Note: See TracChangeset for help on using the changeset viewer.