Changeset 575


Ignore:
Timestamp:
01/25/06 11:08:35 (18 years ago)
Author:
mattausch
Message:

changed view cell parser. warning, not working yet!!

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r574 r575  
    1313#;../data/vienna/vienna-plane.x3d 
    1414#       filename ../data/vienna/viewcells-25-sel.x3d 
    15 #       filename ../data/atlanta/atlanta2.x3d 
     15        filename ../data/atlanta/atlanta2.x3d 
    1616#       filename ../data/soda/soda.dat 
    17         filename ../data/soda/soda5.dat 
     17#       filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    2323        useGlRenderer false 
    2424#       type sampling 
    25         type vss 
    26 #       type rss 
    27         detectEmptyViewSpace true 
     25#       type vss 
     26        type rss 
     27        detectEmptyViewSpace false 
    2828} 
    2929 
     
    303303        Termination { 
    304304                # parameters used for autopartition 
    305                 minRays                 300 
     305                minRays                 150 
    306306                minPolygons             -1 
    307307                maxDepth                30 
     
    309309                #minProbability         0.0001 
    310310                minProbability          -1 
    311                 maxRayContribution      0.1 
     311                maxRayContribution      0.3 
    312312                maxCostRatio            0.9 
    313313                missTolerance           3 
    314314                #maxAccRayLength        100 
    315315                 
    316                 maxViewCells            5000 
     316                maxViewCells            50000 
    317317                 
    318318                # used for pvs criterium 
     
    335335        PostProcess { 
    336336                maxCostRatio 0.1 
    337                 minViewCells 110 
     337                minViewCells 5000 
    338338                useRaysForMerge false 
    339339                exportMergeStats false 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r574 r575  
    194194        environment->GetStringValue("ViewCells.type", viewCellsStr); 
    195195 
    196         int initialSamples = 0; 
    197          
    198         if (strcmp(viewCellsStr, "kdTree") == 0) 
    199         { 
    200                 mViewCellsManager = new KdViewCellsManager(mKdTree); 
    201         } 
    202         else if (strcmp(viewCellsStr, "bspTree") == 0) 
    203         { 
    204                 mBspTree = new BspTree(); 
    205  
    206                 Debug << "view cell type: Bsp" << endl; 
    207  
    208                 mViewCellsManager = new BspViewCellsManager(mBspTree); 
    209         } 
    210         else if (strcmp(viewCellsStr, "vspBspTree") == 0) 
    211         { 
    212                 mVspBspTree = new VspBspTree(); 
    213  
    214                 Debug << "view cell type: VspBsp" << endl; 
    215  
    216                 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
    217         } 
    218         else if (strcmp(viewCellsStr, "vspKdTree") == 0) 
    219         { 
    220                 mVspKdTree = new VspKdTree();            
    221          
    222                 mViewCellsManager = new VspKdViewCellsManager(mVspKdTree); 
    223         } 
    224         else if (strcmp(viewCellsStr, "sceneDependent") == 0) 
    225         { 
    226                 //TODO 
    227                 mBspTree = new BspTree(); 
    228  
    229                 Debug << "view cell type: Bsp" << endl; 
    230                  
    231                 mViewCellsManager = new BspViewCellsManager(mBspTree); 
    232         } 
    233         else 
    234         { 
    235                 cerr<<"Wrong view cells type" << viewCellsStr << endl; 
    236                 exit(1); 
    237         } 
     196        mViewCellsManager = CreateViewCellsManager(viewCellsStr); 
    238197 
    239198        float objRenderCost = 0, vcOverhead = 0, moveSpeed = 0; 
     
    272231 
    273232        return true; 
     233} 
     234 
     235 
     236ViewCellsManager *Preprocessor::CreateViewCellsManager(const char *name) 
     237{ 
     238        if (strcmp(name, "kdTree") == 0) 
     239        { 
     240                mViewCellsManager = new KdViewCellsManager(mKdTree); 
     241        } 
     242        else if (strcmp(name, "bspTree") == 0) 
     243        { 
     244                mBspTree = new BspTree(); 
     245 
     246                Debug << "view cell type: Bsp" << endl; 
     247 
     248                mViewCellsManager = new BspViewCellsManager(mBspTree); 
     249        } 
     250        else if (strcmp(name, "vspBspTree") == 0) 
     251        { 
     252                mVspBspTree = new VspBspTree(); 
     253 
     254                Debug << "view cell type: VspBsp" << endl; 
     255 
     256                mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
     257        } 
     258        else if (strcmp(name, "vspKdTree") == 0) 
     259        { 
     260                mVspKdTree = new VspKdTree();            
     261         
     262                mViewCellsManager = new VspKdViewCellsManager(mVspKdTree); 
     263        } 
     264        else if (strcmp(name, "sceneDependent") == 0) 
     265        { 
     266                //TODO 
     267                mBspTree = new BspTree(); 
     268 
     269                Debug << "view cell type: Bsp" << endl; 
     270                 
     271                mViewCellsManager = new BspViewCellsManager(mBspTree); 
     272        } 
     273        else 
     274        { 
     275                cerr<<"Wrong view cells type" << name << endl; 
     276                exit(1); 
     277        } 
     278 
     279        return mViewCellsManager; 
    274280} 
    275281 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r573 r575  
    121121          VssRayContainer &vssRays) {}; 
    122122 
     123  ViewCellsManager *CreateViewCellsManager(const char *name); 
     124 
    123125  /// scene graph loaded from file 
    124126  SceneGraph *mSceneGraph; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r574 r575  
    356356class BspTree  
    357357{ 
     358        friend class ViewCellsParseHandlers; 
     359 
    358360public: 
    359361         
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r574 r575  
    126126        //-- construction rays => we use uniform samples for this 
    127127        CastPassSamples(mInitialSamples,  
    128                                         Preprocessor::DIRECTION_BASED_DISTRIBUTION, 
    129                                         //Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION,  
     128                                        //Preprocessor::DIRECTION_BASED_DISTRIBUTION, 
     129                                        Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION,  
    130130                                        initialSamples); 
    131131         
     
    157157                                                Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 
    158158 
    159                 dirSamples = !dirSamples; // toggle sampling 
     159                dirSamples = !dirSamples; // toggle sampling method 
    160160                numSamples += CastPassSamples(mSamplesPerPass,  
    161161                                                                          samplingType, 
     
    26792679        mVspBspTree = new VspBspTree(); 
    26802680 
    2681         bool success = parser.ParseFile(filename, mVspBspTree, this, objects); 
     2681        bool success ;//= parser.ParseFile(filename, &this, objects); 
    26822682        mVspBspTree->RepairViewCellsLeafLists(); 
    26832683        mVspBspTree->mBox = GetViewSpaceBox(); 
     
    27642764        viewCell->SetArea(area); 
    27652765} 
     2766 
     2767 
     2768 
     2769ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 
     2770{ 
     2771        //TODO 
     2772        return NULL;// new VspBspViewCellsManager(); 
     2773} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r574 r575  
    688688}; 
    689689 
     690 
     691class ViewCellsManagerFactory 
     692{ 
     693 
     694public: 
     695 
     696        ViewCellsManager *Create(const string mName); 
     697 
     698}; 
     699 
    690700#endif 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParser.cpp

    r556 r575  
    6161//  StdInParseHandlers: Constructors and Destructor 
    6262// --------------------------------------------------------------------------- 
    63 ViewCellsParseHandlers::ViewCellsParseHandlers(VspBspTree *tree, 
    64                                                                                            ViewCellsManager *viewCells, 
     63ViewCellsParseHandlers::ViewCellsParseHandlers(ViewCellsManager **viewCells, 
    6564                                                                                           ObjectContainer *objects): 
    6665  mElementCount(0) 
     
    6968  , mSpaceCount(0) 
    7069{ 
    71         mVspBspTree = tree; 
    72         mCurrentNode = tree->GetRoot(); 
    73         mViewCellsManager = viewCells; 
    7470        mObjects = objects; 
    75 } 
     71        viewCells = &mViewCellsManager; 
     72        //mPreprocessor = preprocessor; 
     73} 
     74 
    7675 
    7776ViewCellsParseHandlers::~ViewCellsParseHandlers() 
     
    9089  string element(lname.LocalForm()); 
    9190  if (element == "Interior") 
    92           EndInterior(); 
     91          EndBspInterior(); 
    9392  if (element == "ViewCells") 
    9493          EndViewCells(); 
     
    9695 
    9796 
    98 void ViewCellsParseHandlers::EndInterior() 
     97void ViewCellsParseHandlers::EndBspInterior() 
    9998{ 
    10099        // go one up in the tree 
     
    114113void ViewCellsParseHandlers::EndViewCells() 
    115114{ 
    116         // sort view cells for easily finding id 
     115        // sort view cells to help associating view cells according to their id 
    117116        stable_sort(mViewCells.begin(), mViewCells.end(), vlt); 
     117} 
     118 
     119 
     120 
     121void ViewCellsParseHandlers::StartHierarchy(AttributeList&  attributes) 
     122{ 
     123        int len = attributes.getLength(); 
     124   
     125        for (int i = 0; i < len; ++ i)  
     126        { 
     127                string attrName(StrX(attributes.getName(i)).LocalForm()); 
     128                 
     129                if (attrName == "name")  
     130                { 
     131                        StrX attrValue(attributes.getValue(i)); 
     132                         
     133                        const char *ptr = attrValue.LocalForm(); 
     134                         
     135                        CreateViewCellsManager(ptr); 
     136                } 
     137        } 
     138} 
     139 
     140 
     141void ViewCellsParseHandlers::startBspElement(string element, 
     142                                                                                         AttributeList& attributes) 
     143{ 
     144        if (element == "ViewCell") 
     145        { 
     146                cout << "v"; 
     147                StartViewCell(attributes); 
     148        } 
     149 
     150        if (element == "Interior")  
     151        { 
     152                cout << "["; 
     153                StartBspInterior(attributes); 
     154        } 
     155 
     156        if (element == "Leaf")  
     157        { 
     158                StartBspLeaf(attributes); 
     159        } 
    118160} 
    119161 
     
    125167        string element(lname.LocalForm()); 
    126168         
    127         if (element == "ViewCell") 
    128         { 
    129                 cout << "v"; 
    130                 StartViewCell(attributes); 
    131         } 
    132  
    133         if (element == "Interior")  
    134         { 
    135                 cout << "["; 
    136                 StartInterior(attributes); 
    137         } 
    138  
    139         if (element == "Leaf")  
    140         { 
    141                 StartLeaf(attributes); 
    142         } 
    143  
     169        if (element == "Hierarchy") 
     170        { 
     171                cout << "h"; 
     172                StartHierarchy(attributes); 
     173        } 
     174 
     175        switch (mViewCellsManager->GetType()) 
     176        { 
     177        case ViewCellsManager::BSP: 
     178        case ViewCellsManager::VSP_BSP: 
     179                startBspElement(element, attributes); 
     180                break; 
     181         
     182        default: 
     183                Debug << "not implemented" << endl; 
     184                break; 
     185 
     186        } 
     187         
    144188        ++ mElementCount; 
    145189        mAttrCount += attributes.getLength(); 
     
    228272 
    229273 
    230 void ViewCellsParseHandlers::StartLeaf(AttributeList& attributes) 
     274void ViewCellsParseHandlers::StartBspLeaf(AttributeList& attributes) 
    231275{ 
    232276        BspLeaf * leaf =  
     
    239283        else 
    240284        { 
    241                 mVspBspTree->mRoot = leaf; 
     285                if (mViewCellsManager->GetType() == ViewCellsManager::BSP) 
     286                        mBspTree->mRoot = leaf; 
     287                else 
     288                        mVspBspTree->mRoot = leaf; 
    242289        } 
    243290 
     
    282329        else 
    283330        { 
    284                 leaf->SetViewCell(mVspBspTree->GetOrCreateOutOfBoundsCell()); 
    285                 leaf->SetTreeValid(false); 
    286                 mVspBspTree->PropagateUpValidity(leaf); 
    287         } 
    288 } 
    289  
    290  
    291 void ViewCellsParseHandlers::StartInterior(AttributeList& attributes) 
     331                if (mViewCellsManager->GetType() == ViewCellsManager::VSP_BSP) 
     332                { 
     333                        leaf->SetViewCell(mVspBspTree->GetOrCreateOutOfBoundsCell()); 
     334                        leaf->SetTreeValid(false); 
     335                        mVspBspTree->PropagateUpValidity(leaf); 
     336                } 
     337        } 
     338} 
     339 
     340 
     341void ViewCellsParseHandlers::StartBspInterior(AttributeList& attributes) 
    292342{ 
    293343        Plane3 plane; 
     
    318368        else 
    319369        { 
    320                 mVspBspTree->mRoot = interior; 
     370                if (mViewCellsManager->GetType() == ViewCellsManager::BSP) 
     371                        mBspTree->mRoot = interior; 
     372                else 
     373                        mVspBspTree->mRoot = interior; 
    321374        } 
    322375 
    323376        mCurrentNode = interior; 
     377} 
     378 
     379 
     380 
     381void ViewCellsParseHandlers::CreateViewCellsManager(const char *name) 
     382{ 
     383         
     384        if (strcmp(name, "bspTree") == 0) 
     385        { 
     386                mBspTree = new BspTree(); 
     387 
     388                Debug << "view cell type: Bsp" << endl; 
     389 
     390                mCurrentNode = mBspTree->GetRoot(); 
     391 
     392                mViewCellsManager = new BspViewCellsManager(mBspTree); 
     393        } 
     394        else if (strcmp(name, "vspBspTree") == 0) 
     395        { 
     396                mVspBspTree = new VspBspTree(); 
     397 
     398                Debug << "view cell type: VspBsp" << endl; 
     399                mCurrentNode = mVspBspTree->GetRoot(); 
     400 
     401                mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
     402        } 
     403        /*else if (strcmp(name, "vspKdTree") == 0) 
     404        { 
     405                mVspKdTree = new VspKdTree();            
     406         
     407                mViewCellsManager = VspKdViewCellsManager(mVspKdTree); 
     408        }*/ 
     409        else 
     410        { 
     411                cerr<<"Wrong view cells type" << name << endl; 
     412                exit(1); 
     413        } 
    324414} 
    325415 
     
    380470 
    381471bool ViewCellsParser::ParseFile(const string filename,  
    382                                                                 VspBspTree *tree, 
    383                                                                 ViewCellsManager *viewCells, 
     472                                                                ViewCellsManager **viewCells, 
    384473                                                                ObjectContainer *objects) 
    385474{ 
     
    414503  //  to do. 
    415504  // 
    416   ViewCellsParseHandlers handler(tree, viewCells, objects); 
     505  ViewCellsParseHandlers handler(viewCells, objects); 
    417506  parser->setDocumentHandler(&handler); 
    418507  parser->setErrorHandler(&handler); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParser.h

    r508 r575  
    1515  //bool ParseFile(const string filename, ViewCellsManager &viewCells); 
    1616  bool ParseFile(const string filename,  
    17                                  VspBspTree *tree,  
    18                                  ViewCellsManager *viewCells, 
     17                                 ViewCellsManager **viewCells, 
    1918                                 ObjectContainer *objects); 
    2019}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParserXerces.h

    r508 r575  
    1414 
    1515class VspBspTree; 
     16class BspTree; 
    1617class ViewCellsManager; 
    1718 
     
    2223  //  Constructors and Destructor 
    2324  // ----------------------------------------------------------------------- 
    24   ViewCellsParseHandlers(VspBspTree *tree,  
    25                                                  ViewCellsManager *viewCellsManager, 
     25  ViewCellsParseHandlers(ViewCellsManager **viewCellsManager, 
    2626                                                 ObjectContainer *objects); 
    2727  ~ViewCellsParseHandlers(); 
     
    6161  void resetDocument(); 
    6262 
     63  void CreateViewCellsManager(const char *name); 
     64 
     65 
    6366  VspBspTree *mVspBspTree; 
     67  BspTree *mBspTree; 
     68   
    6469  BspNode *mCurrentNode; 
    6570  ViewCellContainer mViewCells; 
     
    6873 
    6974  // Handlers for X3D 
    70   void StartLeaf(AttributeList& attributes); 
    71   void StartInterior(AttributeList& attributes); 
    72   void EndInterior(); 
     75  void StartBspLeaf(AttributeList& attributes); 
     76  void StartBspInterior(AttributeList& attributes); 
     77  void EndBspInterior(); 
    7378  
    7479  void StartViewCell(AttributeList&  attributes); 
    7580  void EndViewCells(); 
    7681 
     82  void StartHierarchy(AttributeList& attributes); 
     83 
     84  void startBspElement(string element, AttributeList& attributes); 
    7785  // ----------------------------------------------------------------------- 
    7886  //  Handlers for the SAX ErrorHandler interface 
Note: See TracChangeset for help on using the changeset viewer.