Ignore:
Timestamp:
02/04/06 21:36:40 (18 years ago)
Author:
mattausch
Message:

implemented some code for merge history loading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r587 r590  
    686686{ 
    687687        mViewCells.clear(); 
     688         
    688689        CollectViewCells(); 
    689  
     690         
    690691        mViewCellsStats.Reset(); 
    691692        EvaluateViewCellsStats(); 
     693 
    692694        // has to be recomputed 
    693695        mTotalAreaValid = false; 
     
    699701        return mMaxPvsSize; 
    700702} 
     703 
    701704 
    702705void 
     
    921924        environment->GetIntValue("BspTree.Construction.samples", mInitialSamples); 
    922925        mBspTree->SetViewCellsManager(this); 
     926        mBspTree->mViewCellsTree = mViewCellsTree; 
    923927} 
    924928 
     
    10241028        if (!ViewCellsTreeConstructed()) 
    10251029        { 
     1030                 
    10261031                mBspTree->CollectViewCells(mViewCells); 
    10271032        } 
    10281033        else  
    10291034        { 
     1035                 
    10301036                // we can use the view cells tree hierarchy to get the right set 
    10311037                mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); 
     
    10691075        } 
    10701076 
     1077         
     1078        // view cells already finished before post processing step (i.e. because they were loaded) 
     1079        if (mViewCellsFinished) 
     1080        { 
     1081                FinalizeViewCells(true); 
     1082                EvaluateViewCellsStats(); 
     1083 
     1084                return 0; 
     1085        } 
     1086 
    10711087        //-- post processing of bsp view cells 
    10721088    int vcSize = 0; 
     
    10981114                                m.mDiffuseColor = RgbColor(0, 1, 0); 
    10991115                                exporter->SetForcedMaterial(m); 
     1116                         
    11001117                                exporter->SetWireframe(); 
    11011118 
     
    11321149        FinalizeViewCells(true); 
    11331150         
    1134         // for output we need unique ids for each view cell 
    1135         CreateUniqueViewCellIds(); 
     1151        // HACK: removes view cells in bsp leaves with active ones 
     1152        if (0) 
     1153                AddCurrentViewCellsToHierarchy(); 
    11361154 
    11371155        // write view cells to disc 
     
    11861204                        else 
    11871205                                exporter->SetFilled(); 
     1206 
    11881207                        ExportViewCellsForViz(exporter); 
    11891208 
     
    14861505 
    14871506 
    1488 /**********************************************************************/ 
    1489 /*                   KdViewCellsManager implementation               */ 
    1490 /**********************************************************************/ 
     1507 
     1508bool BspViewCellsManager::ExportViewCells(const string filename) 
     1509{ 
     1510        cout << "exporting view cells to xml ... "; 
     1511        std::ofstream stream; 
     1512 
     1513        // for output we need unique ids for each view cell 
     1514        CreateUniqueViewCellIds(); 
     1515 
     1516 
     1517        stream.open(filename.c_str()); 
     1518        stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 
     1519        stream << "<Visibility_Solution>" << endl; 
     1520 
     1521        //-- the view space bounding box 
     1522        stream << "<ViewSpaceBox"  
     1523                   << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\"" 
     1524                   << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 
     1525 
     1526        //-- the type of the view cells hierarchy 
     1527        //stream << "<Hierarchy name=\"bspTree\" />" << endl; 
     1528        stream << "<Hierarchy name=\"vspBspTree\" />" << endl; // write vsp bsp here because can use same tree and is bug free 
     1529        //-- load the view cells itself, i.e., the ids and the pvs 
     1530        stream << "<ViewCells>" << endl; 
     1531        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     1532        for (it = mViewCells.begin(); it != it_end; ++ it) 
     1533                ExportViewCell(*it, stream); 
     1534 
     1535        stream << "</ViewCells>" << endl; 
     1536 
     1537        //-- load the hierarchy 
     1538        stream << "<Hierarchy>" << endl; 
     1539        mBspTree->Export(stream); 
     1540        stream << endl << "</Hierarchy>" << endl; 
     1541 
     1542        stream << "</Visibility_Solution>" << endl; 
     1543        stream.close(); 
     1544 
     1545        cout << "finished" << endl; 
     1546 
     1547        return true; 
     1548} 
     1549 
     1550 
     1551void BspViewCellsManager::AddCurrentViewCellsToHierarchy() 
     1552{ 
     1553        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     1554        for (it = mViewCells.begin(); it != it_end; ++ it) 
     1555        { 
     1556                ViewCell *vc = *it; 
     1557                ViewCellContainer leaves; 
     1558                mViewCellsTree->CollectLeaves(vc, leaves); 
     1559                 
     1560                ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
     1561 
     1562                for (lit = leaves.begin(); lit != lit_end; ++ lit) 
     1563                { 
     1564                        BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*lit); 
     1565                        bspVc->mLeaf->SetViewCell(vc); 
     1566                } 
     1567        } 
     1568} 
     1569 
     1570/************************************************************************/ 
     1571/*                   KdViewCellsManager implementation                  */ 
     1572/************************************************************************/ 
    14911573 
    14921574 
     
    21772259        environment->GetIntValue("VspBspTree.Construction.samples", mInitialSamples); 
    21782260        mVspBspTree->SetViewCellsManager(this); 
     2261        mVspBspTree->mViewCellsTree = mViewCellsTree; 
    21792262} 
    21802263 
     
    21992282        if (!ViewCellsTreeConstructed()) 
    22002283        { 
    2201                 mVspBspTree->CollectViewCells(mViewCells, true); 
     2284                mVspBspTree->CollectViewCells(mViewCells, false); 
    22022285        } 
    22032286        else  
     
    25682651        FinalizeViewCells(true); 
    25692652 
    2570         // for output we need unique ids for each view cell 
    2571         CreateUniqueViewCellIds(); 
     2653        // HACK: removes view cells in bsp leaves with active ones 
     2654        if (0) 
     2655                AddCurrentViewCellsToHierarchy(); 
     2656 
    25722657 
    25732658        // write view cells to disc 
     
    29663051 
    29673052void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    2968                                                                                           ViewCell *vc) const 
     3053                                                                                                        ViewCell *vc) const 
    29693054{ 
    29703055        if (vc->GetMesh()) 
    29713056        { 
    29723057                exporter->ExportMesh(vc->GetMesh()); 
     3058         
    29733059                return; 
    29743060        } 
     
    30233109                delete vc->GetMesh(); 
    30243110 
     3111         
    30253112        BspNodeGeometry geom; 
     3113 
     3114        mVspBspTree->ConstructGeometry(vc, geom); 
    30263115         
    3027         mVspBspTree->ConstructGeometry(vc, geom); 
    3028  
    30293116        Mesh *mesh = new Mesh(); 
    30303117        geom.AddToMesh(*mesh); 
     
    30433130        if (parser.ParseFile(filename, &vm, objects)) 
    30443131        { 
    3045                 vm->PrepareLoadedViewCells(); 
     3132                //vm->PrepareLoadedViewCells(); 
    30463133                vm->ResetViewCells(); 
    30473134 
     
    30523139 
    30533140                Debug << (int)vm->mViewCells.size() << " view cells loaded" << endl; 
    3054  
    3055                 //vm->ExportViewCells("test.xml"); 
    30563141        } 
    30573142        else 
     
    30783163 
    30793164        // for output we need unique ids for each view cell 
    3080         //CreateUniqueViewCellIds(); 
     3165        CreateUniqueViewCellIds(); 
     3166 
    30813167 
    30823168        stream.open(filename.c_str()); 
     
    31013187 
    31023188        //-- load the hierarchy 
    3103         stream << "<BspTree>" << endl; 
     3189        stream << "<Hierarchy>" << endl; 
    31043190        mVspBspTree->Export(stream); 
    3105         stream << endl << "</BspTree>" << endl; 
     3191        stream << endl << "</Hierarchy>" << endl; 
    31063192 
    31073193        stream << "</Visibility_Solution>" << endl; 
     
    31513237{ 
    31523238        // TODO: do I still need this here? 
     3239        if (0) 
    31533240        mVspBspTree->RepairViewCellsLeafLists(); 
    31543241} 
     
    31763263 
    31773264 
     3265void VspBspViewCellsManager::AddCurrentViewCellsToHierarchy() 
     3266{ 
     3267        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     3268        for (it = mViewCells.begin(); it != it_end; ++ it) 
     3269        { 
     3270        } 
     3271} 
    31783272 
    31793273////////////////////////////////// 
Note: See TracChangeset for help on using the changeset viewer.