Changeset 1344 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 09/12/06 17:39:08 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 2 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1323 r1344 1085 1085 { 1086 1086 VssRay::NewMail(); 1087 1088 1087 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1089 1088 … … 1093 1092 { 1094 1093 Intersectable *obj = *oit; 1095 1096 1094 VssRayContainer::const_iterator rit, rit_end = obj->mVssRays.end(); 1097 1095 -
GTP/trunk/Lib/Vis/Preprocessing/src/Containers.h
r1184 r1344 18 18 class Mesh; 19 19 class KdLeaf; 20 class Vector3; 20 21 21 22 struct IndexedBoundingBox; … … 32 33 33 34 /** Container for Mesh pointers primarily for the use within the kDTree and 34 BSP hierarchies */ 35 BSP hierarchies 36 */ 35 37 typedef vector<Intersectable *> ObjectContainer; 36 38 37 39 /** Container for ViewCell pointers primarily for the use within the kDTree and 38 BSP hierarchies */39 40 BSP hierarchies 41 */ 40 42 typedef vector<ViewCell *> ViewCellContainer; 41 43 42 44 /** Container for HierarchyNodes pointers primarily for the use within the kDTree and 43 45 BSP hierarchies 44 46 */ 45 47 typedef vector<HierarchyNode *> NodeContainer; 46 48 … … 57 59 58 60 /** Container for ViewCell pointers primarily for the use within the kDTree and 59 BSP hierarchies */60 61 BSP hierarchies 62 */ 61 63 typedef vector<KdLeaf *> KdLeafContainer; 62 64 65 typedef std::map<int, Intersectable *> ObjectMap; 63 66 64 typedef std::map<int, Intersectable *> ObjectMap; 67 /// default vertex container for Mesh 68 typedef std::vector<Vector3> VertexContainer; 69 70 /// vertex index container 71 //typedef std::vector<short> VertexIndexContainer; 72 typedef std::vector<int> VertexIndexContainer; 65 73 66 74 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1315 r1344 5 5 #include "IntersectableWrapper.h" 6 6 #include "BvHierarchy.h" 7 #include "Triangle3.h" 8 #include "Polygon3.h" 7 9 8 10 … … 152 154 153 155 154 } 156 void Exporter::ExportIntersectable(Intersectable *object) 157 { 158 switch (object->Type()) 159 { 160 case Intersectable::MESH_INSTANCE: 161 ExportMeshInstance((MeshInstance *)object); 162 break; 163 case Intersectable::TRANSFORMED_MESH_INSTANCE: 164 ExportTransformedMeshInstance(dynamic_cast<TransformedMeshInstance *>(object)); 165 break; 166 case Intersectable::VIEW_CELL: 167 ExportViewCell(dynamic_cast<ViewCell *>(object)); 168 break; 169 case Intersectable::KD_INTERSECTABLE: 170 ExportKdIntersectable(*(dynamic_cast<KdIntersectable *>(object))); 171 break; 172 case Intersectable::TRIANGLE_INTERSECTABLE: 173 { 174 const Triangle3 triangle = dynamic_cast<TriangleIntersectable *>(object)->GetItem(); 175 176 VertexContainer vertices; 177 vertices.push_back(triangle.mVertices[0]); 178 vertices.push_back(triangle.mVertices[1]); 179 vertices.push_back(triangle.mVertices[2]); 180 181 Polygon3 poly(vertices); 182 ExportPolygon(&poly); 183 break; 184 } 185 default: 186 cerr << "Sorry the export for object type " << Intersectable::GetTypeName(object) << " is not available yet" << endl; 187 break; 188 } 189 } 190 191 void Exporter::ExportMeshInstance(MeshInstance *object) 192 { 193 // $$JB$$ 194 // in the future check whether the mesh was not already exported 195 // and use a reference to the that mesh instead 196 ExportMesh(object->GetMesh()); 197 } 198 199 200 void Exporter::ExportTransformedMeshInstance(TransformedMeshInstance *mi) 201 { 202 Mesh mesh(*mi->GetMesh()); 203 204 Matrix4x4 m; 205 mi->GetWorldTransform(m); 206 mesh.ApplyTransformation(m); 207 208 ExportMesh(&mesh); 209 } 210 211 212 void Exporter::ExportViewCells(const ViewCellContainer &viewCells) 213 { 214 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 215 216 for (it = viewCells.begin(); it != it_end; ++ it) 217 { 218 ExportViewCell(*it); 219 } 220 } 221 222 223 224 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
r1287 r1344 30 30 class KdIntersectable; 31 31 class BvHierarchy; 32 class TransformedMeshInstance; 33 32 34 33 35 class Exporter … … 95 97 96 98 virtual void 97 ExportViewCells(const ViewCellContainer &viewCells) = 0; 99 ExportViewCells(const ViewCellContainer &viewCells); 100 98 101 virtual void 99 102 ExportViewCell(ViewCell *viewCell) = 0; 103 100 104 virtual void 101 ExportIntersectable(Intersectable *object) = 0;105 ExportIntersectable(Intersectable *object); 102 106 103 107 virtual void … … 150 154 void ExportKdIntersectable(const KdIntersectable &kdObj); 151 155 bool ExportBvHierarchy(const BvHierarchy &bvHierarchy, const int maxPvs); 156 157 virtual void ExportMeshInstance(MeshInstance *mi); 158 159 virtual void 160 ExportTransformedMeshInstance(TransformedMeshInstance *mi); 161 162 virtual void ExportPolygon(Polygon3 *poly) = 0; 152 163 }; 153 164 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1329 r1344 450 450 return mOspTree && mOspTree->GetRoot(); 451 451 case BV_BASED_OBJ_SUBDIV: 452 return mBvHierarchy && m OspTree->GetRoot();452 return mBvHierarchy && mBvHierarchy->GetRoot(); 453 453 default: 454 454 return false; -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1328 r1344 16 16 struct Face; 17 17 18 18 19 struct FaceParentInfo { 19 // intersectable 20 Intersectable *mObject; 21 // face index 22 int mFaceIndex; 23 24 FaceParentInfo(Intersectable *obj, 25 const int fi): 26 mObject(obj), 27 mFaceIndex(fi) 28 {} 20 /// intersectable 21 Intersectable *mObject; 22 /// face index 23 int mFaceIndex; 24 25 FaceParentInfo(Intersectable *obj, const int fi): 26 mObject(obj), mFaceIndex(fi) 27 {} 29 28 }; 29 30 30 31 31 class Intersectable { … … 147 147 } 148 148 } 149 150 /** returns normal from the face with the specified index. 151 PROBLEM: Does not fit to all intersectable types (e.g., spheres) 152 */ 153 virtual Vector3 GetNormal(const int idx) const { return Vector3(0, 0, 0); } 149 154 }; 150 155 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp
r1328 r1344 9 9 AxisAlignedBox3 TriangleIntersectable::GetBox() const 10 10 { 11 return mItem ->GetBoundingBox();11 return mItem.GetBoundingBox(); 12 12 } 13 13 14 14 15 15 int TriangleIntersectable::CastRay(Ray &ray) 16 { // TODO matt 16 { 17 float nearestT = MAX_FLOAT; 18 float t; 19 Vector3 nearestNormal; 20 21 if (ray.GetType() == Ray::LOCAL_RAY && !ray.intersections.empty()) 22 nearestT = ray.intersections[0].mT; 23 24 const int hitCode = mItem.CastRay(ray, t, nearestT, nearestNormal); 25 26 nearestT = t; 27 28 if ((hitCode == Ray::INTERSECTION) && (ray.GetType() == Ray::LOCAL_RAY)) 29 { 30 if (!ray.intersections.empty()) 31 { 32 ray.intersections[0] = Ray::Intersection(nearestT, nearestNormal, this, 0); 33 } 34 else 35 { 36 ray.intersections.push_back(Ray::Intersection(nearestT, nearestNormal, this, 0)); 37 } 38 39 return 1; 40 } 41 17 42 return 0; 18 43 } … … 23 48 return 1; 24 49 } 25 26 50 51 52 Vector3 TriangleIntersectable::GetNormal(const int idx) const 53 { 54 return mItem.GetNormal(); 27 55 } 56 57 58 } -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
r1328 r1344 4 4 #include "AxisAlignedBox3.h" 5 5 #include "Intersectable.h" 6 #include "Triangle3.h" 6 7 7 8 8 9 namespace GtpVisibilityPreprocessor { 10 9 11 10 12 struct VssRayContainer; … … 24 26 { 25 27 public: 26 IntersectableWrapper(T *item);28 IntersectableWrapper(T item); 27 29 28 30 /** Returns node associated with this instance. 29 31 */ 30 T *GetItem() const;32 T GetItem() const; 31 33 32 34 /** See get. 33 35 */ 34 void SetItem(T *item);36 void SetItem(T item); 35 37 38 39 ///////////////////////////////////////////// 36 40 //-- inherited functions from Intersectable 37 41 … … 45 49 46 50 int NumberOfFaces() const; 47 //int Type() const; 48 51 49 52 int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point, 50 53 GtpVisibilityPreprocessor::Vector3 &normal); … … 60 63 protected: 61 64 62 T *mItem;65 T mItem; 63 66 }; 64 67 65 68 66 69 template<typename T> 67 IntersectableWrapper<T>::IntersectableWrapper(T *item):70 IntersectableWrapper<T>::IntersectableWrapper(T item): 68 71 Intersectable(), mItem(item) 69 72 { … … 71 74 72 75 template<typename T> 73 void IntersectableWrapper<T>::SetItem(T *item)76 void IntersectableWrapper<T>::SetItem(T item) 74 77 { 75 78 mItem = item; … … 77 80 78 81 template<typename T> 79 T *IntersectableWrapper<T>::GetItem() const82 T IntersectableWrapper<T>::GetItem() const 80 83 { 81 84 return mItem; … … 120 123 template<typename T> 121 124 int IntersectableWrapper<T>::GetRandomSurfacePoint(Vector3 &point, 122 Vector3 &normal)125 Vector3 &normal) 123 126 { 124 127 return 0; … … 127 130 template<typename T> 128 131 int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point, 129 130 131 132 Vector3 &normal, 133 const Vector3 &viewpoint, 134 const int maxTries) 132 135 { 133 136 return 0; … … 142 145 143 146 144 class KdIntersectable: public IntersectableWrapper<KdNode >147 class KdIntersectable: public IntersectableWrapper<KdNode *> 145 148 { 146 149 public: 147 150 KdIntersectable(KdNode *item): 148 IntersectableWrapper<KdNode >(item) {}151 IntersectableWrapper<KdNode *>(item) {} 149 152 150 153 int Type() const … … 155 158 156 159 157 class BvhIntersectable: public IntersectableWrapper<BvhNode >160 class BvhIntersectable: public IntersectableWrapper<BvhNode *> 158 161 { 159 162 public: 160 163 BvhIntersectable(BvhNode *item): 161 IntersectableWrapper<BvhNode >(item) {}164 IntersectableWrapper<BvhNode *>(item) {} 162 165 163 166 int Type() const … … 167 170 }; 168 171 172 169 173 class TriangleIntersectable: public IntersectableWrapper<Triangle3> 170 174 { 171 175 public: 172 TriangleIntersectable(Triangle3 *item):176 TriangleIntersectable(Triangle3 item): 173 177 IntersectableWrapper<Triangle3>(item) {} 174 178 175 179 int CastRay(Ray &ray); 176 180 AxisAlignedBox3 GetBox() const; 177 178 181 int NumberOfFaces() const; 182 Vector3 GetNormal(const int idx) const; 179 183 180 184 int Type() const -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1286 r1344 654 654 655 655 if (MeshDebug) { 656 if ( ray.intersections.size())656 if (!ray.intersections.empty()) 657 657 cout<<"nearest t="<<ray.intersections[0].mT<<endl; 658 658 else 659 659 cout<<"nearest t=-INF"<<endl; 660 } 661 660 } 662 661 } 663 662 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1328 r1344 726 726 727 727 728 Vector3 MeshInstance::GetNormal(const int idx) const 729 { 730 return mMesh->GetFacePlane(idx).mNormal; 731 } 732 733 734 728 735 /*************************************************************/ 729 736 /* TransformedMeshInstance implementation */ 730 737 /*************************************************************/ 738 731 739 732 740 TransformedMeshInstance::TransformedMeshInstance(Mesh *mesh): … … 756 764 } 757 765 766 758 767 int TransformedMeshInstance::CastRay(Ray &ray, const vector<int> &faces) 759 768 { … … 799 808 800 809 801 } 810 Vector3 TransformedMeshInstance::GetNormal(const int idx) const 811 { 812 Mesh mesh; 813 GetTransformedMesh(mesh); 814 return mesh.GetFacePlane(idx).mNormal; 815 } 816 817 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r1328 r1344 20 20 class MeshKdTree; 21 21 22 /// default vertex container for Mesh 23 typedef std::vector<Vector3> VertexContainer; 24 25 /// vertex index container 26 //typedef std::vector<short> VertexIndexContainer; 27 typedef std::vector<int> VertexIndexContainer; 28 29 /** Patch used as an element of the mesh */ 22 23 /** Patch used as an element of the mesh 24 */ 30 25 struct Face { 31 26 … … 284 279 Material *GetMaterial() const; 285 280 281 virtual Vector3 GetNormal(const int idx) const; 282 286 283 protected: 287 284 … … 329 326 void GetTransformedMesh(Mesh &transformedMesh) const; 330 327 328 Vector3 GetNormal(const int idx) const; 329 331 330 protected: 332 331 -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r1328 r1344 19 19 namespace GtpVisibilityPreprocessor { 20 20 21 #define CONNECT_SEQUENTIAL_FACES 121 #define CONNECT_SEQUENTIAL_FACES 0 22 22 #define ROTATE_SCENE 0 23 23 … … 36 36 } 37 37 38 38 39 struct ltstr 39 40 { … … 43 44 } 44 45 }; 45 46 //const static int nMaxFaces = 6;47 46 48 47 … … 71 70 72 71 73 static Triangle3 *LoadTriangle(char *str,74 75 72 static Triangle3 LoadTriangle(char *str, 73 const VertexContainer &vertices, 74 map<int, Vector3> &hashTable) 76 75 { 77 76 char *pch = strtok(str + 1, " "); … … 92 91 //if (indices.size() > 4) return NULL; 93 92 94 return new Triangle3(indices[0], indices[1], indices[2]);93 return Triangle3(vertices[indices[0]], vertices[indices[1]], vertices[indices[2]]); 95 94 } 96 95 … … 143 142 vector<FaceParentInfo> &parents) 144 143 { 145 146 147 148 149 150 { 151 144 Mesh *mesh = mi->GetMesh(); 145 146 FaceContainer::const_iterator fit, fit_end = mesh->mFaces.end(); 147 int i = 0; 148 for (fit = mesh->mFaces.begin(); fit != fit_end; ++ fit, i++) 149 { 150 parents.push_back(FaceParentInfo(mi, i)); 152 151 } 153 152 } … … 160 159 { 161 160 Mesh *mesh = CreateMesh(faces, hashTable); 162 163 161 // make an instance of this mesh 164 162 MeshInstance *mi = new MeshInstance(mesh); … … 178 176 179 177 bool ObjParser::ParseFile(const string filename, 180 SceneGraphNode * *proot,178 SceneGraphNode *root, 181 179 const bool loadPolygonsAsMeshes, 182 180 vector<FaceParentInfo> *parents) … … 184 182 FILE *file; 185 183 if ((file = fopen(filename.c_str(), "rt")) == NULL) 184 { 186 185 return false; 187 cout << "here2" << endl; 186 } 187 188 188 map<int, Vector3> hashTable; // table associating indices with vectors 189 190 189 VertexContainer vertices; // table for vertices 191 190 FaceContainer faces; 192 193 SceneGraphNode *root = new SceneGraphNode;194 191 195 192 char str[100]; … … 203 200 switch (str[0]) 204 201 { 205 case 'v': 202 case 'v': // vertex 206 203 { 207 float x,y,z; //cout << "v"; 208 209 // vertex 204 float x, y, z; //cout << "v"; 210 205 sscanf(str + 1, "%f %f %f", &x, &y, &z); 211 206 vertices.push_back(Vector3(x,y,z)); … … 219 214 Face *face = LoadFace(str, vertices, hashTable); 220 215 if (!face) break; 221 216 222 217 faces.push_back(face); 223 218 … … 227 222 } 228 223 #else 224 Triangle3 triangle = LoadTriangle(str, vertices, hashTable); 229 225 230 Triangle3 *triangle = LoadTriangle(str, vertices, hashTable); 231 root->mGeometry.push_back(new TriangleIntersectable(triangle)); 226 TriangleIntersectable *obj = new TriangleIntersectable(triangle); 227 root->mGeometry.push_back(obj); 228 229 // matt: we don't really need to keep an additional data structure 230 // if working with triangles => remove this 231 if (parents) 232 { 233 FaceParentInfo info(obj, 0); 234 parents->push_back(info); 235 } 232 236 #endif 233 237 break; … … 245 249 } 246 250 #endif 247 251 // reset tables 252 hashTable.clear(); 253 faces.clear(); 248 254 fclose(file); 249 *proot = root; 250 255 251 256 return true; 252 257 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.h
r1281 r1344 16 16 17 17 virtual bool ParseFile(const std::string filename, 18 SceneGraphNode * *root,18 SceneGraphNode *root, 19 19 const bool loadPolygonsAsMeshes = false, 20 20 vector<FaceParentInfo> *parents = NULL); -
GTP/trunk/Lib/Vis/Preprocessing/src/Parser.h
r1281 r1344 18 18 Parser() {} 19 19 20 virtual bool ParseFile(const std::string filename, 21 SceneGraphNode * *root,20 virtual bool ParseFile(const std::string filename, 21 SceneGraphNode *root, 22 22 const bool loadPolygonsAsMeshes = false, 23 23 std::vector<FaceParentInfo> *parents = NULL) -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.cpp
r1281 r1344 259 259 bool 260 260 PlyParser::ParseFile(const string filename, 261 SceneGraphNode * *root,261 SceneGraphNode *root, 262 262 const bool loadPolygonsAsMeshes, 263 263 vector<FaceParentInfo> *parents) … … 283 283 filelist.push_back(filename); 284 284 285 *root = new SceneGraphNode;286 287 285 for (int i=0; i < filelist.size(); i++) { 288 if (!ParseSingleFile(filelist[i], *root)) {286 if (!ParseSingleFile(filelist[i], root)) { 289 287 cerr<<"Ply parse error. Quiting ...\n"; 290 288 exit(1); 291 289 } 292 290 } 291 293 292 return true; 294 293 } -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.h
r1281 r1344 15 15 16 16 bool ParseFile(const string filename, 17 SceneGraphNode * *root,17 SceneGraphNode *root, 18 18 const bool loadPolygonsAsMeshes = false, 19 19 vector<FaceParentInfo> *parents = NULL); -
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
r1328 r1344 10 10 11 11 Polygon3::Polygon3(): 12 mMaterial(NULL), mParent(NULL), mPiercingRays(0) 12 mMaterial(NULL), 13 mParent(NULL), 14 mPiercingRays(0) 13 15 , mPlane(NULL) 14 16 { 15 // mostly there will be triangles16 //mVertices.reserve(3);17 17 } 18 18 19 19 Polygon3::Polygon3(const VertexContainer &vertices): 20 mMaterial(NULL), mParent(NULL), mPiercingRays(0) 20 mMaterial(NULL), 21 mParent(NULL), 22 mPiercingRays(0) 21 23 , mPlane(NULL) 22 24 { … … 27 29 28 30 Polygon3::Polygon3(MeshInstance *parent): 29 mMaterial(NULL), mParent(parent), mPiercingRays(0) 31 mMaterial(NULL), 32 mParent(parent), 33 mPiercingRays(0) 30 34 , mPlane(NULL) 31 35 {} … … 33 37 34 38 Polygon3::Polygon3(Face *face, Mesh *parentMesh): 35 mMaterial(NULL), mParent(NULL), mPiercingRays(0) 36 , mPlane(NULL) 39 mMaterial(NULL), 40 mParent(NULL), 41 mPiercingRays(0), 42 mPlane(NULL) 37 43 { 38 44 mVertices.reserve(face->mVertexIndices.size()); 39 45 40 VertexIndexContainer::iterator it = face->mVertexIndices.begin(); 41 for (; it != face->mVertexIndices.end(); ++it) 46 VertexIndexContainer::iterator it, it_end = face->mVertexIndices.end(); 47 48 for (it = face->mVertexIndices.begin(); it != it_end; ++ it) 42 49 { 43 50 mVertices.push_back(parentMesh->mVertices[*it]); … … 54 61 #else 55 62 if (!mPlane) 63 { 56 64 mPlane = new Plane3(mVertices[0], mVertices[1], mVertices[2]); 65 } 66 57 67 return *mPlane; 58 68 #endif … … 65 75 mVertices[0] - mVertices[1])); 66 76 } 77 67 78 68 79 void Polygon3::Split(const Plane3 &partition, … … 72 83 { 73 84 Vector3 ptA = mVertices.back(); 74 75 85 int sideA = partition.Side(ptA, epsilon); 76 77 VertexContainer::const_iterator it;78 79 Vector3 lastSplit;80 81 86 bool foundSplit = false; 82 87 Vector3 lastSplit; 88 83 89 //-- find line - plane intersections 84 for (it = mVertices.begin(); it != mVertices.end(); ++ it) 90 91 VertexContainer::const_iterator it, it_end = mVertices.end(); 92 93 for (it = mVertices.begin(); it != it_end; ++ it) 85 94 { 86 95 Vector3 ptB = *it; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1328 r1344 162 162 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 163 163 Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; 164 165 if (mRayCastMethod == 0) 166 cout << "ray cast method: internal" << endl; 167 else 168 cout << "ray cast method: intel" << endl; 164 169 } 165 170 … … 231 236 cout << "number of input files: " << files << endl; 232 237 bool result = false; 238 239 // root for different files 240 mSceneGraph->SetRoot(new SceneGraphNode()); 241 233 242 if (files == 1) { 234 243 … … 245 254 cout << filename << endl; 246 255 247 SceneGraphNode *sroot = mSceneGraph->GetRoot();248 249 256 if (mRayCastMethod == Preprocessor::INTEL_RAYCASTER) 250 { cout << "here5800" << endl;257 { 251 258 result = parser->ParseFile( 252 259 filename, 253 &sroot,260 mSceneGraph->GetRoot(), 254 261 mLoadPolygonsAsMeshes, 255 262 &mFaceParents); 256 263 } 257 264 else 258 { cout << "here776645" << endl;259 result = parser->ParseFile(filename, &sroot, mLoadPolygonsAsMeshes);265 { 266 result = parser->ParseFile(filename, mSceneGraph->GetRoot(), mLoadPolygonsAsMeshes); 260 267 } 261 cout << "here98809845" << endl;268 262 269 delete parser; 263 270 264 271 } else { 265 // root for different files 266 mSceneGraph->SetRoot(new SceneGraphNode()); 272 267 273 for (int i= 0; i < filenames.size(); i++) { 268 274 if (strstr(filenames[i].c_str(), ".x3d")) … … 271 277 parser = new UnigraphicsParser; 272 278 273 SceneGraphNode *node ;279 SceneGraphNode *node = new SceneGraphNode(); 274 280 bool success; 275 281 276 282 if (mRayCastMethod == Preprocessor::INTEL_RAYCASTER) 277 { cout << "here4500" << endl;283 { 278 284 success = parser->ParseFile( 279 285 filename, 280 &node,286 node, 281 287 mLoadPolygonsAsMeshes, 282 288 &mFaceParents); … … 284 290 else 285 291 { 286 cout << "here45" << endl; 287 success = parser->ParseFile(filename, &node, mLoadPolygonsAsMeshes); 292 success = parser->ParseFile(filename, node, mLoadPolygonsAsMeshes); 288 293 } 289 294 290 295 if (success) 291 { cout << "here4509999" << endl;296 { 292 297 mSceneGraph->GetRoot()->mChildren.push_back(node); 293 // at least one file parsed 294 result = true; 298 result = true; // at least one file parsed 295 299 } 296 300 … … 298 302 } 299 303 } 300 cout << "here8888" << endl; 301 304 302 305 if (result) 303 { cout << "here199" << endl;306 { 304 307 // HACK 305 308 if (ADDITIONAL_GEOMETRY_HACK) … … 307 310 308 311 mSceneGraph->AssignObjectIds(); 309 cout << "here99" << endl;312 310 313 int intersectables, faces; 311 314 mSceneGraph->GetStatistics(intersectables, faces); 312 cout << "here999" << endl;315 313 316 cout<<filename<<" parsed successfully."<<endl; 314 317 cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<intersectables<<endl; … … 316 319 mSceneGraph->CollectObjects(&mObjects); 317 320 mSceneGraph->GetRoot()->UpdateBox(); 318 cout << "here9999" << endl;321 319 322 if (0) 320 323 { … … 369 372 { 370 373 mKdTree = new KdTree; 374 371 375 // add mesh instances of the scene graph to the root of the tree 372 376 KdLeaf *root = (KdLeaf *)mKdTree->GetRoot(); 373 cout << "here3.95" << endl;377 374 378 mSceneGraph->CollectObjects(&root->mObjects); 375 cout << "here3.97" << endl;379 376 380 long startTime = GetTime(); 377 378 381 cout << "building kd tree ... " << endl; 382 379 383 mKdTree->Construct(); 384 380 385 cout << "construction finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs " << endl; 386 381 387 return true; 382 388 } … … 847 853 case INTEL_RAYCASTER: 848 854 #ifdef GTP_INTERNAL 849 cout<<"Ray Cast file: " <<externKdTree<<endl;855 cout<<"Ray Cast file: " << externKdTree << endl; 850 856 return mlrtaLoadAS(externKdTree.c_str()); 851 857 #endif … … 868 874 { 869 875 #ifdef GTP_INTERNAL 876 //cout << "intel ray" << endl; 870 877 VssRay *vssRay = NULL; 871 878 int hits = 0; … … 875 882 Intersectable *objectA = NULL, *objectB = NULL; 876 883 float dist; 877 878 884 double normal[3]; 879 885 880 886 hittriangle = mlrtaIntersectAS(&viewPoint.x, 881 882 883 884 885 if (hittriangle != -1 ) {886 887 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl;888 889 objectA = mFaceParents[hittriangle].mObject;890 normalA = Vector3(normal[0], normal[1], normal[2]);891 // Get the normal of that face892 // Mesh *mesh = ((MeshInstance *)objectA)->GetMesh();893 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;894 //-rays[index+i].mDirection; // $$ temporary895 pointA = viewPoint + direction*dist;896 897 } 898 899 887 &direction.x, 888 normal, 889 dist); 890 891 if (hittriangle != -1 ) { 892 if (hittriangle >= mFaceParents.size()) 893 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 894 else { 895 objectA = mFaceParents[hittriangle].mObject; 896 normalA = Vector3(normal[0], normal[1], normal[2]); 897 // Get the normal of that face 898 // Mesh *mesh = ((MeshInstance *)objectA)->GetMesh(); 899 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 900 //-rays[index+i].mDirection; // $$ temporary 901 pointA = viewPoint + direction*dist; 902 } 903 } 904 905 900 906 Vector3 dir = -direction; 901 907 hittriangle = mlrtaIntersectAS(&viewPoint.x, 902 903 904 905 906 if (hittriangle != -1 ) {907 908 cerr<<"Warning: traingle index out of range! "<<hittriangle<<endl;909 910 objectB = mFaceParents[hittriangle].mObject;911 normalB = Vector3(normal[0], normal[1], normal[2]);912 // Get the normal of that face913 // Mesh *mesh = ((MeshInstance *)objectB)->GetMesh();914 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal;915 //-rays[index+i].mDirection; // $$ temporary916 pointB = viewPoint + dir*dist;917 }908 &dir.x, 909 normal, 910 dist); 911 912 if (hittriangle != -1 ) { 913 if (hittriangle >= mFaceParents.size()) 914 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 915 else { 916 objectB = mFaceParents[hittriangle].mObject; 917 normalB = Vector3(normal[0], normal[1], normal[2]); 918 // Get the normal of that face 919 // Mesh *mesh = ((MeshInstance *)objectB)->GetMesh(); 920 // normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 921 //-rays[index+i].mDirection; // $$ temporary 922 pointB = viewPoint + dir * dist; 923 } 918 924 } 919 925 920 926 return ProcessRay(viewPoint, 921 922 923 924 925 926 927 927 direction, 928 objectA, pointA, normalA, 929 objectB, pointB, normalB, 930 probability, 931 vssRays, 932 box 933 ); 928 934 #else 929 935 return -1; … … 971 977 else { 972 978 if (hittriangle >= mFaceParents.size()) { 973 cerr<<"Warning: tr aingle index out of range! "<<hittriangle<<endl;979 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 974 980 return NULL; 975 981 } … … 989 995 #endif 990 996 991 992 993 997 } 994 998 … … 1002 1006 ) 1003 1007 { 1004 1008 cout << "internal ray" << endl; 1005 1009 int hits = 0; 1006 1010 static Ray ray; … … 1009 1013 1010 1014 // AxisAlignedBox3 box = Union(mKdTree->GetBox(), mViewCellsManager->GetViewSpaceBox()); 1011 1012 1013 1015 AxisAlignedBox3 sbox = box; 1014 1016 sbox.Enlarge(Vector3(-Limits::Small)); … … 1042 1044 } 1043 1045 1044 1045 1046 SetupRay(ray, viewPoint, -direction); 1046 1047 ray.mFlags &= ~Ray::CULL_BACKFACES; … … 1076 1077 ); 1077 1078 vssRays.push_back(vssRay); 1079 //cout << "ray: " << *vssRay << endl; 1078 1080 hits ++; 1079 1081 } … … 1088 1090 ); 1089 1091 vssRays.push_back(vssRay); 1092 //cout << "ray: " << *vssRay << endl; 1090 1093 hits ++; 1091 1094 } … … 1172 1175 ); 1173 1176 vssRays.push_back(vssRay); 1177 //cout << "ray: " << *vssRay << endl; 1174 1178 hits ++; 1175 1179 } … … 1184 1188 ); 1185 1189 vssRays.push_back(vssRay); 1190 //cout << "ray: " << *vssRay << endl; 1186 1191 hits ++; 1187 1192 } … … 1199 1204 { 1200 1205 int i; 1201 int num = 16;1206 const int num = 16; 1202 1207 1203 1208 #if DEBUG_RAYCAST … … 1214 1219 1215 1220 1216 1217 1218 1221 Vector3 min = sbox.Min(); 1219 1222 Vector3 max = sbox.Max(); 1223 1220 1224 for (i=0; i < num; i++) { 1221 1225 mlrtaStoreRayAS16(&rays[index + i].mOrigin.x, … … 1223 1227 i); 1224 1228 } 1225 1226 1229 1227 1230 mlrtaTraverseGroupAS16(&min.x, … … 1237 1240 } 1238 1241 1239 1240 1242 mlrtaTraverseGroupAS16(&min.x, 1241 1243 &max.x, … … 1244 1246 1245 1247 1246 1247 1248 for (i=0; i < num; i++) { 1248 1249 Intersectable *objectA = NULL, *objectB = NULL; … … 1250 1251 Vector3 normalA, normalB; 1251 1252 1252 1253 1254 if (forward_hit_triangles[i] !=-1 ) { 1253 if (forward_hit_triangles[i] != -1 ) { 1255 1254 if (forward_hit_triangles[i] >= mFaceParents.size()) 1256 cerr<<"Warning: tr aingle index out of range! "<<forward_hit_triangles[i]<<endl;1257 else { 1255 cerr<<"Warning: triangle index out of range! "<<forward_hit_triangles[i]<<endl; 1256 else { 1258 1257 objectA = mFaceParents[forward_hit_triangles[i]].mObject; 1259 1258 // Get the normal of that face 1260 Mesh *mesh = ((MeshInstance *)objectA)->GetMesh(); 1261 normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 1259 normalA = objectA->GetNormal(mFaceParents[forward_hit_triangles[i]].mFaceIndex); 1262 1260 //-rays[index+i].mDirection; // $$ temporary 1263 1261 pointA = rays[index+i].Extrap(forward_dist[i]); 1264 1262 } 1265 1263 } 1266 1264 1267 1265 if (backward_hit_triangles[i]!=-1) { 1268 1266 if (backward_hit_triangles[i] >= mFaceParents.size()) 1269 cerr<<"Warning: tr aingleindex out of range! "<<backward_hit_triangles[i]<<endl;1270 else { 1267 cerr<<"Warning: triangle index out of range! "<<backward_hit_triangles[i]<<endl; 1268 else { 1271 1269 objectB = mFaceParents[backward_hit_triangles[i]].mObject; 1272 Mesh *mesh = ((MeshInstance *)objectB)->GetMesh(); 1273 1274 normalB = mesh->GetFacePlane(mFaceParents[backward_hit_triangles[i]].mFaceIndex).mNormal; 1275 1276 // normalB = rays[index+i].mDirection; // $$ temporary 1270 normalB = objectB->GetNormal(mFaceParents[forward_hit_triangles[i]].mFaceIndex); 1271 1272 // normalB = rays[index+i].mDirection; // $$ temporary 1277 1273 pointB = rays[index+i].Extrap(-backward_dist[i]); 1278 1274 } 1279 1275 } 1280 1276 1281 1277 ProcessRay(rays[index+i].mOrigin, 1282 1278 rays[index+i].mDirection, … … 1288 1284 ); 1289 1285 } 1286 1290 1287 #endif 1291 1288 … … 1312 1309 { 1313 1310 long t1 = GetTime(); 1314 for (int i=0; i < rays.size(); ) { 1315 if (i + 16 < rays.size()) { 1311 1312 for (int i = 0; i < (int)rays.size(); ) { 1313 // method only available for intel raycaster yet 1314 if (i + 16 < (int)rays.size()) { 1315 1316 1316 CastRays16( 1317 1317 i, … … 1321 1321 i += 16; 1322 1322 } else { 1323 1324 1323 CastRay(rays[i].mOrigin, 1325 1324 rays[i].mDirection, … … 1327 1326 vssRays, 1328 1327 mViewCellsManager->GetViewSpaceBox()); 1329 1330 1328 i++; 1331 1329 } … … 1335 1333 1336 1334 long t2 = GetTime(); 1337 1338 1335 cout<<2*rays.size()/(1e3*TimeDiff(t1, t2))<<"M rays/s"<<endl; 1339 1336 } … … 1354 1351 1355 1352 int hittriangle; 1356 1357 1353 1358 1354 #ifdef GTP_INTERNAL … … 1367 1363 if (hittriangle !=-1 ) { 1368 1364 if (hittriangle >= mFaceParents.size()) 1369 cerr<<"Warning: tr aingle index out of range! "<<hittriangle<<endl;1365 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 1370 1366 else { 1371 1367 result = mFaceParents[hittriangle].mObject; … … 1375 1371 } 1376 1372 #else 1377 hittriangle = -1;1373 hittriangle = -1; 1378 1374 #endif 1379 1375 1380 1381 1376 break; 1382 1377 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
r1328 r1344 31 31 { 32 32 CLEAR_CONTAINER(mGeometry); 33 34 33 // recursivly delete all children 35 34 CLEAR_CONTAINER(mChildren); … … 78 77 SceneGraphNode *node = nodeStack.top(); 79 78 nodeStack.pop(); 80 cout << "here3.958" << endl;cout << "here3.9587654" << endl;81 ObjectContainer::const_iterator mi = node->mGeometry.begin(); cout << "here3.958" << endl;79 80 ObjectContainer::const_iterator mi = node->mGeometry.begin(); 82 81 for (; mi != node->mGeometry.end(); mi++) 83 82 { 84 cout << "here3.9886" << endl;85 83 instances->push_back(*mi); 86 84 } 87 cout << "here3.969999" << endl;85 88 86 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 89 87 for (; ni != node->mChildren.end(); ni++) { 90 nodeStack.push(*ni); cout << "here3.959" << endl;88 nodeStack.push(*ni); 91 89 number++; 92 90 } 93 cout << "here3.96" << endl;94 91 } 92 95 93 return number; 96 94 } … … 104 102 105 103 nodeStack.push(mRoot); 106 104 107 105 while (!nodeStack.empty()) { 108 106 SceneGraphNode *node = nodeStack.top(); … … 111 109 ObjectContainer::iterator mi = node->mGeometry.begin(); 112 110 for (; mi != node->mGeometry.end(); mi++) { 113 // $$ JB remove object id=2601 (for debugging purposes in atlanta scene) 114 if (1) //id != 2601) 115 (*mi)->SetId(id++); 116 else { 117 node->mGeometry.erase(mi); 118 --mi; 119 id++; 120 } 111 (*mi)->SetId(id++); 121 112 } 122 113 … … 126 117 } 127 118 } 128 // return max id 119 120 // return max id 129 121 return id; 130 122 } -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r1292 r1344 187 187 Name="VCCLCompilerTool" 188 188 Optimization="3" 189 GlobalOptimizations="TRUE" 190 InlineFunctionExpansion="2" 191 FavorSizeOrSpeed="1" 192 EnableFiberSafeOptimizations="TRUE" 193 OptimizeForProcessor="3" 194 OptimizeForWindowsApplication="TRUE" 189 195 AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;"$(QTDIR)\include\QtOpenGl";..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 190 196 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;GTP_INTERNAL" -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.cpp
r1328 r1344 2 2 #include "Ray.h" 3 3 #include "AxisAlignedBox3.h" 4 #include "Containers.h" 5 #include "Polygon3.h" 4 6 5 7 … … 18 20 mVertices[1] = b; 19 21 mVertices[2] = c; 20 21 22 } 22 23 … … 28 29 29 30 30 int Triangle3::CastRay(const Ray &ray, float &t, const float nearestT ) const31 int Triangle3::CastRay(const Ray &ray, float &t, const float nearestT, Vector3 &normal) const 31 32 { 33 /*VertexContainer vertices; 34 vertices.push_back(mVertices[0]); 35 vertices.push_back(mVertices[1]); 36 vertices.push_back(mVertices[2]); 37 38 Polygon3 poly(vertices); 39 40 int dummy = poly.CastRay(ray, t, nearestT); 41 42 cout << "polyversion code: " << dummy << " t: " << t << " nearestT: " << nearestT << endl; 43 return dummy;*/ 44 ///////////////////////////////////////////// 45 // specialised ray casting version 46 47 //-- calc ray-plane intersection 48 32 49 // get triangle edge vectors and plane normal 33 const Vector3 u = mVertices[ 1] - mVertices[0];34 const Vector3 v = mVertices[2] - mVertices[ 0];50 const Vector3 u = mVertices[0] - mVertices[1]; 51 const Vector3 v = mVertices[2] - mVertices[1]; 35 52 36 const Vector3 n = u * v;// cross product53 normal = Normalize(CrossProd(v, u)); // cross product 37 54 38 const Vector3 dir = ray.GetDir(); 39 const Vector3 w0 = ray.GetLoc() - mVertices[ 0];55 const Vector3 dir = ray.GetDir(); // ray direction vector 56 const Vector3 w0 = ray.GetLoc() - mVertices[1]; 40 57 41 58 // params to calc ray-plane intersect 42 const float a = - DotProd(n, w0);43 const float b = DotProd(n , dir);59 const float a = -DotProd(normal, w0); 60 const float b = DotProd(normal, dir); 44 61 62 // check for division by zero 45 63 if (fabs(b) < Limits::Small) 46 64 { … … 56 74 } 57 75 58 // get intersect point of ray with triangleplane76 // distance from origin of ray to plane 59 77 t = a / b; 60 78 61 79 if (t < 0.0) // ray goes away from triangle 62 80 { 63 return Ray::NO_INTERSECTION; // => no intersect 81 return Ray::NO_INTERSECTION; // => no intersect 82 } 83 // already found nearer intersection 84 else if ((ray.GetType() == Ray::LOCAL_RAY) && (t >= nearestT)) 85 { 86 return Ray::NO_INTERSECTION; 64 87 } 65 88 66 // for a segment, also test if (r > 1.0) => no intersect 89 /////////////////////////////////////////////// 90 //-- found intersection point 91 //-- check if it is inside triangle 92 93 const Vector3 pt = ray.GetLoc() + t * dir; 67 94 68 // intersect point of ray and plane 69 const Vector3 pt = ray.GetLoc() + t * dir; 70 71 72 /////////////////////////////////////////////// 73 //-- is point inside triangle? 74 75 const Vector3 w = pt - mVertices[0]; 95 const Vector3 w = pt - mVertices[1]; 76 96 77 97 const float uu = DotProd(u, u); … … 86 106 const float s = (uv * wv - vv * wu) / D; 87 107 88 if ( s < 0.0 || s > 1.0) // pt is outside triangle89 { 108 if ((s < 0.0) || (s > 1.0)) // pt is outside triangle 109 { 90 110 return Ray::NO_INTERSECTION; 91 111 } … … 93 113 const float s2 = (uv * wu - uu * wv) / D; 94 114 95 if ( s2 < 0.0 || (s + s2) > 1.0) // pt is outside triangle96 { 115 if ((s2 < 0.0) || ((s + s2) > 1.0)) // pt is outside triangle 116 { 97 117 return Ray::NO_INTERSECTION; 98 118 } … … 118 138 { 119 139 const Vector3 v1 = mVertices[0] - mVertices[1]; 120 const Vector3 v2 = mVertices[2] -mVertices[1];140 const Vector3 v2 = mVertices[2] - mVertices[1]; 121 141 122 142 return Normalize(CrossProd(v2, v1)); … … 132 152 float Triangle3::GetArea() const 133 153 { 134 Vector3 v1 =mVertices[0]-mVertices[1], v2=mVertices[2]-mVertices[1];154 Vector3 v1 = mVertices[0] - mVertices[1], v2=mVertices[2] - mVertices[1]; 135 155 return 0.5f * Magnitude(CrossProd(v2, v1)); 136 156 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Triangle3.h
r1328 r1344 30 30 31 31 /// Casts ray into this triangle. Returns hit 32 int CastRay(const Ray &ray, float &t, const float nearestT ) const;32 int CastRay(const Ray &ray, float &t, const float nearestT, Vector3 &normal) const; 33 33 34 ////////////////////////////// 34 friend ostream& operator<< (ostream &s, const Triangle3 &A); 35 friend istream& operator>> (istream &s, Triangle3 &A); 35 36 36 /// the triangle vertices 37 Vector3 mVertices[3]; 37 38 ////////////////////////////// 39 /// the triangle vertices 40 Vector3 mVertices[3]; 38 41 }; 42 43 44 // Overload << operator for C++-style output 45 inline ostream& 46 operator<< (ostream &s, const Triangle3 &A) 47 { 48 return s << "(" << A.mVertices[0] << ", " << A.mVertices[1] << ", " << A.mVertices[2] << ")"; 49 } 50 51 // Overload >> operator for C++-style input 52 inline istream& 53 operator>> (istream &s, Triangle3 &A) 54 { 55 char a; 56 // read "(x, y, z)" 57 return s >> a >> A.mVertices[0] >> a >> A.mVertices[1] >> a >> A.mVertices[2] >> a; 58 } 59 39 60 40 61 } -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r1281 r1344 43 43 bool 44 44 UnigraphicsParser::ParseFile(const string filename, 45 SceneGraphNode * *proot,45 SceneGraphNode *root, 46 46 const bool loadPolygonsAsMeshes, 47 47 vector<FaceParentInfo> *parents) … … 61 61 return false; 62 62 63 SceneGraphNode *root = new SceneGraphNode;64 63 Mesh *currentMesh = MeshManager::GetSingleton()->CreateResource(); 65 64 … … 186 185 187 186 fclose(file); 188 189 *proot = root;190 191 187 return true; 192 188 } -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.h
r1281 r1344 16 16 17 17 virtual bool ParseFile(const std::string filename, 18 SceneGraphNode * *root,18 SceneGraphNode *root, 19 19 const bool loadPolygonsAsMeshes = false, 20 20 vector<FaceParentInfo> *parents = NULL); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1315 r1344 276 276 { 277 277 SimpleRayContainer simpleRays; 278 279 278 const long startTime = GetTime(); 280 279 281 280 mPreprocessor->GenerateRays(samplesPerPass, sampleType, simpleRays); 282 283 281 Debug << "generated " << mInitialSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 284 282 285 283 // shoot simple ray and add it to importance samples 286 284 mPreprocessor->CastRays(simpleRays, passSamples); 287 288 285 Debug << "cast " << mInitialSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 289 286 … … 5359 5356 5360 5357 5358 ////////////////////////////////////////////////////////////// 5361 5359 //-- export bounding boxes 5362 5360 5363 5361 stream << "<BoundingBoxes>" << endl; 5364 5365 5362 ObjectContainer::const_iterator oit, oit_end = objects.end(); 5366 5363 5367 5364 for (oit = objects.begin(); oit != oit_end; ++ oit) 5368 5365 { 5369 MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit); 5370 const AxisAlignedBox3 box = mi->GetBox(); 5366 const AxisAlignedBox3 box = (*oit)->GetBox(); 5371 5367 5372 5368 //-- the bounding boxes 5373 stream << "<BoundingBox" << " id=\"" << mi->GetId() << "\""5369 stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 5374 5370 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 5375 5371 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; … … 5378 5374 stream << "</BoundingBoxes>" << endl; 5379 5375 5380 5376 //////////////////////////////////////////////////////////////// 5381 5377 //-- export the view cells and the pvs 5382 5378 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h
r1221 r1344 17 17 ViewCellsParser():Parser() {} 18 18 19 //bool ParseFile(const string filename, ViewCellsManager &viewCells);20 bool ParseViewCellsFile(const string filename,19 bool ParseViewCellsFile( 20 const string filename, 21 21 ViewCellsManager **viewCells, 22 22 ObjectContainer *objects, -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
r1315 r1344 15 15 #include "Beam.h" 16 16 #include "IntersectableWrapper.h" 17 #include "Triangle3.h" 17 18 18 19 … … 20 21 21 22 22 VrmlExporter::VrmlExporter(const string filename): Exporter(filename)23 VrmlExporter::VrmlExporter(const string filename): Exporter(filename) 23 24 { 24 25 stream.open(mFilename.c_str()); … … 159 160 160 161 stream<<"</Group>"<<endl; 161 }162 163 164 void VrmlExporter::ExportIntersectable(Intersectable *object)165 {166 switch (object->Type())167 {168 case Intersectable::MESH_INSTANCE:169 ExportMeshInstance((MeshInstance *)object);170 break;171 case Intersectable::TRANSFORMED_MESH_INSTANCE:172 ExportTransformedMeshInstance(dynamic_cast<TransformedMeshInstance *>(object));173 break;174 case Intersectable::VIEW_CELL:175 ExportViewCell(dynamic_cast<ViewCell *>(object));176 break;177 case Intersectable::KD_INTERSECTABLE:178 ExportKdIntersectable(*(dynamic_cast<KdIntersectable *>(object)));179 break;180 default:181 cerr << "Sorry the export for object type " << Intersectable::GetTypeName(object) << " is not available yet" << endl;182 break;183 }184 }185 186 187 void VrmlExporter::ExportMeshInstance(MeshInstance *object)188 {189 // $$JB$$190 // in the future check whether the mesh was not already exported191 // and use a reference to the that mesh instead192 ExportMesh(object->GetMesh());193 }194 195 196 void VrmlExporter::ExportTransformedMeshInstance(TransformedMeshInstance *mi)197 {198 Mesh mesh(*mi->GetMesh());199 200 Matrix4x4 m;201 mi->GetWorldTransform(m);202 mesh.ApplyTransformation(m);203 204 ExportMesh(&mesh);205 }206 207 208 void VrmlExporter::ExportViewCells(const ViewCellContainer &viewCells)209 {210 ViewCellContainer::const_iterator it, it_end = viewCells.end();211 212 for (it = viewCells.begin(); it != it_end; ++ it)213 {214 ExportViewCell(*it);215 }216 162 } 217 163 -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.h
r1197 r1344 84 84 85 85 virtual void 86 ExportMeshInstance(MeshInstance *mi);87 88 virtual void89 ExportTransformedMeshInstance(TransformedMeshInstance *mi);90 91 virtual void92 ExportIntersectable(Intersectable *object);93 94 virtual void95 86 ExportMesh(Mesh *mesh); 96 87 97 88 virtual void 98 89 ExportViewCell(ViewCell *viewCell); 99 100 virtual void101 ExportViewCells(const ViewCellContainer &viewCells);102 90 103 91 virtual void -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r1233 r1344 200 200 201 201 } 202 void203 X3dExporter::ExportIntersectable(Intersectable *object)204 {205 switch (object->Type())206 {207 case Intersectable::MESH_INSTANCE:208 ExportMeshInstance((MeshInstance *)object);209 break;210 case Intersectable::TRANSFORMED_MESH_INSTANCE:211 ExportTransformedMeshInstance(dynamic_cast<TransformedMeshInstance *>(object));212 break;213 case Intersectable::VIEW_CELL:214 ExportViewCell((ViewCell *)object);215 break;216 default:217 cerr << "Sorry the export for object not yet defined" << endl;218 break;219 }220 }221 222 223 void224 X3dExporter::ExportMeshInstance(MeshInstance *object)225 {226 // $$JB$$227 // in the future check whether the mesh was not already exported228 // and use a reference to the that mesh instead229 ExportMesh(object->GetMesh());230 }231 232 233 void234 X3dExporter::ExportTransformedMeshInstance(TransformedMeshInstance *mi)235 {236 Mesh mesh(*mi->GetMesh());237 238 Matrix4x4 m;239 mi->GetWorldTransform(m);240 mesh.ApplyTransformation(m);241 242 ExportMesh(&mesh);243 }244 245 246 void247 X3dExporter::ExportViewCells(const ViewCellContainer &viewCells)248 {249 ViewCellContainer::const_iterator it, it_end = viewCells.end();250 251 for (it = viewCells.begin(); it != it_end; ++ it)252 ExportViewCell(*it);253 }254 202 255 203 … … 303 251 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 304 252 } 305 306 253 ExportPolygons(cell->GetPolys()); 307 } 308 254 } 309 255 DEL_PTR(cell); 310 256 } … … 315 261 { 316 262 if (viewCell->GetMesh()) 263 { 317 264 ExportMesh(viewCell->GetMesh()); 265 } 318 266 } 319 267 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.h
r1221 r1344 81 81 82 82 virtual void 83 ExportMeshInstance(MeshInstance *mi);84 85 virtual void86 ExportTransformedMeshInstance(TransformedMeshInstance *mi);87 88 virtual void89 ExportIntersectable(Intersectable *object);90 91 virtual void92 83 ExportMesh(Mesh *mesh); 93 84 94 85 virtual void 95 86 ExportViewCell(ViewCell *viewCell); 96 97 virtual void98 ExportViewCells(const ViewCellContainer &viewCells);99 87 100 88 virtual void … … 105 93 const float length=1000, 106 94 const RgbColor &color = RgbColor(1,1,1)); 95 107 96 bool 108 97 ExportRays(const VssRayContainer &rays, … … 121 110 ExportBspLeaves(const BspTree &tree, const int maxPvs = 0); 122 111 123 124 112 virtual void 125 113 ExportBspSplits(const VspBspTree &tree, const bool exportDepth); … … 132 120 133 121 protected: 134 135 122 136 123 virtual void -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1281 r1344 649 649 /*******************+*****************************************************/ 650 650 651 X3dParser::X3dParser(): 652 mViewCellHeight(DEFAULT_VIEWCELL_HEIGHT) 651 X3dParser::X3dParser(): mViewCellHeight(DEFAULT_VIEWCELL_HEIGHT) 653 652 {} 653 654 654 655 655 bool 656 656 X3dParser::ParseFile(const string filename, 657 SceneGraphNode * *root,657 SceneGraphNode *root, 658 658 const bool loadPolygonsAsMeshes, 659 659 vector<FaceParentInfo> *parents) … … 689 689 // to do. 690 690 // 691 *root = new SceneGraphNode; 692 X3dParseHandlers handler(*root, loadPolygonsAsMeshes); 691 X3dParseHandlers handler(root, loadPolygonsAsMeshes); 693 692 parser->setDocumentHandler(&handler); 694 693 parser->setErrorHandler(&handler); -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h
r1281 r1344 17 17 bool ParseFile( 18 18 const string filename, 19 SceneGraphNode * *root,19 SceneGraphNode *root, 20 20 const bool loadPolygonsAsMeshes = false, 21 21 vector<FaceParentInfo> *parents = NULL); -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1328 r1344 214 214 exit(1); 215 215 } 216 cout << "here3.9" << endl; 216 217 217 //-- build kd tree from scene geometry 218 218 preprocessor->BuildKdTree(); 219 219 preprocessor->KdTreeStatistics(cout); 220 cout << "here3" << endl; 220 221 221 /*preprocessor->mKdTree->ExportBinTree("kd.bin.gz"); 222 222 MeshManager::GetSingleton()->ExportEntries("meshes.bin"); … … 242 242 243 243 DEL_PTR(kdTree2); 244 */ cout << "here4" << endl;244 */ 245 245 // parse view cells related options 246 246 preprocessor->PrepareViewCells(); … … 251 251 preprocessor->Export(filename + "-kdtree.x3d", false, true, false); 252 252 } 253 cout << "here5" << endl; 253 254 254 // create a preprocessor thread (note: capsulates calls to boost fuctions!) 255 255 //PreprocessorThread *pt = PreprocessorThreadFactory::Create(preprocessor); … … 260 260 bool guiSupported = false; 261 261 if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 262 262 { 263 263 cout << "using gl widget" << endl; 264 264 // create and run the preprocessor application in a parallel thread … … 267 267 #endif 268 268 //pt.RunThread(); 269 269 270 270 // display the render widget 271 if (!rendererWidget) {272 271 if (!rendererWidget) 272 { 273 273 #if !USE_QT 274 274 guiSupported = LoadMyDll(); 275 275 #else 276 277 278 276 rendererWidget = new QtGlRendererWidget(preprocessor->mSceneGraph, 277 preprocessor->mViewCellsManager, 278 preprocessor->mKdTree); 279 279 #endif 280 280 } 281 282 281 282 } 283 283 284 284 if (!guiSupported) {
Note: See TracChangeset
for help on using the changeset viewer.