Changeset 693


Ignore:
Timestamp:
03/13/06 16:29:28 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r492 r693  
    7878  void AddRectangle(const Rectangle3 &triangle); 
    7979 
    80         void Cleanup(); 
    81         bool 
    82         ValidateFace(const int face); 
     80  void Cleanup(); 
     81   
     82  bool ValidateFace(const int face); 
    8383 
    8484  void AddFace(Face *face)  
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r675 r693  
    12801280        const float vol = box.GetVolume(); 
    12811281 
     1282        Debug << "vsb volume: " << vol << endl; 
     1283        Debug << "root volume: " << mRoot->GetVolume() << endl; 
     1284        Debug << "root pvs: " << mRoot->GetPvs().GetSize() << endl; 
     1285 
    12821286        int totalPvs; 
    12831287        float totalRenderCost, avgRenderCost, expectedCost; 
     
    13941398        mRoot = root; 
    13951399} 
    1396  
    13971400 
    13981401 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r685 r693  
    136136 
    137137 
     138void ViewCellsManager::CollectEmptyViewCells() 
     139{ 
     140        mEmptyViewCells.clear(); 
     141        ViewCellContainer leaves; 
     142        mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
     143 
     144        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     145 
     146        cout << "collecting empty view cells" << endl; 
     147        int i = 0; 
     148        for (it = leaves.begin(); it != it_end; ++ it) 
     149        { 
     150                if ((*it)->GetPvs().Empty()) 
     151                { 
     152                        ++ i; 
     153                        mEmptyViewCells.push_back(*it); 
     154                } 
     155        } 
     156        cout << "view cells found: " << i << endl; 
     157} 
     158 
     159 
     160void ViewCellsManager::TestEmptyViewCells() 
     161{ 
     162        mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), mEmptyViewCells); 
     163 
     164        ViewCellContainer::const_iterator it, it_end = mEmptyViewCells.end(); 
     165 
     166        char buf[50]; 
     167        int i = 0; 
     168        for (it = mEmptyViewCells.begin(); it != it_end; ++ it) 
     169        { 
     170                if (!(*it)->GetPvs().Empty()) 
     171                { 
     172                        sprintf(buf, "empty-viewcells-%09d.x3d", (*it)->GetId()); 
     173                        Exporter *exporter = Exporter::GetExporter(buf); 
     174                         
     175                        if (exporter && i < 20) 
     176                        { 
     177                                Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << endl; 
     178                                ExportViewCellGeometry(exporter, *it); 
     179                        } 
     180 
     181                        ++ i; 
     182                } 
     183        } 
     184        Debug << "\nfound " << i << " new view cells (" << " of " << mEmptyViewCells.size() << ")" << endl << endl; 
     185} 
     186 
     187 
    138188int ViewCellsManager::CastPassSamples(const int samplesPerPass,  
    139189                                                                          const int sampleType,  
     
    235285        } 
    236286 
    237  
    238287        //-- guided rays are used for further sampling 
    239288        const int n = mConstructionSamples; //+initialSamples; 
     
    308357        // merge the view cells 
    309358        PostProcess(preprocessor->mObjects, postProcessSamples); 
     359 
     360        // only for testing 
     361        CollectEmptyViewCells(); 
    310362 
    311363 
     
    441493                disposeRays(evaluationSamples, NULL); 
    442494        } 
     495 
     496        // find empty view cells bug 
     497        TestEmptyViewCells(); 
    443498} 
    444499 
     
    728783{ 
    729784        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     785 
     786        // volume and area of the view cells are recomputed and a view cell mesh is created 
    730787        for (it = mViewCells.begin(); it != it_end; ++ it) 
    731788        { 
     
    11461203                } 
    11471204        } 
    1148  
    11491205} 
    11501206 
     
    14181474                cout << "finished" << endl; 
    14191475        } 
     1476 
     1477         
     1478        // only for testing 
     1479        TestSubdivision(); 
    14201480 
    14211481        mColorCode = savedColorCode; 
     
    16921752 
    16931753 
     1754void BspViewCellsManager::TestSubdivision() 
     1755{ 
     1756        ViewCellContainer leaves; 
     1757        mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
     1758 
     1759        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     1760 
     1761        const float vol = mViewSpaceBox.GetVolume(); 
     1762        float subdivVol = 0; 
     1763        float newVol = 0; 
     1764 
     1765        for (it = leaves.begin(); it != it_end; ++ it) 
     1766        { 
     1767                BspNodeGeometry geom; 
     1768                BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
     1769                mBspTree->ConstructGeometry(leaf, geom); 
     1770 
     1771                const float lVol = geom.GetVolume(); 
     1772                 
     1773                newVol += lVol; 
     1774                subdivVol += (*it)->GetVolume(); 
     1775        } 
     1776         
     1777        Debug << "exact volume: " << vol << endl; 
     1778        Debug << "subdivision volume: " << subdivVol << endl; 
     1779        Debug << "new volume: " << newVol << endl; 
     1780} 
     1781 
     1782 
    16941783void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    16951784                                                                                                 ViewCell *vc, 
     
    17621851        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    17631852 
    1764         for (it = leaves.begin(); it != it_end; ++ it) 
     1853    for (it = leaves.begin(); it != it_end; ++ it) 
    17651854        { 
    17661855                BspNodeGeometry geom; 
     
    17681857                mBspTree->ConstructGeometry(leaf, geom); 
    17691858 
    1770                 area += geom.GetArea(); 
    1771                 volume += geom.GetVolume(); 
    1772                 CreateMesh(*it); 
     1859                float lVol = geom.GetVolume(); 
     1860                float lArea = geom.GetArea(); 
     1861 
     1862                //(*it)->SetVolume(vol); 
     1863                //(*it)->SetArea(area); 
     1864 
     1865                area += lArea; 
     1866                volume += lVol; 
     1867 
     1868        CreateMesh(*it); 
    17731869        } 
    17741870 
     
    29373033         
    29383034 
     3035        Debug << "here4" << endl; 
     3036        // only for testing 
     3037        TestSubdivision(); 
     3038 
    29393039        //-- refines the merged view cells 
    29403040        if (0) 
     
    29533053        cout << ss << endl; 
    29543054        Debug << ss << endl; 
    2955  
    29563055 
    29573056 
     
    36193718        CreateUniqueViewCellIds(); 
    36203719 
    3621  
    36223720        stream.open(filename.c_str()); 
    36233721        stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 
     
    36783776        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    36793777 
    3680         for (it = leaves.begin(); it != it_end; ++ it) 
     3778    for (it = leaves.begin(); it != it_end; ++ it) 
    36813779        { 
    36823780                BspNodeGeometry geom; 
     
    36843782                mVspBspTree->ConstructGeometry(leaf, geom); 
    36853783 
    3686                 area += geom.GetArea(); 
    3687                 volume += geom.GetVolume(); 
    3688                 CreateMesh(*it); 
     3784                float lVol = geom.GetVolume(); 
     3785                float lArea = geom.GetArea(); 
     3786 
     3787                //(*it)->SetVolume(vol); 
     3788                //(*it)->SetArea(area); 
     3789 
     3790                area += lArea; 
     3791                volume += lVol; 
     3792 
     3793        CreateMesh(*it); 
    36893794        } 
    36903795 
     
    36943799 
    36953800 
     3801void VspBspViewCellsManager::TestSubdivision() 
     3802{ 
     3803        ViewCellContainer leaves; 
     3804        mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
     3805 
     3806        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     3807 
     3808        const float vol = mViewSpaceBox.GetVolume(); 
     3809        float subdivVol = 0; 
     3810        float newVol = 0; 
     3811 
     3812        for (it = leaves.begin(); it != it_end; ++ it) 
     3813        { 
     3814                BspNodeGeometry geom; 
     3815                BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
     3816                mVspBspTree->ConstructGeometry(leaf, geom); 
     3817 
     3818                const float lVol = geom.GetVolume(); 
     3819                 
     3820                newVol += lVol; 
     3821                subdivVol += (*it)->GetVolume(); 
     3822        } 
     3823         
     3824        Debug << "exact volume: " << vol << endl; 
     3825        Debug << "subdivision volume: " << subdivVol << endl; 
     3826        Debug << "new volume: " << newVol << endl; 
     3827} 
     3828 
     3829 
    36963830void VspBspViewCellsManager::PrepareLoadedViewCells() 
    36973831{ 
    36983832        // TODO: do I still need this here? 
    36993833        if (0) 
    3700         mVspBspTree->RepairViewCellsLeafLists(); 
     3834                mVspBspTree->RepairViewCellsLeafLists(); 
    37013835} 
    37023836 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r677 r693  
    500500        bool mEvaluateViewCells; 
    501501 
    502         bool mShowVisualization;         
     502        bool mShowVisualization; 
     503 
     504        // HACK in order to detect empty view cells 
     505        void CollectEmptyViewCells(); 
     506        void TestEmptyViewCells(); 
     507 
     508        ViewCellContainer mEmptyViewCells; 
    503509}; 
    504510 
     
    590596        void ExportBspPvs(const ObjectContainer &objects); 
    591597 
     598        void TestSubdivision(); 
    592599}; 
    593600 
     
    827834                                          const VssRayContainer &rays); 
    828835 
     836        void TestSubdivision(); 
    829837}; 
    830838 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r685 r693  
    158158                // cast again to ensure that there is no objectA 
    159159                SetupRay(ray, pointB, direction); 
    160                 ray.mFlags |= Ray::CULL_BACKFACESw; 
     160                ray.mFlags |= Ray::CULL_BACKFACES; 
    161161                 
    162162                if (mKdTree->CastRay(ray))  
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r660 r693  
    8787} 
    8888 
     89// HACK 
     90void RotateMesh(Mesh *mesh) 
     91{ 
     92        VertexContainer::const_iterator it, it_end = mesh->mVertices.end(); 
     93 
     94        const float angle = 30.0f * PI / 180.0f; 
     95        const Matrix4x4 rot = RotationYMatrix(30); 
     96 
     97        for (it = mesh->mVertices.begin(); it != it_end; ++ it) 
     98        { 
     99                const Vector3 pt = rot * (*it); 
     100        } 
     101} 
     102 
     103 
    89104void 
    90105X3dParseHandlers::EndShape() 
     
    109124                         
    110125                        mesh->mFaces.push_back(new Face(vc)); 
     126                        if (0) 
     127                                RotateMesh(mesh); 
    111128                        mesh->Preprocess(); 
    112129                        // make an instance of this mesh 
     
    121138        } 
    122139        else 
    123         { 
    124   
     140        {  
    125141                if (mCurrentMesh->mFaces.size())  
    126142                { 
     143                        // HACK 
     144                        if (0) 
     145                                RotateMesh(mCurrentMesh); 
    127146                        mCurrentMesh->Preprocess(); 
    128147                        // make an instance of this mesh 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r574 r693  
    4242  environment->Parse(argc, argv, USE_EXE_PATH); 
    4343  MeshKdTree::ParseEnvironment(); 
    44    
     44 
    4545  char buff[128]; 
    4646  environment->GetStringValue("Preprocessor.type", buff); 
     
    6565                  exit(1); 
    6666                } 
     67 
    6768 
    6869  QApplication *app = NULL; 
Note: See TracChangeset for help on using the changeset viewer.