Changeset 2113 for GTP/trunk/Lib
- Timestamp:
- 02/12/07 08:37:26 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 5 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h
r2111 r2113 122 122 list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 123 123 // find the bbox which is closest to the current bbox 124 for (sit = sceneNodeList.begin(); sit != s ceneNodeList.end(); ++ sit)124 for (sit = sceneNodeList.begin(); sit != sit_end; ++ sit) 125 125 { 126 126 SceneNode *sn = *sit; -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r2066 r2113 56 56 DUMMY_INTERSECTABLE, 57 57 ENGINE_INTERSECTABLE, 58 CONTAINER_INTERSECTABLE 58 59 }; 59 60 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
r2069 r2113 10 10 11 11 12 struct VssRayContainer;13 12 class KdNode; 14 //class BvhNode;15 13 class BvhLeaf; 16 14 class Ray; 17 15 class KdTree; 16 struct VssRayContainer; 17 struct Triangle3; 18 18 struct Face; 19 struct Triangle3; 20 21 class KdTree; 22 23 24 /** 25 Wrapper used for creating a PVS compliant intersectable. 19 20 /** Wrapper used for creating a PVS compliant intersectable. 26 21 */ 27 22 template<typename T> … … 219 214 220 215 216 /** Intersectable acting as a proxy. 217 */ 221 218 class DummyIntersectable: public IntersectableWrapper<int> 222 219 { 223 220 public: 224 225 IntersectableWrapper<int>(item) {}221 DummyIntersectable(const int item): 222 IntersectableWrapper<int>(item) {} 226 223 227 224 int Type() const … … 231 228 }; 232 229 230 231 /** Intersectable wrapping is a group of objects. 232 */ 233 class ContainerIntersectable: public GtpVisibilityPreprocessor::IntersectableWrapper<ObjectContainer *> 234 { 235 public: 236 ContainerIntersectable(ObjectContainer *item): 237 IntersectableWrapper<ObjectContainer *>(item) {} 238 239 // hack 240 ContainerIntersectable::~ContainerIntersectable() 241 { 242 delete mItem; 243 } 244 245 int Type() const 246 { 247 return Intersectable::CONTAINER_INTERSECTABLE; 248 } 249 }; 250 233 251 } 234 252 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r2066 r2113 413 413 414 414 void GetBoxIntersections(const AxisAlignedBox3 &box, 415 vector<KdLeaf *> &leaves);415 vector<KdLeaf *> &leaves); 416 416 417 417 int -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2111 r2113 733 733 cout << "loading view cells from " << buf << endl<<flush; 734 734 735 mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL); 735 mViewCellsManager = ViewCellsManager::LoadViewCells(buf, 736 mObjects, 737 mObjects, 738 true, 739 NULL); 736 740 737 741 cout << "view cells loaded." << endl<<flush; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r2100 r2113 518 518 </File> 519 519 <File 520 RelativePath=".\IntersectionBoundingBoxConverter.cpp"> 521 </File> 522 <File 523 RelativePath=".\IntersectionBoundingBoxConverter.h"> 524 </File> 525 <File 520 526 RelativePath="..\src\KdTree.cpp"> 521 527 </File> -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2105 r2113 1023 1023 1024 1024 ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename, 1025 ObjectContainer *objects, 1025 ObjectContainer &pvsObjects, 1026 ObjectContainer &preprocessorObjects, 1026 1027 bool finalizeViewCells, 1027 1028 BoundingBoxConverter *bconverter) … … 1032 1033 1033 1034 const long startTime = GetTime(); 1034 bool success = parser.ParseViewCellsFile(filename, &vm, objects, bconverter); 1035 1036 cout<<"viewcells parsed "<<endl<<flush; 1037 1038 if (success) 1039 { 1040 if (0) 1041 { 1042 vm->ResetViewCells(); 1043 } 1044 else 1045 { 1046 //hack: should work with reset function 1047 ViewCellContainer leaves; 1048 1049 vm->mViewCells.clear(); 1050 vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 1051 1052 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1053 1054 for (it = leaves.begin(); it != it_end; ++ it) 1055 { 1056 vm->mViewCells.push_back(*it); 1057 } 1058 } 1059 1060 vm->mViewCellsFinished = true; 1061 vm->mMaxPvsSize = (int)objects->size(); 1062 1063 1064 if (finalizeViewCells) 1065 { 1066 // create the meshes and compute volumes 1067 const bool createMeshes = true; 1068 //const bool createMeshes = false; 1069 1070 vm->FinalizeViewCells(createMeshes); 1071 } 1072 1073 cout << (int)vm->mViewCells.size() << " view cells loaded in " 1074 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 1075 1076 Debug << (int)vm->mViewCells.size() << " view cells loaded in " 1077 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 1078 } 1079 else 1035 const bool success = parser.ParseViewCellsFile(filename, 1036 &vm, 1037 pvsObjects, 1038 preprocessorObjects, 1039 bconverter); 1040 1041 if (!success) 1080 1042 { 1081 1043 Debug << "Error: loading view cells failed!" << endl; 1082 1044 DEL_PTR(vm); 1083 } 1084 1045 1046 return NULL; 1047 } 1048 1049 //cout << "viewcells parsed " <<endl; 1050 1051 if (0) 1052 { 1053 vm->ResetViewCells(); 1054 } 1055 else 1056 { 1057 //hack: should work with reset function 1058 ViewCellContainer leaves; 1059 1060 vm->mViewCells.clear(); 1061 vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 1062 1063 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1064 1065 for (it = leaves.begin(); it != it_end; ++ it) 1066 { 1067 vm->mViewCells.push_back(*it); 1068 } 1069 } 1070 1071 vm->mViewCellsFinished = true; 1072 vm->mMaxPvsSize = (int)pvsObjects.size(); 1073 1074 if (finalizeViewCells) 1075 { 1076 // create the meshes and compute volumes 1077 const bool createMeshes = true; 1078 //const bool createMeshes = false; 1079 1080 vm->FinalizeViewCells(createMeshes); 1081 } 1082 1083 cout << (int)vm->mViewCells.size() << " view cells loaded in " 1084 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 1085 1086 Debug << (int)vm->mViewCells.size() << " view cells loaded in " 1087 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 1088 1085 1089 return vm; 1086 1090 } … … 6781 6785 6782 6786 6783 ViewCellsManager *VspOspViewCellsManager::LoadViewCells(const string &filename, 6784 ObjectContainer *objects, 6785 const bool finalizeViewCells, 6786 BoundingBoxConverter *bconverter) 6787 6788 { 6789 ViewCellsManager *vm = 6790 ViewCellsManager::LoadViewCells(filename, objects, finalizeViewCells, bconverter); 6791 6792 return vm; 6793 } 6794 6795 6796 void 6797 VspOspViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 6787 void VspOspViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, 6788 ObjectContainer &objects) 6798 6789 { 6799 6790 mHierarchyManager->CollectObjects(box, objects); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2111 r2113 571 571 */ 572 572 static ViewCellsManager *LoadViewCells(const string &filename, 573 ObjectContainer *objects, 573 ObjectContainer &pvsObjects, 574 ObjectContainer &preprocessorObjects, 574 575 bool finalizeViewCells = false, 575 576 BoundingBoxConverter *bconverter = NULL); 576 577 577 578 578 /////////////////////// /////////////////////////////////7579 /////////////////////// 579 580 // visiblity filter options 580 581 … … 1212 1213 public: 1213 1214 1214 VspOspViewCellsManager(ViewCellsTree *vcTree, const string &hierarchyType); 1215 VspOspViewCellsManager(ViewCellsTree *vcTree, 1216 const string &hierarchyType); 1215 1217 1216 1218 ~VspOspViewCellsManager(); … … 1245 1247 float GetProbability(ViewCell *viewCell); 1246 1248 1247 ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const; 1249 ViewCell *GetViewCell(const Vector3 &point, 1250 const bool active = false) const; 1248 1251 1249 1252 bool GetViewPoint(Vector3 &viewPoint) const; … … 1260 1263 1261 1264 void Finalize(ViewCell *viewCell, const bool createMesh); 1262 1263 ViewCellsManager *LoadViewCells(const string &filename,1264 ObjectContainer *objects,1265 const bool finalizeViewCells,1266 BoundingBoxConverter *bconverter);1267 1265 1268 1266 void ExportSingleViewCells(const ObjectContainer &objects, -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r2097 r2113 5 5 #include <stdlib.h> 6 6 #include <iostream> 7 //#include <ext/algorithm> 8 7 9 using namespace std; 8 10 #include <xercesc/util/PlatformUtils.hpp> … … 76 78 // StdInParseHandlers: Constructors and Destructor 77 79 // --------------------------------------------------------------------------- 78 ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects, 79 BoundingBoxConverter *bconverter): 80 ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer &pvsObjects, 81 ObjectContainer &preprocessorObjects, 82 BoundingBoxConverter *bconverter 83 ): 80 84 mElementCount(0) 81 85 , mAttrCount(0) … … 92 96 , mCurrentOspNode(NULL) 93 97 , mCurrentBvhNode(NULL) 94 , mObjects(objects) 98 , mPvsObjects(pvsObjects) 99 , mPreprocessorObjects(preprocessorObjects) 95 100 , mBoundingBoxConverter(bconverter) 96 101 , mHierarchyManager(NULL) … … 98 103 , nObjects(0) 99 104 { 100 std::stable_sort(mObjects->begin(), mObjects->end(), ilt); 105 mCreatePvsObjects = mPvsObjects.empty(); 106 107 // sort objects so we can search in them 108 //if (!is_sorted(mPvsObjects.begin(), mPvsObjects.end(), ilt)) 109 sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 110 111 //if (!is_sorted(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt)) 112 sort(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt); 101 113 } 102 114 … … 165 177 // the objects with the leaves, they can be classified geometrically 166 178 mHierarchyManager->mOspTree-> 167 InsertObjects(mHierarchyManager->mOspTree->mRoot, *mObjects);179 InsertObjects(mHierarchyManager->mOspTree->mRoot, mPvsObjects); 168 180 } 169 181 } … … 278 290 // associate object ids with bounding boxes 279 291 const long startTime = GetTime(); 280 Debug<<"here32232"<<endl;292 281 293 if (mBoundingBoxConverter) 282 { Debug<<"here3772"<<endl;283 mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects);294 { 295 mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, mPvsObjects); 284 296 } 285 297 … … 394 406 395 407 396 void ViewCellsParseHandlers:: ExchangePvs(ViewCell *vc)408 void ViewCellsParseHandlers::ReplaceBvhPvs(ViewCell *vc) 397 409 { 398 410 //cout << "exchanging pvs" << endl; … … 404 416 405 417 ObjectContainer oldIntersectables; 418 406 419 // output PVS of view cell 407 420 while (pit.HasMoreEntries()) … … 454 467 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 455 468 { 456 ExchangePvs(*vit);469 ReplaceBvhPvs(*vit); 457 470 } 458 471 } … … 486 499 { 487 500 cout << "\nparsing view cells" << endl; 501 Debug << "\nparsing view cells" << endl; 488 502 489 503 mCurrentState = PARSE_VIEWCELLS; … … 496 510 if (element == "ViewSpaceHierarchy") 497 511 { 512 Debug << "\nparsing view space hierarchy" << endl; 498 513 cout << "\nparsing view space hierarchy" << endl; 499 514 mCurrentState = PARSE_VIEWSPACE_HIERARCHY; … … 505 520 { 506 521 cout << "\nparsing object space hierarchy" << endl; 522 Debug << "\nparsing object space hierarchy" << endl; 523 507 524 mCurrentState = PARSE_OBJECTSPACE_HIERARCHY; 508 525 StartObjectSpaceHierarchy(attributes); … … 574 591 575 592 ObjectContainer::iterator oit = 576 lower_bound(m Objects->begin(),577 m Objects->end(),593 lower_bound(mPvsObjects.begin(), 594 mPvsObjects.end(), 578 595 (Intersectable *)&dummyInst, ilt); 579 596 580 if ((oit != m Objects->end()) && ((*oit)->GetId() == objId))597 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 581 598 { 582 599 // $$JB we should store a float a per object which corresponds … … 669 686 //std::stable_sort(objects.begin(), objects.end(), ilt); 670 687 mHierarchyManager->mOspTree->mBoundingBox.Initialize(); 671 ObjectContainer::const_iterator oit, oit_end = m Objects->end();688 ObjectContainer::const_iterator oit, oit_end = mPvsObjects.end(); 672 689 673 690 //-- compute bounding box 674 for (oit = m Objects->begin(); oit != oit_end; ++ oit)691 for (oit = mPvsObjects.begin(); oit != oit_end; ++ oit) 675 692 { 676 693 Intersectable *obj = *oit; … … 1324 1341 1325 1342 ObjectContainer::iterator oit = 1326 lower_bound(m Objects->begin(),1327 m Objects->end(),1343 lower_bound(mPvsObjects.begin(), 1344 mPvsObjects.end(), 1328 1345 (Intersectable *)&dummyInst, 1329 1346 ilt); 1330 1347 1331 if ((oit != m Objects->end()) && ((*oit)->GetId() == objId))1348 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 1332 1349 { 1333 1350 objects.push_back(*oit); 1351 Debug << "x"; 1334 1352 } 1335 1353 else 1336 1354 { 1337 cerr << "StartBvhLeafObjects error: object with id " << objId << " does not exist" << endl; 1355 Debug << "y"; 1356 //cerr << "StartBvhLeafObjects error: object with id " << objId << " does not exist" << endl; 1338 1357 } 1339 1358 } … … 1412 1431 1413 1432 1414 bool ViewCellsParser::ParseViewCellsFile(const string filename,1433 bool ViewCellsParser::ParseViewCellsFile(const string &filename, 1415 1434 ViewCellsManager **viewCells, 1416 ObjectContainer *objects, 1435 ObjectContainer &pvsObjects, 1436 ObjectContainer &preprocessorObjects, 1417 1437 BoundingBoxConverter *bconverter) 1418 1438 { … … 1448 1468 // to do. 1449 1469 // 1450 ViewCellsParseHandlers handler( objects, bconverter);1470 ViewCellsParseHandlers handler(pvsObjects, preprocessorObjects, bconverter); 1451 1471 parser->setDocumentHandler(&handler); 1452 1472 parser->setErrorHandler(&handler); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h
r1344 r2113 17 17 ViewCellsParser():Parser() {} 18 18 19 bool ParseViewCellsFile( 20 const string filename,21 ViewCellsManager **viewCells,22 ObjectContainer *objects,23 BoundingBoxConverter *bconverter);19 bool ParseViewCellsFile(const string &filename, 20 ViewCellsManager **viewCells, 21 ObjectContainer &pvsObjects, 22 ObjectContainer &preprocessorObjects, 23 BoundingBoxConverter *bconverter); 24 24 }; 25 25 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r2093 r2113 35 35 // Constructors and Destructor 36 36 // ----------------------------------------------------------------------- 37 ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter); 37 ViewCellsParseHandlers(ObjectContainer &pvsObjects, 38 ObjectContainer &preprocessorObjects, 39 BoundingBoxConverter *bconverter); 38 40 ~ViewCellsParseHandlers(); 39 41 … … 74 76 void CreateViewCellsManager(/*const char *name*/); 75 77 76 void ExchangeElements();77 void ExchangePvs(ViewCell *vc);78 void ReplacePvs(); 79 void ReplaceBvhPvs(ViewCell *vc); 78 80 79 81 … … 97 99 VspNode *mVspRoot; 98 100 ViewCell *mViewCellRoot; 99 int mUniqueObjectId; 101 102 int mUniqueObjectId; 100 103 vector<BvhLeaf *> mBvhLeaves; 101 104 //typedef map<int, ViewCell *> ViewCellsMap; … … 104 107 105 108 ViewCellsManager *mViewCellsManager; 106 ObjectContainer *mObjects; 109 110 ObjectContainer &mPvsObjects; 111 ObjectContainer &mPreprocessorObjects; 112 113 bool mCreatePvsObjects; 114 107 115 BoundingBoxConverter *mBoundingBoxConverter; 108 116 AxisAlignedBox3 mViewSpaceBox;
Note: See TracChangeset
for help on using the changeset viewer.