Changeset 2544 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 08/22/07 08:01:21 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2543 r2544 371 371 GlRenderer::SetupCamera() 372 372 { 373 Vector3 target = mViewPoint + mViewDirection; 374 //cout << "vp: " << mViewPoint << " dr: " << mViewDirection << endl; 375 //cout<<"box: " << mKdTree->GetBox()<<endl; 376 Vector3 up(0,1,0); 377 378 if (abs(DotProd(mViewDirection, up)) > 0.99f) 379 up = Vector3(1, 0, 0); 380 381 glLoadIdentity(); 382 gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 383 target.x, target.y, target.z, 384 up.x, up.y, up.z); 373 Vector3 target = mViewPoint + mViewDirection; 374 375 Vector3 up(0,1,0); 376 377 if (abs(DotProd(mViewDirection, up)) > 0.99f) 378 up = Vector3(1, 0, 0); 379 380 glLoadIdentity(); 381 gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 382 target.x, target.y, target.z, 383 up.x, up.y, up.z); 385 384 } 386 385 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2187 r2544 857 857 mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 858 858 AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 859 //cout << "box: " << box << endl;859 860 860 vector<KdLeaf *> leaves; 861 862 861 mKdTree->GetBoxIntersections(box, leaves); 863 862 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectionBoundingBoxConverter.cpp
r2116 r2544 40 40 41 41 bool IntersectionBoundingBoxConverter::IdentifyObjects( 42 43 ObjectContainer &objects) const42 const IndexedBoundingBoxContainer &iboxes, 43 ObjectContainer &objects) const 44 44 { 45 45 GtpVisibilityPreprocessor::IndexedBoundingBoxContainer:: -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2543 r2544 33 33 34 34 35 inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 36 { 37 return obj1->mId < obj2->mId; 38 } 39 40 35 41 Preprocessor *preprocessor = NULL; 36 42 … … 403 409 ((rayCastMethod == RayCaster::INTEL_RAYCASTER) && mLoadMeshes) ? 404 410 &mFaceParents : NULL; 405 411 406 412 if (files == 1) 407 413 { 408 414 if (strstr(filename.c_str(), ".x3d")) 409 415 { 410 416 parser = new X3dParser; 411 417 412 418 result = parser->ParseFile(filename, 413 414 415 419 mSceneGraph->GetRoot(), 420 mLoadMeshes, 421 fi); 416 422 delete parser; 417 423 } … … 421 427 422 428 result = parser->ParseFile(filename, 423 424 425 429 mSceneGraph->GetRoot(), 430 mLoadMeshes, 431 fi); 426 432 delete parser; 427 433 } … … 432 438 // hack: load binary dump 433 439 const string bnFile = ReplaceSuffix(filename, ".obj", ".bn"); 434 440 435 441 if (!mLoadMeshes) 436 442 { … … 439 445 440 446 // parse obj 441 447 if (!result) 442 448 { 443 449 cout << "no binary dump available or loading full meshes, parsing file" << endl; 444 450 parser = new ObjParser; 445 446 result = parser->ParseFile(filename, 447 mSceneGraph->GetRoot(), 448 mLoadMeshes, 449 fi); 450 451 452 result = parser->ParseFile(filename, mSceneGraph->GetRoot(), mLoadMeshes, fi); 453 451 454 cout << "loaded " << (int)mSceneGraph->GetRoot()->mGeometry.size() << " entities" << endl; 452 455 … … 457 460 458 461 ExportBinaryObj(bnFile, mSceneGraph->GetRoot()); 459 462 460 463 cout << "finished" << endl; 461 464 } … … 467 470 { 468 471 parser = new UnigraphicsParser; 469 result = parser->ParseFile(filename, 470 mSceneGraph->GetRoot(), 471 mLoadMeshes, 472 fi); 472 result = parser->ParseFile(filename, mSceneGraph->GetRoot(), mLoadMeshes, fi); 473 473 delete parser; 474 474 } 475 475 476 476 cout << filename << endl; 477 477 } … … 479 479 { 480 480 vector<string>::const_iterator fit, fit_end = filenames.end(); 481 481 482 482 for (fit = filenames.begin(); fit != fit_end; ++ fit) 483 483 { … … 506 506 } 507 507 } 508 508 509 509 if (result) 510 { 511 mSceneGraph->AssignObjectIds(); 512 510 { 513 511 int intersectables, faces; 514 512 mSceneGraph->GetStatistics(intersectables, faces); … … 520 518 mObjects.reserve(intersectables); 521 519 mSceneGraph->CollectObjects(&mObjects); 522 523 // temp hack524 //ExportObj("cropped_vienna.obj", mObjects); 520 521 mSceneGraph->AssignObjectIds(); 522 525 523 mSceneGraph->GetRoot()->UpdateBox(); 526 524 … … 605 603 bool 606 604 Preprocessor::Export( const string &filename, 607 608 609 610 { 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 605 const bool scene, 606 const bool kdtree 607 ) 608 { 609 Exporter *exporter = Exporter::GetExporter(filename); 610 611 if (exporter) { 612 if (2 && scene) 613 exporter->ExportScene(mSceneGraph->GetRoot()); 614 615 if (1 && kdtree) { 616 exporter->SetWireframe(); 617 exporter->ExportKdTree(*mKdTree); 618 } 619 620 delete exporter; 621 return true; 622 } 623 624 return false; 627 625 } 628 626 … … 631 629 { 632 630 // load the view cells assigning the found objects to the pvss 633 #if 1631 #if 0 634 632 cerr << "loading binary view cells" << endl; 635 633 ViewCellsManager *dummyViewCellsManager = … … 816 814 // use ascii format to store rays 817 815 #define USE_ASCII 0 818 819 820 static inline bool ilt(Intersectable *obj1, Intersectable *obj2)821 {822 return obj1->mId < obj2->mId;823 }824 816 825 817 -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
r2176 r2544 100 100 SceneGraph::AssignObjectIds() 101 101 { 102 int id = 1; 103 stack<SceneGraphNode *> nodeStack; 104 105 nodeStack.push(mRoot); 102 // matt: rather start with id zero 103 int id = 0; 104 stack<SceneGraphNode *> nodeStack; 106 105 107 while (!nodeStack.empty()) { 108 SceneGraphNode *node = nodeStack.top(); 109 nodeStack.pop(); 110 111 ObjectContainer::iterator mi = node->mGeometry.begin(); 112 for (; mi != node->mGeometry.end(); mi++) { 113 (*mi)->SetId(id++); 106 nodeStack.push(mRoot); 107 108 while (!nodeStack.empty()) 109 { 110 SceneGraphNode *node = nodeStack.top(); 111 nodeStack.pop(); 112 113 ObjectContainer::iterator mi = node->mGeometry.begin(); 114 115 for (; mi != node->mGeometry.end(); mi ++) 116 { 117 (*mi)->SetId(id ++); 118 } 119 120 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 121 for (; ni != node->mChildren.end(); ni ++) 122 { 123 nodeStack.push(*ni); 124 } 114 125 } 115 116 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 117 for (; ni != node->mChildren.end(); ni++) { 118 nodeStack.push(*ni); 119 } 120 } 121 122 // return max id 123 return id; 126 127 // return max id 128 return id; 124 129 } 125 130 -
GTP/trunk/Lib/Vis/Preprocessing/src/TraversalTree.cpp
r2176 r2544 480 480 AxisAlignedBox3 box = (*mi)->GetBox(); 481 481 482 //cout << "box: " << box << endl; 483 splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 484 box.Max(axis), 485 *mi) 486 ); 482 splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, box.Max(axis), *mi)); 487 483 } 488 484 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r2543 r2544 14 14 #include "Exporter.h" 15 15 #include "BvHierarchy.h" 16 16 #include "Timer/PerfTimer.h" 17 17 18 18 … … 22 22 #define TYPE_INTERIOR -2 23 23 #define TYPE_LEAF -3 24 25 static PerfTimer sPvsTimer; 26 static PerfTimer sSearchTimer; 27 24 28 25 29 … … 2670 2674 const ObjectContainer &pvsObjects) 2671 2675 { 2672 int leafId = TYPE_LEAF; 2673 int objId = leafId; 2676 VspViewCell *leaf = new VspViewCell(); 2677 2678 Intersectable *obj; 2679 2680 sPvsTimer.Entry(); 2681 2674 2682 int pvsSize; 2675 2676 2683 stream.read(reinterpret_cast<char *>(&pvsSize), sizeof(int)); 2677 VspViewCell *leaf = new VspViewCell();2678 2679 // cerr << "\npvs size: " << pvsSize << endl;2680 2681 MeshInstance dummyInst(NULL);2682 2684 stream.read(reinterpret_cast<char *>(mPvsIds), sizeof(int) * pvsSize); 2685 2686 // just add pvs dirty, there won't be any duplicates 2687 ObjectPvs &pvs = leaf->GetPvs(); 2688 pvs.Reserve(pvsSize); 2689 2683 2690 // read object ids 2684 2691 for (int i = 0; i < pvsSize; ++ i) 2685 2692 { 2686 stream.read(reinterpret_cast<char *>(&objId), sizeof(int)); 2687 2688 // load the object 2689 dummyInst.SetId(objId); 2690 2691 ObjectContainer::const_iterator oit = 2692 lower_bound(pvsObjects.begin(), pvsObjects.end(), (Intersectable *)&dummyInst, ilt); 2693 2694 if ((oit != pvsObjects.end()) && ((*oit)->GetId() == objId)) 2695 { 2696 //cerr << "o"; 2697 leaf->GetPvs().AddSample(*oit, 0); 2698 } 2699 else 2700 { 2701 cerr << "x " << objId << " ";//error: object with id " << objId << " does not exist" << endl; 2702 } 2703 } 2693 obj = pvsObjects[mPvsIds[i]]; 2694 if (obj) pvs.AddSampleDirty(obj, 0); 2695 } 2696 2697 sPvsTimer.Exit(); 2704 2698 2705 2699 return leaf; … … 2736 2730 queue<ViewCell *> tStack; 2737 2731 2732 sPvsTimer.Start(); 2733 2734 mPvsIds = new int[pvsObjects.size()]; 2735 2738 2736 // hack: we make a new root 2739 2737 DEL_PTR(mRoot); … … 2741 2739 mRoot = ImportNextNode(stream, NULL, pvsObjects); 2742 2740 2743 cerr << "root: " << mRoot << endl;2741 //cerr << "root: " << mRoot << endl; 2744 2742 tStack.push(mRoot); 2745 2743 … … 2768 2766 } 2769 2767 2768 Debug << "needed " << sPvsTimer.TotalTime() << " secs for pvs loading" << endl; 2769 2770 delete mPvsIds; 2771 2770 2772 return true; 2771 2773 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r2539 r2544 25 25 26 26 27 //class ObjectPvs;28 29 27 30 28 /** Statistics for a view cell partition. 31 29 */ 32 33 30 class ViewCellsStatistics: public StatisticsBase 34 31 { … … 84 81 85 82 83 /** Statistics for a view cells tree. 84 */ 86 85 class ViewCellsTreeStats 87 86 { … … 142 141 143 142 144 /** 145 A view cell. View cells are regions in space. The visibility informations, 146 i.e., the primitives seen by the view cell are stored in a PVs. 147 A view cell can be represented in many different ways, e.g., 148 a mesh representation. 143 /** This class represents a view cell, which is a region in view space. 144 The objects seen by the view cell are stored in a pvs. 145 A view cell can be represented in many different ways, e.g., as a mesh. 149 146 */ 150 147 class ViewCell: public MeshInstance … … 156 153 157 154 ViewCell(); 158 159 155 /** Constructor taking a mesh representing the shape of the viewcell. 160 156 */ 161 157 ViewCell(Mesh *mesh); 162 163 158 /** Default destructor. 164 159 */ 165 160 virtual ~ViewCell(); 166 /** Returns Pvs.161 /** Returns const reference to pvs. 167 162 */ 168 163 const ObjectPvs &GetPvs() const; 169 /** Returns pvs.164 /** Returns reference to pvs. 170 165 */ 171 166 ObjectPvs &GetPvs(); … … 222 217 */ 223 218 bool GetValid() const; 224 225 219 /** Returns estimated render cost of this view cell. 226 220 */ 227 221 float GetRenderCost() const; 228 229 222 /** set color for visiualizations. 230 223 */ 231 224 void SetColor(const RgbColor &color); 232 233 225 /** get color for visualuzations. 234 226 */ 235 227 RgbColor GetColor() const; 236 237 228 /** Adds a sample to the pvs. 238 229 @param sample the sample to be added … … 241 232 */ 242 233 bool AddPvsSample(Intersectable *sample, const float pdf, float &contribution); 243 244 234 /** if this is a view cell correspending to a leaf in a hierarchy. 245 235 */ … … 257 247 */ 258 248 void SetMergeCost(const float mergeCost); 259 260 249 /** Returns merge cost needed to merge this leaf from other cells. 261 250 @hack The function is available for leaves also to have a common interface, … … 391 380 { 392 381 public: 393 ViewCellLeaf() { mActiveViewCell = this; } 394 ViewCellLeaf(Mesh *mesh): 395 ViewCell(mesh) { mActiveViewCell = this; } 382 383 ViewCellLeaf() 384 { 385 mActiveViewCell = this; 386 } 387 388 ViewCellLeaf(Mesh *mesh): ViewCell(mesh) 389 { 390 mActiveViewCell = this; 391 } 396 392 397 393 bool IsLeaf() const … … 454 450 public: 455 451 452 /** Default constructor. 453 */ 456 454 ViewCellsTree(); 457 458 455 /** View cells tree constructor taking a view cell mnanager as parameter 459 456 */ 460 457 ViewCellsTree(ViewCellsManager *vcm); 458 /** Destructor. 459 */ 461 460 ~ViewCellsTree(); 462 463 461 /** Returns number of leaves this view cell consists of. 464 462 */ 465 463 int GetNumInitialViewCells(ViewCell *vc) const; 466 467 464 /** Collects leaves corresponding to a view cell. 468 465 */ 469 466 void CollectLeaves(ViewCell *vc, ViewCellContainer &leaves) const; 470 471 467 /** Merges view cells according to some cost heuristics. 472 468 */ 473 469 int ConstructMergeTree(const VssRayContainer &rays, const ObjectContainer &objects); 474 475 470 /** Refines view cells using shuffling, i.e., border leaves 476 471 of two view cells are exchanged if the resulting view cells … … 479 474 */ 480 475 int RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects); 481 482 476 /** Assign colors to the viewcells so that they can be renderered interactively without 483 477 color flickering. 484 478 */ 485 479 void AssignRandomColors(); 486 487 480 /** Updates view cell stats for this particular view cell. 488 481 */ 489 482 void UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat); 490 491 483 /** Get costs resulting from each merge step. 492 484 */ 493 485 void GetCostFunction(vector<float> &costFunction); 494 495 486 /** Returns storage cost resulting from each merge step. 496 487 */ 497 488 void GetStorageFunction(vector<int> &storageCost); 498 499 489 /** Returns optimal set of view cells for a given number of view cells. 500 490 */ 501 491 void CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells); 502 503 492 /** Root of view cells tree. 504 493 */ 505 494 ViewCell *GetRoot() const; 506 507 495 /** Returns pvs of view cell. 508 496 @note pvs is returned per reference if tree is not compressed, … … 510 498 */ 511 499 void GetPvs(ViewCell *vc, ObjectPvs &pvs) const; 512 513 500 /** Returns pvs size (i.e. the render cost of the stored objects) 514 501 */ 515 502 float GetTrianglesInPvs(ViewCell *vc) const; 516 517 503 /** Returns number of entries associated with this view cell. 518 504 … … 522 508 */ 523 509 int GetPvsEntries(ViewCell *vc) const; 524 525 510 /** Returns the number of physically stored entries in the view cells sub tree. 526 511 This can vary based on the current storage method 527 512 */ 528 513 int CountStoredPvsEntries(ViewCell *root) const; 529 530 514 /** Returns memory cost of this view cell. 531 515 */ 532 516 float GetMemoryCost(ViewCell *vc) const; 533 534 517 /** Sets method of storage for view cells. 535 518 */ 536 519 void SetViewCellsStorage(int type); 537 538 520 /** pvs storage methods 539 521 */ 540 522 enum {PVS_IN_INTERIORS, COMPRESSED, PVS_IN_LEAVES}; 541 542 523 /** If view cells in this tree have compressed pvs. 543 524 */ 544 525 int ViewCellsStorage() const; 545 546 526 /** Returns active view cell that is in the path of this view cell. 547 527 */ … … 736 716 int mMaxMergesPerPass; 737 717 float mAvgCostMaxDeviation; 718 719 int *mPvsIds; 720 ObjectContainer mTempObjects; 738 721 }; 739 722 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2543 r2544 1021 1021 if (!Debug.is_open()) Debug.open("debug.log"); 1022 1022 1023 Debug << "here23" << endl;1024 1023 // give just an empty container as parameter: 1025 1024 // this loading function is used in the engine, thus it … … 1040 1039 stream.read(reinterpret_cast<char *>(&numBoxes), sizeof(int)); 1041 1040 1041 iboxes.reserve(numBoxes); 1042 1043 Vector3 bmin; 1044 Vector3 bmax; 1045 int id; 1046 1047 PerfTimer boxTimer; 1048 1049 boxTimer.Start(); 1050 boxTimer.Entry(); 1051 1042 1052 for (int i = 0; i < numBoxes; ++ i) 1043 1053 { 1044 Vector3 bmin;1045 Vector3 bmax;1046 int id;1047 1048 1054 stream.read(reinterpret_cast<char *>(&bmin), sizeof(Vector3)); 1049 1055 stream.read(reinterpret_cast<char *>(&bmax), sizeof(Vector3)); 1050 1056 stream.read(reinterpret_cast<char *>(&id), sizeof(int)); 1051 1057 1052 AxisAlignedBox3 box(bmin, bmax); 1053 iboxes.push_back(IndexedBoundingBox(id, box)); 1054 } 1058 iboxes.push_back(IndexedBoundingBox(id, AxisAlignedBox3(bmin, bmax))); 1059 } 1060 1061 1062 boxTimer.Exit(); 1063 1064 Debug << numBoxes << " boxes loaded in " << boxTimer.TotalTime() << " secs" << endl; 1055 1065 } 1056 1066 … … 6603 6613 return false; 6604 6614 6605 /*if (strstr(filename.c_str(), ".bn")) 6606 { 6607 cout << "exporting view cells to binary format" << endl; 6615 if (strstr(filename.c_str(), ".bn")) 6616 { 6608 6617 return ExportViewCellsBinary(filename, exportPvs, objects); 6609 } */6610 6611 cout << "exporting binary" << endl; string fname("test.vc"); return ExportViewCellsBinary(fname, exportPvs, objects);6618 } 6619 6620 //cout << "exporting binary" << endl; string fname("test.vc"); return ExportViewCellsBinary(fname, exportPvs, objects); 6612 6621 6613 6622 const long starttime = GetTime(); … … 6767 6776 stream.close(); 6768 6777 6769 mHierarchyManager->GetVspTree()->TestOutput("output.txt");6778 //mHierarchyManager->GetVspTree()->TestOutput("output.txt"); 6770 6779 6771 6780 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3 << " secs" << endl; … … 7121 7130 const long startTime = GetTime(); 7122 7131 7132 // load all the bounding boxes 7123 7133 IndexedBoundingBoxContainer iboxes; 7124 7134 ViewCellsManager::LoadIndexedBoundingBoxesBinary(stream, iboxes); 7125 7135 7126 Debug << (int)iboxes.size() << " boxes loaded" << endl; 7127 7128 /*IndexedBoundingBoxContainer::const_iterator bit, bit_end = iboxes.end(); 7129 for (bit = iboxes.begin(); bit != bit_end; ++ bit) 7130 { 7131 IndexedBoundingBox ibox = *bit; 7132 cerr << "box: " << ibox.first << " " << ibox.second << endl; 7133 }*/ 7134 7136 pvsObjects.reserve(iboxes.size()); 7135 7137 7136 7138 if (bconverter) 7137 7139 { 7138 // all bounding boxes gathered in this step =>7139 7140 // associate object ids with bounding boxes 7140 7141 bconverter->IdentifyObjects(iboxes, pvsObjects); … … 7142 7143 7143 7144 // sort objects by id 7144 sort(pvsObjects.begin(), pvsObjects.end(), ilt); 7145 7145 //sort(pvsObjects.begin(), pvsObjects.end(), ilt); 7146 7147 7148 ObjectContainer pvsLookup; 7149 pvsLookup.resize(iboxes.size()); 7150 7151 for (size_t i = 0; i < pvsLookup.size(); ++ i) 7152 { 7153 pvsLookup[i] = NULL; 7154 } 7155 7156 for (size_t i = 0; i < pvsObjects.size(); ++ i) 7157 { 7158 pvsLookup[pvsObjects[i]->GetId()] = pvsObjects[i]; 7159 } 7160 7146 7161 7147 7162 ///////////// … … 7164 7179 ViewCellsTree *vcTree = new ViewCellsTree(); 7165 7180 7166 if (!vcTree->ImportBinary(stream, pvs Objects))7181 if (!vcTree->ImportBinary(stream, pvsLookup)) 7167 7182 { 7168 7183 Debug << "Error: loading view cells tree failed!" << endl; … … 7177 7192 vspTree->mBoundingBox = viewSpaceBox; 7178 7193 7179 if (!vspTree->ImportBinary(stream , pvsObjects))7194 if (!vspTree->ImportBinary(stream)) 7180 7195 { 7181 7196 Debug << "Error: loading vsp tree failed!" << endl; … … 7198 7213 7199 7214 7200 7201 7215 ////////////// 7202 7216 //-- do some more preparation 7203 7217 7218 vm->mViewSpaceBox = viewSpaceBox; 7204 7219 vm->mViewCells.clear(); 7205 7220 … … 7232 7247 vc->mLeaves.push_back(leaf); 7233 7248 } 7249 7250 7251 /*for (cit = viewCells.begin(); cit != cit_end; ++ cit) 7252 { 7253 Debug << "pvssize: " << (*cit)->GetPvs().GetSize(); 7254 }*/ 7234 7255 7235 7256 … … 7247 7268 << TimeDiff(startTime, GetTime()) * 1e-6f << " secs" << endl; 7248 7269 7249 vspTree->TestOutput("input.txt");7270 //vspTree->TestOutput("input.txt"); 7250 7271 7251 7272 return vm; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2543 r2544 46 46 47 47 48 49 inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 50 { 51 return obj1->mId < obj2->mId; 52 } 53 54 48 55 // pvs penalty can be different from pvs size 49 56 inline static float EvalPvsPenalty(const float pvs, … … 2823 2830 if (node->IsLeaf()) 2824 2831 { 2825 /*const AxisAlignedBox3 box = GetBoundingBox(static_cast<VspLeaf *>(node)); 2832 const AxisAlignedBox3 box = GetBoundingBox(static_cast<VspLeaf *>(node)); 2833 2826 2834 if (!box.IsInside(point)) 2827 cerr<< "error, point " << point << " should be in view cell " << box << endl;2828 */2835 Debug << "error, point " << point << " should be in view cell " << box << endl; 2836 2829 2837 viewcell = static_cast<VspLeaf *>(node)->GetViewCell(); 2830 2838 break; … … 3919 3927 3920 3928 VspLeaf *VspTree::ImportBinLeaf(IN_STREAM &stream, 3921 VspInterior *parent, 3922 const ObjectContainer &pvsObjects) 3929 VspInterior *parent) 3923 3930 { 3924 3931 int leafId = TYPE_LEAF; … … 3933 3940 3934 3941 VspNode *VspTree::ImportNextNode(IN_STREAM &stream, 3935 VspInterior *parent, 3936 const ObjectContainer &objects) 3942 VspInterior *parent) 3937 3943 { 3938 3944 int nodeType; … … 3942 3948 { 3943 3949 //cerr << "l"; 3944 return ImportBinLeaf(stream, static_cast<VspInterior *>(parent) , objects);3950 return ImportBinLeaf(stream, static_cast<VspInterior *>(parent)); 3945 3951 } 3946 3952 … … 3978 3984 3979 3985 3980 bool VspTree::ImportBinary(IN_STREAM &stream , ObjectContainer &pvsObjects)3986 bool VspTree::ImportBinary(IN_STREAM &stream) 3981 3987 { 3982 3988 // export binary version of mesh … … 3988 3994 // hack: we make a new root 3989 3995 DEL_PTR(mRoot); 3990 mRoot = ImportNextNode(stream, NULL , pvsObjects);3996 mRoot = ImportNextNode(stream, NULL); 3991 3997 3992 3998 tStack.push(MyTraversalData(mRoot, 0, mBoundingBox)); … … 4008 4014 interior->SetBoundingBox(tData.mBox); 4009 4015 4010 VspNode *front = ImportNextNode(stream, interior , pvsObjects);4011 VspNode *back = ImportNextNode(stream, interior , pvsObjects);4012 4013 interior->SetupChildLinks( back, front);4016 VspNode *front = ImportNextNode(stream, interior); 4017 VspNode *back = ImportNextNode(stream, interior); 4018 4019 interior->SetupChildLinks(front, back); 4014 4020 4015 4021 ++ mVspStats.splits[interior->GetAxis()]; … … 4044 4050 CollectLeaves(vspLeaves); 4045 4051 4052 str << "root: " << mBoundingBox << endl; 4053 4046 4054 vector<VspLeaf *>::const_iterator vit, vit_end = vspLeaves.end(); 4047 4055 … … 4053 4061 str << "\nleaf: " << GetBoundingBox(leaf) << endl; 4054 4062 4063 ObjectContainer pvsObjects; 4064 4055 4065 ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 4056 4066 … … 4058 4068 { 4059 4069 Intersectable *obj = pit.Next(); 4060 str << obj->GetId() << " "; 4061 } 4062 } 4063 } 4064 4065 4066 } 4070 pvsObjects.push_back(obj); 4071 } 4072 4073 sort(pvsObjects.begin(), pvsObjects.end(), ilt); 4074 str << "pvs: " << pvsObjects.size() << endl; 4075 4076 for (int i = 0; i < pvsObjects.size(); ++ i) 4077 str << pvsObjects[i]->GetId() << " "; 4078 } 4079 } 4080 4081 4082 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r2543 r2544 258 258 */ 259 259 void SetupChildLinks(VspNode *front, VspNode *back); 260 /** Returns boundi Žng box of this node.260 /** Returns bounding box of this node. 261 261 */ 262 262 AxisAlignedBox3 GetBoundingBox() const; … … 661 661 /** Imports tree from binary format. 662 662 */ 663 bool ImportBinary(IN_STREAM &stream , ObjectContainer &pvsObjects);663 bool ImportBinary(IN_STREAM &stream); 664 664 665 665 void TestOutput(const std::string &filename); … … 867 867 868 868 VspInterior *ImportBinInterior(IN_STREAM &stream, VspInterior *parent); 869 VspLeaf *ImportBinLeaf(IN_STREAM &stream, VspInterior *parent , const ObjectContainer &pvsObjects);869 VspLeaf *ImportBinLeaf(IN_STREAM &stream, VspInterior *parent); 870 870 871 871 VspNode *ImportNextNode(IN_STREAM &stream, 872 VspInterior *parent, 873 const ObjectContainer &pvsObjects); 872 VspInterior *parent); 874 873 875 874
Note: See TracChangeset
for help on using the changeset viewer.