Changeset 870 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 05/02/06 10:26:43 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r863 r870 142 142 between 0 (no overlap) and 1 (same box). 143 143 */ 144 friend inline float FactorOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &);144 friend inline float RatioOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &); 145 145 146 146 /** Includes returns true if a includes b (completely) … … 540 540 } 541 541 542 inline float FactorOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 543 { 544 const AxisAlignedBox3 isect = Intersect(box1, box2); 545 return isect.GetVolume() / box1.GetVolume(); 542 inline float RatioOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 543 { 544 // return ratio of intersection to union 545 const AxisAlignedBox3 bisect = Intersect(box1, box2); 546 const AxisAlignedBox3 bunion = Union(box1, box2); 547 548 return bisect.GetVolume() / bunion.GetVolume(); 546 549 } 547 550 -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r860 r870 49 49 50 50 virtual AxisAlignedBox3 GetBox() = 0; 51 virtual int CastRay( Ray &ray) = 0;51 virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0; 52 52 53 53 virtual bool IsConvex() = 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r863 r870 69 69 Mesh::Preprocess() 70 70 { 71 71 Cleanup(); 72 72 73 73 ComputeBoundingBox(); 74 74 75 /** true if it is a watertight convex mesh */ 76 mIsConvex = false; 77 78 if (mFaces.size() > MeshKdTree::mTermMinCost) { 79 mKdTree = new MeshKdTree(this); 80 MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 81 for (int i = 0; i < mFaces.size(); i++) 82 root->mFaces.push_back(i); 83 cout<<"KD"; 84 mKdTree->Construct(); 85 86 if (mKdTree->GetRoot()->IsLeaf()) { 87 cout<<"d"; 88 delete mKdTree; 89 mKdTree = NULL; 90 } 91 } 75 /** true if it is a watertight convex mesh 76 */ 77 mIsConvex = false; 78 79 if (mFaces.size() > MeshKdTree::mTermMinCost) 80 { 81 mKdTree = new MeshKdTree(this); 82 MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 83 84 for (int i = 0; i < mFaces.size(); i++) 85 root->mFaces.push_back(i); 86 87 cout<<"KD"; 88 mKdTree->Construct(); 89 90 if (mKdTree->GetRoot()->IsLeaf()) 91 { 92 cout<<"d"; 93 delete mKdTree; 94 mKdTree = NULL; 95 } 96 } 92 97 } 93 98 -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r863 r870 22 22 23 23 /// vertex index container 24 typedef std::vector<short> VertexIndexContainer;25 24 //typedef std::vector<short> VertexIndexContainer; 25 typedef std::vector<int> VertexIndexContainer; 26 26 27 27 /** Patch used as an element of the mesh */ … … 58 58 /// default vertex container for Mesh 59 59 typedef vector<Vector3> VertexContainer; 60 61 /// vertex index container62 typedef vector<short> VertexIndexContainer;63 60 64 61 /// default patch container for Mesh -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r863 r870 374 374 Debug << "view cell type: VspBsp" << endl; 375 375 376 mVspBspTree = new VspBspTree( );376 mVspBspTree = new VspBspTree(environment); 377 377 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 378 378 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r863 r870 2033 2033 stream << "active=\"" << viewCell->IsActive() << "\" "; 2034 2034 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 2035 stream << "pvs=\""; 2036 2037 //-- NOTE: do not export pvss for interior view cells because 2038 // they can be completely reconstructed from the leaf pvss 2039 if (0) 2040 ExportPvs(viewCell, stream); 2035 2041 2036 //-- NOTE: do not export pvss for interior view cells because2037 // they can be compeletely reconstructed from the leaf pvss2038 if (0)2039 {2040 stream << "pvs=\"";2041 ExportPvs(viewCell, stream);2042 }2043 2044 2042 stream << "\" >" << endl; 2045 2043 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r863 r870 4683 4683 ViewCellsManager *vm = NULL; 4684 4684 4685 Debug << "vc filename: " << filename << endl; 4686 4685 4687 if (parser.ParseFile(filename, &vm, objects)) 4686 4688 { … … 4699 4701 else 4700 4702 { 4701 Debug << " failed loading view cells" << endl;4703 Debug << "Error: loading view cells failed!" << endl; 4702 4704 DEL_PTR(vm); 4703 4705 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r860 r870 362 362 virtual void FinalizeViewCells(const bool createMesh); 363 363 364 365 /** Loads view cells from file. The view cells manager is created with366 respect to the loaded view cells.367 368 @returns the view cells manager if loading was successful, false otherwise369 */370 static ViewCellsManager *LoadViewCells(const string filename,371 ObjectContainer *objects);372 373 364 /** Evaluates statistics values on view cells. 374 365 */ … … 432 423 ); 433 424 434 AxisAlignedBox3 435 GetViewCellBox(ViewCell *vc); 425 /** Returns bounding box of a view cell. 426 */ 427 AxisAlignedBox3 GetViewCellBox(ViewCell *vc); 436 428 437 429 /** Exports bounding boxes of objects to file. … … 442 434 */ 443 435 bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 436 437 438 /** Loads view cells from file. The view cells manager is created with 439 respect to the loaded view cells. 440 441 @returns the view cells manager if loading was successful, false otherwise 442 */ 443 static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 444 444 445 445 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r863 r870 117 117 // go one up in the tree 118 118 if (mCurrentBspNode->GetParent()) 119 { cout<< "]";119 { Debug << "]"; 120 120 mCurrentBspNode = mCurrentBspNode->GetParent(); 121 121 } … … 127 127 // go one up in the tree 128 128 if (mCurrentViewCell->GetParent()) 129 { cout<< "]";129 { Debug << "]"; 130 130 mCurrentViewCell = mCurrentViewCell->GetParent(); 131 131 } … … 160 160 const char *ptr = attrValue.LocalForm(); 161 161 162 //-- the view cells manager is created here 162 163 CreateViewCellsManager(ptr); 163 164 } … … 171 172 if (element == "Interior") 172 173 { 173 cout<< "[";174 Debug << "["; 174 175 StartBspInterior(attributes); 175 176 } … … 177 178 if (element == "Leaf") 178 179 { 179 cout<< "l";180 Debug << "l"; 180 181 Debug << "leaf" << endl; 181 182 StartBspLeaf(attributes); … … 189 190 StrX lname(name); 190 191 string element(lname.LocalForm()); 191 192 192 193 // decides the used view cell hierarchy 193 194 if (element == "ViewCells") 194 195 { 195 cout<< "parsing view cells" << endl;196 Debug << "parsing view cells" << endl; 196 197 mParseViewCells = true; 197 198 } … … 199 200 if (element == "Hierarchy") 200 201 { 201 cout<< "parsing spatial hierarchy" << endl;202 Debug << "parsing spatial hierarchy" << endl; 202 203 mParseViewCells = false; 203 204 StartHierarchy(attributes); … … 207 208 if (element == "ViewSpaceBox") 208 209 { 209 cout<< "b";210 Debug << "b"; 210 211 StartViewSpaceBox(attributes); 211 212 } … … 234 235 if (element == "Interior") 235 236 { 236 cout<< "[";237 Debug << "["; 237 238 StartViewCellInterior(attributes); 238 239 } … … 240 241 if (element == "Leaf") 241 242 { 242 cout<< "l";243 Debug << "l"; 243 244 StartViewCellLeaf(attributes); 244 245 } … … 306 307 // to sumof pdfs, i.e. its relative visibility 307 308 // temporarily set to 1.0f 308 viewCell->GetPvs().AddSample(obj, 1.0f); 309 viewCell->GetPvs().AddSample(obj, 1.0f); 309 310 } 310 311 else … … 559 560 mVspBspTree = new VspBspTree(); 560 561 //mCurrentBspNode = mVspBspTree->GetRoot(); 561 562 562 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 563 563 … … 573 573 else 574 574 { 575 cerr <<"Wrong view cells type " << name << "!!!"<< endl;575 cerr << "Wrong view cells type: " << name << endl; 576 576 exit(1); 577 577 } … … 700 700 catch (const XMLException& e) 701 701 { 702 XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n"702 XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 703 703 << StrX(e.getMessage()) 704 704 << "\n" << XERCES_STD_QUALIFIER endl; 705 errorCount = 1;706 return false;705 errorCount = 1; 706 return false; 707 707 } 708 708 … … 710 710 // Print out the stats that we collected and time taken 711 711 if (!errorCount) { 712 XERCES_STD_QUALIFIER cout<< filename << ": " << duration << " ms ("712 XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 713 713 << handler.GetElementCount() << " elems, " 714 714 << handler.GetAttrCount() << " attrs, " -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r863 r870 55 55 56 56 57 VspBspTree::VspBspTree( ):57 VspBspTree::VspBspTree(Environment *env): 58 58 mRoot(NULL), 59 59 mUseAreaForPvs(false), … … 67 67 { 68 68 bool randomize = false; 69 env ironment->GetBoolValue("VspBspTree.Construction.randomize", randomize);69 env->GetBoolValue("VspBspTree.Construction.randomize", randomize); 70 70 if (randomize) 71 71 Randomize(); // initialise random generator for heuristics 72 72 73 73 //-- termination criteria for autopartition 74 env ironment->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth);75 env ironment->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs);76 env ironment->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays);77 env ironment->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability);78 env ironment->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution);79 env ironment->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength);80 env ironment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio);81 env ironment->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance);82 env ironment->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells);74 env->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth); 75 env->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs); 76 env->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays); 77 env->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability); 78 env->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution); 79 env->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength); 80 env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 81 env->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance); 82 env->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 83 83 84 84 //-- max cost ratio for early tree termination 85 env ironment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio);86 87 env ironment->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio);88 env ironment->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance);85 env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 86 87 env->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 88 env->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 89 89 90 90 // HACK//mTermMinPolygons = 25; 91 91 92 92 //-- factors for bsp tree split plane heuristics 93 env ironment->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor);94 env ironment->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi);93 env->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor); 94 env->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi); 95 95 96 96 97 97 //-- partition criteria 98 env ironment->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates);99 env ironment->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates);100 env ironment->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy);101 102 env ironment->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon);103 env ironment->GetIntValue("VspBspTree.maxTests", mMaxTests);98 env->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates); 99 env->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates); 100 env->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy); 101 102 env->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon); 103 env->GetIntValue("VspBspTree.maxTests", mMaxTests); 104 104 105 105 // if only the driving axis is used for axis aligned split 106 env ironment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis);106 env->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 107 107 108 108 //-- termination criteria for axis aligned split 109 env ironment->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",109 env->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution", 110 110 mTermMaxRayContriForAxisAligned); 111 env ironment->GetIntValue("VspBspTree.Termination.AxisAligned.minRays",111 env->GetIntValue("VspBspTree.Termination.AxisAligned.minRays", 112 112 mTermMinRaysForAxisAligned); 113 113 114 //env ironment->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory);115 env ironment->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory);116 117 env ironment->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight);118 env ironment->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable);119 120 env ironment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics);121 env ironment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue);122 env ironment->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis);123 env ironment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis);124 env ironment->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType);125 126 env ironment->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed);114 //env->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 115 env->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 116 117 env->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 118 env->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 119 120 env->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 121 env->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 122 env->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 123 env->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 124 env->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 125 126 env->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed); 127 127 128 128 char subdivisionStatsLog[100]; 129 env ironment->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog);129 env->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 130 130 mSubdivisionStats.open(subdivisionStatsLog); 131 131 132 env ironment->GetFloatValue("VspBspTree.Construction.minBand", mMinBand);133 env ironment->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand);134 env ironment->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost);132 env->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 133 env->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 134 env->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost); 135 135 136 136 //-- debug output … … 199 199 } 200 200 201 VspBspTree::VspBspTree(): 202 mRoot(NULL), 203 mUseAreaForPvs(false), 204 mCostNormalizer(Limits::Small), 205 mViewCellsManager(NULL), 206 mOutOfBoundsCell(NULL), 207 mStoreRays(false), 208 mRenderCostWeight(0.5), 209 mUseRandomAxis(false), 210 mTimeStamp(1), 211 mEpsilon(1e-6f) 212 { 213 } 201 214 202 215 BspViewCell *VspBspTree::GetOutOfBoundsCell() -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r863 r870 26 26 class Beam; 27 27 class ViewCellsTree; 28 28 class Environment; 29 29 30 30 /** … … 199 199 VspBspTree(); 200 200 201 202 /** Constructor creating an empty tree. Loads parameters 203 from an environment file. 204 */ 205 VspBspTree(Environment *env); 206 201 207 /** Default destructor. 202 208 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r863 r870 219 219 if (mLoadPolygonsAsMeshes) 220 220 { 221 222 /*vector<VertexIndexContainer>::const_iterator it,223 it_end = mCurrentVertexIndices.end();224 225 for (it = mCurrentVertexIndices.begin(); it != it_end; ++ it)226 {227 // only one face per mesh228 Mesh *mesh = new Mesh();229 230 VertexIndexContainer vc;231 232 // add vertices233 for (int i = 0; i < (int)(*it).size(); ++ i)234 {235 mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]);236 vc.push_back(i);237 }238 239 mesh->mFaces.push_back(new Face(vc));240 241 // NOTE: should rather be written into trafo of mesh instance242 ApplyTransformations(mTransformations, mesh);243 244 mesh->Preprocess();245 // make an instance of this mesh246 MeshInstance *mi = new MeshInstance(mesh);247 mCurrentNode->mGeometry.push_back(mi);248 249 }*/250 251 221 //if (mCurrentMesh->mFaces.empty()) cout << "error!" << endl; 252 222
Note: See TracChangeset
for help on using the changeset viewer.