Changeset 1233 for GTP/trunk/Lib
- Timestamp:
- 08/20/06 22:48:01 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1181 r1233 1 1 #include "X3dExporter.h" 2 2 #include "VrmlExporter.h" 3 #include " VspOspTree.h"3 #include "OspTree.h" 4 4 #include "KdTree.h" 5 5 #include "KdIntersectable.h" … … 76 76 void Exporter::ExportKdIntersectable(const KdIntersectable &kdObj) 77 77 { 78 KdNode *node = kdObj.Get Node();78 KdNode *node = kdObj.GetItem(); 79 79 80 80 Intersectable::NewMail(); -
GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h
r1106 r1233 226 226 } 227 227 228 229 228 } 230 229 -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1193 r1233 11 11 struct VssRayContainer; 12 12 class KdLeaf; 13 class BvhLeaf; 14 13 15 14 16 class Intersectable { … … 32 34 ViewCellPvs mViewCellPvs; 33 35 34 /// kd leaves that this intersectable belongs to 35 //set<KdLeaf *> mKdLeaves; 36 /// pointer to the container bvh leaf 37 BvhLeaf *mBvhLeaf; 38 36 39 VssRayContainer mVssRays; 37 40 38 /// # of object references41 /// # of references to this instance 39 42 int mReferences; 40 43 … … 44 47 VIEW_CELL, 45 48 OGRE_MESH_INSTANCE, 46 KD_INTERSECTABLE 49 KD_INTERSECTABLE, 50 BVH_INTERSECTABLE 47 51 }; 48 52 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.cpp
r1199 r1233 5 5 6 6 7 KdIntersectable::KdIntersectable(KdNode *node):8 Intersectable(), mNode(node)9 {10 }11 7 12 13 void KdIntersectable::SetNode(KdNode *node)14 {15 mNode = node;16 }17 18 19 KdNode *KdIntersectable::GetNode() const20 {21 return mNode;22 }23 24 25 AxisAlignedBox3 KdIntersectable::GetBox() const26 { // TODO matt27 return AxisAlignedBox3();28 }29 30 31 int KdIntersectable::CastRay(Ray &ray)32 { // TODO matt33 return 0;34 }35 36 37 bool KdIntersectable::IsConvex() const38 {39 return true;40 }41 42 43 bool KdIntersectable::IsWatertight() const44 {45 return true;46 }47 48 49 float KdIntersectable::IntersectionComplexity()50 {51 return 1.0f;52 }53 54 55 int KdIntersectable::NumberOfFaces() const56 {57 return 0;58 }59 60 61 int KdIntersectable::Type() const62 {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 }88 8 89 9 } -
GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h
r1139 r1233 10 10 struct VssRayContainer; 11 11 class KdNode; 12 class BvhNode; 12 13 13 14 /** 14 Wrapper for Kd nodes for use in a PVS.15 Wrapper used for creating a PVS compliant intersectable. 15 16 */ 16 class KdIntersectable: public Intersectable 17 template<typename T> 18 class IntersectableWrapper: public Intersectable 17 19 { 18 20 public: 19 KdIntersectable(KdNode *node);21 IntersectableWrapper(T *item); 20 22 21 /** Returns 'mesh'associated with this instance.23 /** Returns node associated with this instance. 22 24 */ 23 KdNode *GetNode() const;25 T *GetItem() const; 24 26 25 27 /** See get. 26 28 */ 27 void SetNode(KdNode *node); 28 29 void SetItem(T *item); 29 30 30 31 //-- inherited functions from Intersectable … … 39 40 40 41 int NumberOfFaces() const; 41 int Type() const;42 //int Type() const; 42 43 43 44 int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point, … … 52 53 53 54 54 /** Pointer to kd leaf object that was hit during ray casting.55 */56 Intersectable *mHitObject;57 58 55 protected: 59 56 60 KdNode *mNode;57 T *mItem; 61 58 }; 62 59 60 template<typename T> 61 IntersectableWrapper<T>::IntersectableWrapper(T *item): 62 Intersectable(), mItem(item) 63 { 64 } 65 66 template<typename T> 67 void IntersectableWrapper<T>::SetItem(T *item) 68 { 69 mItem = item; 70 } 71 72 template<typename T> 73 T *IntersectableWrapper<T>::GetItem() const 74 { 75 return mItem; 76 } 77 78 template<typename T> 79 AxisAlignedBox3 IntersectableWrapper<T>::GetBox() const 80 { // TODO matt 81 return AxisAlignedBox3(); 82 } 83 84 template<typename T> 85 int IntersectableWrapper<T>::CastRay(Ray &ray) 86 { // TODO matt 87 return 0; 88 } 89 90 template<typename T> 91 bool IntersectableWrapper<T>::IsConvex() const 92 { 93 return true; 94 } 95 96 template<typename T> 97 bool IntersectableWrapper<T>::IsWatertight() const 98 { 99 return true; 100 } 101 102 template<typename T> 103 float IntersectableWrapper<T>::IntersectionComplexity() 104 { 105 return 1.0f; 106 } 107 108 template<typename T> 109 int IntersectableWrapper<T>::NumberOfFaces() const 110 { 111 return 0; 112 } 113 114 template<typename T> 115 int IntersectableWrapper<T>::GetRandomSurfacePoint(Vector3 &point, 116 Vector3 &normal) 117 { 118 return 0; 119 } 120 121 template<typename T> 122 int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point, 123 Vector3 &normal, 124 const Vector3 &viewpoint, 125 const int maxTries) 126 { 127 return 0; 128 } 129 130 template<typename T> 131 ostream &IntersectableWrapper<T>::Describe(ostream &s) 132 { 133 s << mItem; 134 return s; 135 } 136 137 138 class KdIntersectable: public IntersectableWrapper<KdNode> 139 { 140 public: 141 KdIntersectable(KdNode *item): 142 IntersectableWrapper<KdNode>(item) {} 143 144 int Type() const 145 { 146 return Intersectable::KD_INTERSECTABLE; 147 } 148 }; 149 150 151 class BvhIntersectable: public IntersectableWrapper<BvhNode> 152 { 153 public: 154 BvhIntersectable(BvhNode *item): 155 IntersectableWrapper<BvhNode>(item) {} 156 157 int Type() const 158 { 159 return Intersectable::BVH_INTERSECTABLE; 160 } 161 }; 63 162 64 163 } -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1201 r1233 435 435 436 436 void 437 KdTree::SortS plitCandidates(437 KdTree::SortSubdivisionCandidates( 438 438 KdLeaf *node, 439 439 const int axis … … 485 485 { 486 486 487 SortS plitCandidates(node, axis);487 SortSubdivisionCandidates(node, axis); 488 488 489 489 // go through the lists, count the number of objects left and right -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1201 r1233 20 20 class KdInterior; 21 21 class Intersectable; 22 //class KdViewCell;23 22 class Beam; 24 23 … … 174 173 }; 175 174 176 class S plitCandidate;175 class SubdivisionCandidate; 177 176 178 177 /** Implementation of the kd-tree leaf node */ … … 213 212 214 213 /// pvs of view cells seeing this node. 215 S plitCandidate *mSplitCandidate;214 SubdivisionCandidate *mSubdivisionCandidate; 216 215 217 216 /// pointer to view cell. … … 227 226 }; 228 227 229 230 228 231 229 /** KdTree for indexing scene entities - occluders/occludees/viewcells */ … … 528 526 529 527 void 530 SortS plitCandidates(528 SortSubdivisionCandidates( 531 529 KdLeaf *node, 532 530 const int axis -
GTP/trunk/Lib/Vis/Preprocessing/src/MeshKdTree.cpp
r1004 r1233 19 19 { 20 20 mRoot = new MeshKdLeaf; 21 mS plitCandidates = NULL;21 mSubdivisionCandidates = NULL; 22 22 } 23 23 … … 177 177 178 178 void 179 MeshKdTree::SortS plitCandidates(179 MeshKdTree::SortSubdivisionCandidates( 180 180 MeshKdLeaf *node, 181 181 const int axis 182 182 ) 183 183 { 184 mS plitCandidates->clear();184 mSubdivisionCandidates->clear(); 185 185 186 186 int requestedSize = 2*(int)node->mFaces.size(); 187 187 // creates a sorted split candidates array 188 if (mS plitCandidates->capacity() > 500000 &&189 requestedSize < (int)(mS plitCandidates->capacity()/10) ) {190 delete mS plitCandidates;191 mS plitCandidates = new vector<SortableEntry>;192 } 193 194 mS plitCandidates->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); 195 195 196 196 vector<int>::const_iterator fi; … … 202 202 AxisAlignedBox3 box = mMesh->GetFaceBox(*fi); 203 203 204 mS plitCandidates->push_back(SortableEntry(SortableEntry::FACE_MIN,204 mSubdivisionCandidates->push_back(SortableEntry(SortableEntry::FACE_MIN, 205 205 box.Min(axis), 206 206 *fi) … … 208 208 209 209 210 mS plitCandidates->push_back(SortableEntry(SortableEntry::FACE_MAX,210 mSubdivisionCandidates->push_back(SortableEntry(SortableEntry::FACE_MAX, 211 211 box.Max(axis), 212 212 *fi) … … 214 214 } 215 215 216 stable_sort(mS plitCandidates->begin(), mSplitCandidates->end());216 stable_sort(mSubdivisionCandidates->begin(), mSubdivisionCandidates->end()); 217 217 } 218 218 … … 229 229 { 230 230 231 SortS plitCandidates(node, axis);231 SortSubdivisionCandidates(node, axis); 232 232 233 233 // go through the lists, count the number of objects left and right … … 247 247 vector<SortableEntry>::const_iterator ci; 248 248 249 for(ci = mS plitCandidates->begin();250 ci != mS plitCandidates->end();249 for(ci = mSubdivisionCandidates->begin(); 250 ci != mSubdivisionCandidates->end(); 251 251 ci++) { 252 252 switch ((*ci).type) { … … 409 409 MeshKdTree::Construct() 410 410 { 411 if (!mS plitCandidates)412 mS plitCandidates = new vector<SortableEntry>;411 if (!mSubdivisionCandidates) 412 mSubdivisionCandidates = new vector<SortableEntry>; 413 413 414 414 // first construct a leaf that will get subdivide … … 418 418 419 419 // remove the allocated array 420 delete mS plitCandidates;421 mS plitCandidates = NULL;420 delete mSubdivisionCandidates; 421 mSubdivisionCandidates = NULL; 422 422 423 423 return true; -
GTP/trunk/Lib/Vis/Preprocessing/src/MeshKdTree.h
r860 r1233 134 134 MeshKdTree(Mesh *mesh); 135 135 ~MeshKdTree() { 136 if (mS plitCandidates)137 delete mS plitCandidates;136 if (mSubdivisionCandidates) 137 delete mSubdivisionCandidates; 138 138 139 139 if (mRoot) … … 220 220 221 221 void 222 SortS plitCandidates(222 SortSubdivisionCandidates( 223 223 MeshKdLeaf *node, 224 224 const int axis … … 251 251 252 252 /// reusable array of split candidates 253 vector<SortableEntry> *mS plitCandidates;253 vector<SortableEntry> *mSubdivisionCandidates; 254 254 255 255 public: -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r1221 r1233 1 #include 1 #include <stdlib.h> 2 2 #include <iostream> 3 3 #include <list> … … 155 155 char str[100]; 156 156 157 float x,y,z;158 int i;159 160 157 SceneGraphNode *root = new SceneGraphNode; 161 158 … … 168 165 { 169 166 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 } 179 177 case 'f': 180 178 { -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1232 r1233 13 13 #include "PlyParser.h" 14 14 #include "SamplingStrategy.h" 15 #include "VspOspTree.h" 15 #include "VspTree.h" 16 #include "OspTree.h" 16 17 #include "ObjParser.h" 17 18 #ifdef INTEL_COMPILER -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
r1189 r1233 6 6 #include "KdTree.h" 7 7 #include "common.h" 8 #include "BvHierarchy.h" 8 9 9 10 … … 19 20 } 20 21 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 */ 25 static 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 */ 81 static 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 21 137 22 138 int ObjectPvs::CountObjectsInPvs() const … … 26 142 Intersectable::NewMail(); 27 143 KdLeaf::NewMail(); 144 BvhLeaf::NewMail(); 28 145 29 146 ObjectPvsMap::const_iterator it, it_end = mEntries.end(); … … 33 150 Intersectable *obj = (*it).first; 34 151 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()) 39 153 { 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: 53 155 { 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; 99 160 } 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; 105 170 } 106 171 } -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
r1199 r1233 938 938 } 939 939 940 SortS plitCandidates(leaf, info.axis);940 SortSubdivisionCandidates(leaf, info.axis); 941 941 942 942 // go through the lists, count the number of objects left and right … … 1111 1111 1112 1112 void 1113 RssTree::SortS plitCandidates(1113 RssTree::SortSubdivisionCandidates( 1114 1114 RssTreeLeaf *node, 1115 1115 const int axis … … 2642 2642 else 2643 2643 switch (passDiff) { 2644 //case 0:2644 case 0: 2645 2645 // weight = 1.0f; 2646 2646 // break; -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.h
r1199 r1233 761 761 762 762 void 763 SortS plitCandidates(763 SortSubdivisionCandidates( 764 764 RssTreeLeaf *node, 765 765 const int axis -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1221 r1233 36 36 37 37 38 //int upperPvsLimit = 120;39 //int lowerPvsLimit = 5;40 41 38 float MergeCandidate::sRenderCostWeight = 0; 42 39 … … 73 70 return count; 74 71 } 72 75 73 76 74 /// Fast computation of merged pvs size … … 418 416 { 419 417 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 418 420 419 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 420 421 421 for (it = interior->mChildren.begin(); it != it_end; ++ it) 422 { 422 423 tstack.push(*it); 424 } 423 425 424 426 } … … 1833 1835 while (root->GetParent()) 1834 1836 { 1835 // <<<<<<< .mine1836 // case PVS_IN_LEAVES: //-- store pvs only in leaves1837 // {1838 // // pvs is always stored directly in leaves1839 // if (vc->IsLeaf())1840 // {1841 // if (!countKdPvs)1842 // pvsSize = vc->GetPvs().GetSize();1843 // else1844 // pvsSize = CountKdPvs(dynamic_cast<ViewCellLeaf *>(vc));1845 // break;1846 // }1847 1837 root = root->GetParent(); 1848 1838 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1168 r1233 1170 1170 1171 1171 1172 void BspTree::SortS plitCandidates(const PolygonContainer &polys,1172 void BspTree::SortSubdivisionCandidates(const PolygonContainer &polys, 1173 1173 const int axis, 1174 1174 vector<SortableEntry> &splitCandidates) const … … 1207 1207 vector<SortableEntry> splitCandidates; 1208 1208 1209 SortS plitCandidates(polys, axis, splitCandidates);1209 SortSubdivisionCandidates(polys, axis, splitCandidates); 1210 1210 1211 1211 // go through the lists, count the number of objects left and right -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h
r1121 r1233 890 890 @param splitCandidates returns sorted list of split candidates 891 891 */ 892 void SortS plitCandidates(const PolygonContainer &polys,892 void SortSubdivisionCandidates(const PolygonContainer &polys, 893 893 const int axis, 894 894 vector<SortableEntry> &splitCandidates) const; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1221 r1233 8 8 #include "ViewCellBsp.h" 9 9 #include "KdTree.h" 10 #include " VspOspTree.h"10 #include "HierarchyManager.h" 11 11 #include "Exporter.h" 12 12 #include "VspBspTree.h" … … 19 19 #include "ResourceManager.h" 20 20 #include "KdIntersectable.h" 21 #include "VspTree.h" 22 #include "OspTree.h" 23 21 24 22 25 // should not count origin object for sampling because it disturbs heuristics … … 3472 3475 exporter->SetWireframe(); 3473 3476 3474 KdPvsMap::iterator i= object->mKdPvs.mEntries.begin();3477 KdPvsMap::iterator kit = object->mKdPvs.mEntries.begin(); 3475 3478 Intersectable::NewMail(); 3476 3479 … … 3479 3482 ObjectContainer visibleObjects; 3480 3483 3481 for (; i!= object->mKdPvs.mEntries.end(); i++)3484 for (; kit != object->mKdPvs.mEntries.end(); i++) 3482 3485 { 3483 KdNode *node = (* i).first;3486 KdNode *node = (*kit).first; 3484 3487 exporter->ExportBox(mKdTree->GetBox(node)); 3485 3488 … … 5410 5413 // export bounding box of node 5411 5414 KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj); 5412 AxisAlignedBox3 box = mOspTree->GetBoundingBox(kdObj->Get Node());5415 AxisAlignedBox3 box = mOspTree->GetBoundingBox(kdObj->GetItem()); 5413 5416 5414 5417 exporter->SetWireframe(); … … 5509 5512 5510 5513 // the type of the view space partition 5511 stream << "<ViewSpace Partition>" << endl;5514 stream << "<ViewSpaceHierarchy>" << endl; 5512 5515 mVspTree->Export(stream); 5513 5516 stream << endl << "</ViewSpacePartitioin>" << endl; … … 5517 5520 5518 5521 // the type of the view cells hierarchy 5519 stream << "<ObjectSpace Partition>" << endl;5522 stream << "<ObjectSpaceHierarchy>" << endl; 5520 5523 mOspTree->Export(stream); 5521 stream << endl << "</ObjectSpace Partition>" << endl;5524 stream << endl << "</ObjectSpaceHierarchy>" << endl; 5522 5525 5523 5526 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1221 r1233 30 30 #include "ViewCellsManager.h" 31 31 #include "GzFileInputSource.h" 32 #include "VspOspTree.h" 32 #include "OspTree.h" 33 #include "VspTree.h" 33 34 #include "KdTree.h" 34 35 … … 260 261 } 261 262 262 void ViewCellsParseHandlers::StartViewSpace PartitionElement(const std::string &element,263 void ViewCellsParseHandlers::StartViewSpaceHierarchyElement(const std::string &element, 263 264 AttributeList& attributes) 264 265 { … … 283 284 284 285 285 void ViewCellsParseHandlers::StartObjectSpace PartitionElement(const std::string &element,286 void ViewCellsParseHandlers::StartObjectSpaceHierarchyElement(const std::string &element, 286 287 AttributeList& attributes) 287 288 { … … 340 341 341 342 // decides about the view cell hierarchy 342 if (element == "ViewSpace Partition")343 { 344 //StartViewSpace Partition(attributes);343 if (element == "ViewSpaceHierarchy") 344 { 345 //StartViewSpaceHierarchy(attributes); 345 346 cout << "parsing view space partition" << endl; 346 347 mCurrentTask = PARSE_VSP; … … 348 349 349 350 // decides about the view cell hierarchy 350 if (element == "ObjectSpace Partition")351 { 352 //StartObjectSpace Partition(attributes);351 if (element == "ObjectSpaceHierarchy") 352 { 353 //StartObjectSpaceHierarchy(attributes); 353 354 cout << "parsing object space partition" << endl; 354 355 mCurrentTask = PARSE_OSP; … … 373 374 { 374 375 case PARSE_VSP: 375 StartViewSpace PartitionElement(element, attributes);376 StartViewSpaceHierarchyElement(element, attributes); 376 377 break; 377 378 case PARSE_OSP: 378 StartObjectSpace PartitionElement(element, attributes);379 StartObjectSpaceHierarchyElement(element, attributes); 379 380 break; 380 381 case PARSE_VIEWCELLS: -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r1201 r1233 121 121 void EndViewCellInterior(); 122 122 123 void StartViewSpace PartitionElement(const std::string &element, AttributeList& attributes);124 void StartObjectSpace PartitionElement(const std::string &element, AttributeList& attributes);123 void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes); 124 void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes); 125 125 void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes); 126 126 -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
r1197 r1233 11 11 #include "VssTree.h" 12 12 #include "VspBspTree.h" 13 #include " VspOspTree.h"13 #include "HierarchyManager.h" 14 14 #include "RssTree.h" 15 15 #include "Beam.h" -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1201 r1233 196 196 197 197 198 mLocalS plitCandidates = new vector<SortableEntry>;198 mLocalSubdivisionCandidates = new vector<SortableEntry>; 199 199 200 200 Debug << endl; … … 230 230 { 231 231 DEL_PTR(mRoot); 232 DEL_PTR(mLocalS plitCandidates);232 DEL_PTR(mLocalSubdivisionCandidates); 233 233 } 234 234 … … 639 639 640 640 // compute first split candidate 641 VspBspS plitCandidate splitCandidate;641 VspBspSubdivisionCandidate splitCandidate; 642 642 splitCandidate.mParentData = tData; 643 643 644 EvalS plitCandidate(splitCandidate);644 EvalSubdivisionCandidate(splitCandidate); 645 645 646 646 tQueue.push(splitCandidate); … … 742 742 << "#ViewCells\n" << viewCells << endl 743 743 << "#RenderCostDecrease\n" << renderCostDecr << endl 744 << "#S plitCandidateCost\n" << splitCandidateCost << endl744 << "#SubdivisionCandidateCost\n" << splitCandidateCost << endl 745 745 << "#TotalRenderCost\n" << totalRenderCost << endl 746 746 << "#AvgRenderCost\n" << avgRenderCost << endl; … … 895 895 // subdivide node using a split plane queue 896 896 BspNode *VspBspTree::Subdivide(VspBspSplitQueue &tQueue, 897 VspBspS plitCandidate &splitCandidate)897 VspBspSubdivisionCandidate &splitCandidate) 898 898 { 899 899 VspBspTraversalData &tData = splitCandidate.mParentData; … … 953 953 954 954 //-- push the new split candidates on the stack 955 VspBspS plitCandidate frontCandidate;955 VspBspSubdivisionCandidate frontCandidate; 956 956 frontCandidate.mParentData = tFrontData; 957 957 958 VspBspS plitCandidate backCandidate;958 VspBspSubdivisionCandidate backCandidate; 959 959 backCandidate.mParentData = tBackData; 960 960 961 EvalS plitCandidate(frontCandidate);962 EvalS plitCandidate(backCandidate);961 EvalSubdivisionCandidate(frontCandidate); 962 EvalSubdivisionCandidate(backCandidate); 963 963 964 964 tQueue.push(frontCandidate); … … 1042 1042 1043 1043 /* 1044 void VspBspTree::EvalS plitCandidate(VspBspTraversalData &tData,1045 VspBspS plitCandidate &splitData)1044 void VspBspTree::EvalSubdivisionCandidate(VspBspTraversalData &tData, 1045 VspBspSubdivisionCandidate &splitData) 1046 1046 { 1047 1047 VspBspTraversalData frontData; … … 1065 1065 */ 1066 1066 1067 void VspBspTree::EvalS plitCandidate(VspBspSplitCandidate &splitCandidate)1067 void VspBspTree::EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitCandidate) 1068 1068 { 1069 1069 VspBspTraversalData frontData; … … 1306 1306 1307 1307 1308 void VspBspTree::SortS plitCandidates(const RayInfoContainer &rays,1308 void VspBspTree::SortSubdivisionCandidates(const RayInfoContainer &rays, 1309 1309 const int axis, 1310 1310 float minBand, 1311 1311 float maxBand) 1312 1312 { 1313 mLocalS plitCandidates->clear();1313 mLocalSubdivisionCandidates->clear(); 1314 1314 1315 1315 int requestedSize = 2 * (int)(rays.size()); 1316 1316 // creates a sorted split candidates array 1317 if (mLocalS plitCandidates->capacity() > 500000 &&1318 requestedSize < (int)(mLocalS plitCandidates->capacity() / 10) )1319 { 1320 delete mLocalS plitCandidates;1321 mLocalS plitCandidates = new vector<SortableEntry>;1322 } 1323 1324 mLocalS plitCandidates->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); 1325 1325 1326 1326 if (0) … … 1339 1339 if (0) ClipValue(pos, minBand, maxBand); 1340 1340 1341 mLocalS plitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,1341 mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 1342 1342 pos, (*ri).mRay)); 1343 1343 … … 1347 1347 if (0) ClipValue(pos, minBand, maxBand); 1348 1348 1349 mLocalS plitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,1349 mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin, 1350 1350 pos, (*ri).mRay)); 1351 1351 } 1352 1352 1353 stable_sort(mLocalS plitCandidates->begin(), mLocalSplitCandidates->end());1353 stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1354 1354 } 1355 1355 … … 1380 1380 const float maxBand = minBox + mMaxBand * sizeBox; 1381 1381 1382 SortS plitCandidates(usedRays, axis, minBand, maxBand);1382 SortSubdivisionCandidates(usedRays, axis, minBand, maxBand); 1383 1383 1384 1384 // go through the lists, count the number of objects left and right … … 1442 1442 Intersectable::NewMail(); 1443 1443 1444 vector<SortableEntry>::const_iterator ci, ci_end = mLocalS plitCandidates->end();1445 1446 for (ci = mLocalS plitCandidates->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) 1447 1447 { 1448 1448 VssRay *ray; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r1201 r1233 156 156 157 157 158 struct VspBspS plitCandidate158 struct VspBspSubdivisionCandidate 159 159 { 160 160 /// the current split plane … … 172 172 float mRenderCostDecr; 173 173 174 VspBspS plitCandidate(): mPriority(0), mRenderCostDecr(0)174 VspBspSubdivisionCandidate(): mPriority(0), mRenderCostDecr(0) 175 175 {}; 176 176 177 VspBspS plitCandidate(const Plane3 &plane, const VspBspTraversalData &tData):177 VspBspSubdivisionCandidate(const Plane3 &plane, const VspBspTraversalData &tData): 178 178 mSplitPlane(plane), mParentData(tData), mPriority(0), mRenderCostDecr(0) 179 179 {} … … 190 190 } 191 191 192 friend bool operator<(const VspBspS plitCandidate &a, const VspBspSplitCandidate &b)192 friend bool operator<(const VspBspSubdivisionCandidate &a, const VspBspSubdivisionCandidate &b) 193 193 { 194 194 return a.GetPriority() < b.GetPriority(); … … 196 196 }; 197 197 198 typedef std::priority_queue<VspBspS plitCandidate> VspBspSplitQueue;198 typedef std::priority_queue<VspBspSubdivisionCandidate> VspBspSplitQueue; 199 199 200 200 /** Default constructor creating an empty tree. … … 402 402 /** Evaluates candidate for splitting. 403 403 */ 404 void EvalS plitCandidate(VspBspSplitCandidate &splitData);404 void EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitData); 405 405 406 406 /** Computes priority of the traversal data and stores it in tData. … … 461 461 */ 462 462 BspNode *Subdivide(VspBspSplitQueue &tQueue, 463 VspBspS plitCandidate &splitCandidate);463 VspBspSubdivisionCandidate &splitCandidate); 464 464 465 465 /** Constructs the tree from the given traversal data. … … 563 563 @param splitCandidates returns sorted list of split candidates 564 564 */ 565 void SortS plitCandidates(const RayInfoContainer &rays,565 void SortSubdivisionCandidates(const RayInfoContainer &rays, 566 566 const int axis, 567 567 float minBand, … … 732 732 733 733 /// sorted split candidates used for sweep-heuristics 734 vector<SortableEntry> *mLocalS plitCandidates;734 vector<SortableEntry> *mLocalSubdivisionCandidates; 735 735 736 736 /// box around the whole view domain -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1221 r1233 2881 2881 { 2882 2882 leaf->Mail(); 2883 dirtyList.push_back(leaf->mS plitCandidate);2883 dirtyList.push_back(leaf->mSubdivisionCandidate); 2884 2884 } 2885 2885 … … 2889 2889 { 2890 2890 leaf->Mail(); 2891 dirtyList.push_back(leaf->mS plitCandidate);2891 dirtyList.push_back(leaf->mSubdivisionCandidate); 2892 2892 } 2893 2893 } … … 5972 5972 5973 5973 //-- reevaluate the dirty list 5974 vector<S plitCandidate *>::const_iterator sit, sit_end = dirtyList.end();5974 vector<SubdivisionCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 5975 5975 5976 5976 for (sit = dirtyList.begin(); sit != sit_end; ++ sit) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1221 r1233 16 16 17 17 class ViewCellLeaf; 18 //class VspViewCell;19 18 class Plane3; 20 19 class AxisAlignedBox3; … … 48 47 return c1->GetPriority() < c2->GetPriority(); 49 48 } 50 };51 52 53 /** Candidate for a view space / object space split.54 */55 class SplitCandidate: public Heapable56 {57 public:58 59 enum {OBJECT_SPACE, VIEW_SPACE};60 61 /// the current split plane62 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 split66 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() const86 {87 return mRenderCostDecrease;88 }89 90 protected:91 92 /// render cost decrease achieved through this split93 float mRenderCostDecrease;94 95 49 }; 96 50 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1221 r1233 13 13 #include "Beam.h" 14 14 #include "GlRenderer.h" 15 #include "ArchModeler2MLRT.hxx"15 //#include "ArchModeler2MLRT.hxx" 16 16 #include "Intersectable.h" 17 17 … … 191 191 192 192 float dist = 0; 193 const int hittriangle = mlrtaIntersectAS(pforg, pfdir, pfnorm, dist);193 const int hittriangle = -1//mlrtaIntersectAS(pforg, pfdir, pfnorm, dist); 194 194 195 195 if (hittriangle == -1) -
GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp
r1004 r1233 794 794 } 795 795 796 SortS plitCandidates(leaf, axis);796 SortSubdivisionCandidates(leaf, axis); 797 797 798 798 // go through the lists, count the number of objects left and right … … 892 892 893 893 void 894 VssTree::SortS plitCandidates(894 VssTree::SortSubdivisionCandidates( 895 895 VssTreeLeaf *node, 896 896 const int axis -
GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.h
r863 r1233 727 727 728 728 void 729 SortS plitCandidates(729 SortSubdivisionCandidates( 730 730 VssTreeLeaf *node, 731 731 const int axis -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r1197 r1233 9 9 #include "Polygon3.h" 10 10 #include "VssRay.h" 11 #include " VspOspTree.h"11 #include "HierarchyManager.h" 12 12 #include "VssTree.h" 13 13 #include "VspBspTree.h"
Note: See TracChangeset
for help on using the changeset viewer.