Changeset 1420 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 09/20/06 13:37:29 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1419 r1420 152 152 } 153 153 154 // reset to filled 154 155 SetFilled(); 155 156 … … 266 267 { 267 268 case Intersectable::TRIANGLE_INTERSECTABLE: 268 { 269 {cout << "y"; 269 270 TriangleIntersectable *ti = dynamic_cast<TriangleIntersectable *>(obj); 270 271 polys.push_back(new Polygon3(ti->GetItem())); … … 272 273 } 273 274 case Intersectable::MESH_INSTANCE: 274 { 275 {cout << "x"; 275 276 MeshInstance *mi = dynamic_cast<MeshInstance *>(obj); 276 277 ExportMesh(mi->GetMesh()); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1418 r1420 283 283 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 284 284 285 cout << "here5 " << GetViewSpaceBox() << endl; 286 cout << "here6 " << GetObjectSpaceBox() << endl; 285 #if _DEBUG 286 cout << "view space: " << GetViewSpaceBox() << endl; 287 cout << "object space: " << GetObjectSpaceBox() << endl; 288 #endif 289 287 290 mHierarchyStats.Stop(); 288 291 mVspTree->mVspStats.Stop(); -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1419 r1420 521 521 522 522 523 static void PrintFace(const Mesh *mesh, const int idx, ostream &app) 524 { 525 Face *face = mesh->mFaces[idx]; 526 527 VertexIndexContainer::iterator it, it_end = face->mVertexIndices.end(); 528 529 cout << "face " << idx << endl; 530 for (it = face->mVertexIndices.begin(); it != it_end; ++ it) 531 { 532 cout << (*it) << ": " << mesh->mVertices[*it] << " "; 533 } 534 cout << endl; 535 } 536 537 523 538 void Mesh::Print(ostream &app) const 524 539 { … … 531 546 app << endl; 532 547 533 /*FaceContainer::const_iterator fit, fit_end = mVertices.end(); 534 535 for (vit = mVertices.begin(); vit != vit_end; ++ vit) 548 for (int i = 0; i < (int)mFaces.size(); ++ i) 536 549 { 537 app << (*vit); 538 } 539 app << endl;*/ 550 PrintFace(this, i, app); 551 } 540 552 } 541 553 -
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
r1419 r1420 43 43 { 44 44 mVertices.reserve(face->mVertexIndices.size()); 45 46 45 VertexIndexContainer::iterator it, it_end = face->mVertexIndices.end(); 47 46 48 for (it = face->mVertexIndices.begin(); it != it_end; 47 for (it = face->mVertexIndices.begin(); it != it_end; ++ it) 49 48 { 50 49 mVertices.push_back(parentMesh->mVertices[*it]); … … 69 68 VertexContainer::iterator it, it_end = mVertices.end(); 70 69 71 for (it = mVertices.begin(); it != it_end; ++ it) 72 { 73 cout << (*it) << " "; 74 }cout<<endl<<endl; 70 //for (it = mVertices.begin(); it != it_end; ++ it){cout << (*it) << " ";}cout<<endl<<endl; 75 71 //cout << "poly n: " << GetNormal() << " t normal: " << tri.GetNormal() << endl; 76 72 } … … 267 263 } 268 264 265 269 266 bool Polygon3::Valid(const float epsilon) const 270 267 { … … 272 269 return false; 273 270 274 // TODO: remove for performance275 #if 0276 if ( 1)271 // matt: removed for performance issues 272 #if _DEBUG 273 if (0) 277 274 { 278 275 // check if area exceeds certain size … … 291 288 for (it = mVertices.begin(); it != it_end; ++it) 292 289 { 293 if (EpsilonEqualV3(vtx, *it, 0.0001))290 if (EpsilonEqualV3(vtx, *it, epsilon)) 294 291 { 295 // Debug<< "Malformed vertices:\n" << *this << endl;292 //cout << "Malformed vertices:\n" << *this << endl; 296 293 return false; 297 294 } … … 590 587 const int n = (int)mesh.mVertices.size(); 591 588 589 592 590 ///////////// 593 591 //-- add the vertices to the mesh … … 609 607 poly.Triangulate(indices); 610 608 609 //if (indices.size() < 3) return; // something is wrong 610 611 611 // add indices of triangle strip 612 for (int i = n; i < (int)indices.size() + n; i += 3)613 { 614 Face *face = new Face(indices[i] ,615 indices[i + 1] ,616 indices[i + 2] );612 for (int i = 0; i < (int)indices.size(); i += 3) 613 { 614 Face *face = new Face(indices[i] + n, 615 indices[i + 1] + n, 616 indices[i + 2] + n); 617 617 mesh.AddFace(face); 618 618 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h
r1404 r1420 174 174 //s << setprecision(6) << "Polygon:\n"; 175 175 for (it = A.mVertices.begin(); it != A.mVertices.end(); ++it) 176 s << *it << endl;176 s << *it << " "; 177 177 178 178 return s; -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp
r1344 r1420 31 31 int Triangle3::CastRay(const Ray &ray, float &t, const float nearestT, Vector3 &normal) const 32 32 { 33 /*VertexContainer vertices; 33 #if 0 34 VertexContainer vertices; 34 35 vertices.push_back(mVertices[0]); 35 36 vertices.push_back(mVertices[1]); … … 40 41 int dummy = poly.CastRay(ray, t, nearestT); 41 42 42 cout << "polyversion code: " << dummy << " t: " << t << " nearestT: " << nearestT << endl; 43 return dummy;*/ 44 ///////////////////////////////////////////// 45 // specialised ray casting version 43 cout << "polyversion code: " << dummy << " t: " << t << " nearestT: " << nearestT << endl; 44 return dummy; 45 #endif 46 47 ////////////// 48 // specialised triangle ray casting version 46 49 50 /////////// 47 51 //-- calc ray-plane intersection 48 52 … … 51 55 const Vector3 v = mVertices[2] - mVertices[1]; 52 56 53 normal = Normalize(CrossProd(v, u)); // cross product 57 // cross product 58 normal = Normalize(CrossProd(v, u)); 54 59 55 const Vector3 dir = ray.GetDir(); // ray direction vector 60 // ray direction vector 61 const Vector3 dir = ray.GetDir(); 56 62 const Vector3 w0 = ray.GetLoc() - mVertices[1]; 57 63 … … 64 70 { 65 71 // ray is parallel to triangle plane 66 if (a == 0) // ray lies in triangle plane72 if (a == 0) 67 73 { 74 // ray lies in triangle plane 68 75 return Ray::INTERSECTION_OUT_OF_LIMITS; 69 76 } 70 77 else 71 78 { 72 return Ray::NO_INTERSECTION; // ray disjoint from plane 79 // ray disjoint from plane 80 return Ray::NO_INTERSECTION; 73 81 } 74 82 } … … 87 95 } 88 96 89 ///////////////// //////////////////////////////97 ///////////////// 90 98 //-- found intersection point 91 99 //-- check if it is inside triangle 92 100 93 101 const Vector3 pt = ray.GetLoc() + t * dir; 102 103 if (!pt.CheckValidity()) 104 { 105 cout << "tr: " << *this << endl; 106 cout << "v: " << pt << " t: " << t << " a: " << a << " b: " << b << " n: " << normal << endl; 107 } 94 108 95 109 const Vector3 w = pt - mVertices[1]; … … 157 171 158 172 173 bool Triangle3::CheckValidity() const 174 { 175 return !( 176 EpsilonEqualV3(mVertices[0], mVertices[1]) || 177 EpsilonEqualV3(mVertices[0], mVertices[2]) || 178 EpsilonEqualV3(mVertices[1], mVertices[2]) 179 ); 159 180 } 181 182 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.h
r1344 r1420 35 35 friend istream& operator>> (istream &s, Triangle3 &A); 36 36 37 /** Checks if this triangle is ill-defined. 38 */ 39 bool CheckValidity() const; 37 40 38 41 ////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.cpp
r863 r1420 2 2 #include "Vector3.h" 3 3 #include "Halton.h" 4 #include "float.h" 5 4 6 5 7 namespace GtpVisibilityPreprocessor { … … 253 255 } 254 256 255 } 257 258 bool Vector3::CheckValidity() const 259 { 260 return !(_isnan(x) || _isnan(y) || _isnan(z)); 261 //return ((x != x) || (y != y) || (z != z)); 262 } 263 264 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.h
r1328 r1420 98 98 inline void Normalize(); 99 99 100 /** Returns false if this vector has a nan component. 101 */ 102 bool CheckValidity() const; 103 100 104 /** 101 105 ===> Using ArbitraryNormal() for constructing coord systems -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1419 r1420 5097 5097 exporter->ExportBox(bbox); 5098 5098 exporter->SetFilled(); 5099 5100 5099 5101 5100 if (0 && mExportGeometry) … … 5112 5111 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, &bbox, false); 5113 5112 ExportViewCellsForViz(exporter, &bbox, GetClipPlane()); 5113 5114 5114 delete exporter; 5115 5115 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
r1419 r1420 125 125 const Vector3 a = (*ri)->GetOrigin(); 126 126 const Vector3 b = (*ri)->mTerminationObject ? (*ri)->GetTermination() : a + 1000 * Normalize((*ri)->GetDir()); 127 127 128 #if _DEBUG 128 129 bool isnan = false; 129 130 if ((a[0] != a[0]) || (a[1] != a[1]) || (a[2] != a[2])) 130 if (!a.CheckValidity()) 131 131 { 132 132 cout << "error a"<<endl; … … 134 134 } 135 135 136 if ((b[0] != b[0]) || (b[1] != b[1]) || (b[2] != b[2]))136 if (!b.CheckValidity()) 137 137 { 138 138 cout << "error b"<<endl; 139 139 isnan = true; 140 140 } 141 142 if (!isnan) 143 { 144 stream << a.x << " " << a.y << " " << a.z << " ,"; 145 stream << b.x << " " << b.y << " " << b.z << " ,\n"; 146 } 141 if (isnan) 142 continue; 143 #endif 144 stream << a.x << " " << a.y << " " << a.z << " ,"; 145 stream << b.x << " " << b.y << " " << b.z << " ,\n"; 147 146 } 148 147 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1419 r1420 231 231 if (!mLoadMeshes) 232 232 { 233 /////////////////// /////////////////233 /////////////////// 234 234 //-- load data as single triangles instead of whole meshes 235 235 … … 249 249 Polygon3 poly(face, &tempMesh); 250 250 poly.Triangulate(triangles); 251 251 252 252 vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 253 253 254 254 for (tit = triangles.begin(); tit != tit_end; ++ tit) 255 255 { 256 TriangleIntersectable *ti = new TriangleIntersectable(*tit); 257 cout << "t: " << (*tit) << endl; 258 mCurrentNode->mGeometry.push_back(ti); 256 if ((*tit).CheckValidity()) 257 { 258 TriangleIntersectable *ti = new TriangleIntersectable(*tit); 259 //cout << "t: " << (*tit) << endl; 260 mCurrentNode->mGeometry.push_back(ti); 261 } 262 else 263 { 264 cout << "error tri:\n" << (*tit) << endl; 265 } 259 266 } 260 267 #if 0 … … 262 269 Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 263 270 264 VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end(); 265 266 int i = 0; 271 267 272 // dummy vertex indices container 268 273 VertexIndexContainer vcIndices; 274 VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end(); 275 int i = 0; 269 276 270 277 for (vit = face->mVertexIndices.begin(); vit != vit_end; ++ vit, ++ i)
Note: See TracChangeset
for help on using the changeset viewer.