Ignore:
Timestamp:
01/25/06 17:45:45 (18 years ago)
Author:
mattausch
Message:

fixed loading function: the view cell manager is chosen depending on
the type in the file. the view space box is saved with the file

File:
1 edited

Legend:

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

    r575 r577  
    5252        environment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass); 
    5353 
     54        environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells); 
     55 
    5456        mMinPvsSize = emptyViewCells ? 1 : 0; 
    5557 
     
    236238} 
    237239 
     240 
    238241void 
    239242ViewCellsManager::SetValidity( 
     
    275278} 
    276279 
    277 bool ViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 
     280 
     281bool ViewCellsManager::LoadViewCellsGeometry(const string filename) 
    278282{ 
    279283        X3dParser parser; 
     
    575579{ 
    576580        mViewSpaceBox = box; 
     581        mTotalAreaValid = false; 
    577582} 
    578583 
     
    21762181                FinalizeViewCells(true); 
    21772182                EvaluateViewCellsStats(); 
     2183 
    21782184                return 0; 
    21792185        } 
     
    22792285        FinalizeViewCells(true); 
    22802286 
     2287        // for output we need unique ids for each view cell 
     2288        CreateUniqueViewCellIds(); 
     2289 
    22812290        // write view cells to disc 
    22822291        if (mExportViewCells) 
     
    23682377                        delete exporter; 
    23692378                } 
     2379        } 
     2380 
     2381        if (1) 
     2382        { 
     2383                cout << "exporting depth map ... "; 
     2384 
     2385                Exporter *exporter = Exporter::GetExporter("depth_map.x3d"); 
     2386                if (exporter) 
     2387                { 
     2388                        if (1) 
     2389                        { 
     2390                                exporter->SetWireframe(); 
     2391                                exporter->ExportBox(mViewSpaceBox); 
     2392                                exporter->SetFilled(); 
     2393                        } 
     2394 
     2395                        if (mExportGeometry) 
     2396                        { 
     2397                                exporter->ExportGeometry(objects); 
     2398                        } 
     2399 
     2400                        const int maxDepth = mVspBspTree->mBspStats.maxDepth; 
     2401 
     2402                        ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
     2403 
     2404                        for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
     2405                        { 
     2406                                BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     2407 
     2408                                vector<BspLeaf *>::const_iterator lit, lit_end = vc->mLeaves.end(); 
     2409 
     2410                                for (lit = vc->mLeaves.begin(); lit != lit_end; ++ lit) 
     2411                                { 
     2412                                        BspLeaf *leaf = *lit; 
     2413 
     2414                                        Material m;  
     2415 
     2416                                        float relDepth = (float)leaf->GetDepth() / (float)maxDepth; 
     2417                                        m.mDiffuseColor.r = relDepth; 
     2418                                        m.mDiffuseColor.g = 0.0f; 
     2419                                        m.mDiffuseColor.b = 1.0f - relDepth; 
     2420 
     2421                    exporter->SetForcedMaterial(m); 
     2422                                 
     2423 
     2424                                        BspNodeGeometry geom; 
     2425                                        mVspBspTree->ConstructGeometry(leaf, geom); 
     2426                                        exporter->ExportPolygons(geom.mPolys); 
     2427                                } 
     2428                        } 
     2429 
     2430                        delete exporter; 
     2431                } 
     2432 
     2433 
     2434                cout << "finished" << endl; 
    23702435        } 
    23712436 
     
    26612726void VspBspViewCellsManager::CreateMesh(ViewCell *vc) 
    26622727{ 
     2728        if (vc->GetMesh()) 
     2729                delete vc->GetMesh(); 
     2730 
    26632731        BspNodeGeometry geom; 
    26642732        BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc); 
     
    26722740 
    26732741 
    2674 bool VspBspViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 
     2742ViewCellsManager *ViewCellsManager::LoadViewCells(const string filename,  
     2743                                                                                                  ObjectContainer *objects) 
    26752744{ 
    26762745        ViewCellsParser parser; 
    26772746 
    2678         DEL_PTR(mVspBspTree); 
    2679         mVspBspTree = new VspBspTree(); 
    2680  
    2681         bool success ;//= parser.ParseFile(filename, &this, objects); 
    2682         mVspBspTree->RepairViewCellsLeafLists(); 
    2683         mVspBspTree->mBox = GetViewSpaceBox(); 
    2684         ResetViewCells(); 
    2685  
    2686         mViewCellsFinished = true; 
    2687         mMaxPvsSize = (int)objects->size(); 
    2688  
    2689         FinalizeViewCells(true); 
    2690  
    2691         Debug << (int)mViewCells.size() << " view cells loaded" << endl; 
    2692  
    2693         return success; 
     2747        ViewCellsManager *vm = NULL; 
     2748 
     2749        if (parser.ParseFile(filename, &vm, objects)) 
     2750        { 
     2751                vm->PrepareLoadedViewCells(); 
     2752                vm->ResetViewCells(); 
     2753 
     2754                vm->mViewCellsFinished = true; 
     2755                vm->mMaxPvsSize = (int)objects->size(); 
     2756 
     2757                vm->FinalizeViewCells(true); 
     2758 
     2759                Debug << (int)vm->mViewCells.size() << " view cells loaded" << endl; 
     2760 
     2761                //vm->ExportViewCells("test.xml"); 
     2762        } 
     2763        else 
     2764        { 
     2765                Debug << "failed loading view cells" << endl; 
     2766                DEL_PTR(vm); 
     2767        } 
     2768 
     2769 
     2770        return vm; 
    26942771} 
    26952772 
     
    27062783        std::ofstream stream; 
    27072784 
    2708         // for output we need unique ids 
    2709         CreateUniqueViewCellIds(); 
     2785        // for output we need unique ids for each view cell 
     2786        //CreateUniqueViewCellIds(); 
    27102787 
    27112788        stream.open(filename.c_str()); 
    27122789        stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 
    27132790        stream << "<Visibility_Solution>" << endl; 
     2791 
     2792        //-- the view space bounding box 
     2793        stream << "<ViewSpaceBox"  
     2794                   << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\"" 
     2795                   << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 
     2796 
     2797        //-- the type of the view cells hierarchy 
     2798        stream << "<Hierarchy name=\"vspBspTree\" />" << endl; 
    27142799 
    27152800        //-- load the view cells itself, i.e., the ids and the pvs 
     
    27662851 
    27672852 
    2768  
     2853void VspBspViewCellsManager::PrepareLoadedViewCells() 
     2854{ 
     2855        // TODO: do I still need this here? 
     2856        mVspBspTree->RepairViewCellsLeafLists(); 
     2857} 
     2858 
     2859 
     2860//////////////////////////////////77 
    27692861ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 
    27702862{ 
Note: See TracChangeset for help on using the changeset viewer.