Changeset 712 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 03/22/06 10:13:28 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r708 r712 1241 1241 RegisterOption("ViewCells.PostProcess.samples", 1242 1242 optInt, 1243 "view_cells_post process_samples=",1243 "view_cells_post_process_samples=", 1244 1244 "200000"); 1245 1245 -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r162 r712 1 1 2 2 #include "X3dExporter.h" 3 3 #include "VrmlExporter.h" 4 4 5 5 Exporter * 6 6 Exporter::GetExporter(const string filename) 7 7 { 8 Exporter *e = NULL;8 Exporter *exporter = NULL; 9 9 10 if (strstr(filename.c_str(), ".x3d")) { 11 e = new X3dExporter(filename); 12 } else { 13 cerr<<"Error: Currently unsuported export format, filename "<<filename<<endl; 10 if (strstr(filename.c_str(), ".x3d")) 11 { 12 exporter = new X3dExporter(filename); 13 } 14 else if (strstr(filename.c_str(), ".wrl")) 15 { 16 exporter = new VrmlExporter(filename); 14 17 } 15 return e; 18 else 19 { 20 cerr<<"Error: Currently unsuported export format, filename " << filename << endl; 21 } 22 23 return exporter; 16 24 } 17 25 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r694 r712 85 85 vector<string> filenames; 86 86 int files = SplitFilenames(filename, filenames); 87 cout <<files<<endl;87 cout << "number of input files: " << files << endl; 88 88 bool result = false; 89 89 if (files == 1) { -
GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorThread.cpp
r685 r712 48 48 49 49 50 cerr <<"Preprocessor main finished...\n";50 cerr << "Preprocessor main finished...\n"; 51 51 52 52 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r711 r712 16 16 #include "RssPreprocessor.h" 17 17 18 #define SAMPLE_AFTER_SUBDIVISION 1 19 #define TEST_EMPTY_VIEW_CELLS 0 18 // HACK 19 const static bool SAMPLE_AFTER_SUBDIVISION = true; 20 const static bool TEST_EMPTY_VIEW_CELLS = false; 20 21 21 22 … … 289 290 290 291 cout << "view cell construction: casting " << mInitialSamples << " initial samples ... "; 292 291 293 //-- construction rays => we use uniform samples for this 292 294 CastPassSamples(mInitialSamples, … … 319 321 if (1) // export initial view cells 320 322 { 321 cout << "exporting initial view cells (=leaves) ... "; 322 Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 323 323 const char filename[] = "view_cells.wrl"; 324 Exporter *exporter = Exporter::GetExporter(filename); 325 326 324 327 if (exporter) 325 328 { 329 cout << "exporting initial view cells (=leaves) to " << filename << " ... "; 326 330 if (mExportGeometry) 331 { 327 332 exporter->ExportGeometry(preprocessor->mObjects); 328 333 } 334 335 //exporter->SetWireframe(); 329 336 ExportViewCellsForViz(exporter); 330 337 331 338 delete exporter; 332 }333 cout << "finished" << endl;339 cout << "finished" << endl; 340 } 334 341 } 335 342 … … 340 347 bool dirSamples = (mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 341 348 349 // -- the main loop 342 350 while (numSamples < n) 343 351 { … … 362 370 363 371 // TODO: leak? 364 if ( SAMPLE_AFTER_SUBDIVISION)372 if (1 || SAMPLE_AFTER_SUBDIVISION) 365 373 ComputeSampleContributions(constructionSamples, true, false); 374 366 375 cout << "finished" << endl; 367 376 … … 606 615 neighborhood.pop_back(); 607 616 608 cout << "vc idx: " << bestViewCellIdx << endl;617 //cout << "vc idx: " << bestViewCellIdx << endl; 609 618 if (!bestViewCell || !root) 610 619 cout << "warning!!" << endl; … … 1689 1698 mColorCode = 1; 1690 1699 1691 Exporter *exporter = Exporter::GetExporter("final_view_cells. x3d");1700 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 1692 1701 1693 1702 cout << "exporting view cells after merge (pvs size) ... "; … … 3377 3386 int savedColorCode = mColorCode; 3378 3387 mColorCode = 0; 3379 Exporter *exporter = Exporter::GetExporter("final_view_cells. x3d");3388 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 3380 3389 3381 3390 if (exporter) -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r697 r712 715 715 716 716 717 int numExportRays = 2000;718 //int numExportRays = 0;717 //int numExportRays = 2000; 718 int numExportRays = 0; 719 719 720 720 if (numExportRays) { -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r706 r712 438 438 stream << "</Shape>" << endl; 439 439 } 440 440 441 441 442 void X3dExporter::ExportPolygons(const PolygonContainer &polys) … … 1138 1139 void X3dExporter::ExportGeometry(const ObjectContainer &objects) 1139 1140 { 1140 #if 1 1141 for (int j = 0; j < objects.size(); ++ j) 1142 ExportIntersectable(objects[j]); 1143 #else 1144 // hack 1141 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1142 1143 if (1) 1144 { 1145 for (oit = objects.begin(); oit != oit_end; ++ oit) 1146 { 1147 if (1) 1148 { 1149 SetForcedMaterial(RandomMaterial()); 1150 } 1151 1152 ExportIntersectable(*oit); 1153 } 1154 1155 return; 1156 } 1157 1158 // hack: all object exported as one mesh 1145 1159 PolygonContainer polys; 1146 for (int j = 0; j < objects.size(); ++ j){ 1147 polys.push_back(new Polygon3(dynamic_cast<MeshInstance *>(objects[j])->GetMesh()->mVertices)); 1160 1161 for (oit = objects.begin(); oit != oit_end; ++ oit) 1162 { 1163 polys.push_back(new Polygon3(dynamic_cast<MeshInstance *>(*oit)->GetMesh()->mVertices)); 1148 1164 } 1149 1165 1150 1166 Mesh dummyMesh; 1151 PolygonContainer::const_iterator it, it_end = polys.end(); 1152 1153 for (it = polys.begin(); it != it_end; ++ it) 1154 { 1155 (*it)->AddToMesh(dummyMesh); 1156 } 1167 PolygonContainer::const_iterator pit, pit_end = polys.end(); 1168 1169 for (pit = polys.begin(); pit != pit_end; ++ pit) 1170 { 1171 (*pit)->AddToMesh(dummyMesh); 1172 } 1173 1157 1174 ExportMesh(&dummyMesh); 1175 1158 1176 CLEAR_CONTAINER(polys); 1159 #endif1160 1177 } 1161 1178 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r703 r712 69 69 { 70 70 mCurrentNode = root; 71 // this matrix should never be removed from stack 72 //mTransformations.push(IdentityMatrix()); 71 73 } 72 74 73 75 X3dParseHandlers::~X3dParseHandlers() 74 76 { 77 if (!mTransformations.empty()) 78 cout << "error: transformation stack size: " << (int)mTransformations.size() << endl; 75 79 } 76 80 … … 86 90 if (element == "Shape") 87 91 EndShape(); 92 if (1) 93 if (element == "Transform") 94 EndTransform(); 88 95 } 89 96 … … 100 107 (*it) = rot * (*it); 101 108 } 109 } 110 111 112 void X3dParseHandlers::ApplyTransformation(Mesh *mesh, 113 const Matrix4x4 &m) const 114 { 115 VertexContainer::iterator it, it_end = mesh->mVertices.end(); 116 117 for (it = mesh->mVertices.begin(); it != it_end; ++ it) 118 { 119 (*it) = m * (*it); 120 } 121 } 122 123 124 void X3dParseHandlers::ApplyTransformations(TrafoStack trafos, Mesh *mesh) const 125 { 126 while (!trafos.empty()) 127 { 128 const Matrix4x4 m = trafos.top(); 129 trafos.pop(); 130 131 ApplyTransformation(mesh, m); 132 } 133 } 134 135 void X3dParseHandlers::StartTransform(AttributeList& attributes) 136 { 137 Matrix4x4 currentTransform = IdentityMatrix(); 138 139 const int len = attributes.getLength(); 140 141 for (int i = 0; i < len; ++ i) 142 { 143 string attrName(StrX(attributes.getName(i)).LocalForm()); 144 145 StrX attrValue(attributes.getValue(i)); 146 const char *ptr = attrValue.LocalForm(); 147 148 if (attrName == "rotation") 149 { 150 Vector3 axis; 151 float angle; 152 153 if (sscanf(ptr, "%f %f %f %f", &axis.x, &axis.y, &axis.z, &angle) == 4) 154 { 155 Matrix4x4 rot = RotationAxisMatrix(axis, angle); 156 currentTransform *= rot; 157 } 158 } 159 else if (attrName == "translation") 160 { 161 Vector3 transl; 162 163 if (sscanf(ptr, "%f %f %f %f", &transl.x, &transl.y, &transl.z) == 3) 164 { 165 Matrix4x4 tm = TranslationMatrix(transl); 166 167 currentTransform *= tm; 168 } 169 } 170 } 171 172 mTransformations.push(currentTransform); 173 } 174 175 176 void X3dParseHandlers::EndTransform() 177 { 178 mTransformations.pop(); 102 179 } 103 180 … … 125 202 126 203 mesh->mFaces.push_back(new Face(vc)); 127 if (ROTATE_SCENE) 128 RotateMesh(mesh); 204 205 // NOTE: should rather be written into trafo of mesh instance 206 ApplyTransformations(mTransformations, mesh); 207 129 208 mesh->Preprocess(); 130 209 // make an instance of this mesh … … 142 221 if (mCurrentMesh->mFaces.size()) 143 222 { 144 // HACK 145 if (ROTATE_SCENE) 146 RotateMesh(mCurrentMesh); 223 // should rather be written into the transformation 224 // of a mesh instance 225 ApplyTransformations(mTransformations, mCurrentMesh); 226 147 227 mCurrentMesh->Preprocess(); 148 228 // make an instance of this mesh … … 161 241 } 162 242 } 243 244 163 245 void 164 246 X3dParseHandlers::StartIndexedFaceSet( … … 313 395 if (element == "Material") { 314 396 StartMaterial(attributes); 397 } 398 if (1) 399 if (element == "Transform") { 400 StartTransform(attributes); 315 401 } 316 402 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h
r658 r712 7 7 #include <xercesc/sax/HandlerBase.hpp> 8 8 #include "Mesh.h" 9 #include <stack> 9 10 10 11 XERCES_CPP_NAMESPACE_USE … … 69 70 bool mLoadPolygonsAsMeshes; 70 71 72 typedef stack<Matrix4x4> TrafoStack; 73 74 // stack of accumulated transformations 75 TrafoStack mTransformations; 76 71 77 // Handlers for X3D 72 78 void … … 77 83 EndShape(); 78 84 85 void EndTransform(); 86 void StartTransform(AttributeList& attributes); 87 79 88 void 80 89 StartCoordinate( … … 85 94 AttributeList& attributes); 86 95 87 96 /// applies transformation m to this mesh 97 void ApplyTransformation(Mesh *mesh, const Matrix4x4 &m) const; 98 99 /// transforms mesh using the given transformations 100 void ApplyTransformations(TrafoStack trafos, Mesh *mesh) const; 101 102 88 103 // ----------------------------------------------------------------------- 89 104 // Handlers for the SAX ErrorHandler interface
Note: See TracChangeset
for help on using the changeset viewer.