Changeset 2124 for GTP/trunk/Lib/Vis
- Timestamp:
- 02/19/07 02:51:22 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 4 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/include/ObjReader.h
r2123 r2124 9 9 namespace GtpVisibilityPreprocessor { 10 10 class Intersectable; 11 class Preprocessor; 11 12 } 12 13 … … 31 32 Ogre::SceneManager *mSceneManager; 32 33 GtpVisibilityPreprocessor::ObjectContainer mPvsObjects; 34 GtpVisibilityPreprocessor::Preprocessor *mPreprocessor; 33 35 }; 34 36 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/ObjReader/src/ObjReader.cpp
r2123 r2124 13 13 14 14 ObjReader::ObjReader(Ogre::SceneManager *sceneManager): 15 mSceneManager(sceneManager) 16 {} 15 mSceneManager(sceneManager), mPreprocessor(NULL) 16 { 17 } 17 18 18 19 … … 20 21 { 21 22 CLEAR_CONTAINER(mPvsObjects); 23 24 DEL_PTR(mPreprocessor); 22 25 } 23 26 … … 29 32 GtpVisibilityPreprocessor::Debug.open("debug.log"); 30 33 // HACK: get any preprocessor to load file 31 GtpVisibilityPreprocessor::Preprocessor *preprocessor = 34 // note should be preserved to allow manual mesh reloading, 35 // but then geometry has to be stored two times 36 mPreprocessor = 32 37 GtpVisibilityPreprocessor::PreprocessorFactory::CreatePreprocessor("vss"); 33 38 34 39 // hack 35 preprocessor->mLoadMeshes = false;40 mPreprocessor->mLoadMeshes = false; 36 41 37 42 Ogre::LogManager::getSingleton().logMessage("loading obj scene"); 38 43 39 if ( preprocessor->LoadScene(sceneName))44 if (mPreprocessor->LoadScene(sceneName)) 40 45 { 41 46 Ogre::LogManager::getSingleton().logMessage("scene loaded, loading objects"); 42 47 // form objects from the scene triangles 43 if (! preprocessor->LoadObjects(visibilitySolution, mPvsObjects, preprocessor->mObjects))48 if (!mPreprocessor->LoadObjects(visibilitySolution, mPvsObjects, mPreprocessor->mObjects)) 44 49 { 45 50 Ogre::LogManager::getSingleton().logMessage("objects cannot be loaded"); … … 54 59 55 60 std::stringstream d; 56 d << "successfully loaded " << mPvsObjects.size() << " objects from " << preprocessor->mObjects.size() << " preprocessor objects"; 61 d << "successfully loaded " << (int)mPvsObjects.size() 62 << " objects from " << (int)mPreprocessor->mObjects.size() << " preprocessor objects"; 57 63 58 64 Ogre::LogManager::getSingleton().logMessage(d.str()); … … 65 71 if (i % 5000 == 4999) 66 72 { 67 d << i << " objects created" << endl; 73 d << i << " objects created"; 74 Ogre::LogManager::getSingleton().logMessage(d.str()); 68 75 } 69 76 … … 84 91 } 85 92 86 delete preprocessor;93 //delete preprocessor; 87 94 88 95 return true; -
GTP/trunk/Lib/Vis/Preprocessing/scripts/preprocess_visibility.sh
r2099 r2124 1 1 #!/bin/sh 2 2 3 PREPROCESSOR=../bin/release/preprocessor.exe4 #PREPROCESSOR=../bin/debug/preprocessor.exe3 #PREPROCESSOR=../bin/release/preprocessor.exe 4 PREPROCESSOR=../bin/debug/preprocessor.exe 5 5 6 6 if [ $# -ne 3 ] -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r2070 r2124 209 209 int 210 210 AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, 211 float *tmin,212 float *tmax) const211 float *tmin, 212 float *tmax) const 213 213 { 214 214 float minx, maxx, miny, maxy, minz, maxz; … … 301 301 int 302 302 AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, 303 float *tmin,304 float *tmax) const303 float *tmin, 304 float *tmax) const 305 305 { 306 306 const float dirEps = 1e-8f; … … 396 396 // of intersection with the ray; it returns 1 if the ray hits 397 397 // the bounding box and 0 if it does not. 398 int 399 AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, float *tmin, float *tmax, 400 EFaces &entryFace, EFaces &exitFace) const 398 int AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, float *tmin, float *tmax, 399 EFaces &entryFace, EFaces &exitFace) const 401 400 { 402 401 float minx, maxx, miny, maxy, minz, maxz; … … 532 531 533 532 // computes the signed distances for case tmin<tmax and tmax>0 534 int 535 AxisAlignedBox3::GetMinMaxT(const Ray &ray, float *tmin, float *tmax, 536 EFaces &entryFace, EFaces &exitFace) const 533 int AxisAlignedBox3::GetMinMaxT(const Ray &ray, 534 float *tmin, 535 float *tmax, 536 EFaces &entryFace, 537 EFaces &exitFace) const 537 538 { 538 539 if (!ComputeMinMaxT(ray, tmin, tmax, entryFace, exitFace)) … … 583 584 b.mMax.y <= mMax.y && 584 585 b.mMax.z <= mMax.z); 585 586 586 } 587 587 588 588 589 589 // compute the coordinates of one vertex of the box 590 Vector3 591 AxisAlignedBox3::GetVertex(int xAxis, int yAxis, int zAxis) const 590 Vector3 AxisAlignedBox3::GetVertex(int xAxis, int yAxis, int zAxis) const 592 591 { 593 592 Vector3 p; … … 2389 2388 } 2390 2389 2391 /* 2392 int inline GetIntersection(const float fDst1, 2393 const float fDst2, 2394 const Vector3 p1, 2395 const Vector3 p2, 2396 const Vector3 &hit) 2397 { 2398 if ((fDst1 * fDst2) >= 0.0f) 2399 return 0; 2400 2401 if (fDst1 == fDst2) 2402 return 0; 2403 2404 hit = p1 + (p2 - p1) * (-fDst1 / (fDst2 - fDst1)); 2405 2406 return 1; 2407 } 2408 2409 2410 int inline InBox( CVec3 Hit, CVec3 B1, CVec3 B2, const int Axis) { 2411 if ( Axis==1 && Hit.z > B1.z && Hit.z < B2.z && Hit.y > B1.y && Hit.y < B2.y) return 1; 2412 if ( Axis==2 && Hit.z > B1.z && Hit.z < B2.z && Hit.x > B1.x && Hit.x < B2.x) return 1; 2413 if ( Axis==3 && Hit.x > B1.x && Hit.x < B2.x && Hit.y > B1.y && Hit.y < B2.y) return 1; 2414 return 0; 2415 } 2416 2417 // returns true if line (L1, L2) intersects with the box (B1, B2) 2418 // returns intersection point in Hit 2419 int CheckLineBox( CVec3 B1, CVec3 B2, CVec3 L1, CVec3 L2, CVec3 &Hit) 2420 { 2421 if (L2.x < B1.x && L1.x < B1.x) return false; 2422 if (L2.x > B2.x && L1.x > B2.x) return false; 2423 if (L2.y < B1.y && L1.y < B1.y) return false; 2424 if (L2.y > B2.y && L1.y > B2.y) return false; 2425 if (L2.z < B1.z && L1.z < B1.z) return false; 2426 if (L2.z > B2.z && L1.z > B2.z) return false; 2427 if (L1.x > B1.x && L1.x < B2.x && 2428 L1.y > B1.y && L1.y < B2.y && 2429 L1.z > B1.z && L1.z < B2.z) 2430 {Hit = L1; 2431 return true;} 2432 if ( (GetIntersection( L1.x-B1.x, L2.x-B1.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 )) 2433 || (GetIntersection( L1.y-B1.y, L2.y-B1.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 )) 2434 || (GetIntersection( L1.z-B1.z, L2.z-B1.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 )) 2435 || (GetIntersection( L1.x-B2.x, L2.x-B2.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 )) 2436 || (GetIntersection( L1.y-B2.y, L2.y-B2.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 )) 2437 || (GetIntersection( L1.z-B2.z, L2.z-B2.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 ))) 2438 return true; 2439 2440 return false; 2441 } 2442 */ 2443 2444 } 2445 2390 2391 bool AxisAlignedBox3::Intersects(const Vector3 &lStart, 2392 const Vector3 &lEnd) const 2393 { 2394 float st, et, fst = 0, fet = 1; 2395 float const *bmin = &mMin.x; 2396 float const *bmax = &mMax.x; 2397 float const *si = &lStart.x; 2398 float const *ei = &lEnd.x; 2399 2400 for (int i = 0; i < 3; ++ i) 2401 { 2402 if (*si < *ei) 2403 { 2404 if (*si > *bmax || *ei < *bmin) 2405 return false; 2406 2407 const float di = *ei - *si; 2408 2409 st = (*si < *bmin)? (*bmin - *si) / di : 0; 2410 et = (*ei > *bmax)? (*bmax - *si) / di : 1; 2411 } 2412 else 2413 { 2414 if (*ei > *bmax || *si < *bmin) 2415 return false; 2416 2417 const float di = *ei - *si; 2418 2419 st = (*si > *bmax)? (*bmax - *si) / di : 0; 2420 et = (*ei < *bmin)? (*bmin - *si) / di : 1; 2421 } 2422 2423 if (st > fst) fst = st; 2424 if (et < fet) fet = et; 2425 if (fet < fst) 2426 return false; 2427 2428 ++ bmin; ++ bmax; 2429 ++ si; ++ ei; 2430 } 2431 2432 //*time = fst; 2433 return true; 2434 } 2435 2436 } 2437 -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r2070 r2124 72 72 void Reduce(int axis, int right, float value); 73 73 74 bool Intersects(const Vector3 &lStart, const Vector3 &lEnd) const; 74 75 75 76 // the size of the box along all the axes … … 93 94 void Include(const int &axis, const float &newBound); 94 95 95 96 int 97 Side(const Plane3 &plane) const; 96 int Side(const Plane3 &plane) const; 98 97 99 98 // Overlap returns 1 if the two axis-aligned boxes overlap .. even weakly … … 121 120 bool Includes(const AxisAlignedBox3 &b) const; 122 121 122 /** Returns true if this point is inside box. 123 */ 123 124 virtual int IsInside(const Vector3 &v) const; 124 125 126 /** Returns true if start and endpoint of the ray is inside box. 127 */ 125 128 virtual int IsInside(const VssRay &v) const; 126 129 … … 203 206 // Returns the intersection of two axis-aligned boxes. 204 207 friend inline AxisAlignedBox3 Intersect(const AxisAlignedBox3 &x, 205 const AxisAlignedBox3 &y);208 const AxisAlignedBox3 &y); 206 209 207 210 // Given 4x4 matrix, transform the current box to new one. 208 211 friend inline AxisAlignedBox3 Transform(const AxisAlignedBox3 &box, 209 const Matrix4x4 &tform);212 const Matrix4x4 &tform); 210 213 211 214 212 215 // returns true when two boxes are completely equal 213 friend inline int operator== (const AxisAlignedBox3 &A, const AxisAlignedBox3 &B); 216 friend inline int operator== (const AxisAlignedBox3 &A, 217 const AxisAlignedBox3 &B); 214 218 215 219 virtual float SurfaceArea() const; 216 virtual float GetVolume() const { 217 return (mMax.x - mMin.x) * (mMax.y - mMin.y) * (mMax.z - mMin.z); 220 virtual float GetVolume() const 221 { 222 return (mMax.x - mMin.x) * (mMax.y - mMin.y) * (mMax.z - mMin.z); 218 223 } 219 224 220 225 // Six faces are distuinguished by their name. 221 enum EFaces { ID_Back = 0, ID_Left = 1, ID_Bottom = 2, ID_Front = 3, 222 ID_Right = 4, ID_Top = 5}; 223 224 int 225 ComputeMinMaxT(const Vector3 &origin, 226 const Vector3 &direction, 227 float *tmin, 228 float *tmax) const; 226 enum EFaces {ID_Back = 0, 227 ID_Left = 1, 228 ID_Bottom = 2, 229 ID_Front = 3, 230 ID_Right = 4, 231 ID_Top = 5}; 232 233 int ComputeMinMaxT(const Vector3 &origin, 234 const Vector3 &direction, 235 float *tmin, 236 float *tmax) const; 229 237 230 238 // Compute tmin and tmax for a ray, whenever required .. need not pierce box … … 243 251 // computes the signed distances for case: tmin < tmax and tmax > 0 244 252 int GetMinMaxT(const Ray &ray, float *tmin, float *tmax, 245 EFaces &entryFace, EFaces &exitFace) const;253 EFaces &entryFace, EFaces &exitFace) const; 246 254 247 255 // Writes a brief description of the object, indenting by the given -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2093 r2124 335 335 Debug << "use surface area heuristics: " << mUseSah << endl; 336 336 Debug << "subdivision stats log: " << subdivisionStatsLog << endl; 337 Debug << "split borders: " << mSplitBorder << endl;337 //Debug << "split borders: " << mSplitBorder << endl; 338 338 Debug << "render cost decrease weight: " << mRenderCostDecreaseWeight << endl; 339 339 Debug << "use global sort: " << mUseGlobalSorting << endl; … … 1439 1439 if (sortEntries) 1440 1440 { // no presorted candidate list 1441 //stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end());1442 sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end());1441 stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 1442 //sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 1443 1443 } 1444 1444 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r2119 r2124 1009 1009 int mCreatedLeaves; 1010 1010 /// represents min and max band for sweep 1011 float mSplitBorder;1011 //float mSplitBorder; 1012 1012 /// weight between render cost decrease and node render cost 1013 1013 float mRenderCostDecreaseWeight; -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r2076 r2124 1378 1378 1379 1379 RegisterOption("ViewCells.type", 1380 optString,1381 "view_cells_type=",1382 "vspBspTree");1380 optString, 1381 "view_cells_type=", 1382 "vspBspTree"); 1383 1383 1384 1384 RegisterOption("ViewCells.samplingType", 1385 optString,1386 "view_cells_sampling_type=",1387 "box");1385 optString, 1386 "view_cells_sampling_type=", 1387 "box"); 1388 1388 1389 1389 RegisterOption("ViewCells.mergeStats", … … 2182 2182 2183 2183 RegisterOption("VspBspTree.Termination.AxisAligned.maxCostRatio", 2184 optFloat,2185 "vsp_bsp_term_axis_aligned_max_cost_ratio=",2186 "1.5");2184 optFloat, 2185 "vsp_bsp_term_axis_aligned_max_cost_ratio=", 2186 "1.5"); 2187 2187 2188 2188 RegisterOption("VspBspTree.useCostHeuristics", 2189 optBool,2190 "vsp_bsp_use_cost_heuristics=",2191 "false");2189 optBool, 2190 "vsp_bsp_use_cost_heuristics=", 2191 "false"); 2192 2192 2193 2193 RegisterOption("VspBspTree.Termination.maxViewCells", 2194 optInt,2195 "vsp_bsp_term_max_view_cells=",2196 "10000");2194 optInt, 2195 "vsp_bsp_term_max_view_cells=", 2196 "10000"); 2197 2197 2198 2198 RegisterOption("VspBspTree.Termination.maxCostRatio", 2199 optFloat,2200 "vsp_bsp_term_max_cost_ratio=",2201 "1.5");2199 optFloat, 2200 "vsp_bsp_term_max_cost_ratio=", 2201 "1.5"); 2202 2202 2203 2203 RegisterOption("VspBspTree.Termination.missTolerance", 2204 optInt,2205 "vsp_bsp_term_miss_tolerance=",2206 "4");2204 optInt, 2205 "vsp_bsp_term_miss_tolerance=", 2206 "4"); 2207 2207 2208 2208 RegisterOption("VspBspTree.splitPlaneStrategy", … … 2785 2785 "99990.0"); 2786 2786 2787 2788 /////////////////////////////////////////////////////// 2789 2790 RegisterOption("TraversalTree.Termination.minCost", 2791 optInt, 2792 "kd_term_min_cost=", 2793 "1"); 2794 2795 RegisterOption("TraversalTree.Termination.maxNodes", 2796 optInt, 2797 "kd_term_max_nodes=", 2798 "200000"); 2799 2800 RegisterOption("TraversalTree.Termination.maxDepth", 2801 optInt, 2802 "kd_term_max_depth=", 2803 "20"); 2804 2805 RegisterOption("TraversalTree.Termination.maxCostRatio", 2806 optFloat, 2807 "kd_term_max_cost_ratio=", 2808 "1.5"); 2809 2810 RegisterOption("TraversalTree.Termination.ct_div_ci", 2811 optFloat, 2812 "kd_term_ct_div_ci=", 2813 "1.0"); 2814 2815 RegisterOption("TraversalTree.splitMethod", 2816 optString, 2817 "kd_split_method=", 2818 "spatialMedian"); 2819 2820 RegisterOption("TraversalTree.splitBorder", 2821 optFloat, 2822 "kd_split_border=", 2823 "0.1"); 2824 2825 RegisterOption("TraversalTree.sahUseFaces", 2826 optBool, 2827 "kd_sah_use_faces=", 2828 "true"); 2829 2787 2830 ///////////////////////////////////////////////////////////////// 2788 2831 -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r2072 r2124 7 7 #include "Triangle3.h" 8 8 #include "Polygon3.h" 9 #include "TraversalTree.h" 9 10 10 11 … … 305 306 306 307 307 308 } 308 bool Exporter::ExportTraversalTree(const TraversalTree &tree, 309 const bool exportGeometry) 310 { 311 stack<TraversalNode *> tStack; 312 313 tStack.push(tree.GetRoot()); 314 315 Mesh *mesh = new Mesh; 316 317 SetWireframe(); 318 319 while (!tStack.empty()) 320 { 321 TraversalNode *node = tStack.top(); 322 tStack.pop(); 323 const AxisAlignedBox3 box = tree.GetBox(node); 324 325 // add 6 vertices of the box 326 const int index = (int)mesh->mVertices.size(); 327 328 SetForcedMaterial(RandomMaterial()); 329 330 for (int i=0; i < 8; i++) 331 { 332 Vector3 v; 333 box.GetVertex(i, v); 334 mesh->mVertices.push_back(v); 335 } 336 337 mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 338 mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 339 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 340 341 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 342 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 343 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 344 345 if (!node->IsLeaf()) 346 { 347 TraversalInterior *interior = static_cast<TraversalInterior *>(node); 348 349 tStack.push(interior->mFront); 350 tStack.push(interior->mBack); 351 } 352 else if (exportGeometry) 353 { 354 SetFilled(); 355 SetForcedMaterial(RandomMaterial()); 356 357 ExportViewCells(static_cast<TraversalLeaf *>(node)->mViewCells); 358 SetWireframe(); 359 } 360 } 361 362 ExportMesh(mesh); 363 delete mesh; 364 365 return true; 366 } 367 368 369 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
r2116 r2124 9 9 #include "Material.h" 10 10 #include "Containers.h" 11 //#include "VssRay.h"12 11 #include "AxisAlignedBox3.h" 13 12 … … 32 31 class MeshInstance; 33 32 class VssRay; 34 //class Material; 33 class TraversalTree; 34 35 35 36 36 struct VssRayContainer; … … 64 64 virtual bool 65 65 ExportKdTree(const KdTree &tree, const bool exportGeometry = false) = 0; 66 67 virtual bool 68 ExportTraversalTree(const TraversalTree &tree, const bool exportViewCells); 66 69 67 70 virtual bool -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r2117 r2124 383 383 } 384 384 385 // hack : should be different parameter name385 // hack 386 386 if (mUseMultiLevelConstruction) 387 387 { 388 388 cout << "starting optimizing multilevel ... " << endl; 389 // try to optimize on the above hierarchy389 // try to optimize the hierarchy from above 390 390 OptimizeMultiLevel(sampleRays, objects, forcedViewSpace); 391 391 … … 398 398 } 399 399 400 if (0) CreateTraversalTree(); 400 // create a traversal tree which is optimized for view cell casting 401 if (1) 402 { 403 CreateTraversalTree(); 404 } 401 405 } 402 406 … … 2488 2492 2489 2493 ViewCellContainer viewCells; 2490 2491 // add mesh instances of the scene graph to the root of the tree 2492 TraversalLeaf *root = (TraversalLeaf *)mTraversalTree->GetRoot(); 2493 2494 //mVspTree->CollectViewCells(root->mViewCells, false); 2495 2496 const long startTime = GetTime(); 2494 mVspTree->CollectViewCells(viewCells, false); 2495 2496 const long startTime = GetTime(); 2497 2497 2498 cout << "building traversal tree ... " << endl; 2498 2499 2499 mTraversalTree->Construct( );2500 2501 cout << "finished kdtree construction in " << TimeDiff(startTime, GetTime()) * 1e-32500 mTraversalTree->Construct(viewCells); 2501 2502 cout << "finished traversal tree construction in " << TimeDiff(startTime, GetTime()) * 1e-3 2502 2503 << " secs " << endl; 2504 2505 Debug << "*** TraversalTree Stats ***" << endl; 2506 Debug << mTraversalTree->GetStatistics() << endl; 2507 2508 if (1) 2509 { 2510 Exporter *exporter = Exporter::GetExporter("traversal.wrl"); 2511 exporter->ExportTraversalTree(*mTraversalTree, true); 2512 delete exporter; 2513 } 2503 2514 } 2504 2515 … … 2510 2521 { 2511 2522 if (!mTraversalTree) 2523 { 2512 2524 return mVspTree->CastLineSegment(origin,termination, viewcells, useMailboxing); 2525 } 2513 2526 else 2527 { 2514 2528 return mTraversalTree->CastLineSegment(origin,termination, viewcells, useMailboxing); 2515 } 2516 2517 2518 } 2529 } 2530 } 2531 2532 2533 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r2116 r2124 188 188 class HierarchyManager 189 189 { 190 friend class VspOspViewCellsManager; 191 190 192 public: 193 191 194 /** Constructor with the view space partition tree and 192 195 the object space hierarchy type as argument. 193 196 */ 194 197 HierarchyManager(const int objectSpaceHierarchyType); 198 195 199 /** Hack: OspTree will copy the content from this kd tree. 196 200 Only view space hierarchy will be constructed. -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2117 r2124 188 188 189 189 if (criteriaMet) 190 cerr<<"\n OBJECTS="<< leaf->mObjects.size()<<endl;190 cerr<<"\n OBJECTS="<<(int)leaf->mObjects.size()<<endl; 191 191 192 192 return criteriaMet; -
GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
r2123 r2124 186 186 for (int i=0; i < contributingRays; i++, index--) { 187 187 if (index < 0) 188 index = mRays.size()-1;188 index = (int)mRays.size()-1; 189 189 mRays[index].mImportance = importance; 190 190 } … … 196 196 // reset the start of the buffer 197 197 mBufferStart = 0; 198 mLastIndex = mRays.size();198 mLastIndex = (int)mRays.size(); 199 199 cout<<"Mutation candidates sorted in "<<TimeDiff(t1, GetTime())<<" ms."<<endl; 200 200 #endif … … 214 214 cout<<"Importance = "<< 215 215 GetEntry(0).mImportance<<" "<< 216 GetEntry( mRays.size()-1).mImportance<<endl;216 GetEntry((int)mRays.size()-1).mImportance<<endl; 217 217 218 218 cout<<"Sampling factor = "<< 219 219 GetEntry(0).GetSamplingFactor()<<" "<< 220 GetEntry( mRays.size()-1).GetSamplingFactor()<<endl;220 GetEntry((int)mRays.size()-1).GetSamplingFactor()<<endl; 221 221 222 222 cerr<<"Mutation update done."<<endl; … … 564 564 index = mLastIndex - 1; 565 565 if (index < 0 || index >= mRays.size()-1) { 566 index = mRays.size() - 1;566 index = (int)mRays.size() - 1; 567 567 } else 568 568 if ( … … 573 573 // cout<<mLastIndex<<endl; 574 574 // cout<<index<<endl; 575 index = mRays.size() - 1;575 index = (int)mRays.size() - 1; 576 576 } 577 577 #else -
GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp
r2105 r2124 40 40 mz.SetColumns(sx, sy, sd); 41 41 42 doubledet = md.Det3x3();42 const float det = md.Det3x3(); 43 43 44 44 if (abs(det)<TRASH) … … 46 46 47 47 result.SetValue(mx.Det3x3()/det, 48 my.Det3x3()/det,49 mz.Det3x3()/det);48 my.Det3x3()/det, 49 mz.Det3x3()/det); 50 50 51 51 return true; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2122 r2124 747 747 if (0) LoadObjects(buf, pvsObjects, mObjects); 748 748 749 const bool finalizeViewCells = true; 749 750 cout << "loading view cells from " << buf << endl; 750 751 … … 752 753 pvsObjects, 753 754 mObjects, 754 true,755 finalizeViewCells, 755 756 NULL); 756 757 … … 1366 1367 1367 1368 if ((int)rays.size() > 100000 && i % 100000 == 0) 1368 //cout << "here2 " << vssRays.size()<<endl;1369 1369 cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 1370 1370 } -
GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorFactory.cpp
r2119 r2124 14 14 Preprocessor *PreprocessorFactory::CreatePreprocessor(const string &preprocessorType) 15 15 { 16 Debug << "here9191" << endl;17 16 if (preprocessorType == "vss") 18 { Debug << "here21112" << endl;17 { 19 18 return new VssPreprocessor(); 20 19 } -
GTP/trunk/Lib/Vis/Preprocessing/src/TraversalTree.cpp
r2094 r2124 7 7 #include "ViewCell.h" 8 8 #include "Beam.h" 9 #include "Exporter.h" 9 10 10 11 … … 59 60 60 61 61 void TraversalInterior::ReplaceChildLink(TraversalNode *oldChild, TraversalNode *newChild) 62 void TraversalInterior::ReplaceChildLink(TraversalNode *oldChild, 63 TraversalNode *newChild) 62 64 { 63 65 if (mBack == oldChild) … … 71 73 TraversalNode(parent) 72 74 { 73 m Objects.reserve(objects);75 mViewCells.reserve(objects); 74 76 } 75 77 … … 88 90 TraversalTree::TraversalTree() 89 91 { 90 mRoot = new TraversalLeaf(NULL, 0); 92 TraversalLeaf *leaf = new TraversalLeaf(NULL, 0); 93 leaf->mDepth = 0; 94 mRoot = leaf; 91 95 92 96 Environment::GetSingleton()->GetIntValue("TraversalTree.Termination.maxNodes", mTermMaxNodes); … … 102 106 Environment::GetSingleton()->GetStringValue("TraversalTree.splitMethod", splitType); 103 107 108 splitCandidates = NULL; 104 109 mSplitMethod = SPLIT_SPATIAL_MEDIAN; 110 105 111 if (strcmp(splitType, "spatialMedian") == 0) 106 112 { … … 121 127 else 122 128 { 123 cerr <<"Wrong kd split type "<<splitType<<endl;129 cerr << "Wrong kd split type " << splitType << endl; 124 130 exit(1); 125 131 } 126 127 splitCandidates = NULL; 128 } 129 } 132 } 133 } 134 cout << "Traversal Tree Split method: " << mSplitMethod << endl; 130 135 } 131 136 … … 137 142 138 143 139 bool 140 TraversalTree::Construct() 141 { 142 144 bool TraversalTree::Construct(const ViewCellContainer &viewCells) 145 { 143 146 if (!splitCandidates) 144 147 { … … 149 152 TraversalLeaf *leaf = static_cast<TraversalLeaf *>(mRoot); 150 153 154 leaf->mViewCells = viewCells; 151 155 mStat.nodes = 1; 152 153 156 mBox.Initialize(); 154 157 155 ObjectContainer::const_iterator mi; 156 for ( mi = leaf->mObjects.begin(); mi != leaf->mObjects.end(); ++ mi) 158 ViewCellContainer::const_iterator mi; 159 160 for ( mi = leaf->mViewCells.begin(); mi != leaf->mViewCells.end(); ++ mi) 157 161 { 158 162 mBox.Include((*mi)->GetBox()); … … 163 167 164 168 // remove the allocated array 165 CLEAR_CONTAINER(*splitCandidates); 166 delete splitCandidates; 167 169 if (splitCandidates) 170 { 171 CLEAR_CONTAINER(*splitCandidates); 172 delete splitCandidates; 173 } 174 168 175 return true; 169 176 } … … 182 189 while (!tStack.empty()) 183 190 { 184 // cout<<mStat.Nodes() << " " << mTermMaxNodes << endl;185 191 if (mStat.Nodes() > mTermMaxNodes) 186 192 { … … 226 232 bool TraversalTree::TerminationCriteriaMet(const TraversalLeaf *leaf) 227 233 { 228 const bool criteriaMet = 229 ((int)leaf->mObjects.size() <= mTermMinCost) || 230 (leaf->mDepth >= mTermMaxDepth); 234 const bool criteriaMet = ( 235 ((int)leaf->mViewCells.size() <= mTermMinCost) || 236 (leaf->mDepth >= mTermMaxDepth) 237 || (GetBox(leaf).SurfaceArea() < 0.00001f) 238 ); 231 239 232 240 if (criteriaMet) 233 cerr<< "\n OBJECTS=" << (int)leaf->mObjects.size() << endl; 241 { 242 cerr << "\nOBJECTS=" << (int)leaf->mViewCells.size() << endl; 243 cerr << "\nDEPTH=" << (int)leaf->mDepth << endl; 244 } 234 245 235 246 return criteriaMet; … … 248 259 { 249 260 axis = box.Size().DrivingAxis(); 250 position = (box.Min()[axis] + box.Max()[axis]) *0.5f;261 position = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 251 262 break; 252 263 } … … 254 265 { 255 266 int objectsBack, objectsFront; 256 float costRatio; 257 bool mOnlyDrivingAxis = true; 258 259 if (mOnlyDrivingAxis) 260 { 261 axis = box.Size().DrivingAxis(); 262 costRatio = BestCostRatio(leaf, 263 box, 264 axis, 265 position, 266 objectsBack, 267 objectsFront); 268 } 269 else 270 { 271 costRatio = MAX_FLOAT; 272 273 for (int i=0; i < 3; i++) 267 float costRatio = 99999;//MAX_FLOAT; 268 269 for (int i=0; i < 3; ++ i) 270 { 271 float p; 272 float r = BestCostRatio(leaf, 273 box, 274 i, 275 p, 276 objectsBack, 277 objectsFront); 278 279 if (r < costRatio) 274 280 { 275 float p; 276 float r = BestCostRatio(leaf, 277 box, 278 i, 279 p, 280 objectsBack, 281 objectsFront); 282 283 if (r < costRatio) 284 { 285 costRatio = r; 286 axis = i; 287 position = p; 288 } 281 costRatio = r; 282 axis = i; 283 position = p; 289 284 } 290 285 } … … 292 287 if (costRatio > mMaxCostRatio) 293 288 { 294 //cout<<"Too big cost ratio "<<costRatio<<endl;289 cout << "Too big cost ratio " << costRatio << endl; 295 290 axis = -1; 296 291 } … … 318 313 319 314 if (axis == -1) { 315 cout << "terminate on cost ratio" << endl; 320 316 return leaf; 321 317 } … … 341 337 frontBBox.SetMin(axis, position); 342 338 343 ObjectContainer::const_iterator mi; 344 345 for ( mi = leaf->mObjects.begin(); 346 mi != leaf->mObjects.end(); 347 mi++) 339 ViewCellContainer::const_iterator mi, mi_end = leaf->mViewCells.end(); 340 341 for (mi = leaf->mViewCells.begin(); mi != mi_end; ++ mi) 348 342 { 349 343 // determine the side of this ray with respect to the plane 350 344 AxisAlignedBox3 box = (*mi)->GetBox(); 351 if (box.Max(axis) > position 352 objectsFront++;353 354 if (box.Min(axis) < position 345 if (box.Max(axis) > position) 346 ++ objectsFront; 347 348 if (box.Min(axis) < position) 355 349 ++ objectsBack; 356 350 } 357 358 351 359 352 TraversalLeaf *back = new TraversalLeaf(node, objectsBack); 360 353 TraversalLeaf *front = new TraversalLeaf(node, objectsFront); 361 354 355 back->mDepth = front->mDepth = leaf->mDepth + 1; 362 356 363 357 // replace a link from node's parent … … 370 364 node->SetupChildLinks(back, front); 371 365 372 for (mi = leaf->m Objects.begin(); mi != leaf->mObjects.end(); ++ mi)366 for (mi = leaf->mViewCells.begin(); mi != mi_end; ++ mi) 373 367 { 374 368 // determine the side of this ray with respect to the plane … … 377 371 if (box.Max(axis) >= position ) 378 372 { 379 front->m Objects.push_back(*mi);373 front->mViewCells.push_back(*mi); 380 374 } 381 375 382 376 if (box.Min(axis) < position ) 383 377 { 384 back->m Objects.push_back(*mi);385 } 386 387 mStat.objectRefs -= (int)leaf->m Objects.size();378 back->mViewCells.push_back(*mi); 379 } 380 381 mStat.objectRefs -= (int)leaf->mViewCells.size(); 388 382 mStat.objectRefs += objectsBack + objectsFront; 389 383 } … … 404 398 405 399 app << "#N_SPLITS ( Number of splits in axes x y z dx dy dz)\n"; 406 for (int i=0; i<7; i++) 407 app << splits[i] <<" "; 408 app <<endl; 409 410 app << "#N_RAYREFS ( Number of rayRefs )\n" << 411 rayRefs << "\n"; 412 413 app << "#N_RAYRAYREFS ( Number of rayRefs / ray )\n" << 414 rayRefs/(double)rays << "\n"; 415 416 app << "#N_LEAFRAYREFS ( Number of rayRefs / leaf )\n" << 417 rayRefs/(double)Leaves() << "\n"; 400 401 for (int i = 0; i < 7; ++ i) 402 app << splits[i] << " "; 403 app << endl; 418 404 419 405 app << "#N_MAXOBJECTREFS ( Max number of object refs / leaf )\n" << 420 406 maxObjectRefs << "\n"; 421 407 422 app << "#N_ NONEMPTYRAYREFS ( Number of rayRefs in nonEmpty leaves / non emptyleaf )\n" <<423 rayRefsNonZeroQuery/(double)(Leaves() - zeroQueryNodes) << "\n";408 app << "#N_AVGOBJECTREFS ( Avg number of object refs / leaf )\n" << 409 totalObjectRefs / (double)Leaves() << "\n"; 424 410 425 411 app << "#N_LEAFDOMAINREFS ( Number of query domain Refs / leaf )\n" << 426 objectRefs/(double)Leaves() << "\n"; 412 objectRefs / (double)Leaves() << "\n"; 413 414 app << "#N_PEMPTYLEAVES ( Percentage of leaves with zero query domains )\n"<< 415 zeroQueryNodes * 100 / (double)Leaves() << endl; 416 417 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maxdepth )\n"<< 418 maxDepthNodes * 100 / (double)Leaves() << endl; 419 420 app << "#N_PMINCOSTLEAVES ( Percentage of leaves with minCost )\n"<< 421 minCostNodes * 100 / (double)Leaves() << endl; 427 422 428 423 // app << setprecision(4); 429 430 app << "#N_PEMPTYLEAVES ( Percentage of leaves with zero query domains )\n"<<431 zeroQueryNodes*100/(double)Leaves()<<endl;432 433 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maxdepth )\n"<<434 maxDepthNodes*100/(double)Leaves()<<endl;435 436 app << "#N_PMINCOSTLEAVES ( Percentage of leaves with minCost )\n"<<437 minCostNodes*100/(double)Leaves()<<endl;438 439 app << "#N_ADDED_RAYREFS (Number of dynamically added ray references )\n"<<440 addedRayRefs<<endl;441 442 app << "#N_REMOVED_RAYREFS (Number of dynamically removed ray references )\n"<<443 removedRayRefs<<endl;444 445 // app << setprecision(4);446 447 424 // app << "#N_CTIME ( Construction time [s] )\n" 448 425 // << Time() << " \n"; 449 426 450 app << "===== END OF TraversalTree statistics ==========\n"; 451 427 app << "======= END OF TraversalTree statistics ========\n"; 452 428 } 453 429 … … 455 431 void TraversalTree::EvaluateLeafStats(const TraversalData &data) 456 432 { 457 458 // the node became a leaf -> evaluate stats for leafs 459 TraversalLeaf *leaf = (TraversalLeaf *)data.mNode; 460 461 if (data.mDepth > mTermMaxDepth) 462 mStat.maxDepthNodes++; 463 464 if ( (int)(leaf->mObjects.size()) < mTermMinCost) 465 mStat.minCostNodes++; 466 467 468 if ( (int)(leaf->mObjects.size()) > mStat.maxObjectRefs) 469 mStat.maxObjectRefs = (int)leaf->mObjects.size(); 470 471 } 472 433 // the node became a leaf -> evaluate stats for leafs 434 TraversalLeaf *leaf = (TraversalLeaf *)data.mNode; 435 436 if (data.mDepth > mTermMaxDepth) 437 ++ mStat.maxDepthNodes; 438 439 if ((int)(leaf->mViewCells.size()) < mTermMinCost) 440 ++ mStat.minCostNodes; 441 442 mStat.totalObjectRefs += (int)leaf->mViewCells.size(); 443 444 if ((int)(leaf->mViewCells.size()) > mStat.maxObjectRefs) 445 mStat.maxObjectRefs = (int)leaf->mViewCells.size(); 446 } 473 447 474 448 … … 480 454 //splitCandidates->clear(); 481 455 482 int requestedSize = 2 *(int)node->mObjects.size();456 int requestedSize = 2 * (int)node->mViewCells.size(); 483 457 484 458 // creates a sorted split candidates array 485 459 if (splitCandidates->capacity() > 500000 && 486 requestedSize < (int)(splitCandidates->capacity() /10) )460 requestedSize < (int)(splitCandidates->capacity() / 10) ) 487 461 { 488 462 delete splitCandidates; … … 492 466 splitCandidates->reserve(requestedSize); 493 467 468 494 469 // insert all queries 495 for(ObjectContainer::const_iterator mi = node->mObjects.begin(); 496 mi != node->mObjects.end(); 470 for(ViewCellContainer::const_iterator mi = node->mViewCells.begin(); 471 mi != node->mViewCells.end(); 472 mi++) 473 { 474 AxisAlignedBox3 box = (*mi)->GetBox(); 475 476 splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 477 box.Max(axis), 478 *mi) 479 ); 480 } 481 482 // insert all queries 483 for(ViewCellContainer::const_iterator mi = node->mViewCells.begin(); 484 mi != node->mViewCells.end(); 497 485 mi++) 498 486 { … … 503 491 *mi) 504 492 ); 505 506 splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 493 /*splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 507 494 box.Max(axis), 508 495 *mi) 509 ); 496 );*/ 510 497 } 511 498 … … 550 537 // C = ct_div_ci + (ol + or)/queries 551 538 552 float totalIntersections = 0.0f;553 539 vector<SortableEntry *>::const_iterator ci; 554 540 555 for(ci = splitCandidates->begin(); ci < splitCandidates->end(); ++ ci) 556 if ((*ci)->type == SortableEntry::BOX_MIN) 557 { 558 totalIntersections += (*ci)->intersectable->IntersectionComplexity(); 559 } 560 561 float intersectionsLeft = 0; 562 float intersectionsRight = totalIntersections; 563 564 int objectsLeft = 0, objectsRight = (int)node->mObjects.size(); 541 int objectsLeft = 0, objectsRight = (int)node->mViewCells.size(); 542 543 int dummy1 = objectsLeft, dummy2 = objectsRight; 565 544 566 545 float minBox = box.Min(axis); … … 578 557 { 579 558 case SortableEntry::BOX_MIN: 580 objectsLeft++; 581 intersectionsLeft += (*ci)->intersectable->IntersectionComplexity(); 559 ++ objectsLeft; 582 560 break; 583 561 case SortableEntry::BOX_MAX: 584 objectsRight--; 585 intersectionsRight -= (*ci)->intersectable->IntersectionComplexity(); 562 -- objectsRight; 586 563 break; 587 564 } 588 565 589 if ((*ci)->value > minBand && (*ci)->value <maxBand)566 if ((*ci)->value >= minBand && (*ci)->value <= maxBand) 590 567 { 591 568 AxisAlignedBox3 lbox = box; 592 569 AxisAlignedBox3 rbox = box; 570 593 571 lbox.SetMax(axis, (*ci)->value); 594 572 rbox.SetMin(axis, (*ci)->value); 595 573 596 float sum; 597 598 if (mSahUseFaces) 599 sum = intersectionsLeft*lbox.SurfaceArea() + intersectionsRight*rbox.SurfaceArea(); 600 else 601 sum = objectsLeft*lbox.SurfaceArea() + objectsRight*rbox.SurfaceArea(); 602 603 // cout<<"pos="<<(*ci).value<<"\t q=("<<ql<<","<<qr<<")\t r=("<<rl<<","<<rr<<")"<<endl; 604 // cout<<"cost= "<<sum<<endl; 574 const float sum = objectsLeft * lbox.SurfaceArea() + objectsRight * rbox.SurfaceArea(); 575 576 // cout<<"pos="<<(*ci).value<<"\t q=("<<ql<<","<<qr<<")\t r=("<<rl<<","<<rr<<")"<<endl; 577 // cout<<"cost= "<<sum<<endl; 605 578 606 579 #if DEBUG_COST 607 580 if (nodeId < 100) 608 581 { 609 float oldCost = mSahUseFaces ? totalIntersections : node->mObjects.size();582 float oldCost = (float)node->mViewCells.size(); 610 583 float newCost = mCt_div_ci + sum/boxArea; 611 float ratio = newCost /oldCost;584 float ratio = newCost / oldCost; 612 585 costStream<<(*ci)->value<<" "<<ratio<<endl; 613 586 } … … 625 598 } 626 599 627 const float oldCost = mSahUseFaces ? totalIntersections : node->mObjects.size(); 628 const float newCost = mCt_div_ci + minSum/boxArea; 629 const float ratio = newCost/oldCost; 630 600 const float oldCost = (float)node->mViewCells.size(); 601 const float newCost = mCt_div_ci + minSum / boxArea; 602 const float ratio = newCost / oldCost; 603 604 //if (boxArea == 0) 605 // cout << "error: " << boxArea << endl; 606 if (ratio > 2) 607 { 608 cout << "costratio: " << ratio << " oldcost: " << oldCost << " box area: " << boxArea << " new: " << newCost << endl; 609 cout << "obj left: " <<objectsBack<< " obj right: " << objectsFront << endl; 610 cout << "dummy1: " << dummy1 << " dummy2: " << dummy2 << endl; 611 } 631 612 #if 0 632 613 cout<<"===================="<<endl; … … 634 615 <<"\t o=("<<objectsBack<<","<<objectsFront<<")"<<endl; 635 616 #endif 617 636 618 return ratio; 619 } 620 621 622 int TraversalTree::FindViewCellIntersections(const Vector3 &lStart, 623 const Vector3 &lEnd, 624 const ViewCellContainer &viewCells, 625 ViewCellContainer &hitViewCells, 626 const bool useMailboxing) 627 { 628 int hits = 0; 629 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 630 631 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 632 { 633 ViewCell *viewCell = *vit; 634 // don't have to mail if each view cell belongs to exactly one leaf 635 if (!useMailboxing || !viewCell->Mailed()) 636 { 637 if (useMailboxing) 638 viewCell->Mail(); 639 640 // hack: assume that we use vsp tree, 641 //P so we can just test intersection with bounding boxes 642 if (viewCell->GetBox().Intersects(lStart, lEnd)); 643 { 644 hitViewCells.push_back(viewCell); 645 ++ hits; 646 } 647 } 648 } 649 650 return hits; 637 651 } 638 652 … … 640 654 int TraversalTree::CastLineSegment(const Vector3 &origin, 641 655 const Vector3 &termination, 642 ViewCellContainer &view cells,656 ViewCellContainer &viewCells, 643 657 const bool useMailboxing) 644 658 { … … 709 723 // compute intersection with all objects in this leaf 710 724 TraversalLeaf *leaf = static_cast<TraversalLeaf *>(node); 711 ViewCell *viewCell = NULL; 712 713 #if TODO 714 if (0) 715 viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 716 else 717 viewCell = leaf->mViewCell; 718 #endif 719 // don't have to mail if each view cell belongs to exactly one leaf 720 if (!useMailboxing || !viewCell->Mailed()) 721 { 722 if (useMailboxing) 723 viewCell->Mail(); 724 725 viewcells.push_back(viewCell); 726 ++ hits; 727 } 728 725 726 hits += FindViewCellIntersections(origin, 727 termination, 728 leaf->mViewCells, 729 viewCells, 730 useMailboxing); 731 729 732 // get the next node from the stack 730 733 if (tStack.empty()) -
GTP/trunk/Lib/Vis/Preprocessing/src/TraversalTree.h
r2116 r2124 8 8 #include "AxisAlignedBox3.h" 9 9 #include "Ray.h" 10 //#include "ObjectPvs.h"11 //#include "Viewcell.h"12 //#include "VssRay.h"13 //#include "IntersectableWrapper.h"14 10 15 11 … … 25 21 class TraversalTree; 26 22 27 // TraversalTree *SceneTraversalTree;28 23 29 24 // -------------------------------------------------------------- … … 55 50 // max number of rays per node 56 51 int maxObjectRefs; 52 // max number of rays per node 53 int totalObjectRefs; 57 54 // number of dynamically added ray refs 58 55 int addedRayRefs; … … 83 80 minCostNodes = 0; 84 81 maxObjectRefs = 0; 82 totalObjectRefs = 0; 85 83 addedRayRefs = removedRayRefs = 0; 86 84 } … … 121 119 } 122 120 123 /** Parent of the node - the parent is a little overhead for maintanance of the tree, 124 but allows various optimizations of tree traversal algorithms 121 /** Parent of the node - the parent is a little overhead for 122 maintanance of the tree, but allows various optimizations 123 of tree traversal algorithms 125 124 */ 126 125 TraversalInterior *mParent; … … 217 216 218 217 // pointers to view cells contained in this node 219 ObjectContainer mObjects;218 ViewCellContainer mViewCells; 220 219 221 220 short mDepth; … … 237 236 float mPriority; 238 237 239 TraversalData() {}238 TraversalData(): mNode(NULL), mPriority(0), mDepth(0) {} 240 239 241 240 TraversalData(TraversalNode *n, const float p): 242 mNode(n), mPriority(p) 241 mNode(n), mPriority(p), mDepth(0) 243 242 {} 244 243 245 244 TraversalData(TraversalNode *n, 246 const AxisAlignedBox3 &b, 247 const int d): 248 mNode(n), mBox(b), mDepth(d) {} 245 const AxisAlignedBox3 &b, 246 const int d): 247 mNode(n), mBox(b), mDepth(d) 248 {} 249 249 250 250 … … 255 255 256 256 return 257 leafa->m Objects.size() * mBox.SurfaceArea()257 leafa->mViewCells.size() * mBox.SurfaceArea() 258 258 < 259 leafb->m Objects.size() * b.mBox.SurfaceArea();259 leafb->mViewCells.size() * b.mBox.SurfaceArea(); 260 260 } 261 261 262 262 263 264 263 // comparator for the 264 struct less_priority: public 265 265 binary_function<const TraversalData, const TraversalData, bool> 266 { 267 bool operator()(const TraversalData a, const TraversalData b) 266 268 { 267 bool operator()(const TraversalData a, const TraversalData b) 268 { 269 return a.mPriority < b.mPriority; 270 } 271 }; 269 return a.mPriority < b.mPriority; 270 } 271 }; 272 272 }; 273 273 … … 292 292 const bool useMailboxing); 293 293 294 virtual bool Construct( );294 virtual bool Construct(const ViewCellContainer &viewCells); 295 295 296 296 /** Check whether subdivision criteria are met for the given subtree. 297 297 If not subdivide the leafs of the subtree. The criteria are specified in 298 298 the environment as well as the subdivision method. By default surface area 299 299 heuristics is used. 300 300 … … 372 372 {} 373 373 374 bool operator<(const SortableEntry &b) const374 /*bool operator<(const SortableEntry &b) const 375 375 { 376 // view cells usually adjacent 377 if (EpsilonEqual(value, b.value, 0.001)) 378 return (type == BOX_MAX); 379 376 380 return value < b.value; 377 } 381 }*/ 378 382 }; 379 383 380 384 inline static bool iltS(SortableEntry *a, SortableEntry *b) 381 385 { 386 // view cells usually adjacent 387 //if (EpsilonEqual(a->value, b->value)) 388 // return false; 389 // return (a->type == SortableEntry::BOX_MAX); 390 382 391 return a->value < b->value; 383 392 } … … 409 418 float &position); 410 419 420 int FindViewCellIntersections(const Vector3 &lStart, 421 const Vector3 &lEnd, 422 const ViewCellContainer &viewCells, 423 ViewCellContainer &hitViewCells, 424 const bool useMailboxing); 411 425 412 426 //////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r2117 r2124 261 261 float &contribution) 262 262 { 263 const bool result = mPvs.AddSample(sample, pdf); //, contribution);263 const bool result = mPvs.AddSample(sample, pdf); 264 264 // have to recompute pvs size 265 265 mPvsSizeValid = false; … … 2376 2376 Intersectable *obj = it.Next(); 2377 2377 2378 // hack: just output full pvs2378 // hack: just output all the "elementary" objects 2379 2379 if (0 && (obj->Type() == Intersectable::BVH_INTERSECTABLE)) 2380 2380 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r2117 r2124 203 203 */ 204 204 void SetMesh(Mesh *mesh); 205 206 205 /** Sets this view cell to be a valid view cell according to some criteria. 207 206 */ … … 291 290 void SetFilteredPvsSize(const int s) { 292 291 mFilteredPvsSize = s; 293 } 292 } 293 294 //virtual int ViewCellType; 294 295 295 296 protected: … … 321 322 bool mPvsSizeValid; 322 323 323 324 324 /// Filter cost of the pvs 325 325 int mFilteredPvsSize; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2123 r2124 1051 1051 bconverter); 1052 1052 1053 //Debug << " view cells parsed in "1054 // << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl;1055 1056 1057 1053 if (!success) 1058 1054 { … … 1063 1059 } 1064 1060 1065 //cout << "viewcells parsed " <<endl;1066 1067 1061 if (0) 1068 1062 { … … 1090 1084 if (finalizeViewCells) 1091 1085 { 1092 // create the meshes and compute v olumes1086 // create the meshes and compute view cell volumes 1093 1087 const bool createMeshes = true; 1094 //const bool createMeshes = false;1095 1096 1088 vm->FinalizeViewCells(createMeshes); 1097 1089 } … … 7025 7017 #endif 7026 7018 7027 7028 7029 } 7019 void VspOspViewCellsManager::FinalizeViewCells(const bool createMesh) 7020 { 7021 ViewCellsManager::FinalizeViewCells(createMesh); 7022 7023 if (1) 7024 { // create a traversal tree for optimal view cell casting 7025 mHierarchyManager->CreateTraversalTree(); 7026 } 7027 } 7028 7029 7030 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2123 r2124 1288 1288 float UpdateObjectCosts(); 1289 1289 1290 virtual void FinalizeViewCells(const bool createMesh); 1291 1290 1292 protected: 1291 1293 -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.h
r1486 r2124 39 39 ~VrmlExporter(); 40 40 41 42 // bool43 // ExportRays(const vector<Ray> &rays,44 // const float length=1000,45 // const RgbColor &color = RgbColor(1,1,1));46 47 48 41 bool 49 42 ExportKdTree(const KdTree &tree, const bool exportGeometry = false); 50 51 //bool ExportOspTree(const OspTree &tree);52 43 53 44 bool … … 141 132 void ExportViewpoint(const Vector3 &point, const Vector3 &direction); 142 133 134 //virtual bool ExportTraversalTree(const KdTree &tree, const bool exportViewCells); 143 135 }; 144 136 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r2072 r2124 1341 1341 } 1342 1342 1343 s ort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end());1343 stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1344 1344 } 1345 1345 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2123 r2124 1097 1097 } 1098 1098 1099 //stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end());1100 sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end());1099 stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1100 //sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1101 1101 } 1102 1102 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r2073 r2124 827 827 828 828 @param tData data object holding, e.g., a pointer to the leaf 829 @param frontData returns the data (e.g., 830 @param backData returns the data (e.g., 829 @param frontData returns the data (e.g., pointer to the leaf) in front of the split plane 830 @param backData returns the data (e.g., pointer to the leaf) in the back of the split plane 831 831 832 832 @param rays the polygons to be filtered -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r2017 r2124 1211 1211 1212 1212 1213 } 1214 1213 1214 1215 1216 } 1217 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.h
r1404 r2124 29 29 class X3dExporter : public Exporter 30 30 { 31 31 std::ofstream stream; 32 32 33 33 public: 34 34 35 35 X3dExporter(const string filename); 36 36 37 37 ~X3dExporter(); 38 38 39 bool 40 ExportKdTree(const KdTree &tree, const bool exportGeometry = false); 39 41 40 // bool 41 // ExportRays(const vector<Ray> &rays, 42 // const float length=1000, 43 // const RgbColor &color = RgbColor(1,1,1)); 42 bool 43 ExportVssTree(const VssTree &tree); 44 44 45 bool 46 ExportVssTree2(const VssTree &tree, 47 const Vector3 direction); 45 48 46 bool 47 ExportKdTree(const KdTree &tree, const bool exportGeometry = false); 49 virtual bool 50 ExportRssTree2(const RssTree &tree, 51 const Vector3 direction); 48 52 49 bool 50 ExportVssTree(const VssTree &tree); 53 bool ExportBspTree(const BspTree &tree); 51 54 52 bool 53 ExportVssTree2(const VssTree &tree, 54 const Vector3 direction 55 ); 55 bool 56 ExportScene(SceneGraphNode *root) 57 { 58 ExportSceneNode(root); 59 return true; 60 } 56 61 57 virtual bool 58 ExportRssTree2(const RssTree &tree, 59 const Vector3 direction 60 ); 62 virtual void 63 ExportPolygon(Polygon3 *poly); 61 64 62 // bool ExportOspTree(const OspTree &tree); 65 virtual void 66 ExportPolygons(const PolygonContainer &polys); 63 67 64 bool ExportBspTree(const BspTree &tree); 68 virtual bool 69 ExportBox(const AxisAlignedBox3 &box); 65 70 66 bool 67 ExportScene(SceneGraphNode *root) 68 { 69 ExportSceneNode(root); 70 return true; 71 } 71 virtual void 72 ExportMesh(Mesh *mesh); 72 73 73 74 ExportPolygon(Polygon3 *poly);74 virtual void 75 ExportViewCell(ViewCell *viewCell); 75 76 76 virtual void 77 ExportPolygons(const PolygonContainer &polys); 77 bool 78 ExportRays(const RayContainer &rays, 79 const float length=1000, 80 const RgbColor &color = RgbColor(1,1,1)); 78 81 79 virtual bool 80 ExportBox(const AxisAlignedBox3 &box); 82 bool 83 ExportRays(const VssRayContainer &rays, 84 const RgbColor &color = RgbColor(1,1,1)); 81 85 82 83 ExportMesh(Mesh *mesh);86 virtual void 87 ExportBspSplitPlanes(const BspTree &tree); 84 88 85 86 ExportViewCell(ViewCell *viewCell);89 virtual void 90 ExportBspSplits(const BspTree &tree, const bool exportDepth); 87 91 88 bool 89 ExportRays(const RayContainer &rays, 90 const float length=1000, 91 const RgbColor &color = RgbColor(1,1,1)); 92 virtual void 93 ExportLeavesGeometry(const BspTree &tree, const vector<BspLeaf *> &leaves); 92 94 93 bool 94 ExportRays(const VssRayContainer &rays, 95 const RgbColor &color = RgbColor(1,1,1)); 95 virtual void ExportBspLeaves(const BspTree &tree, const int maxPvs = 0); 96 96 97 virtual void 98 ExportBspSplitPlanes(const BspTree &tree); 97 virtual void ExportBspSplits(const VspBspTree &tree, const bool exportDepth); 99 98 100 virtual void 101 ExportBspSplits(const BspTree &tree, const bool exportDepth); 99 virtual void ExportBeam(const Beam &beam, const AxisAlignedBox3 &box); 102 100 103 virtual void 104 ExportLeavesGeometry(const BspTree &tree, const vector<BspLeaf *> &leaves);101 bool ExportRaySets(const vector<VssRayContainer> &rays, 102 const RgbColor &color); 105 103 106 virtual void107 ExportBspLeaves(const BspTree &tree, const int maxPvs = 0);108 109 virtual void110 ExportBspSplits(const VspBspTree &tree, const bool exportDepth);111 112 virtual void ExportBeam(const Beam &beam, const AxisAlignedBox3 &box);113 114 bool115 ExportRaySets(const vector<VssRayContainer> &rays,116 const RgbColor &color);117 104 118 105 protected: 119 106 120 virtual void 121 ExportSceneNode(SceneGraphNode *node); 107 virtual void ExportSceneNode(SceneGraphNode *node); 122 108 123 bool 124 ExportKdTreeRayDensity(const KdTree &tree); 109 bool ExportKdTreeRayDensity(const KdTree &tree); 125 110 126 bool 127 ExportBspTreeRayDensity(const BspTree &tree); 111 bool ExportBspTreeRayDensity(const BspTree &tree); 128 112 129 130 131 132 113 void ExportBspNodeSplits(BspNode *root, 114 const AxisAlignedBox3 &box, 115 const bool exportDepth, 116 const bool epsilon); 133 117 134 135 void ExportViewpoint(const Vector3 &point, const Vector3 &direction); 136 118 void ExportViewpoint(const Vector3 &point, const Vector3 &direction); 137 119 }; 138 120
Note: See TracChangeset
for help on using the changeset viewer.