- Timestamp:
- 10/05/05 18:36:16 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r309 r310 14 14 # filename ../data/soda/soda.dat 15 15 # filename ../data/soda/soda5.dat 16 # viewcells ../data/atlanta/atlanta_viewcells_large.x3d17 # viewcells ../data/atlanta/atlanta_viewcells_large2.x3d18 viewcells ../data/vienna/viewcells-25-sel.x3d19 # viewcells ../data/vienna/viewcells-25.x3d20 # viewcells ../data/vienna/viewcells-large-sel.x3d21 16 } 22 17 … … 63 58 totalSamples 1000000 64 59 samplesPerPass 5 65 viewCells BSP66 #viewCells KD67 60 } 68 61 62 ViewCells { 63 hierarchyType bspTree 64 #hierarchyType kdTree 65 #hierarchyType sceneDependent 66 # filename ../data/atlanta/atlanta_viewcells_large.x3d 67 # filename ../data/atlanta/atlanta_viewcells_large2.x3d 68 filename ../data/vienna/viewcells-25-sel.x3d 69 # filename ../data/vienna/viewcells-25.x3d 70 # filename ../data/vienna/viewcells-large-sel.x3d 71 } 69 72 70 73 BspTree { 74 # constructionMethod fromRays 75 constructionMethod fromViewCells 76 # constructionMethod fromSceneGeometry 77 71 78 # next polygon = 1 72 79 # axis aligned = 2 … … 93 100 #splitPlaneStrategy 72 94 101 95 # constructionMethod rays96 constructionMethod viewCells97 # constructionMethod sceneGeometry98 102 maxCandidates 50 99 103 maxViewCells 999999 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r309 r310 1068 1068 "atlanta2.x3d"); 1069 1069 1070 RegisterOption("Scene.viewcells",1071 optString,1072 "-viewcells_filename=",1073 "atlanta_viewcells_large.x3d");1074 1075 1070 RegisterOption("Unigraphics.meshGrouping", 1076 1071 optInt, … … 1109 1104 "0.1"); 1110 1105 1111 1112 1106 RegisterOption("KdTree.sahUseFaces", 1113 1107 optBool, … … 1151 1145 "1000000"); 1152 1146 1153 RegisterOption("Sampling.viewCells",1154 optString,1155 "-view_cells",1156 "BSP");1157 1158 1147 RegisterOption("Sampling.samplesPerPass", 1159 1148 optInt, … … 1161 1150 "10"); 1162 1151 1152 RegisterOption("ViewCells.type", 1153 optString, 1154 "-view_cells", 1155 "BSP"); 1156 1157 RegisterOption("ViewCells.filename", 1158 optString, 1159 "-viewcells_filename=", 1160 "atlanta_viewcells_large.x3d"); 1161 1162 1163 RegisterOption("BspTree.constructionMethod", 1164 optString, 1165 "-bsp_construction_method=", 1166 "fromViewCells"); 1167 1163 1168 RegisterOption("BspTree.Termination.maxPolygons", 1164 1169 optInt, … … 1180 1185 "-bsp_split_method=", 1181 1186 "leastSplits"); 1182 1183 RegisterOption("BspTree.constructionMethod",1184 optString,1185 "-bsp_construction_method=",1186 "viewCells");1187 1187 1188 1188 RegisterOption("BspTree.maxCandidates", -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r309 r310 30 30 } 31 31 32 bool Preprocessor::ParseViewCellsOptions() 33 { 34 // parse type of view cells 35 char viewCellsStr[64]; 36 environment->GetStringValue("ViewCells.hierarchyType", viewCellsStr); 37 38 int vcType = BSP_VIEW_CELLS; 39 40 if (strcmp(viewCellsStr, "bspTree") == 0) 41 vcType = BSP_VIEW_CELLS; 42 else if (strcmp(viewCellsStr, "kdTree") == 0) 43 vcType = KD_VIEW_CELLS; 44 else if (strcmp(viewCellsStr, "sceneDependent") == 0) 45 vcType = SCENE_DEPENDENT; 46 else 47 { 48 cerr<<"Wrong view cells type" << viewCellsStr << endl; 49 exit(1); 50 } 51 52 // decide about view cell subdivision type used for preprocessing 53 switch (vcType) 54 { 55 case BSP_VIEW_CELLS: 56 case KD_VIEW_CELLS: 57 mViewCellsType = vcType; 58 break; 59 case SCENE_DEPENDENT: 60 mViewCellsType = BSP_VIEW_CELLS; // TODO 61 break; 62 } 63 64 return true; 65 } 66 32 67 void Preprocessor::DeleteViewCells() 33 68 { … … 108 143 switch (BspTree::sConstructionMethod) 109 144 { 110 case BspTree:: VIEW_CELLS:145 case BspTree::FROM_INPUT_VIEW_CELLS: 111 146 mBspTree->Construct(mViewCells); 112 147 break; 113 case BspTree:: SCENE_GEOMETRY:148 case BspTree::FROM_SCENE_GEOMETRY: 114 149 DeleteViewCells(); // we generate new view cells 115 150 mSceneGraph->CollectObjects(&objects); 116 151 mBspTree->Construct(objects, &mViewCells); 117 152 break; 118 case BspTree:: RAYS:153 case BspTree::FROM_RAYS: 119 154 DeleteViewCells(); // we generate new view cells 120 155 mBspTree->Construct(rays, &mViewCells); … … 126 161 return true; 127 162 } 163 128 164 129 165 … … 169 205 return false; 170 206 } 171 172 173 -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r309 r310 92 92 void DeleteViewCells(); 93 93 94 /** Parses the view cell options 95 */ 96 bool ParseViewCellsOptions(); 97 94 98 /// scene graph loaded from file 95 99 SceneGraph *mSceneGraph; … … 111 115 ViewCell *mRootViewCell; 112 116 113 enum {BSP_VIEW_CELLS, KD_VIEW_CELLS}; 117 /// view cell hierarchy types 118 enum {BSP_VIEW_CELLS, KD_VIEW_CELLS, SCENE_DEPENDENT}; 114 119 120 /// type of the view cells 115 121 int mViewCellsType; 116 122 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.cpp
r308 r310 4 4 #include "Intersectable.h" 5 5 6 7 /* 8 int mypvs::AddSample(T *sample) 9 { 10 int result; 11 12 PvsData<typename T> *data = Find(sample); 13 if (data) { 14 data->mVisibleSamples++; 15 result = 0; 16 } else { 17 mEntries[node] = PvsData<typename T>(1); 18 result = 1; 19 } 20 return result; 21 } 22 23 24 25 */ 6 26 KdPvsData * 7 27 KdPvs::Find(KdNode *node) -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r308 r310 8 8 class Ray; 9 9 class Intersectable; 10 11 12 template<typename T> 13 struct LtSample { 14 bool operator()(const T *a, const T *b) const 15 { 16 return a < b; 17 } 18 }; 19 20 //typedef std::map<T *, PvsData<T>, LtSample<T>> PvsMap<T>; 21 22 template<typename T> 23 struct PvsData { 24 int mVisibleSamples; 25 PvsData<T>() {} 26 PvsData<T>(const int samples):mVisibleSamples(samples) {} 27 }; 28 29 template<typename T> 30 class mypvs 31 { 32 public: 33 mypvs(): mSamples(0), mEntries() {} 34 int mSamples; 35 36 //int Compress() {return 0;} 37 int GetSize() {return (int)mEntries.size();} 38 39 PvsData<T> *Find(T sample); 40 int AddSample(T sample); 41 42 void GetData(const int index, 43 T &entry, 44 PvsData<T> &data); 45 std::map<T, PvsData<T>, LtSample<T> > mEntries; 46 }; 47 48 49 template <typename T> 50 PvsData<T> *mypvs<T>::Find(T sample) 51 { 52 /*std::map<T *, PvsData<T>, LtSample<T> >::iterator i = mEntries.find(sample); 53 if (i != mEntries.end()) { 54 return &(*i).second; 55 } else*/ 56 return NULL; 57 } 58 59 template <typename T> 60 void mypvs<T>::GetData(const int index, 61 T &entry, 62 PvsData<T> &data) 63 { 64 /*PvsMap<typename T>::iterator i = mEntries.begin(); 65 for (int k = 0; k != index && i != mEntries.end(); i++, k++); 66 67 entry = (*i).first; 68 data = (*i).second;*/ 69 } 10 70 11 71 struct LtKdNode -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r309 r310 14 14 environment->GetIntValue("Sampling.totalSamples", mTotalSamples); 15 15 16 char viewCellsStr[64];17 environment->GetStringValue("Sampling.viewCells", viewCellsStr);18 19 mViewCellsType = BSP_VIEW_CELLS;20 21 if (strcmp(viewCellsStr, "BSP") == 0)22 mViewCellsType = BSP_VIEW_CELLS;23 else if (strcmp(viewCellsStr, "KD") == 0)24 mViewCellsType= KD_VIEW_CELLS;25 else26 {27 cerr<<"Wrong view cells type" << viewCellsStr << endl;28 exit(1);29 }30 31 16 mKdPvsDepth = 100; 32 17 mStats.open("stats.log"); … … 117 102 int sampleContributions = 0; 118 103 119 if (mViewCellsType == KD_VIEW_CELLS) 104 if (mViewCellsType == BSP_VIEW_CELLS) 105 { 106 // cast ray to KD tree to find intersection with other objects 107 mKdTree->CastRay(ray); 108 109 // cast ray to BSP tree to get intersection with view cells 110 mBspTree->CastRay(ray); 111 112 sampleContributions += sampleContributions += AddObjectSamples(object, ray); 113 114 if (ray.intersections.size() > 0) // view cell found 115 { 116 if (ray.intersections.size()) 117 sampleContributions += AddObjectSamples(ray.intersections[0].mObject, ray); 118 } 119 } 120 else 120 121 { 121 122 mKdTree->CastRay(ray); … … 128 129 } 129 130 } 130 } else 131 { 132 mBspTree->CastRay(ray); 133 134 if (ray.viewCells.size() > 0) // view cell found 135 { 136 sampleContributions += sampleContributions += AddObjectSamples(object, ray); 131 } 137 132 138 // cast ray to KD tree to find intersections with other objects139 mKdTree->CastRay(ray);140 141 if (ray.intersections.size())142 sampleContributions += AddObjectSamples(ray.intersections[0].mObject, ray);143 }144 }145 146 133 return sampleContributions; 147 134 } … … 251 238 int passSamples = 0; 252 239 int index = 0; 253 Debug << "************************************" << endl; 254 240 255 241 for (i = 0; i < objects.size(); i++) { 256 242 KdNode *nodeToSample = NULL; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r308 r310 45 45 void AddPassingRay(const Ray &ray, const int contributions); 46 46 47 static bool ParseEnvironment(); 48 49 47 50 protected: 48 51 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r309 r310 17 17 int BspTree::sMaxCandidates = 10; 18 18 int BspTree::sSplitPlaneStrategy = NEXT_POLYGON; 19 int BspTree::sConstructionMethod = VIEW_CELLS;19 int BspTree::sConstructionMethod = FROM_INPUT_VIEW_CELLS; 20 20 int BspTree::sTermMaxPolysForAxisAligned = 50; 21 21 … … 263 263 mStoreSplitPolys(false) 264 264 { 265 mypvs<BspNode *> testpvs; testpvs.Find(mRoot); 265 266 Randomize(); // initialise random generator for heuristics 266 267 } … … 1059 1060 void BspTree::ParseEnvironment() 1060 1061 { 1062 //-- parse bsp cell tree construction method 1063 char constructionMethodStr[60]; 1064 1065 environment->GetStringValue("BspTree.constructionMethod", constructionMethodStr); 1066 1067 sConstructionMethod = FROM_INPUT_VIEW_CELLS; 1068 1069 if (strcmp(constructionMethodStr, "fromViewCells") == 0) 1070 sConstructionMethod = FROM_INPUT_VIEW_CELLS; 1071 else if (strcmp(constructionMethodStr, "fromSceneGeometry") == 0) 1072 sConstructionMethod = FROM_SCENE_GEOMETRY; 1073 else if (strcmp(constructionMethodStr, "fromRays") == 0) 1074 sConstructionMethod = FROM_RAYS; 1075 else 1076 { 1077 cerr << "Wrong construction method " << constructionMethodStr << endl; 1078 exit(1); 1079 } 1080 1081 Debug << "Construction method: " << constructionMethodStr << endl; 1082 1061 1083 environment->GetIntValue("BspTree.Termination.maxDepth", sTermMaxDepth); 1062 1084 environment->GetIntValue("BspTree.Termination.maxPolygons", sTermMaxPolygons); … … 1092 1114 1093 1115 Debug << endl; 1094 1095 //-- parse BSP tree construction method1096 char constructionMethodStr[60];1097 1098 environment->GetStringValue("BspTree.constructionMethod", constructionMethodStr);1099 1100 sConstructionMethod = BspTree::VIEW_CELLS;1101 1102 if (strcmp(constructionMethodStr, "viewCells") == 0)1103 sConstructionMethod = BspTree::VIEW_CELLS;1104 else if (strcmp(constructionMethodStr, "sceneGeometry") == 0)1105 sConstructionMethod = BspTree::SCENE_GEOMETRY;1106 else if (strcmp(constructionMethodStr, "rays") == 0)1107 sConstructionMethod = BspTree::RAYS;1108 else1109 {1110 cerr << "Wrong bsp construction method " << constructionMethodStr << endl;1111 exit(1);1112 }1113 1114 Debug << "Construction method: " << constructionMethodStr << endl;1115 1116 } 1116 1117 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r308 r310 244 244 }; 245 245 246 /** Implementation of the ViewCell BSP tree. */ 246 /** Implementation of the view cell BSP tree. 247 */ 247 248 class BspTree 248 249 { … … 271 272 typedef std::stack<BspTraversalData> BspTraversalStack; 272 273 273 /// BSP tree construction type274 enum {VIEW_CELLS, SCENE_GEOMETRY, RAYS};275 276 274 /** Default constructor creating an empty tree. 277 275 @param viewCell view cell corresponding to unbounded space … … 335 333 int CastRay(Ray &ray); 336 334 337 //static bool displayDebug; 335 /// bsp tree construction types 336 enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_RAYS}; 337 338 338 protected: 339 339 -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r309 r310 9 9 #include "Exporter.h" 10 10 #include "X3dExporter.h" // delete later 11 #include "ViewCell.h" 11 12 12 13 #define USE_EXE_PATH false … … 33 34 p->BuildKdTree(); 34 35 p->KdTreeStatistics(cout); 35 36 37 // parse view cell hierarchy options 38 p->ParseViewCellsOptions(); 36 39 37 40 if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS) 38 41 { 39 // if BSP tree construction method needs predefined view cells 40 if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS) 42 if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) 41 43 { 42 environment->GetStringValue("Scene.viewcells", buff);43 44 // view cells input file name 45 environment->GetStringValue("ViewCells.filename", buff); 44 46 string vcFilename(buff); 45 47 46 48 if (vcFilename != "") 47 49 p->LoadViewCells(vcFilename); 48 50 else 49 51 p->GenerateViewCells(); 50 52 51 53 Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl; 52 54 } 55 56 p->BuildBspTree(); 53 57 54 p->BuildBspTree();55 58 p->BspTreeStatistics(Debug); 56 59 p->Export("vc_bsptree2.x3d", false, false, true);
Note: See TracChangeset
for help on using the changeset viewer.