Changeset 719 for GTP/trunk/Lib
- Timestamp:
- 03/27/06 18:56:45 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r710 r719 1566 1566 if (!mIsCompressed) 1567 1567 return vc->GetPvs().GetSize(); 1568 1569 1570 ////////////////////////777 1571 //-- compressed pvs 1568 1572 1569 1573 int pvsSize = 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r711 r719 44 44 45 45 46 /**************************************************************** /47 /* class BspNode implementation */48 /**************************************************************** /46 /******************************************************************/ 47 /* class BspNode implementation */ 48 /******************************************************************/ 49 49 50 50 … … 2086 2086 stack<BspRayTraversalData> tStack; 2087 2087 2088 float mint = 0.0f, maxt = 1.0f;2088 float mint = 0.0f, maxt = 1.0f; 2089 2089 2090 2090 Intersectable::NewMail(); … … 2097 2097 BspNode *farChild = NULL; 2098 2098 2099 2099 2100 const float thresh = 1 ? 1e-6f : 0.0f; 2100 2101 … … 2104 2105 { 2105 2106 BspInterior *in = dynamic_cast<BspInterior *>(node); 2106 2107 2107 2108 Plane3 splitPlane = in->GetPlane(); 2108 2109 … … 2113 2114 { 2114 2115 node = in->GetBack(); 2115 2116 if(extSide <= 0) // plane does not split ray => no far child 2116 2117 // plane does not split ray => no far child 2118 if (extSide <= 0) 2117 2119 continue; 2118 2120 2119 2121 farChild = in->GetFront(); // plane splits ray 2120 2121 2122 } 2122 else if (entSide > 0) 2123 else if (entSide > 0) 2123 2124 { 2124 2125 node = in->GetFront(); 2125 2126 2126 2127 if (extSide >= 0) // plane does not split ray => no far child 2127 2128 continue; 2128 2129 farChild = in->GetBack(); // plane splits ray 2129 2130 farChild = in->GetBack(); // plane splits ray 2130 2131 } 2131 else // ray and plane are coincident 2132 { 2133 // NOTE: what to do if ray is coincident with plane? 2132 else // one of the ray end points is on the plane 2133 { // NOTE: what to do if ray is coincident with plane? 2134 2134 if (extSide < 0) 2135 2135 node = in->GetBack(); 2136 2136 else //if (extSide > 0) 2137 2137 node = in->GetFront(); 2138 //else break; 2138 //else break; // coincident => count no intersections 2139 2139 2140 2140 continue; // no far child 2141 2141 } 2142 2142 2143 2143 // push data for far child 2144 2144 tStack.push(BspRayTraversalData(farChild, extp, maxt)); … … 2177 2177 } 2178 2178 } 2179 2179 2180 return hits; 2180 2181 } … … 2319 2320 // split plane of node itself 2320 2321 n = n->GetParent(); 2321 2322 2322 2323 if (n) 2323 2324 { … … 2361 2362 vector<Plane3> candidatePlanes; 2362 2363 2364 vector<Plane3>::const_iterator pit, pit_end = halfSpaces.end(); 2365 2363 2366 // bounded planes are added to the polygons 2364 for ( int i = 0; i < (int)halfSpaces.size(); ++ i)2365 { 2366 Polygon3 *p = GetBoundingBox().CrossSection( halfSpaces[i]);2367 for (pit = halfSpaces.begin(); pit != pit_end; ++ pit) 2368 { 2369 Polygon3 *p = GetBoundingBox().CrossSection(*pit); 2367 2370 2368 2371 if (p->Valid(mEpsilon)) 2369 2372 { 2370 2373 candidatePolys.push_back(p); 2371 candidatePlanes.push_back( halfSpaces[i]);2374 candidatePlanes.push_back(*pit); 2372 2375 } 2373 2376 } … … 2415 2418 DEL_PTR(candidatePolys[i]); 2416 2419 2417 if ( frontPoly->Valid(mEpsilon))2418 candidatePolys[i] = frontPoly;2420 if (backPoly->Valid(mEpsilon)) 2421 candidatePolys[i] = backPoly; 2419 2422 else 2420 DEL_PTR(frontPoly); 2421 2422 DEL_PTR(backPoly); 2423 DEL_PTR(backPoly); 2424 2425 // outside, don't need this 2426 DEL_PTR(frontPoly); 2423 2427 break; 2424 2428 // polygon outside of halfspace -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r718 r719 47 47 mMaxPvsSize(9999999), 48 48 mMinPvsSize(0), // one means only empty view cells are invalid 49 mMaxPvsRatio(1.0) 49 mMaxPvsRatio(1.0), 50 mViewCellPvsIsUpdated(false) 50 51 { 51 52 mViewSpaceBox.Initialize(); … … 558 559 // find empty view cells bug 559 560 if (TEST_EMPTY_VIEW_CELLS) 561 { 560 562 TestEmptyViewCells(preprocessor->mObjects); 563 } 561 564 } 562 565 … … 1131 1134 1132 1135 1136 void ViewCellsManager::UpdatePvs() 1137 { 1138 if (mViewCellPvsIsUpdated) 1139 return; 1140 1141 mViewCellPvsIsUpdated = true; 1142 1143 ViewCellContainer leaves; 1144 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 1145 1146 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1147 1148 for (it = leaves.begin(); it != it_end; ++ it) 1149 { 1150 mViewCellsTree->PropagatePvs(*it); 1151 } 1152 } 1153 1154 1133 1155 void ViewCellsManager::GetPvsStatistics(PvsStatistics &stat) 1134 1156 { 1135 ViewCellContainer::const_iterator it = mViewCells.begin(); 1136 stat.viewcells = 0; 1137 stat.minPvs = 100000000; 1138 stat.maxPvs = 0; 1139 stat.avgPvs = 0.0f; 1140 1141 for (; it != mViewCells.end(); ++it) { 1142 ViewCell *viewcell = *it; 1143 int pvsSize = viewcell->GetPvs().GetSize(); 1144 if ( pvsSize < stat.minPvs) 1145 stat.minPvs = pvsSize; 1146 if (pvsSize > stat.maxPvs) 1147 stat.maxPvs = pvsSize; 1148 stat.avgPvs += pvsSize; 1149 stat.viewcells++; 1150 } 1151 if (stat.viewcells) 1152 stat.avgPvs/=stat.viewcells; 1157 // update pvs of view cells tree if necessary 1158 UpdatePvs(); 1159 1160 ViewCellContainer::const_iterator it = mViewCells.begin(); 1161 1162 stat.viewcells = 0; 1163 stat.minPvs = 100000000; 1164 stat.maxPvs = 0; 1165 stat.avgPvs = 0.0f; 1166 1167 for (; it != mViewCells.end(); ++ it) 1168 { 1169 ViewCell *viewcell = *it; 1170 1171 const int pvsSize = mViewCellsTree->GetPvsSize(viewcell); 1172 1173 if (pvsSize < stat.minPvs) 1174 stat.minPvs = pvsSize; 1175 if (pvsSize > stat.maxPvs) 1176 stat.maxPvs = pvsSize; 1177 stat.avgPvs += pvsSize; 1178 1179 ++ stat.viewcells; 1180 } 1181 1182 if (stat.viewcells) 1183 stat.avgPvs/=stat.viewcells; 1153 1184 } 1154 1185 … … 1571 1602 ComputeSampleContributions(savedRays, true, false); 1572 1603 1604 // real meshes are contructed at this stage 1605 if (0) 1606 { 1607 cout << "finalizing view cells ... "; 1608 FinalizeViewCells(true); 1609 cout << "finished" << endl; 1610 } 1611 1573 1612 return sampleContributions; 1574 1613 } … … 1732 1771 mColorCode = savedColorCode; 1733 1772 1734 FinalizeViewCells(true); 1735 1773 // compute final meshes and volume / area 1774 if (1) FinalizeViewCells(true); 1775 1736 1776 // write view cells to disc 1737 1777 if (mExportViewCells) … … 2113 2153 mBspTree->ConstructGeometry(leaf, geom); 2114 2154 2115 float lVol = geom.GetVolume();2116 float lArea = geom.GetArea();2155 const float lVol = geom.GetVolume(); 2156 const float lArea = geom.GetArea(); 2117 2157 2118 2158 //(*it)->SetVolume(vol); … … 3062 3102 cout << "construction finished" << endl; 3063 3103 3104 // real meshes are contructed at this stage 3105 if (0) 3106 { 3107 cout << "finalizing view cells ... "; 3108 FinalizeViewCells(true); 3109 cout << "finished" << endl; 3110 } 3111 3064 3112 return sampleContributions; 3065 3113 } … … 3296 3344 // should maybe be done here to allow merge working with area or volume 3297 3345 // and to correct the rendering statistics 3298 if (0) 3299 { 3300 FinalizeViewCells(false); 3301 } 3302 3346 if (0) FinalizeViewCells(false); 3347 3303 3348 3304 3349 //-- merge the individual view cells … … 3312 3357 RefineViewCells(postProcessRays, objects); 3313 3358 3314 3359 3315 3360 //-- render simulation after merge + refine 3316 3361 … … 3347 3392 ResetViewCells(); 3348 3393 3349 // real meshes are only contructed only at this stage 3350 FinalizeViewCells(true); 3394 // compute final meshes and volume / area 3395 if (1) FinalizeViewCells(true); 3396 3351 3397 3352 3398 // write view cells to disc … … 3967 4013 vm->mMaxPvsSize = (int)objects->size(); 3968 4014 4015 // create the meshes and compute volumes 3969 4016 vm->FinalizeViewCells(true); 3970 4017 … … 3977 4024 DEL_PTR(vm); 3978 4025 } 3979 3980 4026 3981 4027 return vm; … … 4061 4107 mVspBspTree->ConstructGeometry(leaf, geom); 4062 4108 4063 float lVol = geom.GetVolume();4064 float lArea = geom.GetArea();4109 const float lVol = geom.GetVolume(); 4110 const float lArea = geom.GetArea(); 4065 4111 4066 4112 //(*it)->SetVolume(vol); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r713 r719 267 267 virtual void PrintPvsStatistics(ostream &s); 268 268 269 /** Updates pvs of the view cell hierarchy if necessary. 270 */ 271 void UpdatePvs(); 272 269 273 /** Returns probability that view point lies in one view cell. 270 274 */ … … 529 533 bool mPruneEmptyViewCells; 530 534 535 bool mViewCellPvsIsUpdated; 531 536 /// maximum number of samples taken for construction of the view cells 532 537 int mConstructionSamples; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r711 r719 2641 2641 vector<Plane3> candidatePlanes; 2642 2642 2643 vector<Plane3>::const_iterator pit, pit_end = halfSpaces.end(); 2644 2643 2645 // bounded planes are added to the polygons 2644 for ( int i = 0; i < (int)halfSpaces.size(); ++ i)2645 { 2646 Polygon3 *p = GetBoundingBox().CrossSection( halfSpaces[i]);2646 for (pit = halfSpaces.begin(); pit != pit_end; ++ pit) 2647 { 2648 Polygon3 *p = GetBoundingBox().CrossSection(*pit); 2647 2649 2648 2650 if (p->Valid(mEpsilon)) 2649 2651 { 2650 2652 candidatePolys.push_back(p); 2651 candidatePlanes.push_back( halfSpaces[i]);2653 candidatePlanes.push_back(*pit); 2652 2654 } 2653 2655 } … … 3137 3139 { 3138 3140 int hits = 0; 3139 stack<BspRayTraversalData> t Queue;3141 stack<BspRayTraversalData> tStack; 3140 3142 3141 3143 float mint = 0.0f, maxt = 1.0f; … … 3195 3197 3196 3198 // push data for far child 3197 t Queue.push(BspRayTraversalData(farChild, extp));3199 tStack.push(BspRayTraversalData(farChild, extp)); 3198 3200 3199 3201 // find intersection of ray segment with plane … … 3219 3221 3220 3222 //-- fetch the next far child from the stack 3221 if (t Queue.empty())3223 if (tStack.empty()) 3222 3224 break; 3223 3225 3224 3226 entp = extp; 3225 3227 3226 BspRayTraversalData &s = tQueue.top();3228 const BspRayTraversalData &s = tStack.top(); 3227 3229 3228 3230 node = s.mNode; 3229 3231 extp = s.mExitPoint; 3230 3232 3231 t Queue.pop();3233 tStack.pop(); 3232 3234 } 3233 3235 }
Note: See TracChangeset
for help on using the changeset viewer.