- Timestamp:
- 01/03/07 16:48:59 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1923 r1933 1023 1023 1024 1024 const bool noValidSplit = ((objectsLeft <= Limits::Small) || (objectsRight <= Limits::Small)); 1025 const float sum = noValidSplit ? 1e25 : objectsLeft * al + objectsRight * ar;1025 const float sum = noValidSplit ? 1e25f : objectsLeft * al + objectsRight * ar; 1026 1026 1027 1027 /*cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=(" … … 1325 1325 // the heuristics 1326 1326 const float sum = noValidSplit ? 1327 1e25 : volLeft * (float)nObjectsLeft + volRight * (float)nObjectsRight;1327 1e25f : volLeft * (float)nObjectsLeft + volRight * (float)nObjectsRight; 1328 1328 1329 1329 #ifdef GTP_DEBUG -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1920 r1933 824 824 const bool onlyMailedRays) const; 825 825 826 /** Counts the view cells of this object. note: only827 counts unmailed objects.828 */829 int CountViewCells(Intersectable *obj) const;830 831 /** Counts the view cells seen by this bvh leaf832 */833 int CountViewCells(const ObjectContainer &objects) const;834 835 826 /** Collects view cells which see an object. 827 @param useMailBoxing if mailing should be used and 828 only unmailed object should pass 829 @param setCounter counter for the sweep algorithm 830 @param onlyMailedRays if only mailed rays should be considered 836 831 */ 837 832 int CollectViewCells(Intersectable *object, … … 840 835 const bool setCounter, 841 836 const bool onlyMailedRays) const; 837 838 /** Counts the view cells of this object. note: only 839 counts unmailed objects. 840 */ 841 int CountViewCells(Intersectable *obj) const; 842 843 /** Counts the view cells seen by this bvh leaf 844 */ 845 int CountViewCells(const ObjectContainer &objects) const; 842 846 843 847 /** Evaluates increase in pvs size. -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1932 r1933 61 61 62 62 // distance large => this is likely to be a discontinuity 63 #if 1 63 64 if ((predictedLen - len) > mThreshold) 65 #else // rather use relative distance 66 if ((predictedLen / len) > mThreshold) 67 #endif 64 68 { 65 69 cout << "d"; 70 // apply reverse sampling to find the gap 66 71 VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay); 67 72 73 if (!newRay) 74 return false; 75 68 76 // set flag for visualization 69 77 newRay->mFlags |= VssRay::ReverseSample; … … 71 79 // if ray is not further processed => can delete ray 72 80 if (!HandleRay(newRay)) 81 { 73 82 delete newRay; 74 83 } 84 else if (mVssRays.size() < 3) 85 { 86 mVssRays.push_back(new VssRay(oldRay)); 87 mVssRays.push_back(new VssRay(currentRay)); 88 mVssRays.push_back(new VssRay(*newRay)); 89 } 90 75 91 return true; 76 92 } … … 84 100 // compute the contribution to the view cells 85 101 const bool storeRaysForViz = true; 102 86 103 mViewCellsManager->ComputeSampleContribution(*vssRay, 87 104 true, … … 317 334 318 335 319 Vector3 GvsPreprocessor::GetPassingPoint(const VssRay ¤tRay,336 /*Vector3 GvsPreprocessor::GetPassingPoint(const VssRay ¤tRay, 320 337 const Triangle3 &hitTriangle, 321 338 const VssRay &oldRay) const … … 333 350 334 351 return newPoint; 352 }*/ 353 354 355 Vector3 GvsPreprocessor::GetPassingPoint(const VssRay ¤tRay, 356 const Triangle3 &occluder, 357 const VssRay &oldRay) const 358 { 359 //-- The plane p = (xp, hit(x), hit(xold)) is intersected 360 //-- with the newly found occluder (xold is the previous ray from 361 //-- which x was generated). On the intersecting line, we select a point 362 //-- pnew which lies just outside of the new triangle so the ray 363 //-- just passes through the gap 364 365 const Plane3 plane(currentRay.GetOrigin(), 366 currentRay.GetTermination(), 367 oldRay.GetTermination()); 368 369 Vector3 pt1, pt2; 370 371 const bool intersects = occluder.GetPlaneIntersection(plane, pt1, pt2); 372 373 cout << "triangle: " << occluder << " pt1: " << pt1 << " pt2: " << pt2 << endl; 374 if (!intersects) 375 cerr << "big error!! no intersection" << endl; 376 377 // get the intersection point on the old ray 378 const Plane3 triPlane(occluder.GetNormal(), occluder.mVertices[0]); 379 380 const float t = triPlane.FindT(oldRay.mOrigin, oldRay.mTermination); 381 const Vector3 pt3 = oldRay.mOrigin + t * (oldRay.mTermination - oldRay.mOrigin); 382 383 // Evaluate new hitpoint just outside the triangle 384 Vector3 newPoint; 385 386 const float eps = mEps; 387 // the point is chosen to be on the side closer to the original ray 388 if (Distance(pt1, pt3) < Distance(pt2, pt3)) 389 { 390 newPoint = pt1 + eps * (pt1 - pt2); 391 } 392 else 393 { 394 newPoint = pt2 + eps * (pt2 - pt1); 395 } 396 397 cout << "passing point: " << newPoint << endl << endl; 398 return newPoint; 335 399 } 336 400 … … 340 404 const VssRay &oldRay) 341 405 { 342 //-- The plane p = (xp, hit(x), hit(xold)) is intersected 343 //-- with the newly found triangle (xold is the previous ray from 344 //-- which x was generated). On the intersecting line, we select a point 345 //-- pnew which lies just outside of the new triangle so the ray 346 //-- just passes by inside the gap 347 const Vector3 newPoint = GetPassingPoint(currentRay, hitTriangle, oldRay); 406 // get triangle occluding the path to the hit mesh 407 Triangle3 occluder; 408 Intersectable *tObj = currentRay.mTerminationObject; 409 // q: why can this happen? 410 if (!tObj) 411 return NULL; 412 413 // other types not implemented yet 414 if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE) 415 occluder = dynamic_cast<TriangleIntersectable *>(tObj)->GetItem(); 416 else 417 cout << "not yet implemented" << endl; 418 419 // get a point which is passing just outside of the occluder 420 const Vector3 newPoint = GetPassingPoint(currentRay, occluder, oldRay); 348 421 const Vector3 predicted = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay); 349 422 350 423 //-- Construct the mutated ray with xnew, 351 424 //-- dir = predicted(x)- pnew as direction vector 352 const Vector3 newDir = predicted - newPoint 353 354 // take xnew, p = intersect(viewcell, line(pnew, predicted(x)) as origin ?425 const Vector3 newDir = predicted - newPoint; 426 427 // take xnew, p = intersect(viewcell, line(pnew, predicted(x)) as origin ? 355 428 // difficult to say!! 356 const Vector3 newOrigin = newDir * -5000.0f; 357 358 ++ mReverseSamples; 359 360 return new VssRay(currentRay); 429 const Vector3 newOrigin = newPoint + newDir * -5000.0f; 430 431 const SimpleRay simpleRay(newOrigin, newDir, SamplingStrategy::GVS, 1.0f); 432 433 VssRay *reverseRay = 434 mRayCaster->CastRay(simpleRay, mViewCellsManager->GetViewSpaceBox()); 435 436 ++ mReverseSamples; 437 438 return reverseRay; 361 439 } 362 440 … … 533 611 } 534 612 535 exporter->ExportRays(mVssRays); 613 VssRayContainer::const_iterator rit, rit_end = mVssRays.end(); 614 for (rit = mVssRays.begin(); rit != rit_end; ++ rit) 615 { 616 Intersectable *obj = (*rit)->mTerminationObject; 617 exporter->ExportIntersectable(obj); 618 } 619 620 VssRayContainer vcRays, vcRays2, vcRays3; 621 622 // prepare some rays for output 623 for (rit = mVssRays.begin(); rit != rit_end; ++ rit) 624 { 625 const float p = RandomValue(0.0f, (float)mVssRays.size()); 626 if (1)//(p < raysOut) 627 { 628 if ((*rit)->mFlags & VssRay::BorderSample) 629 { 630 vcRays.push_back(*rit); 631 } 632 else if ((*rit)->mFlags & VssRay::ReverseSample) 633 { 634 vcRays2.push_back(*rit); 635 } 636 else 637 { 638 vcRays3.push_back(*rit); 639 } 640 } 641 } 642 643 exporter->ExportRays(vcRays, RgbColor(1, 0, 0)); 644 exporter->ExportRays(vcRays2, RgbColor(0, 1, 0)); 645 exporter->ExportRays(vcRays3, RgbColor(1, 1, 1)); 646 647 //exporter->ExportRays(mVssRays); 536 648 delete exporter; 537 649 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1920 r1933 1069 1069 const ObjectContainer &objects) 1070 1070 { 1071 SubdivisionCandidate *firstCandidate;1072 1073 1071 // object space partition constructed => reconstruct 1074 1072 switch (mObjectSpaceSubdivisionType) … … 2146 2144 char str[100]; 2147 2145 char statsPrefix[100]; 2148 int histoStepSize;2146 //int histoStepSize; 2149 2147 2150 2148 Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); … … 2213 2211 bool isLeaf; 2214 2212 int timeStamp; 2215 float rcDecr;2216 int entriesIncr;2213 //float rcDecr; 2214 //int entriesIncr; 2217 2215 2218 2216 if (nextCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp
r1932 r1933 186 186 187 187 188 bool Triangle3:: IntersectPlane(const Plane3 &plane,189 190 188 bool Triangle3::GetPlaneIntersection(const Plane3 &plane, 189 Vector3 &intersectA, 190 Vector3 &intersectB) const 191 191 { 192 192 int side[3]; … … 215 215 intersectA = mVertices[i]; 216 216 intersectB = mVertices[(i + 1) % 3]; 217 217 218 218 return true; 219 219 } … … 228 228 229 229 // intersection found 230 if ((side[i] >= 0) && (side[i_2] <= 0)) 230 if ((side[i] >= 0) && (side[i_2] <= 0) || 231 (side[i] <= 0) && (side[i_2] >= 0)) 231 232 { 232 233 const float t = plane.FindT(mVertices[i], mVertices[i_2]); … … 235 236 { 236 237 intersectA = mVertices[i] + t * (mVertices[i_2] - mVertices[i]); 238 237 239 foundA = true; 238 240 } … … 240 242 { 241 243 intersectB = mVertices[i] + t * (mVertices[i_2] - mVertices[i]); 244 242 245 return true; 243 246 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.h
r1932 r1933 44 44 @returns true if triangle intersects plane 45 45 */ 46 bool IntersectPlane(const Plane3 &plane, Vector3 &intersectA, Vector3 &intersectB) const; 46 bool GetPlaneIntersection(const Plane3 &plane, 47 Vector3 &intersectA, 48 Vector3 &intersectB) const; 47 49 48 50 /////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1926 r1933 343 343 { 344 344 cout << "executing main thread" << endl; 345 346 345 // just call the mail method -> will be executed in the main thread 347 346 pt->Main();
Note: See TracChangeset
for help on using the changeset viewer.