Changeset 267
- Timestamp:
- 09/14/05 01:59:22 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r265 r267 13 13 # viewcells ../data/atlanta/atlanta_viewcells_large.x3d 14 14 #viewcells ../data/atlanta/atlanta_viewcells_large2.x3d 15 viewcells ../data/vienna/viewcells-25-sel.x3d16 #viewcells ../data/vienna/viewcells-25.x3d15 # viewcells ../data/vienna/viewcells-25-sel.x3d 16 viewcells ../data/vienna/viewcells-25.x3d 17 17 # viewcells ../data/vienna/viewcells-large-sel.x3d 18 18 } … … 64 64 BspTree { 65 65 # splitPlaneStrategy leastSplits 66 splitPlaneStrategy balancedTree66 # splitPlaneStrategy balancedTree 67 67 # splitPlaneStrategy nextPolygon 68 #splitPlaneStrategy combined68 splitPlaneStrategy combined 69 69 # constructionMethod rays 70 70 constructionMethod viewCells … … 74 74 Termination { 75 75 maxPolygons 0 76 maxDepth 99976 maxDepth 3000 77 77 } 78 78 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r265 r267 30 30 int BspTree::sBalancedTreeTable[4] = {-1, 1, 0, 0}; 31 31 32 const int FACTOR_BALANCE = 1; 33 const int FACTOR_LEAST_SPLITS = 1; 34 32 35 /****************************************************************/ 33 36 /* class BspNode implementation */ … … 144 147 int &splits, bool storePolys) 145 148 { 146 //#ifdef _Debug149 #ifdef _Debug 147 150 Debug << "Splitting polygons of node " << this << " with plane " << mPlane << endl; 148 //#endif151 #endif 149 152 bool inside = false; 150 153 … … 157 160 int classification = poly->ClassifyPlane(mPlane); 158 161 159 //Debug << "polygon plane: " << poly->GetSupportingPlane() << endl;160 162 Polygon3 *front_piece = NULL; 161 163 Polygon3 *back_piece = NULL; … … 169 171 inside = (DotProd(mPlane.mNormal, poly->GetSupportingPlane().mNormal) > 0); 170 172 171 Debug << "coincident" << endl;173 //Debug << "coincident" << endl; 172 174 // discard polygons or saves them in node 173 175 ProcessPolygon(poly, storePolys); 174 176 break; 175 177 case Polygon3::FRONT_SIDE: 176 Debug << "front" << endl;178 //Debug << "front" << endl; 177 179 frontPolys->push_back(poly); 178 180 break; 179 181 case Polygon3::BACK_SIDE: 180 182 inside = true; 181 Debug << "back" << endl;183 //Debug << "back" << endl; 182 184 backPolys->push_back(poly); 183 185 break; 184 186 case Polygon3::SPLIT: 185 187 inside = true; 186 Debug << "split " << poly << endl;188 //Debug << "split " << poly << endl; 187 189 188 190 front_piece = new Polygon3(); … … 279 281 app << "#N_NODES ( Number of nodes )\n" << nodes << "\n"; 280 282 281 app << "#N_ LEAVES ( Number of interior nodes )\n" << Interior() << "\n";283 app << "#N_INTERIORS ( Number of interior nodes )\n" << Interior() << "\n"; 282 284 283 285 app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; … … 313 315 app << "#N_PMINDEPTH ( Minimal reached depth )\n" << minDepth << endl; 314 316 315 app << "#AVG EPTH ( average depth )\n" << AvgDepth() << endl;317 app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl; 316 318 317 319 app << "#N_ADDED_RAYREFS ( Number of dynamically added ray references )\n"<< … … 389 391 int splits = 0; 390 392 391 Debug << "Splitting poly, YEAHH\n";392 393 // split viecell polygons with respect to split plane 393 394 bool inside = interior->SplitPolygons(tData.mPolygons, frontPolys, backPolys, splits, mStorePolys); 394 //Debug << " Reachedlevel " << tData.mDepth << " bk: " << backPolys->size() << " frnt: " << frontPolys->size() << endl;395 //Debug << "split node on level " << tData.mDepth << " bk: " << backPolys->size() << " frnt: " << frontPolys->size() << endl; 395 396 mStat.splits += splits; 396 397 … … 408 409 { 409 410 if (tData.mPolygons->size() > 0) 410 Debug << "WARNING (should not come here): polygon size: " << tData.mPolygons->size() << " inside: " << tData.mIsInside << endl;411 Debug << "WARNING (should not come here): polygon size: " << (int)tData.mPolygons->size() << " inside: " << tData.mIsInside << endl; 411 412 412 413 BspNode *root = Subdivide(tStack, tData, viewCell); 413 414 414 //if (!root->IsLeaf())415 // Debug << "WARNING should NOT have subdivided further\n";416 417 415 if (!mRoot) // tree empty => new root 418 416 mRoot = root; … … 514 512 // copy view cell meshes into one big polygon soup 515 513 PolygonContainer *polys = new PolygonContainer(); 516 Copy2PolygonSoup(viewCells, *polys , sMaxCandidates);514 Copy2PolygonSoup(viewCells, *polys); 517 515 518 516 // polygons are stored only during view cell insertion … … 524 522 } 525 523 526 //-- insert all viewcells 524 //-- insert all viewcells one after another 527 525 ViewCellContainer::const_iterator it; 528 526 … … 530 528 mStat.polys = 0; 531 529 mStat.splits = 0; 532 //int counter= 0;533 530 mStat.accumDepth = 0; 531 534 532 long startTime = GetTime(); 533 534 int counter = 0; 535 535 Debug << "**** Starting view cell insertion ****" << endl; 536 536 for (it = viewCells.begin(); it != viewCells.end(); ++ it) 537 537 { 538 //Debug << "*** Inserting view cell " << counter ++ << " ***" << endl;538 Debug << "** inserting view cell " << counter ++ << " **" << endl; 539 539 InsertViewCell(*it); 540 540 } 541 541 542 Debug << "**** Finished view cell insertion ****" << endl; 542 543 Debug << "insertion time: "<< TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; … … 552 553 553 554 // copy mesh instance polygons into one big polygon soup 554 mStat.polys = Copy2PolygonSoup(objects, *polys , sMaxCandidates);555 mStat.polys = Copy2PolygonSoup(objects, *polys); 555 556 556 557 // construct tree from polygon soup 557 Construct(polys); 558 559 // TODO: generate view cells 558 Construct(polys, viewCells); 560 559 } 561 560 … … 609 608 //&& !(viewCell && tData.mIsInside && dynamic_cast<BspLeaf *>(tData.mNode)->GetViewCell())) 610 609 { 611 #ifdef _DEBUG610 //#ifdef _DEBUG 612 611 Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " << (int)tData.mPolygons->size() << endl; 613 #endif612 //#endif 614 613 615 614 EvaluateLeafStats(tData); … … 623 622 Debug << "ERROR: leaf already has view cell" << endl; 624 623 624 Debug << "insert view cell" << endl; 625 625 leaf->SetViewCell(viewCell); 626 626 } … … 638 638 bool inside = false; 639 639 640 Debug << "Subdividing node at depth " << tData.mDepth << endl;641 640 BspInterior *interior = SubdivideNode(dynamic_cast<BspLeaf *>(tData.mNode), 642 641 tData.mPolygons, … … 732 731 } 733 732 } 734 735 if (lowestCost > 0) 736 Debug << "Split plane cost: " << lowestCost << " plane: " << (*polygons)[bestPlaneIdx]->GetSupportingPlane() << endl; 737 else 738 Debug << "no splits for plane: " << (*polygons)[bestPlaneIdx]->GetSupportingPlane() << endl; 733 //Debug << "Plane lowest cost: " << lowestCost << endl; 734 739 735 return (*polygons)[bestPlaneIdx]->GetSupportingPlane(); 740 736 } … … 758 754 { 759 755 sumLeastSplits += sLeastSplitsTable[classification]; 760 Debug << "Adding " << sLeastSplitsTable[classification] << " for poly " << *it << "!"; 761 } 762 } 763 764 Debug << "\n" << candidatePlane << " evaluation: " << abs(sumBalanced) + abs(sumLeastSplits) << endl; 756 } 757 } 765 758 766 759 // return linear combination of both sums 767 return abs(sumBalanced) +abs(sumLeastSplits);760 return FACTOR_BALANCE * abs(sumBalanced) + FACTOR_LEAST_SPLITS *abs(sumLeastSplits); 768 761 } 769 762 … … 791 784 else if (strcmp(splitPlaneStrategyStr, "balancedTree") == 0) 792 785 sSplitPlaneStrategy = BspTree::BALANCED_TREE; 786 else if (strcmp(splitPlaneStrategyStr, "combined") == 0) 787 sSplitPlaneStrategy = BspTree::COMBINED; 793 788 else 794 789 { … … 927 922 mStat.minDepth = data.mDepth; 928 923 924 // accumulate depth to compute average 929 925 mStat.accumDepth += data.mDepth; 930 926 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r265 r267 82 82 int Interior() const { return nodes / 2; } 83 83 int Leaves() const { return (nodes / 2) + 1; } 84 int AvgDepth() const { return accumDepth / Leaves();};84 float AvgDepth() const { return accumDepth / (double)Leaves();}; // TODO: computation wrong 85 85 86 86 void Reset() … … 394 394 @returns the number of polygons 395 395 */ 396 int Copy2PolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects );396 int Copy2PolygonSoup(const ObjectContainer &objects, PolygonContainer &polys, int maxObjects = 0); 397 397 /** Extracts the meshes of the view cells and copies them into the mesh. 398 398 Adds view cell aabb to the aabb of the tree. … … 400 400 @returns the number of polygons 401 401 */ 402 int Copy2PolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects );402 int Copy2PolygonSoup(const ViewCellContainer &viewCells, PolygonContainer &polys, int maxObjects = 0); 403 403 404 404 /** Extract polygons of this mesh and add to polygon container.
Note: See TracChangeset
for help on using the changeset viewer.