Changeset 931 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 05/08/06 18:57:11 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
r879 r931 123 123 </File> 124 124 <File 125 RelativePath="..\src\BoundingBoxConverter.h"> 126 </File> 127 <File 125 128 RelativePath="..\src\Camera.cpp"> 126 129 </File> -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r904 r931 930 930 RenderIntersectable(*oi); 931 931 932 ViewCell *viewcell ;932 ViewCell *viewcell = NULL; 933 933 934 934 QImage im1, im2; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r925 r931 265 265 { 266 266 267 mViewCellsManager->ExportViewCells(filename, 268 true); 267 mViewCellsManager->ExportViewCells(filename, true, mObjects); 269 268 270 269 return true; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r904 r931 15 15 #include "VssPreprocessor.h" 16 16 #include "RssPreprocessor.h" 17 #include "BoundingBoxConverter.h" 18 17 19 18 20 namespace GtpVisibilityPreprocessor { … … 1858 1860 1859 1861 1860 bool ViewCellsManager::ExportViewCells(const string filename, const bool exportPvs )1862 bool ViewCellsManager::ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects) 1861 1863 { 1862 1864 return false; … … 1956 1958 IndexedBoundingBoxContainer &boxes) const 1957 1959 { 1958 // HACK: needed only for lower_bound algorithm to find the1959 // intersected objects1960 1961 1960 Vector3 bmin, bmax; 1962 1961 int id; … … 2021 2020 } 2022 2021 2022 2023 float ViewCellsManager::GetFilterWidth() 2024 { 2025 return mFilterWidth; 2026 } 2027 2028 2029 float ViewCellsManager::GetAbsFilterWidth() 2030 { 2031 return Magnitude(mViewSpaceBox.Size()) * mFilterWidth; 2032 } 2033 2034 2035 bool ViewCellsManager::ExportBoundingBoxes(ofstream &xmlstream, 2036 const ObjectContainer &objects) const 2037 { 2038 //-- export the view cells and the pvs 2039 xmlstream << "<BoundingBoxes>" << endl; 2040 2041 ObjectContainer::const_iterator oit, oit_end = objects.end(); 2042 2043 for (oit = objects.begin(); oit != oit_end; ++ oit) 2044 { 2045 MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit); 2046 const AxisAlignedBox3 box = mi->GetBox(); 2047 2048 //-- the bounding boxes 2049 xmlstream << "<BoundingBox" << " id=\"" << mi->GetId() << "\"" 2050 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 2051 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 2052 } 2053 2054 xmlstream << "</BoundingBoxes>" << endl; 2055 2056 return true; 2057 } 2058 2059 2023 2060 /**********************************************************************/ 2024 /* BspViewCellsManager implementation*/2061 /* BspViewCellsManager implementation */ 2025 2062 /**********************************************************************/ 2026 2063 … … 2282 2319 char filename[100]; 2283 2320 environment->GetStringValue("ViewCells.filename", filename); 2284 ExportViewCells(filename, mExportPvs );2321 ExportViewCells(filename, mExportPvs, objects); 2285 2322 } 2286 2323 2287 2324 // export bounding boxes 2288 if ( mExportBboxesForPvs)2325 if (0 && mExportBboxesForPvs) 2289 2326 { 2290 2327 char filename[100]; … … 2729 2766 2730 2767 2731 bool BspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs )2768 bool BspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects) 2732 2769 { 2733 2770 cout << "exporting view cells to xml ... "; … … 3974 4011 char filename[100]; 3975 4012 environment->GetStringValue("ViewCells.filename", filename); 3976 ExportViewCells(filename, mExportPvs );4013 ExportViewCells(filename, mExportPvs, objects); 3977 4014 } 3978 4015 … … 4687 4724 4688 4725 ViewCellsManager *ViewCellsManager::LoadViewCells(const string filename, 4689 ObjectContainer *objects) 4726 ObjectContainer *objects, 4727 BoundingBoxConverter *bconverter) 4690 4728 { 4691 4729 ViewCellsParser parser; … … 4695 4733 Debug << "vc filename: " << filename << endl; 4696 4734 4697 if (parser.ParseFile(filename, &vm, objects)) 4735 //BoundingBoxConverter bconverter; 4736 4737 if (parser.ParseFile(filename, &vm, objects, bconverter)) 4698 4738 { 4699 4739 //vm->PrepareLoadedViewCells(); … … 4719 4759 4720 4760 4721 4722 bool VspBspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs) 4761 bool VspBspViewCellsManager::ExportViewCells(const string filename, 4762 const bool exportPvs, 4763 const ObjectContainer &objects) 4723 4764 { 4724 4765 cout << "exporting view cells to xml ... "; … … 4737 4778 << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 4738 4779 4739 4780 ExportBoundingBoxes(stream, objects); 4740 4781 4741 4782 //-- the type of the view cells hierarchy … … 4750 4791 4751 4792 4752 //-- export the hierarchy4793 //-- export the spatial hierarchy 4753 4794 stream << "<Hierarchy>" << endl; 4754 4795 mVspBspTree->Export(stream); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r904 r931 32 32 class ViewCellsTree; 33 33 class MergeCandidate; 34 class BoundingBoxConverter; 35 34 36 35 37 struct BspRay; … … 50 52 }; 51 53 52 53 struct IndexedBoundingBox: public std::pair<int, AxisAlignedBox3>54 {55 typedef std::pair<int, AxisAlignedBox3> IndexedBoundingBoxParent;56 57 IndexedBoundingBox(int idx, const AxisAlignedBox3 &box): IndexedBoundingBoxParent(idx, box)58 {59 60 }61 };62 54 63 55 /** Manages different higher order operations on the view cells. … … 77 69 enum {BSP, KD, VSP_KD, VSP_BSP}; 78 70 79 /// view cellsevaluation type71 /// render cost evaluation type 80 72 enum {PER_OBJECT, PER_TRIANGLE}; 81 73 … … 308 300 /** Writes view cells to disc. 309 301 */ 310 virtual bool ExportViewCells(const string filename, const bool exportPvs );302 virtual bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 311 303 312 304 /** Casts beam to collect view cells. … … 418 410 float EvalRenderCost(Intersectable *obj) const; 419 411 420 void 421 ApplyFilter(KdTree *kdTree, 422 const float viewSpaceFilterSize, 423 const float spatialFilterSize 424 ); 425 426 void 427 ApplySpatialFilter( 428 KdTree *kdTree, 429 const float spatialFilterSize, 430 ObjectPvs &pvs 431 ); 412 432 413 433 414 /** Returns bounding box of a view cell. … … 438 419 */ 439 420 bool ExportBoundingBoxes(const string filename, const ObjectContainer &objects) const; 440 421 441 422 /** Load the bounding boxes into the container. 442 423 */ 443 424 bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 444 425 445 bool GetExportPvs() const { 446 return mExportPvs; 447 } 426 bool GetExportPvs() const 427 { 428 return mExportPvs; 429 } 448 430 449 431 /** Loads view cells from file. The view cells manager is created with … … 452 434 @returns the view cells manager if loading was successful, false otherwise 453 435 */ 454 static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 455 456 float GetFilterWidth() { 457 return mFilterWidth; 458 } 459 460 float GetAbsFilterWidth() { 461 return Magnitude(mViewSpaceBox.Size())*mFilterWidth; 462 } 436 static ViewCellsManager *LoadViewCells(const string filename, 437 ObjectContainer *objects, 438 BoundingBoxConverter *bconverter = NULL); 439 440 441 ////////////////////////////////////////////////////////7 442 // visiblity filter options 443 // TODO: write own visibiltiy filter class 444 void ApplyFilter(KdTree *kdTree, 445 const float viewSpaceFilterSize, 446 const float spatialFilterSize); 447 448 void ApplySpatialFilter(KdTree *kdTree, 449 const float spatialFilterSize, 450 ObjectPvs &pvs); 451 452 void ApplyFilter(ViewCell *viewCell, 453 KdTree *kdTree, 454 const float viewSpaceFilterSize, 455 const float spatialFilterSize, 456 ObjectPvs &pvs); 457 458 float GetFilterWidth(); 459 460 float GetAbsFilterWidth(); 461 462 463 /** Returns the bounding box of filter width. 464 */ 465 AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const; 463 466 464 467 protected: 465 void 466 ApplyFilter(ViewCell *viewCell, 467 KdTree *kdTree, 468 const float viewSpaceFilterSize, 469 const float spatialFilterSize, 470 ObjectPvs &pvs 471 ); 472 473 474 /** Returns the bounding box of filter width. 475 */ 476 AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const; 468 /** Exports bounding boxes as xml stream 469 */ 470 bool ExportBoundingBoxes(ofstream &xmlstream, const ObjectContainer &objects) const; 477 471 478 472 /** Intersects box with the tree and returns the number of intersected boxes. … … 486 480 virtual void TestFilter(const ObjectContainer &objects) {}; 487 481 488 /** 489 if the view cells tree was already constructed or not. 482 /** If the view cells tree was already constructed or not. 490 483 */ 491 484 bool ViewCellsTreeConstructed() const; … … 495 488 VssRayContainer &vssRays) const; 496 489 490 /** Parse the options from the environment file. 491 */ 497 492 void ParseEnvironment(); 498 493 … … 700 695 void Finalize(ViewCell *viewCell, const bool createMesh); 701 696 702 bool ExportViewCells(const string filename, const bool exportPvs );697 bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 703 698 704 699 /** Constructs merge hierarchy which corresponds to the spatial hierarchy. … … 908 903 void CreateMesh(ViewCell *vc); 909 904 910 bool ExportViewCells(const string filename, const bool exportPvs );905 bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 911 906 912 907 int CastBeam(Beam &beam); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r881 r931 65 65 // StdInParseHandlers: Constructors and Destructor 66 66 // --------------------------------------------------------------------------- 67 ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects ):67 ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter): 68 68 mElementCount(0) 69 69 , mAttrCount(0) … … 77 77 , mCurrentViewCell(NULL) 78 78 , mCurrentBspNode(NULL) 79 { 80 mObjects = objects; 79 , mObjects(objects) 80 , mBoundingBoxConverter(bconverter) 81 { 82 // mObjects = objects; 81 83 } 82 84 … … 132 134 } 133 135 136 134 137 inline static bool vlt(ViewCell *v1, ViewCell *v2) 135 138 { … … 144 147 } 145 148 149 150 void ViewCellsParseHandlers::EndBoundingBoxes() 151 { 152 // bounding boxes gathered: associate object ids with bounding boxes 153 if (mBoundingBoxConverter) 154 mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects); 155 } 146 156 147 157 … … 208 218 if (element == "ViewSpaceBox") 209 219 { 220 Debug << "v"; 221 StartViewSpaceBox(attributes); 222 } 223 224 // decides the used view cell hierarchy 225 if (element == "BoundingBox") 226 { 210 227 Debug << "b"; 211 StartViewSpaceBox(attributes); 212 } 213 228 StartBoundingBox(attributes); 229 } 214 230 215 231 // use different methods for the given view cell hierarchy types … … 379 395 380 396 397 void ViewCellsParseHandlers::StartBoundingBox(AttributeList& attributes) 398 { 399 int len = attributes.getLength(); 400 401 Vector3 bmin, bmax; 402 int id; 403 404 for (int i = 0; i < len; ++ i) 405 { 406 string attrName(StrX(attributes.getName(i)).LocalForm()); 407 StrX attrValue(attributes.getValue(i)); 408 const char *ptr = attrValue.LocalForm(); 409 410 411 if (attrName == "id") 412 { 413 sscanf(ptr, "%d", &id); 414 } 415 416 if (attrName == "min") 417 { 418 sscanf(ptr, "%f %f %f", 419 &bmin.x, &bmin.y, &bmin.z); 420 } 421 else if (attrName == "max") 422 { 423 sscanf(ptr, "%f %f %f", 424 &bmax.x, &bmax.y, &bmax.z); 425 } 426 } 427 428 AxisAlignedBox3 box(bmin, bmax); 429 mIBoundingBoxes.push_back(IndexedBoundingBox(id, box)); 430 431 Debug << "view space box: " << mViewSpaceBox << endl; 432 } 433 434 381 435 void ViewCellsParseHandlers::StartBspLeaf(AttributeList& attributes) 382 436 { … … 637 691 bool ViewCellsParser::ParseFile(const string filename, 638 692 ViewCellsManager **viewCells, 639 ObjectContainer *objects) 693 ObjectContainer *objects, 694 BoundingBoxConverter *bconverter) 640 695 { 641 696 // Initialize the XML4C system … … 669 724 // to do. 670 725 // 671 ViewCellsParseHandlers handler(objects );726 ViewCellsParseHandlers handler(objects, bconverter); 672 727 parser->setDocumentHandler(&handler); 673 728 parser->setErrorHandler(&handler); … … 724 779 XMLPlatformUtils::Terminate(); 725 780 726 //assign new view cells manager781 //-- assign new view cells manager 727 782 *viewCells = handler.mViewCellsManager; 728 783 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h
r860 r931 9 9 class ViewCellsManager; 10 10 class VspBspTree; 11 class BoundingBoxConverter; 11 12 12 13 class ViewCellsParser : public Parser … … 18 19 bool ParseFile(const string filename, 19 20 ViewCellsManager **viewCells, 20 ObjectContainer *objects); 21 ObjectContainer *objectsm, 22 BoundingBoxConverter *bconverter); 21 23 }; 22 24 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r860 r931 7 7 #include <xercesc/sax/HandlerBase.hpp> 8 8 #include "Mesh.h" 9 #include "BoundingBoxConverter.h" 9 10 10 11 namespace GtpVisibilityPreprocessor { … … 27 28 // Constructors and Destructor 28 29 // ----------------------------------------------------------------------- 29 ViewCellsParseHandlers(ObjectContainer *objects );30 ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter); 30 31 ~ViewCellsParseHandlers(); 31 32 … … 78 79 ViewCellsManager *mViewCellsManager; 79 80 ObjectContainer *mObjects; 81 BoundingBoxConverter *mBoundingBoxConverter; 80 82 81 83 AxisAlignedBox3 mViewSpaceBox; 84 85 IndexedBoundingBoxContainer mIBoundingBoxes; 82 86 83 87 bool mParseViewCells; … … 90 94 void StartViewCell(ViewCell *viewCell, AttributeList& attributes); 91 95 void EndViewCells(); 96 void EndBoundingBoxes(); 92 97 93 98 void StartHierarchy(AttributeList& attributes); … … 96 101 void StartViewSpaceBox(AttributeList& attributes); 97 102 103 void StartBoundingBox(AttributeList& attributes); 98 104 void StartViewCellLeaf(AttributeList& attributes); 99 105 void StartViewCellInterior(AttributeList& attributes); -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r871 r931 627 627 VssRayContainer dummies; 628 628 mViewCellsManager->Visualize(mObjects, dummies); 629 mViewCellsManager->ExportViewCells("test.xml", mViewCellsManager->GetExportPvs() );629 mViewCellsManager->ExportViewCells("test.xml", mViewCellsManager->GetExportPvs(), mObjects); 630 630 } 631 631
Note: See TracChangeset
for help on using the changeset viewer.