- Timestamp:
- 10/17/05 18:57:10 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r331 r332 9 9 # filename vienna.x3d 10 10 # filename ../data/vienna/vienna-simple.x3d 11 #filename ../data/vienna/vienna-buildings.x3d11 filename ../data/vienna/vienna-buildings.x3d 12 12 # filename ../data/vienna/viewcells-25-sel.x3d 13 filename ../data/atlanta/atlanta2.x3d13 # filename ../data/atlanta/atlanta2.x3d 14 14 # filename ../data/soda/soda.dat 15 15 # filename ../data/soda/soda5.dat … … 92 92 # vertical axis = 64 93 93 # blocked rays = 128 94 94 # least ray splits = 256 95 # balanced rays = 512 96 95 97 # least splits + balanced polygons 96 98 #splitPlaneStrategy 12 … … 108 110 #splitPlaneStrategy 72 109 111 110 splitPlaneStrategy 8 112 # axis aligned + blocked rays 113 #splitPlaneStrategy 130 111 114 112 maxCandidates 50 115 splitPlaneStrategy 66 116 117 maxCandidates 130 113 118 114 119 Termination { 120 # autopartition 121 maxRays -1 122 maxPolygons 4 123 maxDepth 100 124 125 #axis aligned split 115 126 maxPolysForAxisAligned 100 116 max Polygons 2117 maxDepth 100127 maxCostRatio 0.9 128 ct_div_ci 0.5 118 129 } 130 131 #axis aligned split 132 splitBorder 0.01 133 119 134 # if split polys are stored for visualization 120 135 storeSplitPolys false -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r329 r332 1180 1180 "0.002"); 1181 1181 1182 1183 1182 RegisterOption("BspTree.Termination.maxPolygons", 1184 1183 optInt, 1185 1184 "-bsp_term_max_polygons=", 1186 1185 "5"); 1187 1186 1187 RegisterOption("BspTree.Termination.maxRays", 1188 optInt, 1189 "-bsp_term_max_rays=", 1190 "-1"); 1191 1188 1192 RegisterOption("BspTree.Termination.maxPolysForAxisAligned", 1189 1193 optInt, … … 1195 1199 "-bsp_term_max_depth=", 1196 1200 "100"); 1201 1202 RegisterOption("BspTree.Termination.maxCostRatio", 1203 optFloat, 1204 "-bsp_term_max_cost_ratio=", 1205 "1.5"); 1206 1207 RegisterOption("BspTree.Termination.ct_div_ci", 1208 optFloat, 1209 "-bsp_term_ct_div_ci=", 1210 "1.0"); 1211 1212 RegisterOption("BspTree.splitBorder", 1213 optFloat, 1214 "-bsp_split_border=", 1215 "0.1"); 1197 1216 1198 1217 RegisterOption("BspTree.storeSplitPolys", -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r331 r332 58 58 { 59 59 case BspTree::FROM_INPUT_VIEW_CELLS: 60 mBspTree->SetGenerateViewCells(false); 60 61 mBspTree->Construct(mViewCells); 61 62 break; 62 63 case BspTree::FROM_SCENE_GEOMETRY: 63 64 DeleteViewCells(); // we generate new view cells 65 mBspTree->SetGenerateViewCells(true); 64 66 mSceneGraph->CollectObjects(&objects); 65 mBspTree->Construct(objects, &mViewCells); 67 mBspTree->Construct(objects); 68 Debug << "collecting view cells" << endl; 69 mBspTree->CollectViewCells(mViewCells); 66 70 break; 67 71 case BspTree::FROM_RAYS: 68 72 DeleteViewCells(); // we generate new view cells 69 mBspTree->Construct(mSampleRays, &mViewCells); 73 mBspTree->SetGenerateViewCells(true); 74 mBspTree->Construct(mSampleRays); 75 Debug << "collecting view cells" << endl; 76 mBspTree->CollectViewCells(mViewCells); 70 77 break; 71 78 default: … … 407 414 (totalSamples < mBspConstructionSamples)) 408 415 { 409 //cout << "pushing back sampling ray << " << mSampleRays.size() << endl;410 416 mSampleRays.push_back(new Ray(ray)); 411 417 } … … 417 423 BuildBspTree(); 418 424 425 cout << "generated " << (int)mViewCells.size() << " view cells" << endl; 426 passContributingSamples += mBspTree->GetStat().contributingSamples; 427 passSampleContributions += mBspTree->GetStat().pvs; 428 419 429 BspTreeStatistics(Debug); 420 430 Export("vc_bsptree.x3d", false, false, true); 421 431 } 422 // check whether we can add this to the rays 423 for (int k = 0; k < ray.viewCells.size(); ++ k) 424 for (int j = 0; j < (int)pvsViewCells.size(); ++ j) 425 if (pvsViewCells[j] == ray.viewCells[k]) 426 { 427 vcRays[j].push_back(ray); 428 } 432 429 433 // some random view cells for output 430 434 if (pvsViewCells.empty()) … … 438 442 pvsViewCells.push_back(mViewCells[Random((int)mViewCells.size())]); 439 443 } 444 } 445 else 446 { 447 // check whether we can add the current ray to the rays 448 for (int k = 0; k < (int)ray.viewCells.size(); ++ k) 449 for (int j = 0; j < (int)pvsViewCells.size(); ++ j) 450 if (pvsViewCells[j] == ray.viewCells[k]) 451 vcRays[j].push_back(ray); 440 452 } 441 453 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r331 r332 20 20 int BspTree::sConstructionMethod = FROM_INPUT_VIEW_CELLS; 21 21 int BspTree::sTermMaxPolysForAxisAligned = 50; 22 int BspTree::sTermMaxRays = -1; 22 23 23 24 float BspTree::sCt_div_ci = 1.0f; … … 34 35 float BspTree::sLargestPolyAreaFactor = 1.0f; 35 36 float BspTree::sBlockedRaysFactor = 1.0f; 37 float BspTree::sLeastRaySplitsFactor = 1.0f; 38 float BspTree::sBalancedRaysFactor = 1.0f; 36 39 37 40 bool BspTree::sStoreSplitPolys = false; … … 50 53 /****************************************************************/ 51 54 52 BspNode::BspNode(): mParent(NULL), mPolygons(NULL)//,mViewCellIdx(0) 55 BspNode::BspNode(): 56 mParent(NULL), mPolygons(NULL) 53 57 {} 54 58 55 BspNode::BspNode(BspInterior *parent): mParent(parent), mPolygons(NULL)//,mViewCellIdx(0) 59 BspNode::BspNode(BspInterior *parent): 60 mParent(parent), mPolygons(NULL) 56 61 {} 57 62 … … 343 348 } 344 349 345 int BspLeaf::GenerateViewCell(const RayContainer &rays, 346 ViewCellContainer &viewCells) 347 { 348 int sampleContri = 0; 349 ViewCell *viewCell = new ViewCell(); 350 viewCells.push_back(viewCell); 351 352 mViewCell = viewCell; 350 int BspLeaf::GenerateViewCell(const RayContainer &rays) 351 { 352 int contributingSamples = 0; 353 354 mViewCell = new ViewCell(); 353 355 354 356 RayContainer::const_iterator it, it_end = rays.end(); … … 357 359 for (it = rays.begin(); it != it_end; ++ it) 358 360 { 359 for (int i = 0; i < (int)(*it)->intersections.size(); ++ i) 360 sampleContri = viewCell->GetPvs().AddSample((*it)->intersections[i].mObject); 361 } 362 return sampleContri; 361 if (!(*it)->intersections.empty()) 362 { 363 if (mViewCell->GetPvs().AddSample((*it)->intersections[0].mObject) > 0) 364 ++ contributingSamples; 365 } 366 } 367 368 return contributingSamples; 363 369 } 364 370 … … 369 375 370 376 BspTree::BspTree(ViewCell *viewCell): 371 mRoot(NULL), 372 mRootCell(viewCell) 377 mRootCell(viewCell), mRoot(NULL), mGenerateViewCells(false) 373 378 { 374 379 Randomize(); // initialise random generator for heuristics … … 404 409 405 410 app << "#N_INPUT_POLYGONS (number of input polygons )\n" << polys << endl; 411 412 app << "#N_PVS: " << pvs << endl; 406 413 407 414 app << "#N_ROUTPUT_INPUT_POLYGONS ( ratio polygons after subdivision / input polygons )\n" << … … 447 454 } 448 455 449 void BspTree::InsertPolygons(PolygonContainer *polys , ViewCellContainer *viewCells)456 void BspTree::InsertPolygons(PolygonContainer *polys) 450 457 { 451 458 std::stack<BspTraversalData> tStack; 452 459 453 460 // traverse existing tree or create new tree 454 BspNode *firstNode = mRoot ? mRoot : new BspLeaf(); 455 456 tStack.push(BspTraversalData(firstNode, polys, 0, mRootCell, new RayContainer())); 461 if (!mRoot) 462 mRoot = new BspLeaf(); 463 464 tStack.push(BspTraversalData(mRoot, polys, 0, mRootCell, new RayContainer())); 457 465 458 466 while (!tStack.empty()) … … 486 494 ViewCell *backViewCell = mRootCell; 487 495 488 if (! viewCells)496 if (!mGenerateViewCells) 489 497 { 490 498 ExtractViewCells(&backViewCell, … … 518 526 DEL_PTR(tData.mPolygons); 519 527 } 520 else // reached leaf => subdivide current viewcell 521 { 522 // root of the new subtree 523 BspNode *subRoot = Subdivide(tStack, tData); 524 525 int sampleContri = 0; 526 527 // generate new view cell for each leaf 528 if (viewCells && subRoot->IsLeaf()) 529 sampleContri += dynamic_cast<BspLeaf *>(subRoot)-> 530 GenerateViewCell(*tData.mRays, *viewCells); 531 532 DEL_PTR(tData.mRays); 528 else 529 { 530 // reached leaf => subdivide current viewcell 531 BspNode *subRoot = Subdivide(tStack, tData); 533 532 } 534 533 } … … 604 603 } 605 604 606 intBspTree::Construct(const ViewCellContainer &viewCells)605 void BspTree::Construct(const ViewCellContainer &viewCells) 607 606 { 608 607 mStat.nodes = 1; … … 614 613 615 614 // construct tree from the view cell polygons 616 returnConstruct(polys, new RayContainer());617 } 618 619 620 int BspTree::Construct(const ObjectContainer &objects, ViewCellContainer *viewCells)615 Construct(polys, new RayContainer()); 616 } 617 618 619 void BspTree::Construct(const ObjectContainer &objects) 621 620 { 622 621 mStat.nodes = 1; … … 629 628 630 629 // construct tree from polygon soup 631 return Construct(polys, new RayContainer(), viewCells); 632 } 633 634 int BspTree::Construct(const RayContainer &sampleRays, 635 ViewCellContainer *viewCells) 630 Construct(polys, new RayContainer()); 631 } 632 633 void BspTree::Construct(const RayContainer &sampleRays) 636 634 { 637 635 mStat.nodes = 1; … … 648 646 std::map<Face *, Polygon3 *> facePolyMap; 649 647 650 //-- extract polygons from faces stored inthe rays648 //-- extract polygons intersected by the rays 651 649 for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 652 650 { … … 655 653 rays->push_back(ray); 656 654 657 for (int i = 0; i < (int)ray->intersections.size(); ++ i) 658 { 659 MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->intersections[i].mObject); 660 Face *face = obj->GetMesh()->mFaces[ray->intersections[i].mFace]; 661 662 // store rays piercing a face with the polygon representing the face 655 // get ray-face intersection. Store polygon representing the rays together 656 // with rays intersecting the face. 657 if (!ray->intersections.empty()) 658 { 659 MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->intersections[0].mObject); 660 Face *face = obj->GetMesh()->mFaces[ray->intersections[0].mFace]; 661 663 662 std::map<Face *, Polygon3 *>::iterator it= facePolyMap.find(face); 664 663 … … 671 670 Polygon3 *poly = new Polygon3(face, obj->GetMesh()); 672 671 polys->push_back(poly); 673 Debug << "poly: " << *poly << endl;674 672 poly->AddPiercingRay(ray); 675 673 … … 683 681 684 682 Debug << "**** Finished polygon extraction ****" << endl; 685 Debug << polys->size() << " polys extracted from " <<rays->size() << " rays" << endl;683 Debug << (int)polys->size() << " polys extracted from " << (int)rays->size() << " rays" << endl; 686 684 Debug << "extraction time: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 687 685 688 return Construct(polys, rays, viewCells); 689 } 690 691 int BspTree::Construct(PolygonContainer *polys, 692 RayContainer *rays, 693 ViewCellContainer *viewCells) 686 Construct(polys, rays); 687 } 688 689 void BspTree::Construct(PolygonContainer *polys, RayContainer *rays) 694 690 { 695 691 std::stack<BspTraversalData> tStack; 696 692 697 BspTraversalData tData(new BspLeaf(), polys, 0, mRootCell, rays); 693 mRoot = new BspLeaf(); 694 695 BspTraversalData tData(mRoot, polys, 0, mRootCell, rays); 698 696 tStack.push(tData); 699 697 … … 701 699 cout << "**** Contructing bsp tree ****\n"; 702 700 703 int sampleContri = 0;704 705 701 while (!tStack.empty()) 706 702 { … … 710 706 // subdivide leaf node 711 707 BspNode *subRoot = Subdivide(tStack, tData); 712 713 if (viewCells && subRoot->IsLeaf())714 sampleContri += dynamic_cast<BspLeaf *>(subRoot)->715 GenerateViewCell(*tData.mRays, *viewCells);716 DEL_PTR(tData.mRays);717 708 } 718 709 719 710 cout << "**** Finished tree construction ****\n"; 720 711 Debug << "BSP tree contruction time: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 721 return sampleContri;722 712 } 723 713 … … 726 716 { 727 717 //-- terminate traversal 728 if ((tData.mPolygons->size() <= sTermMaxPolygons) || (tData.mDepth >= sTermMaxDepth)) 729 { 730 //#ifdef _DEBUG 731 Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " 732 << (int)tData.mPolygons->size() << endl; 733 //#endif 718 if (((int)tData.mPolygons->size() <= sTermMaxPolygons) || 719 ((int)tData.mRays->size() <= sTermMaxRays) || 720 (tData.mDepth >= sTermMaxDepth)) 721 722 { 723 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 724 725 // generate new view cell for each leaf 726 if (mGenerateViewCells) 727 mStat.contributingSamples += leaf->GenerateViewCell(*tData.mRays); 728 else 729 // add view cell to leaf 730 leaf->SetViewCell(tData.mViewCell); 731 734 732 EvaluateLeafStats(tData); 735 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 736 737 // add view cell to leaf 738 leaf->SetViewCell(tData.mViewCell); 739 733 740 734 //-- clean up 741 742 735 // remaining polygons are discarded or added to node 743 736 leaf->ProcessPolygons(tData.mPolygons, sStoreSplitPolys); 744 737 DEL_PTR(tData.mPolygons); 745 738 DEL_PTR(tData.mRays); 739 746 740 return leaf; 747 741 } … … 762 756 *frontPolys, 763 757 *backPolys, 764 765 766 767 758 coincident, 759 *tData.mRays, 760 *frontRays, 761 *backRays); 768 762 ViewCell *frontViewCell = mRootCell; 769 763 ViewCell *backViewCell = mRootCell; … … 778 772 // extract view cells from coincident polygons according to plane normal 779 773 // only if front or back polygons are empty 780 ExtractViewCells(&backViewCell, 781 &frontViewCell, 782 coincident, 783 interior->mPlane, 784 backPolys->empty(), 785 frontPolys->empty()); 774 if (!mGenerateViewCells) 775 { 776 ExtractViewCells(&backViewCell, 777 &frontViewCell, 778 coincident, 779 interior->mPlane, 780 backPolys->empty(), 781 frontPolys->empty()); 782 } 786 783 787 784 // don't need coincident polygons anymore … … 804 801 DEL_PTR(tData.mNode); 805 802 DEL_PTR(tData.mPolygons); 806 803 DEL_PTR(tData.mRays); 804 807 805 return interior; 808 806 } … … 1102 1100 } 1103 1101 1104 // strategies where the effect of the split plane is tested1105 // on all input polygons1106 1102 if (!((sSplitPlaneStrategy & BALANCED_POLYS) || 1107 1103 (sSplitPlaneStrategy & LEAST_SPLITS) || … … 1113 1109 } 1114 1110 1111 // -- strategies where the effect of the split plane is tested 1112 // on all input polygons 1113 1115 1114 float sumBalancedPolys = 0; 1116 1115 float sumSplits = 0; … … 1118 1117 float sumBalancedViewCells = 0; 1119 1118 float sumBlockedRays = 0; 1120 1121 1119 float totalBlockedRays = 0; 1122 1120 //float totalArea = 0; … … 1144 1142 //totalArea += area; 1145 1143 } 1146 1147 1144 1148 1145 if (sSplitPlaneStrategy & BLOCKED_RAYS) 1149 1146 { 1150 1147 float blockedRays = (float)(*it)->GetPiercingRays()->size(); 1148 1151 1149 if (classification == Plane3::COINCIDENT) 1152 {1153 1150 sumBlockedRays += blockedRays; 1154 }1151 Debug << "adding rays: " << blockedRays << endl; 1155 1152 1156 1153 totalBlockedRays += blockedRays; … … 1219 1216 (float)(frontViewCells.size() + backViewCells.size()); 1220 1217 } 1218 1219 float sumBalancedRays = 0; 1220 float sumRaySplits = 0; 1221 1222 RayContainer::const_iterator rit, rit_end = rays.end(); 1223 1224 for (rit = rays.begin(); rit != rays.end(); ++ rit) 1225 { 1226 if (sSplitPlaneStrategy & LEAST_RAY_SPLITS) 1227 { 1228 } 1229 1230 if (sSplitPlaneStrategy & BALANCED_RAYS) 1231 { 1232 } 1233 } 1234 if (sSplitPlaneStrategy & LEAST_RAY_SPLITS) 1235 if (!rays.empty()) 1236 val += sLeastRaySplitsFactor * sumRaySplits / (float)rays.size(); 1237 1238 if (sSplitPlaneStrategy & BALANCED_RAYS) 1239 if (!rays.empty()) 1240 val += sBalancedRaysFactor * fabs(sumBalancedRays) / (float)rays.size(); 1221 1241 1222 1242 // return linear combination of the sums … … 1247 1267 Debug << "Construction method: " << constructionMethodStr << endl; 1248 1268 1269 //-- termination criteria for autopartition 1249 1270 environment->GetIntValue("BspTree.Termination.maxDepth", sTermMaxDepth); 1250 1271 environment->GetIntValue("BspTree.Termination.maxPolygons", sTermMaxPolygons); 1272 environment->GetIntValue("BspTree.Termination.maxRays", sTermMaxRays); 1273 1274 //-- termination criteria for axis aligned split 1275 environment->GetFloatValue("BspTree.Termination.ct_div_ci", sCt_div_ci); 1276 environment->GetFloatValue("BspTree.Termination.maxCostRatio", sMaxCostRatio); 1251 1277 environment->GetIntValue("BspTree.Termination.maxPolysForAxisAligned", 1252 1278 sTermMaxPolysForAxisAligned); 1279 1280 //-- partition criteria 1253 1281 environment->GetIntValue("BspTree.maxCandidates", sMaxCandidates); 1254 1282 environment->GetIntValue("BspTree.splitPlaneStrategy", sSplitPlaneStrategy); 1255 1256 // need kdtree criteria for axis aligned split 1257 environment->GetFloatValue("MeshKdTree.Termination.ct_div_ci", sCt_div_ci); 1258 environment->GetFloatValue("MeshKdTree.splitBorder", sSplitBorder); 1259 environment->GetFloatValue("MeshKdTree.Termination.maxCostRatio", sMaxCostRatio); 1260 1283 environment->GetFloatValue("BspTree.splitBorder", sSplitBorder); 1284 1261 1285 environment->GetBoolValue("BspTree.storeSplitPolys", sStoreSplitPolys); 1262 1286 … … 1341 1365 1342 1366 if (leaf->mViewCell != mRootCell) 1367 { 1343 1368 ++ mStat.viewCells; 1344 1345 #ifdef _DEBUG 1346 Debug << "BSP Traversal data. Depth: " << data.mDepth 1347 << " (max: " << mTermMaxDepth << "), #polygons: " 1348 << data.mPolygons->size() << " (max: " 1349 << sTermMaxPolygons << ")" << endl; 1350 #endif 1369 mStat.pvs += leaf->mViewCell->GetPvs().GetSize(); 1370 } 1371 1372 //#ifdef _DEBUG 1373 Debug << "BSP stats: " 1374 << "Depth: " << data.mDepth << " (max: " << sTermMaxDepth << "), " 1375 << "#polygons: " << (int)data.mPolygons->size() << " (max: " << sTermMaxPolygons << "), " 1376 << "#rays: " << (int)data.mRays->size() << " (max: " << sTermMaxRays << ")" << endl; 1377 //#endif 1351 1378 } 1352 1379 … … 1474 1501 } 1475 1502 1476 void BspTree::CollectViewCells( BspNode *n, ViewCellContainer &viewCells)1503 void BspTree::CollectViewCells(ViewCellContainer &viewCells) const 1477 1504 { 1478 1505 stack<BspNode *> nodeStack; 1479 1480 nodeStack.push(n); 1506 nodeStack.push(mRoot); 1507 1508 ViewCell::NewMail(); 1481 1509 1482 1510 while (!nodeStack.empty()) … … 1498 1526 { 1499 1527 BspInterior *interior = dynamic_cast<BspInterior *>(node); 1528 1500 1529 nodeStack.push(interior->mFront); 1501 1530 nodeStack.push(interior->mBack); … … 1504 1533 } 1505 1534 1506 1507 //} // GtpVisibilityPreprocessor 1535 void BspTree::SetGenerateViewCells(int generateViewCells) 1536 { 1537 mGenerateViewCells = generateViewCells; 1538 } 1539 1540 BspTreeStatistics &BspTree::GetStat() 1541 { 1542 return mStat; 1543 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r331 r332 50 50 /// number of view cells different to the view cell representing unbounded space. 51 51 int viewCells; 52 52 /// size of the VPS 53 int pvs; 54 /// samples contributing to pvs 55 int contributingSamples; 53 56 // Constructor 54 57 BspTreeStatistics() … … 72 75 accumDepth = 0; 73 76 viewCells = 0; 77 pvs = 0; 78 contributingSamples = 0; 74 79 } 75 80 … … 229 234 void SetViewCell(ViewCell *viewCell); 230 235 231 /** Generates new view cell and stores it back in the container.232 @returns the number of sample contributions from the rays233 */ 234 int GenerateViewCell(const RayContainer &rays , ViewCellContainer &viewCells);236 /** Generates new view cell and adds rays to the PVS. 237 @returns the number of samples contributing to the pvs. 238 */ 239 int GenerateViewCell(const RayContainer &rays); 235 240 236 241 protected: … … 300 305 Many leafs can point to the same viewcell. 301 306 */ 302 intConstruct(const ViewCellContainer &viewCells);307 void Construct(const ViewCellContainer &viewCells); 303 308 304 309 /** Constructs tree using the given list of objects. 305 310 @note the objects are not taken as view cells, but the view cells are 306 311 constructed from the subdivision: Each leaf is taken as one viewcell. 307 308 312 @param objects list of objects 309 @returns list of view cells. 310 */ 311 int Construct(const ObjectContainer &objects, ViewCellContainer *viewCells); 313 */ 314 void Construct(const ObjectContainer &objects); 312 315 313 316 /** Constructs the tree from a given set of rays. … … 316 319 created in the leafs and stored in the conatainer 317 320 */ 318 int Construct(const RayContainer &sampleRays, 319 ViewCellContainer *viewCells = NULL); 321 void Construct(const RayContainer &sampleRays); 320 322 321 323 /** Returns list of BSP leaves. … … 335 337 bool Export(const string filename); 336 338 337 void CollectViewCells(BspNode *n, ViewCellContainer &viewCells); 339 /** Collects the leaf view cells of the tree 340 @param viewCells returns the view cells 341 */ 342 void CollectViewCells(ViewCellContainer &viewCells) const; 338 343 339 344 /** A ray is cast possible intersecting the tree. … … 343 348 int CastRay(Ray &ray); 344 349 350 /** Set true if view cells shall be generated in each leaf. 351 */ 352 void SetGenerateViewCells(int generateViewCells); 353 345 354 /// bsp tree construction types 346 355 enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_RAYS}; 356 357 /** Returns statistics. 358 */ 359 BspTreeStatistics &GetStat(); 347 360 348 361 protected: … … 380 393 BspNode *Subdivide(BspTraversalStack &tStack, BspTraversalData &tData); 381 394 382 /** Constructs the tree from the given list of polygons. 383 @param rayContainer stores bundle of rays on which subdivision may be based 384 @param viewCells if not NULL, new view cells are 385 created in the leafs and stored in the conatainer 386 */ 387 int Construct(PolygonContainer *polys, 388 RayContainer *rays, 389 ViewCellContainer *viewCells = NULL); 395 /** Constructs the tree from the given list of polygons and rays. 396 @param polys stores set of polygons on which subdivision may be based 397 @param rays storesset of rays on which subdivision may be based 398 */ 399 void Construct(PolygonContainer *polys, RayContainer *rays); 390 400 391 401 /** Selects the best possible splitting plane. … … 413 423 /** Inserts polygons down the tree. The polygons are filtered until a leaf is reached, 414 424 then further subdivided. 415 @param viewCellContainer if not null, a new viewcell is created and stored in the container 416 */ 417 void InsertPolygons(PolygonContainer *polys, ViewCellContainer *viewCells = NULL); 425 */ 426 void InsertPolygons(PolygonContainer *polys); 418 427 419 428 /** Subdivide leaf. … … 550 559 LARGEST_POLY_AREA = 32, 551 560 VERTICAL_AXIS = 64, 552 BLOCKED_RAYS = 128 561 BLOCKED_RAYS = 128, 562 LEAST_RAY_SPLITS = 256, 563 BALANCED_RAYS = 512 553 564 }; 554 565 … … 558 569 /// view cell corresponding to unbounded space 559 570 ViewCell *mRootCell; 571 572 bool mGenerateViewCells; 560 573 561 574 public: … … 563 576 static void ParseEnvironment(); 564 577 565 /// maximal number of polygons where tree construction is terminated578 /// maximal number of polygons before subdivision termination 566 579 static int sTermMaxPolygons; 580 /// maximal number of rays before subdivision termination 581 static int sTermMaxRays; 567 582 /// maximal possible depth 568 583 static int sTermMaxDepth; … … 576 591 static int sTermMaxPolysForAxisAligned; 577 592 593 /// axis aligned split criteria 578 594 static float sCt_div_ci; 579 595 static float sSplitBorder; 580 596 static float sMaxCostRatio; 581 597 582 // factors to guidthe split plane heuristics598 // factors guiding the split plane heuristics 583 599 static float sLeastSplitsFactor; 584 600 static float sBalancedPolysFactor; … … 587 603 static float sLargestPolyAreaFactor; 588 604 static float sBlockedRaysFactor; 589 605 static float sLeastRaySplitsFactor; 606 static float sBalancedRaysFactor; 607 590 608 /// if polygons should be stored in the tree 591 609 static bool sStoreSplitPolys; -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r331 r332 60 60 61 61 p->BuildBspTree(); 62 62 63 p->Export("vc_bsptree.x3d", false, false, true); 63 64 p->BspTreeStatistics(Debug);
Note: See TracChangeset
for help on using the changeset viewer.