Changeset 1221 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 08/18/06 19:28:12 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 2 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
r1184 r1221 61 61 <Tool 62 62 Name="VCCLCompilerTool" 63 Optimization="0" 63 64 InlineFunctionExpansion="0" 64 65 FavorSizeOrSpeed="0" 65 66 OptimizeForWindowsApplication="TRUE" 66 AdditionalIncludeDirectories="..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;"$(BOOST_INCLUDE)" "67 PreprocessorDefinitions="WIN32;NDEBUG;_LIB ;"67 AdditionalIncludeDirectories="..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;"$(BOOST_INCLUDE)";..\..\Preprocessing\MultiLevelRayTracing" 68 PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 68 69 ExceptionHandling="TRUE" 69 70 RuntimeLibrary="2" … … 245 246 </File> 246 247 <File 248 RelativePath="..\src\ObjParser.cpp"> 249 </File> 250 <File 251 RelativePath="..\src\ObjParser.h"> 252 </File> 253 <File 247 254 RelativePath="..\src\OcclusionQuery.cpp"> 248 255 </File> … … 459 466 </File> 460 467 <File 468 RelativePath="..\src\VssRay.cpp"> 469 </File> 470 <File 461 471 RelativePath="..\src\VssRay.h"> 462 472 </File> … … 535 545 <File 536 546 RelativePath="..\src\Renderer.h"> 537 </File>538 <File539 RelativePath="..\src\VssRay.cpp">540 547 </File> 541 548 </Filter> -
GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj
r1163 r1221 70 70 <Tool 71 71 Name="VCCLCompilerTool" 72 AdditionalIncludeDirectories="..\include;"$(BOOST_INCLUDE)";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 72 Optimization="0" 73 AdditionalIncludeDirectories="..\include;"$(BOOST_INCLUDE)";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing" 73 74 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 74 75 RuntimeLibrary="2" … … 82 83 <Tool 83 84 Name="VCLinkerTool" 84 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib "85 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib RTWorld.lib RTScene.lib" 85 86 OutputFile="$(OutDir)/Preprocessor.exe" 86 87 LinkIncremental="1" 87 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;..\include;..\src\GL;"$(CG_LIB_PATH)";..\lib\release;..\..\Preprocessing\lib\release;"$(BOOST_LIB)";..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib "88 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;..\include;..\src\GL;"$(CG_LIB_PATH)";..\lib\release;..\..\Preprocessing\lib\release;"$(BOOST_LIB)";..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\..\Preprocessing\MultiLevelRayTracing\RTScene\Release;..\..\Preprocessing\MultiLevelRayTracing\RTWorld\Release" 88 89 GenerateDebugInformation="FALSE" 89 90 SubSystem="1" -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1199 r1221 1093 1093 "atlanta2.x3d"); 1094 1094 1095 1096 1095 RegisterOption("Unigraphics.meshGrouping", 1097 1096 optInt, … … 1099 1098 "0"); 1100 1099 1100 RegisterOption("ObjParser.meshGrouping", 1101 optInt, 1102 "objparser_mesh_grouping=", 1103 "0"); 1101 1104 1102 1105 RegisterOption("KdTree.Termination.minCost", … … 1737 1740 "1000"); 1738 1741 1742 RegisterOption("Preprocessor.rayCastMethod", 1743 optInt, 1744 "preprocessor_ray_cast_method=", 1745 "0"); 1746 1739 1747 RegisterOption("Preprocessor.histogram.intervals", 1740 1748 optInt, -
GTP/trunk/Lib/Vis/Preprocessing/src/Parser.h
r1020 r1221 3 3 4 4 #include <string> 5 #include <vector> 6 5 7 6 8 namespace GtpVisibilityPreprocessor { 7 9 8 10 class SceneGraphNode; 9 11 class Intersectable; 10 12 11 13 … … 17 19 virtual bool ParseFile(const std::string filename, 18 20 SceneGraphNode **root, 19 const bool loadPolygonsAsMeshes = false) 21 const bool loadPolygonsAsMeshes = false, 22 std::vector<Intersectable *> *parents = NULL) 20 23 {return false;}; 21 24 -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.cpp
r863 r1221 260 260 PlyParser::ParseFile(const string filename, 261 261 SceneGraphNode **root, 262 const bool loadPolygonsAsMeshes) 262 const bool loadPolygonsAsMeshes, 263 vector<Intersectable *> *parents) 263 264 { 264 265 vector<string> filelist; -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.h
r863 r1221 16 16 bool ParseFile(const string filename, 17 17 SceneGraphNode **root, 18 const bool loadPolygonsAsMeshes = false); 18 const bool loadPolygonsAsMeshes = false, 19 vector<Intersectable *> *parents = NULL); 19 20 20 21 bool ParseFile(const string filename, ViewCellsManager &viewCells) { return false; } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1201 r1221 14 14 #include "SamplingStrategy.h" 15 15 #include "VspOspTree.h" 16 16 #include "ObjParser.h" 17 #include "ArchModeler2MLRT.hxx" 17 18 18 19 … … 93 94 scene->mRoot->UpdateBox(); 94 95 } 95 96 // plane separating view space regions 96 97 97 if (1) 98 98 { 99 // plane separating view space regions 99 100 const Vector3 scale(1.0f, 0.0, 0); 100 101 … … 133 134 Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 134 135 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportVisibility", mExportVisibility ); 136 Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", mRayCastMethod); 135 137 136 138 char buffer[256]; … … 220 222 if (strstr(filename.c_str(), ".ply") || strstr(filename.c_str(), ".plb")) 221 223 parser = new PlyParser; 222 else 223 parser = new UnigraphicsParser; 224 else if (strstr(filename.c_str(), ".obj")) 225 parser = new ObjParser; 226 else 227 parser = new UnigraphicsParser; 224 228 225 229 cout<<filename<<endl; 226 result = parser->ParseFile(filename, &mSceneGraph->mRoot, mLoadPolygonsAsMeshes); 230 231 if (mRayCastMethod == Preprocessor::INTEL_RAYCASTER) 232 result = parser->ParseFile(filename, &mSceneGraph->mRoot, mLoadPolygonsAsMeshes, &mFaceParents); 233 else 234 result = parser->ParseFile(filename, &mSceneGraph->mRoot, mLoadPolygonsAsMeshes); 227 235 228 236 delete parser; … … 234 242 if (strstr(filenames[i].c_str(), ".x3d")) 235 243 parser = new X3dParser; 236 else 244 else 237 245 parser = new UnigraphicsParser; 238 246 239 247 SceneGraphNode *node; 240 248 if (parser->ParseFile(filenames[i], &node)) { … … 736 744 return NULL; 737 745 } 746 738 747 // should never come here 739 748 return NULL; … … 741 750 742 751 743 } 752 bool Preprocessor::InitRayCast(const string externKdTree) 753 { 754 switch (mRayCastMethod) // use intel ray tracing 755 { 756 case INTEL_RAYCASTER: 757 return mlrtaLoadAS(externKdTree.c_str()); 758 case INTERNAL_RAYCASTER: 759 default: 760 break; 761 } 762 763 return true; 764 } 765 766 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1197 r1221 26 26 class VspTree; 27 27 class OspTree; 28 class Intersectable; 28 29 29 30 /** Namespace for the external visibility preprocessor … … 131 132 }; 132 133 134 enum { 135 INTERNAL_RAYCASTER, 136 INTEL_RAYCASTER 137 }; 138 133 139 virtual bool 134 140 GenerateRays( … … 144 150 */ 145 151 ViewCellsManager *CreateViewCellsManager(const char *name); 152 153 154 GlRendererBuffer *GetRenderer() { return renderer;} 155 156 bool InitRayCast(const string externKdTree); 157 158 //////////////////////////////////////////////// 146 159 147 160 /// scene graph loaded from file … … 192 205 193 206 float mVisibilityFilterWidth; 194 195 GlRendererBuffer *GetRenderer() { return renderer;} 196 207 208 int GetRayCastMethod() { return mRayCastMethod; } 209 void SetRayCastMethod(int rayCastMethod) { mRayCastMethod = rayCastMethod; } 210 197 211 protected: 198 212 199 213 ///////////////////////// 200 214 215 int mRayCastMethod; 201 216 /// samples used for construction of the BSP view cells tree. 202 217 int mBspConstructionSamples; … … 207 222 RenderSimulator *mRenderSimulator; 208 223 224 vector<Intersectable *> mFaceParents; 209 225 GlRendererBuffer *renderer; 210 226 // matt: remove qt dependencies -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r1199 r1221 11 11 12 12 13 13 14 namespace GtpVisibilityPreprocessor { 14 15 … … 35 36 ) 36 37 { 37 38 //float *pforg; 39 //float *pfdir; 40 //mlrtaStoreRayAS4(pforg, pfdir, 4); 41 ////////////////////////////////// 38 42 static Ray ray; 39 43 AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.h
r1199 r1221 13 13 14 14 /** Sampling based visibility preprocessing. The implementation is based on heuristical 15 sampling of view space */ 15 sampling of view space 16 */ 16 17 class SamplingPreprocessor : public Preprocessor { 17 18 public: -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r1076 r1221 44 44 UnigraphicsParser::ParseFile(const string filename, 45 45 SceneGraphNode **proot, 46 const bool loadPolygonsAsMeshese) 46 const bool loadPolygonsAsMeshes, 47 vector<Intersectable *> *parents) 47 48 { 48 49 map<string, Vector3, ltstr> vht; // hash table for vectors -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.h
r1001 r1221 17 17 virtual bool ParseFile(const std::string filename, 18 18 SceneGraphNode **root, 19 const bool loadPolygonsAsMeshes = false); 19 const bool loadPolygonsAsMeshes = false, 20 vector<Intersectable *> *parents = NULL); 20 21 21 22 }; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1201 r1221 32 32 myless<vector<ViewCell *>::value_type> > TraversalQueue; 33 33 34 int ViewCell::sMailId = 21843194198;34 int ViewCell::sMailId = 0;//21843194198; 35 35 int ViewCell::sReservedMailboxes = 1; 36 36 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1201 r1221 239 239 } 240 240 241 AxisAlignedBox3 242 ViewCellsManager::GetViewCellBox(ViewCell *vc)241 242 AxisAlignedBox3 ViewCellsManager::GetViewCellBox(ViewCell *vc) 243 243 { 244 244 Mesh *m = vc->GetMesh(); … … 349 349 SimpleRayContainer simpleRays; 350 350 351 mPreprocessor->GenerateRays(samplesPerPass, 352 sampleType, 353 simpleRays); 351 const long startTime = GetTime(); 352 353 mPreprocessor->GenerateRays(samplesPerPass, sampleType, simpleRays); 354 355 Debug << "generated " << mInitialSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 354 356 355 357 // shoot simple ray and add it to importance samples 356 358 mPreprocessor->CastRays(simpleRays, passSamples); 359 360 Debug << "cast " << mInitialSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 357 361 358 362 return (int)passSamples.size(); 359 363 } 360 361 364 362 365 … … 408 411 409 412 //-- construction rays => we use uniform samples for this 410 CastPassSamples(mInitialSamples, 411 mSamplingType, 412 initialSamples); 413 414 cout << "finished" << endl; 413 CastPassSamples(mInitialSamples, mSamplingType, initialSamples); 414 415 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 415 416 416 417 … … 677 678 ViewCellsManager *vm = NULL; 678 679 679 if (parser.Parse File(filename, &vm, objects, bconverter))680 if (parser.ParseViewCellsFile(filename, &vm, objects, bconverter)) 680 681 { 681 682 long startTime = GetTime(); … … 3672 3673 3673 3674 if (1) 3675 { 3674 3676 mVspBspTree->Construct(constructionRays, &mViewSpaceBox); 3677 } 3675 3678 else 3679 { 3676 3680 mVspBspTree->Construct(rays, &mViewSpaceBox); 3681 } 3677 3682 3678 3683 // collapse invalid regions … … 3685 3690 cout << "finished" << endl; 3686 3691 3687 //-- stats 3692 //-- stats after construction 3693 3688 3694 Debug << mVspBspTree->GetStatistics() << endl; 3689 3695 … … 5798 5804 Debug << "compute new statistics ... "; 5799 5805 5800 // --propagate pvs or pvs size information5806 // propagate pvs or pvs size information 5801 5807 ObjectPvs pvs; 5802 5808 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 5803 5809 5804 //-- output stats 5805 5806 sprintf(s, "-%09d-eval.log", castSamples); 5807 string fileName = string(statsPrefix) + string(s); 5808 5809 ViewCellContainer leaves; 5810 5811 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 5810 5811 //-- test render cost 5812 5813 sprintf(s, "-%09d-eval.log", castSamples); 5814 string fileName = string(statsPrefix) + string(s); 5815 5816 ViewCellContainer leaves; 5817 5818 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 5812 5819 float rc = 0; 5813 ViewCellContainer::const_iterator vit, vit_end = leaves.end(); 5814 for (vit = leaves.begin(); vit != vit_end; ++ vit) 5815 { 5816 ViewCell *vc = *vit; 5817 5820 ViewCellContainer::const_iterator vit, vit_end = leaves.end(); 5821 for (vit = leaves.begin(); vit != vit_end; ++ vit) 5822 { 5823 ViewCell *vc = *vit; 5818 5824 int pvs = vc->GetPvs().CountObjectsInPvs(); 5819 5820 5825 float vol = vc->GetVolume(); 5826 rc += pvs * vol; 5821 5827 5822 5828 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1201 r1221 964 964 965 965 966 bool ViewCellsParser::Parse File(const string filename,967 ViewCellsManager **viewCells,968 ObjectContainer *objects,969 BoundingBoxConverter *bconverter)966 bool ViewCellsParser::ParseViewCellsFile(const string filename, 967 ViewCellsManager **viewCells, 968 ObjectContainer *objects, 969 BoundingBoxConverter *bconverter) 970 970 { 971 971 // Initialize the XML4C system -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h
r1004 r1221 18 18 19 19 //bool ParseFile(const string filename, ViewCellsManager &viewCells); 20 bool Parse File(const string filename,21 22 ObjectContainer *objectsm,23 20 bool ParseViewCellsFile(const string filename, 21 ViewCellsManager **viewCells, 22 ObjectContainer *objects, 23 BoundingBoxConverter *bconverter); 24 24 }; 25 25 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1201 r1221 581 581 582 582 583 bool VspTree::LocalTerminationCriteriaMet(const VspTraversalData &data) const583 inline bool VspTree::LocalTerminationCriteriaMet(const VspTraversalData &data) const 584 584 { 585 585 const bool localTerminationCriteriaMet = ( … … 606 606 607 607 608 bool VspTree::GlobalTerminationCriteriaMet(const VspTraversalData &data) const608 inline bool VspTree::GlobalTerminationCriteriaMet(const VspTraversalData &data) const 609 609 { 610 610 const bool terminationCriteriaMet = ( … … 2931 2931 2932 2932 2933 void VspTree::GetViewCells( VssRay &ray, ViewCellContainer &viewCells)2934 { 2935 mViewCellsManager->ComputeSampleContribution(ray, false, true);2933 void VspTree::GetViewCells(const VssRay &ray, ViewCellContainer &viewCells) 2934 { 2935 /*mViewCellsManager->ComputeSampleContribution(ray, false, true); 2936 2936 viewCells = ray.mViewCells; 2937 2937 ray.mViewCells.clear(); 2938 /*2938 */ 2939 2939 static Ray hray; 2940 2940 hray.Init(ray); … … 2951 2951 2952 2952 // if no precomputation of view cells 2953 CastLineSegment(origin, termination, viewCells); */2953 CastLineSegment(origin, termination, viewCells); 2954 2954 } 2955 2955 … … 3368 3368 3369 3369 3370 bool OspTree::LocalTerminationCriteriaMet(const OspTraversalData &data) const3370 inline bool OspTree::LocalTerminationCriteriaMet(const OspTraversalData &data) const 3371 3371 { 3372 3372 // matt: TODO … … 3379 3379 3380 3380 3381 bool OspTree::GlobalTerminationCriteriaMet(const OspTraversalData &data) const3381 inline bool OspTree::GlobalTerminationCriteriaMet(const OspTraversalData &data) const 3382 3382 { 3383 3383 // matt: TODO … … 3537 3537 { 3538 3538 float currentPos; 3539 Debug << "here29 : " << minRenderCost / viewSpaceVol << endl;3539 //Debug << "here29 : " << minRenderCost / viewSpaceVol << endl; 3540 3540 3541 3541 // HACK: current positition is BETWEEN visibility events … … 3677 3677 // collect view cells and set mail + counter 3678 3678 ViewCellContainer viewCells; 3679 mVspTree->GetViewCells( VssRay(ray), viewCells);3679 mVspTree->GetViewCells(ray, viewCells); 3680 3680 3681 3681 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); … … 3798 3798 3799 3799 3800 void OspTree::EvalRayContribution(KdLeaf *leaf, 3801 const VssRay &ray, 3802 float &renderCost) 3800 void OspTree::EvalRayContribution(KdLeaf *leaf, const VssRay &ray, float &renderCost) 3803 3801 { 3804 3802 ViewCellContainer viewCells; 3805 3803 3806 mVspTree->GetViewCells( VssRay(ray), viewCells);3804 mVspTree->GetViewCells(ray, viewCells); 3807 3805 3808 3806 // classify view cells and compute volume contri accordingly … … 3994 3992 plane.mPosition = nPosition[bestAxis]; 3995 3993 3996 pFront = nProbFront[bestAxis];3997 pBack = nProbBack[bestAxis];3994 //pFront = nProbFront[bestAxis]; 3995 //pBack = nProbBack[bestAxis]; 3998 3996 3999 3997 Debug << "val: " << nCostRatio[bestAxis] << " axis: " << bestAxis << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1201 r1221 774 774 or by recomputation. 775 775 */ 776 void GetViewCells( VssRay &ray, ViewCellContainer &viewCells);776 void GetViewCells(const VssRay &ray, ViewCellContainer &viewCells); 777 777 778 778 … … 1001 1001 /** Returns true if tree can be terminated. 1002 1002 */ 1003 inlinebool LocalTerminationCriteriaMet(const VspTraversalData &data) const;1003 /*inline*/ bool LocalTerminationCriteriaMet(const VspTraversalData &data) const; 1004 1004 1005 1005 /** Returns true if global tree can be terminated. 1006 1006 */ 1007 inlinebool GlobalTerminationCriteriaMet(const VspTraversalData &data) const;1007 /*inline*/ bool GlobalTerminationCriteriaMet(const VspTraversalData &data) const; 1008 1008 1009 1009 /** Adds ray sample contributions to the PVS. … … 1587 1587 1588 1588 */ 1589 void UpdateObjPvsContri(Intersectable *obj, 1590 const int cf, 1591 float &frontPvs, 1592 float &backPvs, 1593 float &totalPvs) const; 1589 void UpdateObjPvsContri( 1590 Intersectable *obj, 1591 const int cf, 1592 float &frontPvs, 1593 float &backPvs, 1594 float &totalPvs) const; 1594 1595 1595 1596 /** Returns true if tree can be terminated. 1596 1597 */ 1597 inlinebool LocalTerminationCriteriaMet(const OspTraversalData &data) const;1598 /*inline*/ bool LocalTerminationCriteriaMet(const OspTraversalData &data) const; 1598 1599 1599 1600 /** Returns true if global tree can be terminated. 1600 1601 */ 1601 inlinebool GlobalTerminationCriteriaMet(const OspTraversalData &data) const;1602 /*inline*/ bool GlobalTerminationCriteriaMet(const OspTraversalData &data) const; 1602 1603 1603 1604 float SelectSplitPlane(const OspTraversalData &tData, -
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 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.h
r860 r1221 66 66 int 67 67 CastRay( 68 Vector3 &viewPoint,69 Vector3 &direction,70 VssRayContainer &vssRays 71 68 const Vector3 &viewPoint, 69 const Vector3 &direction, 70 VssRayContainer &vssRays, 71 const AxisAlignedBox3 &box 72 72 ); 73 73 … … 112 112 113 113 bool mTestBeamSampling; 114 115 protected: 116 int CastInternalRay( 117 const Vector3 &viewPoint, 118 const Vector3 &direction, 119 VssRayContainer &vssRays, 120 const AxisAlignedBox3 &sbox); 121 122 int CastIntelDoubleRay( 123 const Vector3 &viewPoint, 124 const Vector3 &direction, 125 VssRayContainer &vssRays, 126 const AxisAlignedBox3 &sbox); 127 128 Intersectable *CastIntelSingleRay( 129 const Vector3 &viewPoint, 130 const Vector3 &direction, 131 Vector3 &tPoint, 132 const AxisAlignedBox3 &abox); 133 134 void CastRays16(SimpleRayContainer &rays, 135 VssRayContainer &vssRays, 136 const AxisAlignedBox3 &sbox); 114 137 }; 115 138 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h
r1133 r1221 282 282 return SqrMagnitude(diff); 283 283 } 284 284 friend ostream& operator<< (ostream &s, const VssRay &vssRay); 285 285 286 }; 286 287 … … 297 298 const float overlap 298 299 ); 300 301 // Overload << operator for C++-style output 302 inline ostream& 303 operator<< (ostream &s, const VssRay &vssRay) 304 { 305 return s 306 << "(" << vssRay.mPass << ", " << vssRay.mOrigin << ", " << vssRay.mTermination 307 << ", " << vssRay.mOriginObject << ", " << vssRay.mTerminationObject << ", " << vssRay.mPdf << ")"; 308 } 299 309 300 310 // -------------------------------------------------------------- -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.h
r1197 r1221 24 24 class VspBspTree; 25 25 class BspNode; 26 //class VspKdViewCell;27 26 class Beam; 27 28 28 29 29 class X3dExporter : public Exporter -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1112 r1221 655 655 X3dParser::ParseFile(const string filename, 656 656 SceneGraphNode **root, 657 const bool loadPolygonsAsMeshes) 657 const bool loadPolygonsAsMeshes, 658 vector<Intersectable *> *parents) 658 659 { 659 660 // Initialize the XML4C system -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h
r971 r1221 15 15 X3dParser(); 16 16 17 bool ParseFile(const string filename, SceneGraphNode **root, const bool loadPolygonsAsMeshes = false); 17 bool ParseFile( 18 const string filename, 19 SceneGraphNode **root, 20 const bool loadPolygonsAsMeshes = false, 21 vector<Intersectable *> *parents = NULL); 22 18 23 bool ParseFile(const string filename, ViewCellsManager &viewCells); 19 24 -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1201 r1221 161 161 preprocessor->LoadScene(filename); 162 162 163 //-- initialize external ray casters 164 if (preprocessor->InitRayCast("../data/grandcanyon1_RotXmin90.kdf")) 165 { 166 cout << "ray casting initialized!" << endl; 167 } 168 else 169 { 170 cout << "ray casting initialization failed" << endl; 171 exit(1); 172 } 173 163 174 //-- build kd tree from scene geometry 164 175 preprocessor->BuildKdTree(); 165 176 preprocessor->KdTreeStatistics(cout); 166 preprocessor->mKdTree->ExportBinTree("kd.bin.gz");167 177 178 /*preprocessor->mKdTree->ExportBinTree("kd.bin.gz"); 168 179 MeshManager::GetSingleton()->ExportEntries("meshes.bin"); 169 180 … … 188 199 189 200 DEL_PTR(kdTree2); 190 201 */ 191 202 // parse view cells related options 192 203 preprocessor->PrepareViewCells(); … … 209 220 // create and run the preprocessor application in a parallel thread 210 221 pt.InitThread(); 211 //pt.RunThread(); 212 222 213 223 // display the render widget 214 224 DisplayWidget();
Note: See TracChangeset
for help on using the changeset viewer.