- Timestamp:
- 01/25/06 17:45:45 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r575 r577 52 52 environment->GetIntValue("ViewCells.Construction.samplesPerPass", mSamplesPerPass); 53 53 54 environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells); 55 54 56 mMinPvsSize = emptyViewCells ? 1 : 0; 55 57 … … 236 238 } 237 239 240 238 241 void 239 242 ViewCellsManager::SetValidity( … … 275 278 } 276 279 277 bool ViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 280 281 bool ViewCellsManager::LoadViewCellsGeometry(const string filename) 278 282 { 279 283 X3dParser parser; … … 575 579 { 576 580 mViewSpaceBox = box; 581 mTotalAreaValid = false; 577 582 } 578 583 … … 2176 2181 FinalizeViewCells(true); 2177 2182 EvaluateViewCellsStats(); 2183 2178 2184 return 0; 2179 2185 } … … 2279 2285 FinalizeViewCells(true); 2280 2286 2287 // for output we need unique ids for each view cell 2288 CreateUniqueViewCellIds(); 2289 2281 2290 // write view cells to disc 2282 2291 if (mExportViewCells) … … 2368 2377 delete exporter; 2369 2378 } 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; 2370 2435 } 2371 2436 … … 2661 2726 void VspBspViewCellsManager::CreateMesh(ViewCell *vc) 2662 2727 { 2728 if (vc->GetMesh()) 2729 delete vc->GetMesh(); 2730 2663 2731 BspNodeGeometry geom; 2664 2732 BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc); … … 2672 2740 2673 2741 2674 bool VspBspViewCellsManager::LoadViewCells(const string filename, ObjectContainer *objects) 2742 ViewCellsManager *ViewCellsManager::LoadViewCells(const string filename, 2743 ObjectContainer *objects) 2675 2744 { 2676 2745 ViewCellsParser parser; 2677 2746 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; 2694 2771 } 2695 2772 … … 2706 2783 std::ofstream stream; 2707 2784 2708 // for output we need unique ids 2709 CreateUniqueViewCellIds();2785 // for output we need unique ids for each view cell 2786 //CreateUniqueViewCellIds(); 2710 2787 2711 2788 stream.open(filename.c_str()); 2712 2789 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 2713 2790 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; 2714 2799 2715 2800 //-- load the view cells itself, i.e., the ids and the pvs … … 2766 2851 2767 2852 2768 2853 void VspBspViewCellsManager::PrepareLoadedViewCells() 2854 { 2855 // TODO: do I still need this here? 2856 mVspBspTree->RepairViewCellsLeafLists(); 2857 } 2858 2859 2860 //////////////////////////////////77 2769 2861 ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 2770 2862 {
Note: See TracChangeset
for help on using the changeset viewer.