Changeset 2114


Ignore:
Timestamp:
02/12/07 09:05:33 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp

    r2067 r2114  
    13251325        GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 
    13261326        BvhBoundingBoxConverter bconverter(this); 
    1327  
     1327GtpVisibilityPreprocessor::ObjectContainer dummys; 
    13281328        // load the view cells and assigns the objects in the pvs to  
    13291329        // the scene objects using the bounding boxes 
    13301330        mViewCellsManager =  
    13311331                GtpVisibilityPreprocessor::ViewCellsManager:: 
    1332                 LoadViewCells(filename, &mObjects, false, &bconverter); 
     1332                LoadViewCells(filename, mObjects, dummys, false, &bconverter); 
    13331333 
    13341334        return (mViewCellsManager != NULL); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp

    r2097 r2114  
    13251325        GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 
    13261326        KdTreeBoundingBoxConverter bconverter(this); 
    1327  
     1327GtpVisibilityPreprocessor::ObjectContainer dummys; 
    13281328        // load the view cells assigning the found objects to the pvss 
    13291329        mViewCellsManager =  
    1330                 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, false, &bconverter); 
     1330                GtpVisibilityPreprocessor::ViewCellsManager:: 
     1331                        LoadViewCells(filename, mObjects, dummys, false, &bconverter); 
    13311332 
    13321333        return (mViewCellsManager != NULL); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r2108 r2114  
    14591459        const bool finalizeViewCells = false; 
    14601460 
    1461         mViewCellsManager = GtpVisibilityPreprocessor:: 
    1462                 ViewCellsManager::LoadViewCells(filename,  
    1463                                                                                 &mObjects,  
    1464                                                                                 true,  
    1465                                                                                 &bconverter); 
     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); 
    14661466         
    14671467        Ogre::LogManager::getSingleton().logMessage("******** view cells loaded *********"); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParser.cpp

    r2113 r2114  
    458458 
    459459 
    460 void ViewCellsParseHandlers::ExchangeElements() 
     460void ViewCellsParseHandlers::ReplacePvs() 
    461461{ 
    462462        ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
     
    14971497 
    14981498        if (1 && PVS_HACK) 
    1499                 handler.ExchangeElements(); 
     1499                handler.ReplacePvs(); 
    15001500 
    15011501        const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h

    r2113 r2114  
    2929 
    3030 
    31 class ViewCellsParseHandlers: public HandlerBase 
     31class ObjectsParseHandlers: public HandlerBase 
    3232{ 
    3333public: 
     
    3535  //  Constructors and Destructor 
    3636  // ----------------------------------------------------------------------- 
    37   ViewCellsParseHandlers(ObjectContainer &pvsObjects,  
     37  ObjectsParseHandlers(ObjectContainer &pvsObjects,  
    3838                                                 ObjectContainer &preprocessorObjects,  
    3939                                                 BoundingBoxConverter *bconverter); 
    40   ~ViewCellsParseHandlers(); 
     40  ~ObjectsParseHandlers(); 
    4141   
    4242   
     
    7474  void resetDocument(); 
    7575 
    76   void CreateViewCellsManager(/*const char *name*/); 
    77  
    78   void ReplacePvs(); 
    79   void ReplaceBvhPvs(ViewCell *vc); 
    80  
    81  
    8276  ///////////////////////// 
    8377 
    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    
    10278  int mUniqueObjectId; 
    10379  vector<BvhLeaf *> mBvhLeaves; 
    104   //typedef map<int, ViewCell *> ViewCellsMap; 
    105   //ViewCellsMap mViewCells; 
    106   ViewCellContainer mViewCells; 
    107  
    108   ViewCellsManager *mViewCellsManager; 
    109  
    110   ObjectContainer &mPvsObjects; 
    11180  ObjectContainer &mPreprocessorObjects; 
    11281 
    113   bool mCreatePvsObjects; 
    114  
    115   BoundingBoxConverter *mBoundingBoxConverter; 
    116   AxisAlignedBox3 mViewSpaceBox; 
    117   IndexedBoundingBoxContainer mIBoundingBoxes; 
    118   
    11982  /// current state of the parser 
    12083  int mCurrentState; 
    12184   
    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}; 
    13086 
    13187  int mViewSpaceHierarchyType; 
     
    14096  // Handlers for X3D 
    14197   
    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); 
    15998  void StartObjectSpaceHierarchy(AttributeList& attributes); 
    16099 
    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); 
    166100  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(); 
    175101 
    176102  void StartBvhLeaf(AttributeList& attributes); 
     
    178104  void StartBvhElement(string element, AttributeList& attributes); 
    179105 
    180   void EndViewSpaceHierarchyInterior(); 
    181106  void EndObjectSpaceHierarchyInterior(); 
    182107 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r2113 r2114  
    103103  , nObjects(0) 
    104104{ 
     105        // pvs objects empty => have to create new ones 
    105106        mCreatePvsObjects = mPvsObjects.empty(); 
    106107 
     
    278279{ 
    279280        // sort view cells to help associating view cells according to their id 
    280         stable_sort(mViewCells.begin(), mViewCells.end(), vlt); 
     281        sort(mViewCells.begin(), mViewCells.end(), vlt); 
    281282 
    282283        // not parsing view cells anymore 
     
    287288void ViewCellsParseHandlers::EndBoundingBoxes() 
    288289{ 
    289         // all bounding boxes gathered in this step =>  
    290         // associate object ids with bounding boxes 
    291290        const long startTime = GetTime(); 
    292291         
    293292        if (mBoundingBoxConverter) 
    294293        { 
     294                // all bounding boxes gathered in this step =>  
     295                // associate object ids with bounding boxes 
    295296                mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, mPvsObjects); 
    296297        } 
     
    458459 
    459460 
    460 void ViewCellsParseHandlers::ExchangeElements() 
    461 { 
     461void ViewCellsParseHandlers::ReplacePvs() 
     462{ 
     463        // sort the pvs entries 
     464        sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 
     465 
    462466        ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
    463467         
    464         sort(mBvhLeaves.begin(), mBvhLeaves.end(), ilt); 
    465  
    466468        //cout << "viewcells : " << mViewCells.size() << endl; 
    467469        for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 
     
    583585        for (it = objIndices.begin(); it != it_end; ++ it) 
    584586        { 
    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 =  
    593598                                                                lower_bound(mPvsObjects.begin(),  
    594599                                                                                        mPvsObjects.end(),  
    595600                                                                                        (Intersectable *)&dummyInst, ilt);       
    596601 
    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                } 
    611615        } 
    612616} 
     
    13061310        BvHierarchy::AssociateObjectsWithLeaf(leaf); 
    13071311         
    1308         if (PVS_HACK) 
    1309         { 
    1310                 if (0) // Temp matt: should already have right id 
    1311                         leaf->SetId((int)mBvhLeaves.size()); 
     1312        if (mCreatePvsObjects) 
     1313        { 
     1314                // Temp matt: leaves should already have right id 
     1315                if (0) leaf->SetId((int)mBvhLeaves.size()); 
    13121316                 
    1313                 mBvhLeaves.push_back(leaf);      
     1317                mPvsObjects.push_back(leaf);     
    13141318        } 
    13151319} 
     
    14371441                                                                                 BoundingBoxConverter *bconverter) 
    14381442{ 
    1439   // Initialize the XML4C system 
    1440   try { 
    1441     XMLPlatformUtils::Initialize(); 
    1442   } 
    1443    
    1444   catch (const XMLException& toCatch) 
    1445     { 
    1446       XERCES_STD_QUALIFIER cerr << "Error during initialization! Message:\n" 
    1447                                 << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; 
    1448       return false; 
    1449     } 
    1450  
    1451   //  cout<<"parsing started"<<endl<<flush; 
    1452  
    1453   // 
    1454   //  Create a SAX parser object. Then, according to what we were told on 
    1455   //  the command line, set the options. 
    1456   // 
    1457   SAXParser* parser = new SAXParser; 
    1458   parser->setValidationScheme(valScheme); 
    1459   parser->setDoNamespaces(doNamespaces); 
    1460   parser->setDoSchema(doSchema); 
    1461   parser->setValidationSchemaFullChecking(schemaFullChecking); 
    1462    
    1463  
    1464   // 
    1465   //  Create our SAX handler object and install it on the parser, as the 
    1466   //  document and error handler. We are responsible for cleaning them 
    1467   //  up, but since its just stack based here, there's nothing special 
    1468   //  to do. 
    1469   // 
    1470   ViewCellsParseHandlers handler(pvsObjects, preprocessorObjects, bconverter); 
    1471   parser->setDocumentHandler(&handler); 
    1472   parser->setErrorHandler(&handler); 
    1473    
    1474   unsigned long duration; 
    1475   int errorCount = 0; 
    1476   // create a faux scope so that 'src' destructor is called before 
    1477   // XMLPlatformUtils::Terminate 
    1478   { 
    1479     // 
    1480     //  Kick off the parse and catch any exceptions. Create a standard 
    1481     //  input input source and tell the parser to parse from that. 
    1482     // 
    1483     //    StdInInputSource src; 
    1484     try 
    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(); 
    14871491 
    14881492#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); 
    14931497#else 
    1494         parser->parse(filename.c_str()); 
     1498                        parser->parse(filename.c_str()); 
    14951499 
    14961500#endif 
    14971501 
    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     catch (const OutOfMemoryException&) 
    1506       { 
    1507         XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl; 
    1508         errorCount = 2; 
    1509         return false; 
    1510       } 
    1511     catch (const XMLException& e) 
    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                { 
    15131517                        XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 
    1514                                   << StrX(e.getMessage()) 
    1515                                   << "\n" << XERCES_STD_QUALIFIER endl; 
     1518                                << StrX(e.getMessage()) 
     1519                                << "\n" << XERCES_STD_QUALIFIER endl; 
    15161520                        errorCount = 1; 
    15171521                        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 (" 
    15241529                                << handler.GetElementCount() << " elems, " 
    15251530                                << handler.GetAttrCount() << " attrs, " 
    15261531                                << handler.GetSpaceCount() << " spaces, " 
    15271532                                << handler.GetCharacterCount() << " chars)" << XERCES_STD_QUALIFIER endl; 
    1528     } 
    1529   } 
    1530  
    1531   cout<<"parsed - will delete the parser"<<endl<<flush; 
    1532   // 
    1533   //  Delete the parser itself.  Must be done prior to calling Terminate, below. 
    1534   // 
    1535   delete parser; 
    1536    
    1537   XMLPlatformUtils::Terminate(); 
    1538    
    1539   //-- assign new view cells manager 
    1540   *viewCells = handler.mViewCellsManager; 
    1541    
    1542   if (errorCount > 0) 
    1543     return false; 
    1544   else 
    1545     return true; 
    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  
    1212class Environment; 
    1313 
    14 class ViewCellsParser : public Parser 
     14class ViewCellsParser: public Parser 
    1515{ 
    1616public: 
    17   ViewCellsParser():Parser() {} 
     17  ViewCellsParser(): Parser() {} 
    1818   
    1919  bool ParseViewCellsFile(const string &filename,  
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r2113 r2114  
    124124          PARSE_VIEWCELLS,  
    125125          PARSE_VIEWSPACE_HIERARCHY,  
    126           PARSE_OBJECTSPACE_HIERARCHY}; 
     126          PARSE_OBJECTSPACE_HIERARCHY 
     127  }; 
    127128 
    128129  /// view space / object space hierarchy types 
Note: See TracChangeset for help on using the changeset viewer.