Changeset 1221 for GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
- Timestamp:
- 08/18/06 19:28:12 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1145 r1221 13 13 #include "Beam.h" 14 14 #include "GlRenderer.h" 15 #include "ViewCellBsp.h" 15 #include "ArchModeler2MLRT.hxx" 16 #include "Intersectable.h" 17 16 18 17 19 namespace GtpVisibilityPreprocessor { … … 76 78 ) 77 79 { 78 for (int i=0; i < rays.size(); i++) 79 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays); 80 AxisAlignedBox3 &box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 81 82 #if 1 83 for (int i=0; i < rays.size(); i++) 84 { 85 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays, box); 86 } 87 #else 88 for (int i = 0; i < rays.size(); i += 16) 89 { 90 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays, box); 91 } 92 93 #endif 94 } 95 96 97 void VssPreprocessor::CastRays16(SimpleRayContainer &rays, 98 VssRayContainer &vssRays, 99 const AxisAlignedBox3 &sbox) 100 { 101 /* 102 mlrtaStoreRayAS16(const float* pforg, const float* pfdir, int j); 103 104 105 // input parameters 106 const RTVec3f& org = *reinterpret_cast<const RTVec3f*> (pforg); 107 const RTVec3f& rd = *reinterpret_cast<const RTVec3f*> (pfdir); 108 109 int ri = j/4; 110 int ci = j%4; 111 *((float*)&ibp4.ray4X[ri].m_origin.t[0] + ci) = org[0]; 112 *((float*)&ibp4.ray4X[ri].m_origin.t[1] + ci) = org[1]; 113 *((float*)&ibp4.ray4X[ri].m_origin.t[2] + ci) = org[2]; 114 115 *((float*)&ibp4.ray4X[ri].m_direction.t[0] + ci) = rd[0]; 116 *((float*)&ibp4.ray4X[ri].m_direction.t[1] + ci) = rd[1]; 117 *((float*)&ibp4.ray4X[ri].m_direction.t[2] + ci) = rd[2]; 118 119 mlrtaTraverseGroupAS16(const float* bbmin, const float* bbmax, int* hit_triangles, float* dist);*/ 120 } 121 122 123 int VssPreprocessor::CastIntelDoubleRay( 124 const Vector3 &viewPoint, 125 const Vector3 &direction, 126 VssRayContainer &vssRays, 127 const AxisAlignedBox3 &box) 128 { 129 VssRay *vssRay = NULL; 130 int hits = 0; 131 132 Vector3 pointA, pointB; 133 134 Intersectable *objectA = 135 CastIntelSingleRay(viewPoint, direction, pointA, box); 136 137 // cast ray into other direction 138 Intersectable *objectB = 139 CastIntelSingleRay(viewPoint, -direction, pointB, box); 140 141 const bool validSample = (objectA != objectB); 142 143 if (validSample) 144 { 145 if (objectA) 146 { 147 vssRay = new VssRay(pointB, 148 pointA, 149 objectB, 150 objectA, 151 mPass); 152 vssRays.push_back(vssRay); 153 hits ++; 154 } 155 156 if (objectB) 157 { 158 vssRay = new VssRay(pointA, 159 pointB, 160 objectA, 161 objectB, 162 mPass); 163 vssRays.push_back(vssRay); 164 hits ++; 165 } 166 //Debug << "intel ray: " << *vssRay << endl; 167 } 168 //cout << "a"; 169 return hits; 170 } 171 172 173 Intersectable *VssPreprocessor::CastIntelSingleRay(const Vector3 &viewPoint, 174 const Vector3 &direction, 175 Vector3 &tPoint, 176 const AxisAlignedBox3 &box 177 ) 178 { 179 AxisAlignedBox3 sbox = box; 180 sbox.Enlarge(Vector3(-Limits::Small)); 181 182 if (!sbox.IsInside(viewPoint)) 183 return 0; 184 185 float pforg[3]; 186 float pfdir[3]; 187 double pfnorm[3]; 188 189 pforg[0] = viewPoint[0]; pforg[1] = viewPoint[1]; pforg[2] = viewPoint[2]; 190 pfdir[0] = direction[0]; pfdir[1] = direction[1]; pfdir[2] = direction[2]; 191 192 float dist = 0; 193 const int hittriangle = mlrtaIntersectAS(pforg, pfdir, pfnorm, dist); 194 195 if (hittriangle == -1) 196 { 197 static Ray ray; 198 SetupRay(ray, viewPoint, direction); 199 200 float tmin = 0, tmax; 201 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 202 { 203 tPoint = ray.Extrap(tmax); 204 } 205 206 return NULL; 207 } 208 else 209 { 210 tPoint[0] = pforg[0] + pfdir[0] * dist; 211 tPoint[1] = pforg[1] + pfdir[1] * dist; 212 tPoint[2] = pforg[2] + pfdir[2] * dist; 213 214 return mFaceParents[hittriangle]; 215 } 80 216 } 81 217 82 218 83 219 int 84 VssPreprocessor::Cast Ray(85 Vector3 &viewPoint,86 Vector3 &direction,87 VssRayContainer &vssRays88 )89 { 90 220 VssPreprocessor::CastInternalRay( 221 const Vector3 &viewPoint, 222 const Vector3 &direction, 223 VssRayContainer &vssRays, 224 const AxisAlignedBox3 &box 225 ) 226 { 91 227 int hits = 0; 92 228 static Ray ray; 93 94 AxisAlignedBox3 box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 229 95 230 AxisAlignedBox3 sbox = box; 96 97 231 sbox.Enlarge(Vector3(-Limits::Small)); 98 232 99 233 if (!sbox.IsInside(viewPoint)) 100 234 return 0; … … 109 243 110 244 //float bsize = Magnitude(box.Size()); 111 112 245 if (!mDetectEmptyViewSpace) 113 246 ray.mFlags &= ~Ray::CULL_BACKFACES; … … 132 265 133 266 // matt: point A could be undefined? 267 268 // cast ray into opposite direction 134 269 if (1 && mDetectEmptyViewSpace) { 135 270 SetupRay(ray, pointA, -direction); … … 215 350 hits ++; 216 351 } 217 } 218 352 //Debug << "internal ray: " << *vssRay << endl << endl; 353 } 354 //cout << "b"; 219 355 return hits; 356 } 357 358 359 int 360 VssPreprocessor::CastRay( 361 const Vector3 &viewPoint, 362 const Vector3 &direction, 363 VssRayContainer &vssRays, 364 const AxisAlignedBox3 &box 365 ) 366 { 367 switch (mRayCastMethod) 368 { 369 case INTEL_RAYCASTER: 370 return CastIntelDoubleRay(viewPoint, direction, vssRays, box); 371 case INTERNAL_RAYCASTER: 372 default: 373 return CastInternalRay(viewPoint, direction, vssRays, box); 374 } 220 375 } 221 376 … … 565 720 box.SetMax(1, box.Min(1)); 566 721 567 cout << "use view space box=" << mUseViewSpaceBox <<endl;722 cout << "use view space box=" << mUseViewSpaceBox << endl; 568 723 569 724 570 725 if (mUseViewSpaceBox) 571 726 { 727 //mViewSpaceBox = ConstructViewSpaceBox(); 728 572 729 if (!mEnlargeViewSpace) 573 730 { … … 671 828 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 672 829 673 sampleContributions = CastRay(viewpoint, direction, mVssRays );830 sampleContributions = CastRay(viewpoint, direction, mVssRays, vbox); 674 831 675 832 if (sampleContributions) { … … 802 959 803 960 for (int i=0; i < rays.size(); i++) 804 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays );961 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays, vbox); 805 962 806 963 vssTree->AddRays(vssRays); … … 842 999 } 843 1000 844 if (0) 845 Debug << vssTree->stat << endl; 1001 if (0) Debug << vssTree->stat << endl; 846 1002 847 1003 if (0) 848 1004 { 849 1005 VssRayContainer viewCellRays; 850 851 // compute rays used for view cells construction 1006 // compute rays used for view cells construction 852 1007 const int numRays = mViewCellsManager->GetVisualizationSamples(); 853 854 1008 vssTree->CollectRays(viewCellRays, numRays); 855 1009 }
Note: See TracChangeset
for help on using the changeset viewer.