Changeset 1492 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 09/26/06 12:42:41 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1489 r1492 32 32 const VssRay &oldRay) const 33 33 { 34 //|predicted(x)-xp|-|hit(x)-xp| > ?, 34 35 //const Plane3 plane = tri->GetPlane(); 35 36 return false; … … 57 58 new sample points around a triangle in a eps environment 58 59 */ 59 static void CreateNew Samples(VertexContainer &samples,60 61 62 63 60 static void CreateNewRays(SimpleRayContainer &simpleRays, 61 const Triangle3 &hitTriangle, 62 const VssRay &ray, 63 const int index, 64 const float eps) 64 65 { 65 66 const int indexU = (index + 1) % 3; … … 69 70 const Vector3 b = hitTriangle.mVertices[indexU] - hitTriangle.mVertices[index]; 70 71 const Vector3 c = hitTriangle.mVertices[index] - hitTriangle.mVertices[indexL]; 72 71 73 const float len = Magnitude(a); 74 75 const Vector3 dir1 = CrossProd(a, b); //N((pi-xp)×(pi+1- pi)); 76 const Vector3 dir2 = CrossProd(a, c); // N((pi-xp)×(pi- pi-1)) 77 const Vector3 dir3 = DotProd(dir1, dir2) > 0 ? 78 Normalize(dir2 + dir1) : Normalize(CrossProd(a, dir2) + CrossProd(dir1, a)); // N((pi-xp)×di,i-1+di,i+1×(pi-xp)) 72 79 73 80 // compute the new three hit points 74 81 // pi, i + 1 75 const Vector3 dir1 = CrossProd(a, b); //N((pi-xp)×(pi+1- pi));76 82 const Vector3 pt1 = hitTriangle.mVertices[index] + eps * len * dir1; //pi+ e·|pi-xp|·di, j 77 samples.push_back(pt1);78 79 83 // pi, i - 1 80 const Vector3 dir2 = CrossProd(a, c); // N((pi-xp)×(pi- pi-1)) 81 const Vector3 pt2 = hitTriangle.mVertices[index] + eps * len * dir2; //pi+ e·|pi-xp|·di, j 82 samples.push_back(pt2); 83 84 const Vector3 pt2 = hitTriangle.mVertices[index] + eps * len * dir2; //pi+ e·|pi-xp|·di, j 84 85 // pi, i 85 const Vector3 dir3 = DotProd(dir1, dir2) > 0 ?86 Normalize(dir2 + dir1) : Normalize(CrossProd(a, dir2) + CrossProd(dir1, a)); // N((pi-xp)×di,i-1+di,i+1×(pi-xp))87 86 const Vector3 pt3 = hitTriangle.mVertices[index] + eps * len * dir3; //pi+ e·|pi-xp|·di, j 88 samples.push_back(pt3); 89 } 90 91 92 /** Generate rays from sample points. 93 */ 94 static void CreateRays(VssRayContainer &rays, 95 const VertexContainer &samples) 96 { 97 VertexContainer::const_iterator vit, vit_end = samples.end(); 98 99 for (vit = samples.begin(); vit != vit_end; ++ vit) 100 { 101 const Vector3 currentSample = *vit; 102 VssRay *ray;// = new VssRay(ray->mOrigin, currentSample); 103 } 104 } 87 88 /// create simple rays and store them in container 89 Vector3 rayDir; 90 rayDir = Normalize(pt1 - ray.GetOrigin()); 91 simpleRays.push_back(SimpleRay(rayDir, ray.GetOrigin())); 92 rayDir = Normalize(pt2 - ray.GetOrigin()); 93 simpleRays.push_back(SimpleRay(rayDir, ray.GetOrigin())); 94 rayDir = Normalize(pt3 - ray.GetOrigin()); 95 simpleRays.push_back(SimpleRay(rayDir, ray.GetOrigin())); 96 } 97 105 98 106 99 … … 117 110 } 118 111 119 VertexContainer samples;120 s amples.reserve(9);121 122 CreateNew Samples(samples, hitTriangle, prevRay, 0, mEps);123 CreateNew Samples(samples, hitTriangle, prevRay, 1, mEps);124 CreateNew Samples(samples, hitTriangle, prevRay, 2, mEps);112 SimpleRayContainer simpleRays; 113 simpleRays.reserve(9); 114 115 CreateNewRays(simpleRays, hitTriangle, prevRay, 0, mEps); 116 CreateNewRays(simpleRays, hitTriangle, prevRay, 1, mEps); 117 CreateNewRays(simpleRays, hitTriangle, prevRay, 2, mEps); 125 118 126 119 VssRayContainer vssRays; 127 CreateRays(vssRays, samples); 128 129 VssRayContainer::const_iterator rit, rit_end = vssRays.end(); 130 131 for (rit = vssRays.begin(); rit != rit_end; ++ rit) 132 { 133 VssRay *ray = *rit; 134 135 // discontinuity found? 136 // schedule for reverse sampling or adaptive border sampling 137 const bool gap = DiscontinuityFound(*ray, prevRay); 138 mRayQueue.push(GvsRayInfo(ray, gap)); 139 } 140 141 return 9; 142 } 143 144 145 int GvsPreprocessor::ReverseSampling(const VssRay &ray) 120 121 CastRays(simpleRays, vssRays); 122 // add to ray queue 123 EnqueueRays(vssRays); 124 125 return (int)vssRays.size(); 126 } 127 128 129 int GvsPreprocessor::ReverseSampling(const VssRay &oldRay) 146 130 { 147 131 cout << "r" << endl; … … 165 149 166 150 // add to ray queue 167 Enqueue Samples(samples);151 EnqueueRays(samples); 168 152 169 153 Debug << "generated " << numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 173 157 174 158 175 void GvsPreprocessor::Enqueue Samples(VssRayContainer &samples, VssRay *oldRay)159 void GvsPreprocessor::EnqueueRays(VssRayContainer &samples, VssRay *oldRay) 176 160 { 177 161 // add samples to ray queue … … 183 167 mRayQueue.push(GvsRayInfo(*vit, gap)); 184 168 } 185 186 169 } 187 170 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1489 r1492 40 40 }; 41 41 42 typedef stack<GvsRayInfo> RayQueue; 42 43 43 typedef stack<GvsRayInfo> RayQueue; 44 struct PendingRay 45 { 46 PendingRay(VssRay *ray, const bool d) 47 : mRay(ray), mFoundDiscontinuity(d) 48 {} 49 50 VssRay *mRay; 51 bool mFoundDiscontinuity; 52 }; 53 54 typedef stack<PendingRay> PendingQueue; 44 55 45 56 /** Runs the adaptive sampling until the ray queue is empty. … … 92 103 with respect to the previous ray. 93 104 */ 94 void Enqueue Samples(VssRayContainer &samples, VssRay *prevRay = NULL);105 void EnqueueRays(VssRayContainer &samples, VssRay *prevRay = NULL); 95 106 96 107 ////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1486 r1492 127 127 exit(1); 128 128 } 129 130 129 131 130 string externKdTree = ReplaceSuffix(filename, ".obj", ".kdf");
Note: See TracChangeset
for help on using the changeset viewer.