Changeset 2114 for GTP/trunk/Lib/Vis
- Timestamp:
- 02/12/07 09:05:33 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp
r2067 r2114 1325 1325 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1326 1326 BvhBoundingBoxConverter bconverter(this); 1327 1327 GtpVisibilityPreprocessor::ObjectContainer dummys; 1328 1328 // load the view cells and assigns the objects in the pvs to 1329 1329 // the scene objects using the bounding boxes 1330 1330 mViewCellsManager = 1331 1331 GtpVisibilityPreprocessor::ViewCellsManager:: 1332 LoadViewCells(filename, &mObjects, false, &bconverter);1332 LoadViewCells(filename, mObjects, dummys, false, &bconverter); 1333 1333 1334 1334 return (mViewCellsManager != NULL); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r2097 r2114 1325 1325 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 1326 1326 KdTreeBoundingBoxConverter bconverter(this); 1327 1327 GtpVisibilityPreprocessor::ObjectContainer dummys; 1328 1328 // load the view cells assigning the found objects to the pvss 1329 1329 mViewCellsManager = 1330 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, false, &bconverter); 1330 GtpVisibilityPreprocessor::ViewCellsManager:: 1331 LoadViewCells(filename, mObjects, dummys, false, &bconverter); 1331 1332 1332 1333 return (mViewCellsManager != NULL); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r2108 r2114 1459 1459 const bool finalizeViewCells = false; 1460 1460 1461 mViewCellsManager = GtpVisibilityPreprocessor::1462 ViewCellsManager::LoadViewCells(filename,1463 &mObjects,1464 true,1465 1461 GtpVisibilityPreprocessor::ObjectContainer dummys; 1462 // load the view cells assigning the found objects to the pvss 1463 mViewCellsManager = 1464 GtpVisibilityPreprocessor::ViewCellsManager:: 1465 LoadViewCells(filename, mObjects, dummys, false, &bconverter); 1466 1466 1467 1467 Ogre::LogManager::getSingleton().logMessage("******** view cells loaded *********"); -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.cpp
r2113 r2114 458 458 459 459 460 void ViewCellsParseHandlers:: ExchangeElements()460 void ViewCellsParseHandlers::ReplacePvs() 461 461 { 462 462 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); … … 1497 1497 1498 1498 if (1 && PVS_HACK) 1499 handler. ExchangeElements();1499 handler.ReplacePvs(); 1500 1500 1501 1501 const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h
r2113 r2114 29 29 30 30 31 class ViewCellsParseHandlers: public HandlerBase31 class ObjectsParseHandlers: public HandlerBase 32 32 { 33 33 public: … … 35 35 // Constructors and Destructor 36 36 // ----------------------------------------------------------------------- 37 ViewCellsParseHandlers(ObjectContainer &pvsObjects,37 ObjectsParseHandlers(ObjectContainer &pvsObjects, 38 38 ObjectContainer &preprocessorObjects, 39 39 BoundingBoxConverter *bconverter); 40 ~ ViewCellsParseHandlers();40 ~ObjectsParseHandlers(); 41 41 42 42 … … 74 74 void resetDocument(); 75 75 76 void CreateViewCellsManager(/*const char *name*/);77 78 void ReplacePvs();79 void ReplaceBvhPvs(ViewCell *vc);80 81 82 76 ///////////////////////// 83 77 84 VspBspTree *mVspBspTree;85 HierarchyManager *mHierarchyManager;86 87 BspTree *mBspTree;88 ViewCellsTree *mViewCellsTree;89 VspTree *mVspTree;90 91 BspNode *mCurrentBspNode;92 BvhNode *mCurrentBvhNode;93 KdNode *mCurrentOspNode;94 VspNode *mCurrentVspNode;95 96 ViewCell *mCurrentViewCell;97 98 BspNode *mBspRoot;99 VspNode *mVspRoot;100 ViewCell *mViewCellRoot;101 102 78 int mUniqueObjectId; 103 79 vector<BvhLeaf *> mBvhLeaves; 104 //typedef map<int, ViewCell *> ViewCellsMap;105 //ViewCellsMap mViewCells;106 ViewCellContainer mViewCells;107 108 ViewCellsManager *mViewCellsManager;109 110 ObjectContainer &mPvsObjects;111 80 ObjectContainer &mPreprocessorObjects; 112 81 113 bool mCreatePvsObjects;114 115 BoundingBoxConverter *mBoundingBoxConverter;116 AxisAlignedBox3 mViewSpaceBox;117 IndexedBoundingBoxContainer mIBoundingBoxes;118 119 82 /// current state of the parser 120 83 int mCurrentState; 121 84 122 enum { 123 PARSE_OPTIONS, 124 PARSE_VIEWCELLS, 125 PARSE_VIEWSPACE_HIERARCHY, 126 PARSE_OBJECTSPACE_HIERARCHY}; 127 128 /// view space / object space hierarchy types 129 enum {BSP, VSP, OSP, BVH}; 85 enum {, BVH}; 130 86 131 87 int mViewSpaceHierarchyType; … … 140 96 // Handlers for X3D 141 97 142 void StartBspLeaf(AttributeList& attributes);143 void StartBspInterior(AttributeList& attributes);144 void EndBspInterior();145 146 void StartVspLeaf(AttributeList& attributes);147 void StartVspInterior(AttributeList& attributes);148 void EndVspInterior();149 150 void StartViewCellPvs(ObjectPvs &pvs, const char *ptr);151 152 void EndViewCells();153 void EndBoundingBoxes();154 155 void StartBspElement(string element, AttributeList& attributes);156 void StartVspElement(string element, AttributeList& attributes);157 158 void StartViewSpaceHierarchy(AttributeList& attributes);159 98 void StartObjectSpaceHierarchy(AttributeList& attributes); 160 99 161 void StartBoundingBox(AttributeList& attributes);162 void StartViewCell(AttributeList& attributes, const bool isLeaf);163 void EndViewCellInterior();164 165 void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);166 100 void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes); 167 void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);168 169 void StartOspElement(string element, AttributeList& attributes);170 171 void StartOspLeaf(AttributeList& attributes);172 void StartOspInterior(AttributeList& attributes);173 174 void CreateViewSpaceHierarchy();175 101 176 102 void StartBvhLeaf(AttributeList& attributes); … … 178 104 void StartBvhElement(string element, AttributeList& attributes); 179 105 180 void EndViewSpaceHierarchyInterior();181 106 void EndObjectSpaceHierarchyInterior(); 182 107 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r2113 r2114 103 103 , nObjects(0) 104 104 { 105 // pvs objects empty => have to create new ones 105 106 mCreatePvsObjects = mPvsObjects.empty(); 106 107 … … 278 279 { 279 280 // sort view cells to help associating view cells according to their id 280 s table_sort(mViewCells.begin(), mViewCells.end(), vlt);281 sort(mViewCells.begin(), mViewCells.end(), vlt); 281 282 282 283 // not parsing view cells anymore … … 287 288 void ViewCellsParseHandlers::EndBoundingBoxes() 288 289 { 289 // all bounding boxes gathered in this step =>290 // associate object ids with bounding boxes291 290 const long startTime = GetTime(); 292 291 293 292 if (mBoundingBoxConverter) 294 293 { 294 // all bounding boxes gathered in this step => 295 // associate object ids with bounding boxes 295 296 mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, mPvsObjects); 296 297 } … … 458 459 459 460 460 void ViewCellsParseHandlers::ExchangeElements() 461 { 461 void ViewCellsParseHandlers::ReplacePvs() 462 { 463 // sort the pvs entries 464 sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 465 462 466 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 463 467 464 sort(mBvhLeaves.begin(), mBvhLeaves.end(), ilt);465 466 468 //cout << "viewcells : " << mViewCells.size() << endl; 467 469 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) … … 583 585 for (it = objIndices.begin(); it != it_end; ++ it) 584 586 { 585 #if PVS_HACK 586 //cout << "u"; 587 pvs.AddSample(new DummyIntersectable(*it), 1); 588 #else 589 const int objId = *it; 590 dummyInst.SetId(objId); 591 592 ObjectContainer::iterator oit = 587 if (mCreatePvsObjects) 588 { 589 // pvs entries will be created => just use dummy proxy 590 pvs.AddSample(new DummyIntersectable(*it), 1); 591 } 592 else 593 { 594 const int objId = *it; 595 dummyInst.SetId(objId); 596 597 ObjectContainer::iterator oit = 593 598 lower_bound(mPvsObjects.begin(), 594 599 mPvsObjects.end(), 595 600 (Intersectable *)&dummyInst, ilt); 596 601 597 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 598 { 599 // $$JB we should store a float a per object which corresponds 600 // to sumof pdfs, i.e. its relative visibility 601 // temporarily set to 1.0f 602 pvs.AddSample(*oit, 1.0f); 603 //Debug << "y"; 604 } 605 else 606 { 607 Debug << "x"; 608 //Debug << "StartViewCellPvs error: object with id " << objId << " does not exist" << endl; 609 } 610 #endif 602 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 603 { 604 // $$JB we should store a float a per object which corresponds 605 // to sumof pdfs, i.e. its relative visibility 606 // temporarily set to 1.0f 607 pvs.AddSample(*oit, 1.0f); 608 } 609 else 610 { 611 //Debug << "x"; 612 //Debug << "StartViewCellPvs error: object with id " << objId << " does not exist" << endl; 613 } 614 } 611 615 } 612 616 } … … 1306 1310 BvHierarchy::AssociateObjectsWithLeaf(leaf); 1307 1311 1308 if ( PVS_HACK)1309 { 1310 if (0) // Temp matt:should already have right id1311 1312 if (mCreatePvsObjects) 1313 { 1314 // Temp matt: leaves should already have right id 1315 if (0) leaf->SetId((int)mBvhLeaves.size()); 1312 1316 1313 m BvhLeaves.push_back(leaf);1317 mPvsObjects.push_back(leaf); 1314 1318 } 1315 1319 } … … 1437 1441 BoundingBoxConverter *bconverter) 1438 1442 { 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 {1486 const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();1443 // Initialize the XML4C system 1444 try { 1445 XMLPlatformUtils::Initialize(); 1446 } 1447 1448 catch (const XMLException& toCatch) 1449 { 1450 XERCES_STD_QUALIFIER cerr << "Error during initialization! Message:\n" 1451 << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; 1452 return false; 1453 } 1454 1455 // cout<<"parsing started"<<endl<<flush; 1456 1457 // 1458 // Create a SAX parser object. Then, according to what we were told on 1459 // the command line, set the options. 1460 // 1461 SAXParser* parser = new SAXParser; 1462 parser->setValidationScheme(valScheme); 1463 parser->setDoNamespaces(doNamespaces); 1464 parser->setDoSchema(doSchema); 1465 parser->setValidationSchemaFullChecking(schemaFullChecking); 1466 1467 1468 // 1469 // Create our SAX handler object and install it on the parser, as the 1470 // document and error handler. We are responsible for cleaning them 1471 // up, but since its just stack based here, there's nothing special 1472 // to do. 1473 // 1474 ViewCellsParseHandlers handler(pvsObjects, preprocessorObjects, bconverter); 1475 parser->setDocumentHandler(&handler); 1476 parser->setErrorHandler(&handler); 1477 1478 unsigned long duration; 1479 int errorCount = 0; 1480 // create a faux scope so that 'src' destructor is called before 1481 // XMLPlatformUtils::Terminate 1482 { 1483 // 1484 // Kick off the parse and catch any exceptions. Create a standard 1485 // input input source and tell the parser to parse from that. 1486 // 1487 // StdInInputSource src; 1488 try 1489 { 1490 const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); 1487 1491 1488 1492 #if USE_GZLIB 1489 XMLCh *myFilePath = XMLString::transcode(filename.c_str());1490 1491 GzFileInputSource isource(myFilePath);1492 parser->parse(isource);1493 XMLCh *myFilePath = XMLString::transcode(filename.c_str()); 1494 1495 GzFileInputSource isource(myFilePath); 1496 parser->parse(isource); 1493 1497 #else 1494 parser->parse(filename.c_str());1498 parser->parse(filename.c_str()); 1495 1499 1496 1500 #endif 1497 1501 1498 if (1 && PVS_HACK)1499 handler.ExchangeElements();1500 1501 const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();1502 duration = endMillis - startMillis;1503 errorCount = parser->getErrorCount();1504 1505 1506 1507 XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl;1508 errorCount = 2;1509 return false;1510 1511 1512 1502 //if (mCreatePvsObjects) 1503 // handler.ReplacePvs(); 1504 1505 const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); 1506 duration = endMillis - startMillis; 1507 errorCount = parser->getErrorCount(); 1508 } 1509 catch (const OutOfMemoryException&) 1510 { 1511 XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl; 1512 errorCount = 2; 1513 return false; 1514 } 1515 catch (const XMLException& e) 1516 { 1513 1517 XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 1514 1515 1518 << StrX(e.getMessage()) 1519 << "\n" << XERCES_STD_QUALIFIER endl; 1516 1520 errorCount = 1; 1517 1521 return false; 1518 } 1519 1520 1521 // Print out the stats that we collected and time taken 1522 if (!errorCount) { 1523 XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 1522 } 1523 1524 1525 // Print out the stats that we collected and time taken 1526 if (!errorCount) 1527 { 1528 XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 1524 1529 << handler.GetElementCount() << " elems, " 1525 1530 << handler.GetAttrCount() << " attrs, " 1526 1531 << handler.GetSpaceCount() << " spaces, " 1527 1532 << handler.GetCharacterCount() << " chars)" << XERCES_STD_QUALIFIER endl; 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 } 1547 1548 } 1533 } 1534 } 1535 1536 cout<<"parsed - will delete the parser"<<endl<<flush; 1537 // 1538 // Delete the parser itself. Must be done prior to calling Terminate, below. 1539 // 1540 delete parser; 1541 1542 XMLPlatformUtils::Terminate(); 1543 1544 //-- assign new view cells manager 1545 *viewCells = handler.mViewCellsManager; 1546 1547 if (errorCount > 0) 1548 return false; 1549 else 1550 return true; 1551 } 1552 1553 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h
r2113 r2114 12 12 class Environment; 13 13 14 class ViewCellsParser 14 class ViewCellsParser: public Parser 15 15 { 16 16 public: 17 ViewCellsParser(): Parser() {}17 ViewCellsParser(): Parser() {} 18 18 19 19 bool ParseViewCellsFile(const string &filename, -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r2113 r2114 124 124 PARSE_VIEWCELLS, 125 125 PARSE_VIEWSPACE_HIERARCHY, 126 PARSE_OBJECTSPACE_HIERARCHY}; 126 PARSE_OBJECTSPACE_HIERARCHY 127 }; 127 128 128 129 /// view space / object space hierarchy types
Note: See TracChangeset
for help on using the changeset viewer.