Changeset 2543 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 08/21/07 19:37:28 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2542 r2543 528 528 SimpleRay &ray) 529 529 { 530 // do not use this function since it could return different viewpoints for 531 // different executions of the algorithm 530 // do not use this function since it could return different 531 // viewpoints for different executions of the algorithm 532 532 533 int tries = 0; 533 534 Vector3 viewPoint, direction; … … 542 543 Mesh *mesh = viewCell->GetMesh(); 543 544 AxisAlignedBox3 box = mesh->mBox; 544 //cout <<"box: " << box << endl; 545 /*Vector3 pVector = Vector3(halton.GetNumber(1), 546 halton.GetNumber(2), 547 halton.GetNumber(3));*/ 548 545 549 546 Vector3 pVector = Vector3(Random(1.0f), 550 547 Random(1.0f), … … 553 550 viewPoint = box.GetPoint(pVector); 554 551 555 //const Vector3 dVector = Vector3(2 * M_PI * halton.GetNumber(4), M_PI*halton.GetNumber(5),0.0f);556 552 const Vector3 dVector = Vector3(2 * M_PI * Random(1.0f), M_PI * Random(1.0f), 0.0f); 557 553 direction = Normalize(Vector3(sin(dVector.x), 0.0f, cos(dVector.x))); 558 //halton.GenerateNext();559 554 560 555 ViewCell *v = GetViewCell(viewPoint); … … 564 559 mPreprocessor->GetRenderer()->mViewPoint = viewPoint; 565 560 mPreprocessor->GetRenderer()->mViewDirection = direction; 566 //mPreprocessor->GetRenderer()->EvalPvsStat(); 567 561 568 562 if (mPreprocessor->GetRenderer()->ValidViewPoint()) 569 563 { … … 574 568 } 575 569 576 // generate a new vector577 //halton.GenerateNext();578 579 //if (!box.IsInside(viewPoint))580 // cout << "error!" << endl;581 570 if (++ tries > maxTries) 582 571 { … … 672 661 673 662 DEL_PTR(mMixtureDistribution); 674 675 663 CLEAR_CONTAINER(mViewCellPoints); 676 664 } … … 829 817 830 818 // mix of sampling strategies 819 #if 0 831 820 vector<int>dummy; 832 //dummy.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION);833 //dummy.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION);834 //dummy.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION);835 821 dummy.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 822 dummy.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 823 dummy.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 824 #endif 836 825 CastPassSamples(mInitialSamples, mStrategies, initialSamples); 837 826 … … 1032 1021 if (!Debug.is_open()) Debug.open("debug.log"); 1033 1022 1023 Debug << "here23" << endl; 1034 1024 // give just an empty container as parameter: 1035 1025 // this loading function is used in the engine, thus it … … 1045 1035 1046 1036 1047 void ViewCellsManager::LoadIndexedBoundingBoxes(IN_STREAM &stream, IndexedBoundingBoxContainer &iboxes) 1048 { 1049 Vector3 bmin; 1050 Vector3 bmax; 1051 int id; 1052 1053 stream.read(reinterpret_cast<char *>(&bmin), sizeof(Vector3)); 1054 stream.read(reinterpret_cast<char *>(&bmax), sizeof(Vector3)); 1055 stream.read(reinterpret_cast<char *>(&id), sizeof(int)); 1056 1057 AxisAlignedBox3 box(bmin, bmax); 1058 1059 iboxes.push_back(IndexedBoundingBox(id, box)); 1060 //Debug << "bbox: " << box << endl; 1061 } 1062 1063 1064 ViewCellsManager *ViewCellsManager::LoadViewCellsBin(const string &filename, 1065 ObjectContainer &pvsObjects, 1066 ObjectContainer &preprocessorObjects, 1067 bool finalizeViewCells, 1068 BoundingBoxConverter *bconverter) 1069 { 1070 IN_STREAM stream(filename.c_str()); 1071 1072 IndexedBoundingBoxContainer iboxes; 1073 LoadIndexedBoundingBoxes(stream, iboxes); 1074 1075 if (bconverter) 1076 { 1077 // all bounding boxes gathered in this step => 1078 // associate object ids with bounding boxes 1079 bconverter->IdentifyObjects(iboxes, pvsObjects); 1080 } 1081 1082 // sort objects by id 1083 sort(pvsObjects.begin(), pvsObjects.end(), ilt); 1084 1085 ViewCellsTree *vcTree = new ViewCellsTree(); 1086 VspTree *vspTree = new VspTree(); 1087 1088 HierarchyManager *hm = new HierarchyManager(0); 1089 1090 vspTree->ImportBinary(stream, pvsObjects); 1091 1092 VspOspViewCellsManager *vcm = new VspOspViewCellsManager(vcTree, hm); 1093 1094 return vcm; 1037 void ViewCellsManager::LoadIndexedBoundingBoxesBinary(IN_STREAM &stream, IndexedBoundingBoxContainer &iboxes) 1038 { 1039 int numBoxes; 1040 stream.read(reinterpret_cast<char *>(&numBoxes), sizeof(int)); 1041 1042 for (int i = 0; i < numBoxes; ++ i) 1043 { 1044 Vector3 bmin; 1045 Vector3 bmax; 1046 int id; 1047 1048 stream.read(reinterpret_cast<char *>(&bmin), sizeof(Vector3)); 1049 stream.read(reinterpret_cast<char *>(&bmax), sizeof(Vector3)); 1050 stream.read(reinterpret_cast<char *>(&id), sizeof(int)); 1051 1052 AxisAlignedBox3 box(bmin, bmax); 1053 iboxes.push_back(IndexedBoundingBox(id, box)); 1054 } 1095 1055 } 1096 1056 … … 1100 1060 ObjectContainer &preprocessorObjects, 1101 1061 bool finalizeViewCells, 1102 BoundingBoxConverter *bconverter) 1103 1062 BoundingBoxConverter *bconverter) 1104 1063 { 1105 1064 ViewCellsParser parser; … … 1145 1104 if (finalizeViewCells) 1146 1105 { 1106 // do some final computations, e.g., 1147 1107 // create the meshes and compute view cell volumes 1148 1108 const bool createMeshes = true; … … 1250 1210 } 1251 1211 1212 1252 1213 void ViewCellsManager::EvalViewCellHistogram(const string filename, 1253 1214 const int nViewCells) … … 1257 1218 1258 1219 ViewCellContainer viewCells; 1259 // $$ JB hack - the collect best viewcells does not work?1260 #if 1 1220 1221 // the collect best viewcells does not work? 1261 1222 mViewCellsTree->CollectBestViewCellSet(viewCells, nViewCells); 1262 #else1263 viewCells = mViewCells;1264 #endif1265 1223 1266 1224 float maxRenderCost, minRenderCost; … … 3192 3150 if (boxesIn.eof()) 3193 3151 break; 3194 3195 3152 3196 3153 AxisAlignedBox3 box(bmin, bmax); 3197 3154 MeshInstance *mi = new MeshInstance(NULL); 3198 3155 3199 // HACK: set bounding box to new box3200 //mi->mBox = box;3201 //boxes.push_back(mi);3202 3156 boxes.push_back(IndexedBoundingBox(id, box)); 3203 3157 } … … 3256 3210 return; 3257 3211 3258 if (viewSpaceFilterSize >= 0.0f) {3259 3212 if (viewSpaceFilterSize >= 0.0f) 3213 { 3260 3214 const bool usePrVS = false; 3261 3215 3262 if (!usePrVS) { 3216 if (!usePrVS) 3217 { 3263 3218 AxisAlignedBox3 box = GetViewCellBox(viewCell); 3264 3219 box.Enlarge(Vector3(viewSpaceFilterSize/2)); … … 3278 3233 pvs = interPvs; 3279 3234 } 3280 } else 3235 } 3236 else 3281 3237 { 3282 3238 PrVs prvs; … … 3349 3305 ) 3350 3306 { 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3307 // now compute a new Pvs by including also objects intersecting the 3308 // extended boxes of visible objects 3309 Intersectable::NewMail(); 3310 3311 ObjectPvsIterator pit = pvs.GetIterator(); 3312 3313 while (pit.HasMoreEntries()) 3314 pit.Next()->Mail(); 3315 3316 ObjectPvs nPvs; 3317 int nPvsSize = 0; 3318 3319 ObjectPvsIterator pit2 = pvs.GetIterator(); 3320 3321 while (pit2.HasMoreEntries()) 3322 { 3323 // now go through the pvs again 3324 Intersectable *object = pit2.Next(); 3325 3326 // Vector3 center = object->GetBox().Center(); 3327 // AxisAlignedBox3 box(center - Vector3(spatialFilterSize/2), 3328 // center + Vector3(spatialFilterSize/2)); 3329 3330 AxisAlignedBox3 box = object->GetBox(); 3331 box.Enlarge(Vector3(spatialFilterSize/2)); 3332 3333 ObjectContainer objects; 3334 3335 // $$ warning collect objects takes only unmailed ones! 3336 kdTree->CollectObjects(box, objects); 3337 // cout<<"collected objects="<<objects.size()<<endl; 3338 ObjectContainer::const_iterator noi = objects.begin(); 3339 for (; noi != objects.end(); ++ noi) 3340 { 3341 Intersectable *o = *noi; 3342 cout<<"w"; 3343 // $$ JB warning: pdfs are not correct at this point! 3344 nPvs.AddSample(o, Limits::Small); 3345 nPvsSize ++; 3346 } 3347 } 3348 3349 // cout<<"nPvs size = "<<nPvsSize<<endl; 3350 pvs.MergeInPlace(nPvs); 3395 3351 } 3396 3352 … … 3433 3389 ) 3434 3390 { 3391 pvs.Reserve(viewCell->GetFilteredPvsSize()); 3392 3435 3393 PvsFilterStatistics stats; 3436 3394 3437 3395 AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 3438 Vector3 center = vbox.Center(); 3396 const Vector3 center = vbox.Center(); 3397 3439 3398 // copy the PVS 3440 Intersectable::NewMail(); 3399 if (!mUseKdPvs) 3400 Intersectable::NewMail(); 3401 else 3402 KdNode::NewMail(); 3403 3441 3404 ObjectPvs basePvs = viewCell->GetPvs(); 3442 3405 ObjectPvsIterator pit = basePvs.GetIterator(); 3443 3406 3444 pvs.Reserve(viewCell->GetFilteredPvsSize());3445 3446 3407 if (!mUseKdPvs) 3447 { 3448 // first mark all objects from this pvs 3408 { // first mark all objects from this pvs 3449 3409 while (pit.HasMoreEntries()) 3450 3410 pit.Next()->Mail(); … … 3453 3413 int pvsSize = 0; 3454 3414 int nPvsSize = 0; 3455 float samples = (float)basePvs.GetSamples(); 3456 3457 Debug<<"f #s="<<samples<<" pvs size = "<<basePvs.GetSize(); 3415 3416 //Debug<<"f #s="<<samples<<" pvs size = "<<basePvs.GetSize(); 3458 3417 // cout<<"Filter size = "<<filterSize<<endl; 3459 3418 // cout<<"vbox = "<<vbox<<endl; … … 3468 3427 // and gobal estimate for the view cell 3469 3428 // (total #rays intersecting the viewcell) 3470 int minLocalSamples = 2; 3471 3472 float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 3473 3474 // now compute the filter box around the current viewCell 3429 const int minLocalSamples = 2; 3430 const float viewCellRadius = 0.5f * Magnitude(vbox.Diagonal()); 3431 3432 float samples = (float)basePvs.GetSamples(); 3433 3434 ////////// 3435 //-- now compute the filter box around the current viewCell 3475 3436 3476 3437 if (useViewSpaceFilter) 3477 3438 { 3478 // 3479 float radius = viewCellRadius /100.0f;3439 // float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 3440 float radius = viewCellRadius / 100.0f; 3480 3441 vbox.Enlarge(radius); 3481 3442 cout<<"vbox = "<<vbox<<endl; 3443 3482 3444 ViewCellContainer viewCells; 3483 3445 ComputeBoxIntersections(vbox, viewCells); … … 3487 3449 for (int i = 0; it != it_end; ++ it, ++ i) 3488 3450 { 3489 3490 3451 if ((*it) != viewCell) 3491 3452 { … … 3592 3553 } 3593 3554 } 3555 3594 3556 stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 3595 3557 } … … 3613 3575 viewCell->SetFilteredPvsSize(pvs.GetSize()); 3614 3576 3615 Intersectable::NewMail(); 3577 //cout << "pvssize: " << pvs.GetSize() << endl; 3578 // warning: not thread-safe! 3579 if (!mUseKdPvs) 3580 Intersectable::NewMail(); 3581 3616 3582 return stats; 3617 3583 } … … 3735 3701 Intersectable::NewMail(); 3736 3702 3703 3737 3704 /////////// 3738 3705 //-- merge pvss 3739 3706 3707 PvsData pvsData; 3708 3740 3709 vector<ObjectPvs>::iterator oit = pvsList.begin(); 3741 3742 PvsData pvsData;3743 3710 3744 3711 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) … … 4786 4753 exporter->SetWireframe(); 4787 4754 4788 // matt: we do n't have nokd pvs4755 // matt: we do not use kd pvs 4789 4756 #if 0 4790 4757 KdPvsMap::iterator kit = object->mKdPvs.mEntries.begin(); … … 5919 5886 { 5920 5887 Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", mInitialSamples); 5921 5922 5888 Environment::GetSingleton()->GetBoolValue("ViewCells.compressObjects", mCompressObjects); 5923 5889 … … 5926 5892 5927 5893 mHierarchyManager = CreateHierarchyManager(hierarchyType); 5894 5928 5895 mHierarchyManager->SetViewCellsManager(this); 5929 5896 mHierarchyManager->SetViewCellsTree(mViewCellsTree); … … 6247 6214 ) const 6248 6215 { 6216 Plane3 plane; 6217 if (clipPlane) 6218 { 6219 // arbitrary plane definition 6220 plane = clipPlane->GetPlane(); 6221 } 6222 6249 6223 ViewCellContainer leaves; 6250 6224 mViewCellsTree->CollectLeaves(vc, leaves); 6225 6251 6226 ViewCellContainer::const_iterator it, it_end = leaves.end(); 6252 6253 Plane3 plane;6254 if (clipPlane)6255 {6256 // arbitrary plane definition6257 plane = clipPlane->GetPlane();6258 }6259 6227 6260 6228 for (it = leaves.begin(); it != it_end; ++ it) … … 6522 6490 { 6523 6491 Material m; 6524 6525 6492 Intersectable::NewMail(); 6526 6493 … … 6636 6603 return false; 6637 6604 6638 cout << "exporting binary" << endl; 6639 string fname("test.vc"); 6640 return ExportBinaryViewCells(fname, exportPvs, objects); 6605 /*if (strstr(filename.c_str(), ".bn")) 6606 { 6607 cout << "exporting view cells to binary format" << endl; 6608 return ExportViewCellsBinary(filename, exportPvs, objects); 6609 }*/ 6610 6611 cout << "exporting binary" << endl; string fname("test.vc"); return ExportViewCellsBinary(fname, exportPvs, objects); 6641 6612 6642 6613 const long starttime = GetTime(); … … 6662 6633 6663 6634 int id = 0; 6664 6665 6635 vector<KdIntersectable *>::const_iterator kit, kit_end = mPreprocessor->mKdTree->mKdIntersectables.end(); 6666 6636 … … 6697 6667 6698 6668 6699 ///////////////// /////6669 ///////////////// 6700 6670 //-- export the view space hierarchy 6701 6671 … … 6707 6677 stream << "</ViewSpaceHierarchy>" << endl; 6708 6678 6709 ///////////////// /////6710 //-- export the object space partition6679 ///////////////// 6680 //-- export the object space hierarchy 6711 6681 6712 6682 mHierarchyManager->ExportObjectSpaceHierarchy(stream); … … 6720 6690 6721 6691 6722 bool VspOspViewCellsManager::Export BinaryViewCells(const string filename,6692 bool VspOspViewCellsManager::ExportViewCellsBinary(const string filename, 6723 6693 const bool exportPvs, 6724 6694 const ObjectContainer &objects) … … 6736 6706 CreateUniqueViewCellIds(); 6737 6707 6738 int numBo undingBoxes = mPreprocessor->mKdTree->mKdIntersectables.size();6739 stream.write(reinterpret_cast<char *>(&numBo undingBoxes), sizeof(int));6708 int numBoxes = mPreprocessor->mKdTree->mKdIntersectables.size(); 6709 stream.write(reinterpret_cast<char *>(&numBoxes), sizeof(int)); 6740 6710 6741 6711 … … 6751 6721 { 6752 6722 Intersectable *obj = (*kit); 6723 // set the kd node id to identify the kd node as a pvs entry 6724 obj->SetId(id); 6725 6753 6726 const AxisAlignedBox3 &box = obj->GetBox(); 6754 6755 // setting the kd node id important to identify the kd node as pvs entry6756 obj->SetId(id);6757 6758 6727 Vector3 bmin = box.Min(); 6759 6728 Vector3 bmax = box.Max(); … … 6764 6733 } 6765 6734 6735 cout << "written " << numBoxes << " kd nodes" << endl; 6766 6736 6767 6737 /////////////// 6768 6738 //-- export the view cells and the pvs 6769 6739 6770 int numViewCells = m CurrentViewCellsStats.viewCells;6740 int numViewCells = mViewCells.size(); 6771 6741 stream.write(reinterpret_cast<char *>(&numViewCells), sizeof(int)); 6772 6742 … … 6777 6747 stream.write(reinterpret_cast<char *>(&vmax), sizeof(Vector3)); 6778 6748 6779 // todo 6749 6750 ////////// 6751 //-- export binary view cells 6752 6780 6753 mViewCellsTree->ExportBinary(stream); 6781 6754 6782 6755 6783 ///////// /////////////6756 ///////// 6784 6757 //-- export the view space hierarchy 6785 6758 6786 6759 mHierarchyManager->GetVspTree()->ExportBinary(stream); 6787 6760 6761 6762 //////// 6763 //-- export the object space hierarchy 6764 6765 //mHierarchyManager->ExportObjectSpaceHierarchyBinary(); 6766 6788 6767 stream.close(); 6789 6768 6769 mHierarchyManager->GetVspTree()->TestOutput("output.txt"); 6770 6790 6771 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3 << " secs" << endl; 6791 6772 return true; … … 6888 6869 if (!(ViewCellsTreeConstructed() && mCompressViewCells)) 6889 6870 return; 6871 6890 6872 6891 6873 //////////// … … 7042 7024 cout << "computing histogram for " << pass << " view cells" << endl; 7043 7025 7044 /////////////////// //////////7026 /////////////////// 7045 7027 //-- evaluate histogram for pvs size 7046 7028 … … 7060 7042 7061 7043 if (mHierarchyManager->mUseTraversalTree) 7062 { 7063 // create a traversal tree for optimal view cell casting 7044 { // create a traversal tree for optimal view cell casting 7064 7045 mHierarchyManager->CreateTraversalTree(); 7065 7046 } … … 7097 7078 { 7098 7079 ComputeSampleContribution(*tmpRays[i], addContributions, true, useHitObjects); 7099 7100 //////////7101 7080 // compare results 7102 cout << "ray " << i << ": " << (int)tmpRays[i]->mViewCells.size() << " " << (int)packet.mViewCells[i].size() << endl; 7081 cout << "ray " << i << ": " << (int)tmpRays[i]->mViewCells.size() << " " 7082 << (int)packet.mViewCells[i].size() << endl; 7103 7083 } 7104 7084 … … 7127 7107 BoundingBoxConverter *bconverter) 7128 7108 { 7129 ViewCellsParser parser; 7130 ViewCellsManager *vm = NULL; 7109 if (!Debug.is_open()) Debug.open("debug.log"); 7110 7111 IN_STREAM stream(filename.c_str()); 7112 7113 if (!stream.is_open()) 7114 { 7115 Debug << "View cells loading failed: could not open file" << endl; 7116 return NULL; 7117 } 7118 7119 Debug << "loading boxes" << endl; 7131 7120 7132 7121 const long startTime = GetTime(); 7133 const bool success = false; 7134 7135 if (!success) 7136 { 7137 Debug << "Error: loading view cells failed!" << endl; 7138 DEL_PTR(vm); 7139 7122 7123 IndexedBoundingBoxContainer iboxes; 7124 ViewCellsManager::LoadIndexedBoundingBoxesBinary(stream, iboxes); 7125 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 7135 7136 if (bconverter) 7137 { 7138 // all bounding boxes gathered in this step => 7139 // associate object ids with bounding boxes 7140 bconverter->IdentifyObjects(iboxes, pvsObjects); 7141 } 7142 7143 // sort objects by id 7144 sort(pvsObjects.begin(), pvsObjects.end(), ilt); 7145 7146 7147 ///////////// 7148 //-- load the view cells 7149 7150 int numViewCells; 7151 stream.read(reinterpret_cast<char *>(&numViewCells), sizeof(int)); 7152 7153 Debug << "loading " << numViewCells << " view cells " << endl; 7154 7155 Vector3 vmin, vmax; 7156 7157 stream.read(reinterpret_cast<char *>(&vmin), sizeof(Vector3)); 7158 stream.read(reinterpret_cast<char *>(&vmax), sizeof(Vector3)); 7159 7160 AxisAlignedBox3 viewSpaceBox(vmin, vmax); 7161 7162 Debug << "view space box: " << viewSpaceBox << endl; 7163 7164 ViewCellsTree *vcTree = new ViewCellsTree(); 7165 7166 if (!vcTree->ImportBinary(stream, pvsObjects)) 7167 { 7168 Debug << "Error: loading view cells tree failed!" << endl; 7169 delete vcTree; 7170 7140 7171 return NULL; 7141 7172 } 7142 7143 ViewCellContainer leaves; 7173 7174 Debug << "loading the view space partition tree" << endl; 7175 VspTree *vspTree = new VspTree(); 7176 7177 vspTree->mBoundingBox = viewSpaceBox; 7178 7179 if (!vspTree->ImportBinary(stream, pvsObjects)) 7180 { 7181 Debug << "Error: loading vsp tree failed!" << endl; 7182 delete vcTree; delete vspTree; 7183 7184 return NULL; 7185 } 7186 7187 7188 HierarchyManager * hm = 7189 new HierarchyManager(HierarchyManager::BV_BASED_OBJ_SUBDIV); 7190 7191 hm->SetVspTree(vspTree); 7192 7193 7194 ///////// 7195 //-- create view cells manager 7196 7197 VspOspViewCellsManager *vm = new VspOspViewCellsManager(vcTree, hm); 7198 7199 7200 7201 ////////////// 7202 //-- do some more preparation 7144 7203 7145 7204 vm->mViewCells.clear(); 7146 vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 7147 7148 ViewCellContainer::const_iterator it, it_end = leaves.end(); 7149 7150 for (it = leaves.begin(); it != it_end; ++ it) 7151 { 7152 vm->mViewCells.push_back(*it); 7153 } 7205 7206 ViewCellContainer viewCells; 7207 vcTree->CollectLeaves(vcTree->GetRoot(), viewCells); 7208 7209 ViewCellContainer::const_iterator cit, cit_end = viewCells.end(); 7210 7211 for (cit = viewCells.begin(); cit != cit_end; ++ cit) 7212 { 7213 vm->mViewCells.push_back(*cit); 7214 } 7215 7216 7217 ////////////// 7218 //-- associate view cells with vsp leaves 7219 7220 vector<VspLeaf *> vspLeaves; 7221 vspTree->CollectLeaves(vspLeaves); 7222 7223 vector<VspLeaf *>::const_iterator vit, vit_end = vspLeaves.end(); 7224 cit = viewCells.begin(); 7225 7226 for (vit = vspLeaves.begin(); vit != vit_end; ++ vit, ++ cit) 7227 { 7228 VspLeaf *leaf = *vit; 7229 VspViewCell *vc = static_cast<VspViewCell *>(*cit); 7230 7231 leaf->SetViewCell(vc); 7232 vc->mLeaves.push_back(leaf); 7233 } 7234 7154 7235 7155 7236 vm->mViewCellsFinished = true; … … 7163 7244 } 7164 7245 7165 cout << (int)vm->mViewCells.size() << " view cells loaded in "7166 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl;7167 7168 7246 Debug << (int)vm->mViewCells.size() << " view cells loaded in " 7169 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 7170 7247 << TimeDiff(startTime, GetTime()) * 1e-6f << " secs" << endl; 7248 7249 vspTree->TestOutput("input.txt"); 7250 7171 7251 return vm; 7172 7252 }
Note: See TracChangeset
for help on using the changeset viewer.