- Timestamp:
- 07/10/06 01:57:41 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
r1099 r1106 544 544 </File> 545 545 </Filter> 546 <Filter547 Name="mixkit"548 Filter="">549 <File550 RelativePath="..\src\mixkit\getopt.c">551 </File>552 <File553 RelativePath="..\src\mixkit\getopt.h">554 </File>555 <File556 RelativePath="..\src\mixkit\getopt1.c">557 </File>558 <File559 RelativePath="..\src\mixkit\mixio.h">560 </File>561 <File562 RelativePath="..\src\mixkit\mixmops.cxx">563 </File>564 <File565 RelativePath="..\src\mixkit\mixmops.h">566 </File>567 <File568 RelativePath="..\src\mixkit\mixmsg.cxx">569 </File>570 <File571 RelativePath="..\src\mixkit\mixmsg.h">572 </File>573 <File574 RelativePath="..\src\mixkit\mixvops.h">575 </File>576 <File577 RelativePath="..\src\mixkit\MxArcball.cxx">578 </File>579 <File580 RelativePath="..\src\mixkit\MxArcball.h">581 </File>582 <File583 RelativePath="..\src\mixkit\MxAsp.cxx">584 </File>585 <File586 RelativePath="..\src\mixkit\MxAsp.h">587 </File>588 <File589 RelativePath="..\src\mixkit\MxBlock.h">590 </File>591 <File592 RelativePath="..\src\mixkit\MxBlock2.h">593 </File>594 <File595 RelativePath="..\src\mixkit\MxBlock3.h">596 </File>597 <File598 RelativePath="..\src\mixkit\MxBlockModel.cxx">599 </File>600 <File601 RelativePath="..\src\mixkit\MxBlockModel.h">602 </File>603 <File604 RelativePath="..\src\mixkit\MxCamera.cxx">605 </File>606 <File607 RelativePath="..\src\mixkit\MxCamera.h">608 </File>609 <File610 RelativePath="..\src\mixkit\MxCmdParser.cxx">611 </File>612 <File613 RelativePath="..\src\mixkit\MxCmdParser.h">614 </File>615 <File616 RelativePath="..\src\mixkit\MxDynBlock.h">617 </File>618 <File619 RelativePath="..\src\mixkit\MxEdgeFilter.cxx">620 </File>621 <File622 RelativePath="..\src\mixkit\MxEdgeFilter.h">623 </File>624 <File625 RelativePath="..\src\mixkit\MxGeom3D.cxx">626 </File>627 <File628 RelativePath="..\src\mixkit\MxGeom3D.h">629 </File>630 <File631 RelativePath="..\src\mixkit\MxGeoPrims.h">632 </File>633 <File634 RelativePath="..\src\mixkit\MxGL.h">635 </File>636 <File637 RelativePath="..\src\mixkit\MxGLDebug.cxx">638 </File>639 <File640 RelativePath="..\src\mixkit\MxGLPane.cxx">641 </File>642 <File643 RelativePath="..\src\mixkit\MxGLPane.h">644 </File>645 <File646 RelativePath="..\src\mixkit\MxGLUtils.cxx">647 </File>648 <File649 RelativePath="..\src\mixkit\MxGLUtils.h">650 </File>651 <File652 RelativePath="..\src\mixkit\MxHeap.cxx">653 <FileConfiguration654 Name="Debug|Win32">655 <Tool656 Name="VCCLCompilerTool"657 ObjectFile="$(IntDir)/$(InputName)1.obj"/>658 </FileConfiguration>659 <FileConfiguration660 Name="Release|Win32">661 <Tool662 Name="VCCLCompilerTool"663 ObjectFile="$(IntDir)/$(InputName)1.obj"/>664 </FileConfiguration>665 </File>666 <File667 RelativePath="..\src\mixkit\MxHeap.h">668 </File>669 <File670 RelativePath="..\src\mixkit\MxLineModel.cxx">671 </File>672 <File673 RelativePath="..\src\mixkit\MxManipulator.h">674 </File>675 <File676 RelativePath="..\src\mixkit\MxMat2.cxx">677 </File>678 <File679 RelativePath="..\src\mixkit\MxMat2.h">680 </File>681 <File682 RelativePath="..\src\mixkit\MxMat3-jacobi.cxx">683 </File>684 <File685 RelativePath="..\src\mixkit\MxMat3.cxx">686 </File>687 <File688 RelativePath="..\src\mixkit\MxMat3.h">689 </File>690 <File691 RelativePath="..\src\mixkit\MxMat4-jacobi.cxx">692 </File>693 <File694 RelativePath="..\src\mixkit\MxMat4.cxx">695 </File>696 <File697 RelativePath="..\src\mixkit\MxMat4.h">698 </File>699 <File700 RelativePath="..\src\mixkit\MxMath.h">701 </File>702 <File703 RelativePath="..\src\mixkit\MxMatrix.cxx">704 </File>705 <File706 RelativePath="..\src\mixkit\MxMatrix.h">707 </File>708 <File709 RelativePath="..\src\mixkit\MxPropSlim.cxx">710 </File>711 <File712 RelativePath="..\src\mixkit\MxPropSlim.h">713 </File>714 <File715 RelativePath="..\src\mixkit\MxQMetric.cxx">716 </File>717 <File718 RelativePath="..\src\mixkit\MxQMetric.h">719 </File>720 <File721 RelativePath="..\src\mixkit\MxQMetric2.cxx">722 </File>723 <File724 RelativePath="..\src\mixkit\MxQMetric2.h">725 </File>726 <File727 RelativePath="..\src\mixkit\MxQMetric3.cxx">728 </File>729 <File730 RelativePath="..\src\mixkit\MxQMetric3.h">731 </File>732 <File733 RelativePath="..\src\mixkit\MxQSlim.cxx">734 </File>735 <File736 RelativePath="..\src\mixkit\MxQSlim.h">737 </File>738 <File739 RelativePath="..\src\mixkit\MxQVis3.cxx">740 </File>741 <File742 RelativePath="..\src\mixkit\MxRaster-tiff.cxx">743 </File>744 <File745 RelativePath="..\src\mixkit\MxRaster.cxx">746 </File>747 <File748 RelativePath="..\src\mixkit\MxRaster.h">749 </File>750 <File751 RelativePath="..\src\mixkit\MxSMF.cxx">752 </File>753 <File754 RelativePath="..\src\mixkit\MxSMF.h">755 </File>756 <File757 RelativePath="..\src\mixkit\MxStack.h">758 </File>759 <File760 RelativePath="..\src\mixkit\MxStdModel.cxx">761 </File>762 <File763 RelativePath="..\src\mixkit\MxStdModel.h">764 </File>765 <File766 RelativePath="..\src\mixkit\MxStdPane.cxx">767 </File>768 <File769 RelativePath="..\src\mixkit\MxStdPane.h">770 </File>771 <File772 RelativePath="..\src\mixkit\MxStdRender.cxx">773 </File>774 <File775 RelativePath="..\src\mixkit\MxStdSlim.cxx">776 </File>777 <File778 RelativePath="..\src\mixkit\MxStdSlim.h">779 </File>780 <File781 RelativePath="..\src\mixkit\MxTimer.cxx">782 </File>783 <File784 RelativePath="..\src\mixkit\MxTimer.h">785 </File>786 <File787 RelativePath="..\src\mixkit\MxTriProject.cxx">788 </File>789 <File790 RelativePath="..\src\mixkit\MxVec2.h">791 </File>792 <File793 RelativePath="..\src\mixkit\MxVec3.h">794 </File>795 <File796 RelativePath="..\src\mixkit\MxVec4.h">797 </File>798 <File799 RelativePath="..\src\mixkit\MxVector.h">800 </File>801 <File802 RelativePath="..\src\mixkit\stdmix.h">803 </File>804 </Filter>805 546 <File 806 547 RelativePath=".\VTune\Preprocessor.vpj"> -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1074 r1106 2206 2206 "1"); 2207 2207 2208 2209 /***************************************************************************/ 2210 /* Object space partition tree related options */ 2211 /***************************************************************************/ 2212 2213 RegisterOption("OspTree.Construction.randomize", 2214 optBool, 2215 "osp_construction_randomize=", 2216 "false"); 2217 2218 RegisterOption("OspTree.Termination.maxDepth", 2219 optInt, 2220 "osp_term_max_depth=", 2221 "30"); 2222 2223 RegisterOption("OspTree.Termination.maxLeaves", 2224 optInt, 2225 "osp_term_max_leaves=", 2226 "1000"); 2227 2228 RegisterOption("OspTree.Termination.minObjects", 2229 optInt, 2230 "osp_term_min_objects=", 2231 "1"); 2232 2233 RegisterOption("OspTree.Termination.minProbability", 2234 optFloat, 2235 "osp_term_min_objects=", 2236 "0.0001"); 2237 2238 RegisterOption("OspTree.Termination.missTolerance", 2239 optInt, 2240 "osp_term_miss_tolerance=", 2241 "4"); 2242 2243 RegisterOption("OspTree.Termination.maxCostRatio", 2244 optFloat, 2245 "osp_term_max_cost_ratio=", 2246 "0.99"); 2247 2248 RegisterOption("OspTree.Termination.minGlobalCostRatio", 2249 optFloat, 2250 "osp_term_min_global_cost_ratio=", 2251 "0.00001"); 2252 2253 RegisterOption("OspTree.Termination.globalCostMissTolerance", 2254 optInt, 2255 "osp_term_global_cost_miss_tolerance=", 2256 "4"); 2257 2258 RegisterOption("OspTree.Termination.ct_div_ci", 2259 optFloat, 2260 "osp_term_ct_div_ci=", 2261 "0"); 2262 2263 RegisterOption("OspTree.Construction.epsilon", 2264 optFloat, 2265 "osp_construction_epsilon=", 2266 "0.00001"); 2267 2268 // if only the driving axis is used for axis aligned split 2269 RegisterOption("OspTree.splitUseOnlyDrivingAxis", 2270 optBool, 2271 "osp_split_only_driving_axis=", 2272 "false"); 2273 2274 RegisterOption("OspTree.maxStaticMemory", 2275 optFloat, 2276 "osp_max_static_mem=", 2277 "8.0"); 2278 2279 RegisterOption("OspTree.useCostHeuristics", 2280 optBool, 2281 "osp_use_cost_heuristics=", 2282 "false"); 2283 2284 2285 RegisterOption("OspTree.subdivisionStats", 2286 optString, 2287 "osp_subdivision_stats=", 2288 "ospSubdivisionStats.log"); 2289 2290 RegisterOption("OspTree.Construction.splitBorder", 2291 optFloat, 2292 "osp_construction_split_border=", 2293 "0.01"); 2294 2295 2208 2296 2209 2297 ////////////////////////////////////////////////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
r1006 r1106 27 27 class Mesh; 28 28 class Beam; 29 class OspTree; 30 29 31 30 32 class Exporter … … 66 68 virtual bool 67 69 ExportBspTree(const BspTree &tree) = 0; 70 71 virtual bool 72 ExportOspTree(const OspTree &tree) = 0; 68 73 69 74 // virtual bool -
GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h
r1099 r1106 193 193 return NULL; 194 194 195 Swap(0, mBuffer.size() - 1);195 Swap(0, (int)mBuffer.size() - 1); 196 196 197 197 T dead = mBuffer.back(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1027 r1106 1094 1094 mStat.nodes += 2; 1095 1095 1096 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 1097 1098 1096 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 1099 1097 1100 1098 // select subdivision plane 1101 BspInterior *interior = 1102 new BspInterior(SelectPlane(leaf, tData)); 1099 BspInterior *interior = new BspInterior(SelectPlane(leaf, tData)); 1103 1100 1104 1101 … … 1107 1104 #endif 1108 1105 1109 1110 1106 // subdivide rays into front and back rays 1111 1107 SplitRays(interior->mPlane, *tData.mRays, *frontData.mRays, *backData.mRays); 1112 1113 1114 1108 1115 1109 // subdivide polygons with plane … … 1119 1113 *backData.mPolygons, 1120 1114 coincident); 1121 1122 1115 1123 1116 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1077 r1106 4810 4810 mHierarchyManager = new HierarchyManager(*vspTree, *ospTree); 4811 4811 Environment::GetSingleton()->GetIntValue("VspTree.Construction.samples", mInitialSamples); 4812 4812 4813 mVspTree->SetViewCellsManager(this); 4814 mOspTree->SetViewCellsManager(this); 4815 4813 4816 mVspTree->mViewCellsTree = mViewCellsTree; 4814 4817 } … … 4881 4884 long startTime; 4882 4885 4883 mHierarchyManager->Construct (constructionRays, objects, &mViewSpaceBox);4886 mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 4884 4887 4885 4888 … … 5229 5232 GetRaySets(sampleRays, mVisualizationSamples, visRays); 5230 5233 5231 //-- export final view cells5232 5233 5234 if (1) 5234 5235 { 5236 //-- export final view cells 5237 5235 5238 // hack pvs 5236 5239 const int savedColorCode = mColorCode; … … 5266 5269 // HACK: export without clip plane 5267 5270 const bool b = mUseClipPlaneForViz; 5268 if (0) 5269 mUseClipPlaneForViz = false; 5271 if (0) mUseClipPlaneForViz = false; 5270 5272 5271 5273 ExportViewCellsForViz(exporter); … … 5278 5280 5279 5281 mColorCode = savedColorCode; 5282 } 5283 5284 if (1) 5285 { 5286 //-- export final object partition 5287 Exporter *exporter = Exporter::GetExporter("final_object_partition.wrl"); 5288 5289 if (exporter) 5290 { 5291 cout << "exporting object space partition ... "; 5292 5293 if (mExportGeometry) 5294 { 5295 exporter->ExportGeometry(objects); 5296 } 5297 5298 // export rays 5299 if (0 && mExportRays) 5300 { 5301 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 5302 } 5303 5304 exporter->SetWireframe(); 5305 exporter->ExportOspTree(*mOspTree); 5306 5307 delete exporter; 5308 5309 cout << "finished" << endl; 5310 } 5280 5311 } 5281 5312 -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
r1077 r1106 11 11 #include "VssTree.h" 12 12 #include "VspBspTree.h" 13 #include "VspOspTree.h" 13 14 #include "RssTree.h" 14 15 #include "Beam.h" … … 595 596 } 596 597 597 #if 0598 bool VrmlExporter::ExportVspOspTree(const VspOspTree &tree,599 const int maxPvs)600 {601 stack<VspKdNode *> tStack;602 603 tStack.push(tree.GetRoot());604 605 //Mesh *mesh = new Mesh;606 607 if (maxPvs)608 mUseForcedMaterial = true;609 610 while (!tStack.empty())611 {612 VspKdNode *node = tStack.top();613 614 tStack.pop();615 616 if (node->IsLeaf())617 {618 AxisAlignedBox3 box = tree.GetBBox(node);619 620 Mesh *mesh = new Mesh;621 622 // add 6 vertices of the box623 int index = (int)mesh->mVertices.size();624 625 for (int i=0; i < 8; ++ i)626 {627 Vector3 v;628 box.GetVertex(i, v);629 mesh->mVertices.push_back(v);630 }631 632 mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) );633 mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) );634 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) );635 636 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) );637 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) );638 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) );639 640 if (maxPvs)641 {642 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node);643 644 mForcedMaterial.mDiffuseColor.b = 1.0f;645 646 leaf->UpdatePvsSize();647 648 const float importance = (float)leaf->GetPvsSize() / (float)maxPvs;649 mForcedMaterial.mDiffuseColor.r = importance;650 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r;651 }652 653 ExportMesh(mesh);654 DEL_PTR(mesh);655 }656 else657 {658 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node);659 tStack.push(interior->GetFront());660 tStack.push(interior->GetBack());661 }662 }663 664 //ExportMesh(mesh);665 //DEL_PTR(mesh);666 667 return true;668 }669 #endif670 598 671 599 bool VrmlExporter::ExportKdTree(const KdTree &tree) … … 685 613 { 686 614 KdNode *node = tStack.top(); 687 615 688 616 tStack.pop(); 689 617 690 618 AxisAlignedBox3 box = tree.GetBox(node); 691 619 // add 6 vertices of the box 692 620 int index = (int)mesh->mVertices.size(); 693 621 694 622 for (int i=0; i < 8; i++) 695 623 { … … 703 631 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 704 632 705 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 706 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 707 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 708 709 if (!node->IsLeaf()) 710 { 711 KdInterior *interior = (KdInterior *)node; 712 tStack.push(interior->mFront); 713 tStack.push(interior->mBack); 714 } 715 } 716 717 ExportMesh(mesh); 718 719 delete mesh; 720 return true; 721 } 633 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 634 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 635 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 636 637 if (!node->IsLeaf()) 638 { 639 KdInterior *interior = (KdInterior *)node; 640 tStack.push(interior->mFront); 641 tStack.push(interior->mBack); 642 } 643 } 644 645 ExportMesh(mesh); 646 647 delete mesh; 648 return true; 649 } 650 651 652 bool VrmlExporter::ExportOspTree(const OspTree &ospTree) 653 { 654 vector<KdLeaf *> leaves; 655 ospTree.CollectLeaves(leaves); 656 657 vector<KdLeaf *>::const_iterator it, it_end = leaves.end(); 658 659 for (it = leaves.begin(); it != it_end; ++ it) 660 { 661 ExportBox(ospTree.GetBBox(*it)); 662 } 663 664 return true; 665 } 666 722 667 723 668 bool VrmlExporter::ExportVssTree(const VssTree &tree) -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.h
r1006 r1106 24 24 class VspBspTree; 25 25 class BspNode; 26 //class VspKdViewCell;27 26 class Beam; 27 class OspTree; 28 28 29 29 class VrmlExporter : public Exporter … … 46 46 bool 47 47 ExportKdTree(const KdTree &tree); 48 49 bool 50 ExportOspTree(const OspTree &tree); 48 51 49 52 bool -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1077 r1106 1554 1554 if (!useSpecialAxis || (axis == sAxis)) 1555 1555 { 1556 //-- place split plane using heuristics1557 1558 1556 if (mUseCostHeuristics) 1559 1557 { 1558 //-- place split plane using heuristics 1560 1559 nCostRatio[axis] = 1561 1560 BestCostRatioHeuristics(*tData.mRays, … … 1565 1564 nPosition[axis]); 1566 1565 } 1567 else //-- split plane position is spatial median 1568 { 1566 else 1567 { 1568 //-- split plane position is spatial median 1569 1569 1570 1570 nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1101 r1106 22 22 23 23 #define USE_FIXEDPOINT_T 0 24 24 #define COUNT_OBJECTS 1 25 25 26 26 //-- static members 27 28 int VspTree::sFrontId = 0;29 int VspTree::sBackId = 0;30 int VspTree::sFrontAndBackId = 0;31 27 32 28 VspTree *VspTree::VspSplitCandidate::sVspTree = NULL; … … 379 375 380 376 Debug << "******* VSP options ******** " << endl; 377 381 378 Debug << "max depth: " << mTermMaxDepth << endl; 382 379 Debug << "min PVS: " << mTermMinPvs << endl; … … 399 396 Debug << "minband: " << mMinBand << endl; 400 397 Debug << "maxband: " << mMaxBand << endl; 401 Debug << "pvs count method: " << mPvsCountMethod << endl; 402 398 399 if (mPvsCountMethod == 0) 400 Debug << "pvs count method: per object" << endl; 401 else 402 Debug << "pvs count method: per kd node" << endl; 403 403 404 404 mSplitCandidates = new vector<SortableEntry>; … … 504 504 bool VspTree::LocalTerminationCriteriaMet(const VspTraversalData &data) const 505 505 { 506 return 507 #if TODO 508 (((int)data.mRays->size() <= mTermMinRays) || 509 (data.mPvs <= mTermMinPvs) || 510 (data.mProbability <= mTermMinProbability) || 511 (data.GetAvgRayContribution() > mTermMaxRayContribution) || 512 (data.mDepth >= mTermMaxDepth)); 513 #else 514 false; 515 #endif 506 return( 507 ((int)data.mRays->size() <= mTermMinRays) || 508 (data.mPvs <= mTermMinPvs) || 509 (data.mProbability <= mTermMinProbability) || 510 (data.GetAvgRayContribution() > mTermMaxRayContribution) || 511 (data.mDepth >= mTermMaxDepth) 512 ); 513 516 514 } 517 515 … … 519 517 bool VspTree::GlobalTerminationCriteriaMet(const VspTraversalData &data) const 520 518 { 521 return 522 #if TODO 523 (mOutOfMemory || 519 return ( 520 // mOutOfMemory || 524 521 (mVspStats.Leaves() >= mMaxViewCells) || 525 (mGlobalCostMisses >= mTermGlobalCostMissTolerance)); 526 #else 527 (mVspStats.Leaves() >= mMaxViewCells) ; 528 #endif 522 (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 523 ); 529 524 } 530 525 … … 729 724 // and setup child links 730 725 interior->SetupChildLinks(new VspLeaf(interior), new VspLeaf(interior)); 726 731 727 // add bounding box 732 728 interior->SetBoundingBox(tData.mBoundingBox); 729 730 // set front and back leaf 731 frontData.mNode = interior->GetFront(); 732 backData.mNode = interior->GetBack(); 733 733 734 734 interior->mTimeStamp = mTimeStamp ++; … … 915 915 node->mCounter = 1; 916 916 917 //Debug << "here5 "<<(int)node->mObjects.size() <<" "<< node->mMultipleObjects.size()<< " " <<(int)node->mObjects.size() - node->mMultipleObjects.size()<<endl;918 917 // add objects without the objects which are in several kd leaves 919 918 pvsSize += (int)(node->mObjects.size() - node->mMultipleObjects.size()); … … 933 932 if (!object->Mailed()) 934 933 { 935 //Debug << "here233: " << object->mKdLeaves.size() << endl;936 934 object->Mail(); 937 935 object->mCounter = 1; … … 1322 1320 sAxis = box.Size().DrivingAxis(); 1323 1321 } 1324 //sAxis = 2;1322 1325 1323 for (int axis = 0; axis < 3; ++ axis) 1326 1324 { 1327 1325 if (!useSpecialAxis || (axis == sAxis)) 1328 1326 { 1329 //-- place split plane using heuristics1330 1331 1327 if (mUseCostHeuristics) 1332 1328 { 1329 //-- place split plane using heuristics 1333 1330 nCostRatio[axis] = 1334 1331 EvalLocalCostHeuristics(*tData.mRays, … … 1338 1335 nPosition[axis]); 1339 1336 } 1340 else //-- split plane position is spatial median 1341 { 1337 else 1338 { 1339 //-- split plane position is spatial median 1340 1342 1341 nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 1343 1342 … … 2545 2544 mTimeStamp(1) 2546 2545 { 2547 #if TODO 2546 2548 2547 bool randomize = false; 2549 2548 Environment::GetSingleton()->GetBoolValue("VspTree.Construction.randomize", randomize); … … 2552 2551 2553 2552 //-- termination criteria for autopartition 2554 Environment::GetSingleton()->GetIntValue("VspTree.Termination.maxDepth", mTermMaxDepth); 2555 Environment::GetSingleton()->GetIntValue("VspTree.Termination.minPvs", mTermMinPvs); 2556 Environment::GetSingleton()->GetIntValue("VspTree.Termination.minRays", mTermMinRays); 2557 Environment::GetSingleton()->GetFloatValue("VspTree.Termination.minProbability", mTermMinProbability); 2558 Environment::GetSingleton()->GetFloatValue("VspTree.Termination.maxRayContribution", mTermMaxRayContribution); 2559 2560 Environment::GetSingleton()->GetIntValue("VspTree.Termination.missTolerance", mTermMissTolerance); 2561 Environment::GetSingleton()->GetIntValue("VspTree.Termination.maxViewCells", mMaxViewCells); 2562 2553 Environment::GetSingleton()->GetIntValue("OspTree.Termination.maxDepth", mTermMaxDepth); 2554 Environment::GetSingleton()->GetIntValue("OspTree.Termination.maxLeaves", mTermMaxLeaves); 2555 Environment::GetSingleton()->GetIntValue("OspTree.Termination.minObjects", mTermMinObjects); 2556 Environment::GetSingleton()->GetFloatValue("OspTree.Termination.minProbability", mTermMinProbability); 2557 2558 Environment::GetSingleton()->GetIntValue("OspTree.Termination.missTolerance", mTermMissTolerance); 2559 2563 2560 //-- max cost ratio for early tree termination 2564 Environment::GetSingleton()->GetFloatValue("VspTree.Termination.maxCostRatio", mTermMaxCostRatio); 2565 2566 Environment::GetSingleton()->GetFloatValue("VspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 2567 Environment::GetSingleton()->GetIntValue("VspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 2568 2569 // HACK//mTermMinPolygons = 25; 2561 Environment::GetSingleton()->GetFloatValue("OspTree.Termination.maxCostRatio", mTermMaxCostRatio); 2562 2563 Environment::GetSingleton()->GetFloatValue("OspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 2564 Environment::GetSingleton()->GetIntValue("OspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 2565 2570 2566 2571 2567 //-- factors for bsp tree split plane heuristics 2572 Environment::GetSingleton()->GetFloatValue(" VspTree.Termination.ct_div_ci", mCtDivCi);2568 Environment::GetSingleton()->GetFloatValue("OspTree.Termination.ct_div_ci", mCtDivCi); 2573 2569 2574 2570 //-- partition criteria 2575 Environment::GetSingleton()->GetFloatValue(" VspTree.Construction.epsilon", mEpsilon);2571 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.epsilon", mEpsilon); 2576 2572 2577 2573 // if only the driving axis is used for axis aligned split 2578 Environment::GetSingleton()->GetBoolValue("VspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 2579 2580 //Environment::GetSingleton()->GetFloatValue("VspTree.maxTotalMemory", mMaxTotalMemory); 2581 Environment::GetSingleton()->GetFloatValue("VspTree.maxStaticMemory", mMaxMemory); 2582 2583 Environment::GetSingleton()->GetBoolValue("VspTree.useCostHeuristics", mUseCostHeuristics); 2584 Environment::GetSingleton()->GetBoolValue("VspTree.simulateOctree", mCirculatingAxis); 2574 Environment::GetSingleton()->GetBoolValue("OspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 2575 2576 Environment::GetSingleton()->GetFloatValue("OspTree.maxStaticMemory", mMaxMemory); 2577 2578 Environment::GetSingleton()->GetBoolValue("OspTree.useCostHeuristics", mUseCostHeuristics); 2585 2579 2586 2580 2587 2581 char subdivisionStatsLog[100]; 2588 Environment::GetSingleton()->GetStringValue(" VspTree.subdivisionStats", subdivisionStatsLog);2582 Environment::GetSingleton()->GetStringValue("OspTree.subdivisionStats", subdivisionStatsLog); 2589 2583 mSubdivisionStats.open(subdivisionStatsLog); 2590 2584 2591 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.minBand", mMinBand); 2592 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.maxBand", mMaxBand); 2593 2594 mSplitBorder = 0.1f; 2585 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.splitBorder", mSplitBorder); 2586 //mSplitBorder = 0.1f; 2595 2587 2596 2588 … … 2598 2590 2599 2591 Debug << "******* OSP options ******** " << endl; 2592 2600 2593 Debug << "max depth: " << mTermMaxDepth << endl; 2601 Debug << "min PVS: " << mTermMinPvs << endl;2602 2594 Debug << "min probabiliy: " << mTermMinProbability << endl; 2603 Debug << "min rays: " << mTermMinRays << endl; 2604 Debug << "max ray contri: " << mTermMaxRayContribution << endl; 2595 Debug << "min objects: " << mTermMinObjects << endl; 2605 2596 Debug << "max cost ratio: " << mTermMaxCostRatio << endl; 2606 2597 Debug << "miss tolerance: " << mTermMissTolerance << endl; 2607 Debug << "max view cells: " << mMaxViewCells << endl; 2598 Debug << "max leaves: " << mTermMaxLeaves << endl; 2599 2608 2600 Debug << "randomize: " << randomize << endl; 2609 2601 … … 2615 2607 Debug << "subdivision stats log: " << subdivisionStatsLog << endl; 2616 2608 2617 Debug << "circulating axis: " << mCirculatingAxis << endl; 2618 Debug << "minband: " << mMinBand << endl; 2619 Debug << "maxband: " << mMaxBand << endl; 2620 2609 Debug << "split borders: " << mSplitBorder << endl; 2610 2621 2611 2622 2612 mSplitCandidates = new vector<SortableEntry>; 2623 2613 2624 2614 Debug << endl; 2625 #endif2626 2615 } 2627 2616 … … 2630 2619 void OspTree::SplitObjects(const AxisAlignedPlane & splitPlane, 2631 2620 const ObjectContainer &objects, 2632 ObjectContainer & back,2633 ObjectContainer & front)2621 ObjectContainer &front, 2622 ObjectContainer &back) 2634 2623 { 2635 2624 ObjectContainer::const_iterator oit, oit_end = objects.end(); … … 2645 2634 if (box.Min(splitPlane.mAxis) < splitPlane.mPosition) 2646 2635 back.push_back(*oit); 2647 #if TODO 2648 mStat.objectRefs -= (int)objects.size(); 2649 mStat.objectRefs += objectsBack + objectsFront;2650 #endif 2651 2652 } 2653 2654 2655 KdInterior *OspTree::SubdivideNode(KdLeaf *leaf,2636 } 2637 2638 mOspStats.objectRefs -= (int)objects.size(); 2639 mOspStats.objectRefs += (int)back.size() + (int)front.size(); 2640 } 2641 2642 2643 KdInterior *OspTree::SubdivideNode( 2644 KdLeaf *leaf, 2656 2645 const AxisAlignedPlane &splitPlane, 2657 2646 const AxisAlignedBox3 &box, 2658 AxisAlignedBox3 &backBBox, 2659 AxisAlignedBox3 &frontBBox) 2660 { 2661 #if TODO 2662 mSpatialStat.nodes += 2; 2663 mSpatialStat.splits[axis]; 2664 #endif 2647 OspTraversalData &frontData, 2648 OspTraversalData &backData 2649 ) 2650 { 2651 mOspStats.nodes += 2; 2665 2652 2666 2653 // add the new nodes to the tree … … 2674 2661 node->mBox = box; 2675 2662 2676 backBBox = box;2677 front BBox = box;2663 backData.mBoundingBox = box; 2664 frontData.mBoundingBox = box; 2678 2665 2679 2666 // first count ray sides … … 2681 2668 int objectsFront = 0; 2682 2669 2683 back BBox.SetMax(axis, position);2684 front BBox.SetMin(axis, position);2670 backData.mBoundingBox.SetMax(axis, position); 2671 frontData.mBoundingBox.SetMin(axis, position); 2685 2672 2686 2673 ObjectContainer::const_iterator mi, mi_end = leaf->mObjects.end(); … … 2701 2688 KdLeaf *front = new KdLeaf(node, objectsFront); 2702 2689 2690 ///////////// 2691 //-- create front and back leaf 2692 2693 KdInterior *parent = leaf->mParent; 2694 2703 2695 // replace a link from node's parent 2704 if (leaf->mParent) 2705 leaf->mParent->ReplaceChildLink(leaf, node); 2696 if (parent) 2697 { 2698 parent->ReplaceChildLink(leaf, node); 2699 node->mParent = parent; 2700 } 2701 else // new root 2702 { 2703 mRoot = node; 2704 } 2706 2705 2707 2706 // and setup child links 2708 2707 node->SetupChildLinks(back, front); 2709 2708 2710 SplitObjects(splitPlane, leaf->mObjects, back->mObjects, front->mObjects);2709 SplitObjects(splitPlane, leaf->mObjects, front->mObjects, back->mObjects); 2711 2710 2712 2711 ProcessLeafObjects(back, leaf); 2713 2712 ProcessLeafObjects(front, leaf); 2714 2713 2714 backData.mNode = back; 2715 frontData.mNode = front; 2716 2715 2717 //delete leaf; 2716 2718 return node; … … 2721 2723 OspSplitCandidate &splitCandidate, 2722 2724 const bool globalCriteriaMet) 2723 { 2725 {Debug << "here11" << endl; 2724 2726 OspTraversalData &tData = splitCandidate.mParentData; 2725 2727 Debug << "here993" << endl; 2726 2728 KdNode *newNode = tData.mNode; 2727 2729 2730 Debug << "here996" << endl; 2728 2731 if (!LocalTerminationCriteriaMet(tData) && !globalCriteriaMet) 2729 2732 { 2730 2733 OspTraversalData tFrontData; 2731 2734 OspTraversalData tBackData; 2732 2735 Debug << "here3" << endl; 2733 2736 //-- continue subdivision 2734 2737 … … 2739 2742 splitPlane, 2740 2743 tData.mBoundingBox, 2741 tFrontData .mBoundingBox,2742 tBackData .mBoundingBox);2744 tFrontData, 2745 tBackData); 2743 2746 2744 2747 const int maxCostMisses = splitCandidate.mMaxCostMisses; … … 2752 2755 OspSplitCandidate *backCandidate = new OspSplitCandidate(tBackData); 2753 2756 2757 Debug << "here 54 " << tFrontData.mNode << " " << tBackData.mNode << endl; 2758 2754 2759 EvalSplitCandidate(*frontCandidate); 2755 2760 EvalSplitCandidate(*backCandidate); … … 2766 2771 if (newNode->IsLeaf()) 2767 2772 { 2768 //KdLeaf *leaf = dynamic_cast<KdLeaf *>(newNode);2769 2773 EvaluateLeafStats(tData); 2770 2774 } 2771 2775 Debug << "here888 "<< endl; 2772 2776 //-- cleanup 2773 2777 tData.Clear(); 2774 2778 Debug << "here876"<< endl; 2775 2779 return newNode; 2776 2780 } … … 2782 2786 float backProb; 2783 2787 2784 KdLeaf *leaf = dynamic_cast<KdLeaf *>(splitCandidate.mParentData.mNode);2785 2786 2788 // compute locally best split plane 2787 2789 const bool success = 2788 2790 SelectSplitPlane(splitCandidate.mParentData, splitCandidate.mSplitPlane, frontProb, backProb); 2789 2791 2790 //TODO2792 const float priority = EvalRenderCostDecrease(splitCandidate.mSplitPlane, splitCandidate.mParentData); 2791 2793 // compute global decrease in render cost 2792 splitCandidate.SetPriority(EvalRenderCostDecrease(splitCandidate.mSplitPlane, splitCandidate.mParentData)); 2793 splitCandidate.mMaxCostMisses = success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1; 2794 splitCandidate.SetPriority(priority); 2795 2796 splitCandidate.mMaxCostMisses = 2797 success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1; 2794 2798 } 2795 2799 … … 2798 2802 { 2799 2803 // matt: TODO 2800 return true; 2801 /* (((int)data.mRays->size() <= mTermMinRays) || 2802 (data.mPvs <= mTermMinPvs) || 2803 (data.mProbability <= mTermMinProbability) || 2804 (data.GetAvgRayContribution() > mTermMaxRayContribution) || 2805 (data.mDepth >= mTermMaxDepth));*/ 2804 return ( 2805 //(data.mNode->mObjects.size() < mTermMinObjects) || 2806 //(data.mProbability <= mTermMinProbability) || 2807 (data.mDepth >= mTermMaxDepth) 2808 ); 2806 2809 } 2807 2810 … … 2810 2813 { 2811 2814 // matt: TODO 2812 return true; 2813 /*(mOutOfMemory || 2814 (mVspStats.Leaves() >= mMaxViewCells) || 2815 (mGlobalCostMisses >= mTermGlobalCostMissTolerance));*/ 2815 Debug << "here888 " << mTermMaxLeaves << " " << mOspStats.Leaves() << endl; 2816 return ( 2817 (mOspStats.Leaves() >= mTermMaxLeaves) 2818 //mOutOfMemory || 2819 //(mGlobalCostMisses >= mTermGlobalCostMissTolerance) 2820 ); 2816 2821 } 2817 2822 … … 2819 2824 void OspTree::EvaluateLeafStats(const OspTraversalData &data) 2820 2825 { 2821 #if TODO2822 2826 // the node became a leaf -> evaluate stats for leafs 2823 VspLeaf *leaf = dynamic_cast<VspLeaf *>(data.mNode);2824 2825 if (data.mPvs > m VspStats.maxPvs)2826 { 2827 m VspStats.maxPvs = data.mPvs;2828 } 2829 2830 m VspStats.pvs += data.mPvs;2831 2832 if (data.mDepth < m VspStats.minDepth)2833 { 2834 m VspStats.minDepth = data.mDepth;2827 KdLeaf *leaf = data.mNode; 2828 2829 if (data.mPvs > mOspStats.maxPvs) 2830 { 2831 mOspStats.maxPvs = data.mPvs; 2832 } 2833 2834 mOspStats.pvs += data.mPvs; 2835 2836 if (data.mDepth < mOspStats.minDepth) 2837 { 2838 mOspStats.minDepth = data.mDepth; 2835 2839 } 2836 2840 2837 2841 if (data.mDepth >= mTermMaxDepth) 2838 2842 { 2839 ++ m VspStats.maxDepthNodes;2843 ++ mOspStats.maxDepthNodes; 2840 2844 //Debug << "new max depth: " << mVspStats.maxDepthNodes << endl; 2841 2845 } 2842 2846 2843 // accumulate rays to compute rays / leaf 2844 mVspStats.accumRays += (int)data.mRays->size(); 2845 2846 if (data.mPvs < mTermMinPvs) 2847 ++ mVspStats.minPvsNodes; 2848 2849 if ((int)data.mRays->size() < mTermMinRays) 2850 ++ mVspStats.minRaysNodes; 2851 2852 if (data.GetAvgRayContribution() > mTermMaxRayContribution) 2853 ++ mVspStats.maxRayContribNodes; 2847 // if (data.mPvs < mTermMinPvs) 2848 // ++ mOspStats.minPvsNodes; 2854 2849 2855 2850 if (data.mProbability <= mTermMinProbability) 2856 ++ m VspStats.minProbabilityNodes;2851 ++ mOspStats.minProbabilityNodes; 2857 2852 2858 2853 // accumulate depth to compute average depth 2859 m VspStats.accumDepth += data.mDepth;2860 2861 ++ mCreated ViewCells;2854 mOspStats.accumDepth += data.mDepth; 2855 2856 ++ mCreatedLeaves; 2862 2857 2863 2858 #ifdef _DEBUG 2864 2859 Debug << "BSP stats: " 2865 2860 << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 2866 << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 2867 << "Area: " << data.mProbability << " (min: " << mTermMinProbability << "), " 2868 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 2869 << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "), " 2870 << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 2871 #endif 2872 2861 // << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 2862 << "Prob: " << data.mProbability << " (min: " << mTermMinProbability << "), " 2863 << "#pvs: " << data.mPvs << ")\n"; 2873 2864 #endif 2874 2865 } … … 2879 2870 const int axis, 2880 2871 float &position, 2881 int &objects Back,2882 int &objects Front)2872 int &objectsFront, 2873 int &objectsBack) 2883 2874 { 2884 2875 … … 2889 2880 // C = ct_div_ci + (ol + or)/queries 2890 2881 2891 int pvsSize = PrepareHeuristics(node->mObjects); ;2882 int pvsSize = PrepareHeuristics(node->mObjects); 2892 2883 int pvsl = 0, pvsr = pvsSize; 2893 2884 … … 3009 3000 int OspTree::PrepareHeuristics(Intersectable *object) 3010 3001 { 3002 #if COUNT_OBJECTS 3003 return 1; 3004 #else 3011 3005 ViewCellPvsMap::const_iterator vit, vit_end = object->mViewCellPvs.mEntries.end(); 3012 3006 … … 3030 3024 3031 3025 return pvsSize; 3026 #endif 3032 3027 } 3033 3028 … … 3073 3068 3074 3069 3070 void OspTree::SetViewCellsManager(ViewCellsManager *vcm) 3071 { 3072 mViewCellsManager = vcm; 3073 } 3074 3075 3076 AxisAlignedBox3 OspTree::GetBoundingBox() const 3077 { 3078 return mBoundingBox; 3079 } 3080 3081 3075 3082 void OspTree::RemoveContriFromPvs(Intersectable *object, int &pvs) const 3076 3083 { 3084 #if COUNT_OBJECTS 3085 -- pvs; 3086 #else 3077 3087 ViewCellPvsMap::const_iterator vit, vit_end = object->mViewCellPvs.mEntries.end(); 3078 3088 … … 3086 3096 } 3087 3097 } 3098 #endif 3088 3099 } 3089 3100 … … 3093 3104 ViewCellPvsMap::const_iterator vit, vit_end = object->mViewCellPvs.mEntries.end(); 3094 3105 3106 #if COUNT_OBJECTS 3107 ++ pvs; 3108 #else 3095 3109 for (vit = object->mViewCellPvs.mEntries.begin(); vit != vit_end; ++ vit) 3096 3110 { … … 3103 3117 } 3104 3118 } 3119 #endif 3105 3120 } 3106 3121 … … 3127 3142 } 3128 3143 3129 /* 3130 //sAxis = 2; 3144 // -- evaluate split cost for all three axis 3131 3145 for (int axis = 0; axis < 3; ++ axis) 3132 3146 { 3133 3147 if (!mOnlyDrivingAxis || (axis == sAxis)) 3134 3148 { 3135 //-- place split plane using heuristics 3136 3137 if (mUseCostHeuristics) 3138 { 3149 if (1 || mUseCostHeuristics) 3150 { 3151 //-- place split plane using heuristics 3152 int objectsFront, objectsBack; 3153 3139 3154 nCostRatio[axis] = 3140 EvalLocalCostHeuristics(*tData.mRays, 3141 box, 3142 tData.mPvs, 3143 axis, 3144 nPosition[axis]); 3145 } 3146 else //-- split plane position is spatial median 3147 { 3155 EvalLocalCostHeuristics(tData.mNode, 3156 tData.mBoundingBox, 3157 axis, 3158 nPosition[axis], 3159 objectsFront, 3160 objectsBack); 3161 } 3162 /* else 3163 { 3164 //-- split plane position is spatial median 3165 3148 3166 nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 3149 3167 … … 3154 3172 nProbFront[axis], 3155 3173 nProbBack[axis]); 3156 } 3174 }*/ 3157 3175 3158 3176 if (bestAxis == -1) … … 3167 3185 } 3168 3186 3169 */3170 3187 //-- assign values 3171 3188 3172 3189 plane.mAxis = bestAxis; 3173 3190 // split plane position … … 3184 3201 float OspTree::EvalViewCellPvsIncr(Intersectable *object) const 3185 3202 { 3186 return 0; 3203 // TODO 3204 return 1; 3187 3205 } 3188 3206 … … 3206 3224 3207 3225 Intersectable::NewMail(); 3226 KdLeaf::NewMail(); 3208 3227 ViewCell::NewMail(); 3209 3228 3210 KdLeaf *leaf = d ynamic_cast<KdLeaf *>(data.mNode);3229 KdLeaf *leaf = data.mNode; 3211 3230 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 3212 3231 … … 3252 3271 3253 3272 const float normalizedOldRenderCost = oldRenderCost / mBoundingBox.GetVolume(); 3273 3254 3274 return factor * renderCostDecrease + (1.0f - factor) * normalizedOldRenderCost; 3255 3275 } … … 3315 3335 3316 3336 3317 3318 /*********************************************************************/ 3319 /* class HierarchyManager implementation */ 3320 /*********************************************************************/ 3337 void OspTree::CollectLeaves(vector<KdLeaf *> &leaves) const 3338 { 3339 stack<KdNode *> nodeStack; 3340 nodeStack.push(mRoot); 3341 3342 while (!nodeStack.empty()) 3343 { 3344 KdNode *node = nodeStack.top(); 3345 nodeStack.pop(); 3346 if (node->IsLeaf()) 3347 { 3348 KdLeaf *leaf = (KdLeaf *)node; 3349 leaves.push_back(leaf); 3350 } 3351 else 3352 { 3353 KdInterior *interior = (KdInterior *)node; 3354 nodeStack.push(interior->mBack); 3355 nodeStack.push(interior->mFront); 3356 } 3357 } 3358 } 3359 3360 3361 AxisAlignedBox3 OspTree::GetBBox(KdNode *node) const 3362 { 3363 if (!node->mParent) 3364 return mBoundingBox; 3365 3366 if (!node->IsLeaf()) 3367 { 3368 return (dynamic_cast<KdInterior *>(node))->mBox; 3369 } 3370 3371 KdInterior *parent = dynamic_cast<KdInterior *>(node->mParent); 3372 3373 AxisAlignedBox3 box(parent->mBox); 3374 3375 if (parent->mFront == node) 3376 box.SetMin(parent->mAxis, parent->mPosition); 3377 else 3378 box.SetMax(parent->mAxis, parent->mPosition); 3379 3380 return box; 3381 } 3382 3383 3384 /********************************************************************/ 3385 /* class HierarchyManager implementation */ 3386 /********************************************************************/ 3321 3387 3322 3388 … … 3330 3396 SplitCandidate *HierarchyManager::NextSplitCandidate() 3331 3397 { 3332 SplitCandidate *splitCandidate = static_cast<SplitCandidate *>(mTQueue.Top()); 3333 //Debug << "priority: " << splitCandidate->GetPriority() << endl; 3398 SplitCandidate *splitCandidate = mTQueue.Top(); 3399 3400 Debug << "next candidate: " << splitCandidate->Type() 3401 << ", priority: " << splitCandidate->GetPriority() << endl; 3402 3334 3403 mTQueue.Pop(); 3335 3404 … … 3415 3484 3416 3485 // first osp traversal data 3417 OspTree::OspTraversalData oData( mOspTree.mRoot,3486 OspTree::OspTraversalData oData(leaf, 3418 3487 0, 3419 &rays,3420 3488 pvsSize, 3421 3489 prop, … … 3455 3523 3456 3524 void HierarchyManager::Construct2(const VssRayContainer &sampleRays, 3457 const ObjectContainer &objects,3458 AxisAlignedBox3 *forcedViewSpace)3525 const ObjectContainer &objects, 3526 AxisAlignedBox3 *forcedViewSpace) 3459 3527 { 3460 3528 RayInfoContainer *rays = new RayInfoContainer(); … … 3493 3561 3494 3562 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 3495 3496 3563 3497 3564 const int pvsSize = mVspTree.ComputePvsSize(*rays); … … 3549 3616 3550 3617 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 3551 3552 3618 mVspTree.mVspStats.Stop(); 3553 3554 3619 3620 Debug << "object space" << endl; 3555 3621 3556 3622 //-- object space partition … … 3566 3632 3567 3633 //-- first osp traversal data 3568 OspTree::OspTraversalData oData( mOspTree.mRoot,3634 OspTree::OspTraversalData oData(leaf, 3569 3635 0, 3570 rays,3571 3636 pvsSize, 3572 3637 prop, … … 3580 3645 mOspTree.EvalSplitCandidate(*oSplitCandidate); 3581 3646 3582 mTQueue.Push( splitCandidate);3647 mTQueue.Push(oSplitCandidate); 3583 3648 3584 3649 i = 0; … … 3590 3655 GlobalTerminationCriteriaMet(splitCandidate); 3591 3656 3592 cout << " view cells: " << i ++ << endl;3657 cout << "kd nodes: " << i ++ << endl; 3593 3658 3594 3659 // cost ratio of cost decrease / totalCost … … 3609 3674 DEL_PTR(splitCandidate); 3610 3675 } 3611 3676 3612 3677 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 3613 3678 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1101 r1106 181 181 int splits[3]; 182 182 183 // totals number of rays184 int rays;185 183 // maximal reached depth 186 184 int maxDepth; … … 194 192 // max depth nodes 195 193 int minPvsNodes; 196 // nodes with minimum PVS197 int minRaysNodes;198 // max ray contribution nodes199 int maxRayContribNodes;200 194 // minimum area nodes 201 195 int minProbabilityNodes; 202 196 /// nodes termination because of max cost ratio; 203 197 int maxCostNodes; 204 // max number of rays per node198 // max number of objects per node 205 199 int maxObjectRefs; 200 int objectRefs; 206 201 /// samples contributing to pvs 207 202 int contributingSamples; … … 214 209 /// accumulated number of rays refs 215 210 int accumRays; 211 /// potentially visible objects from this leaf 216 212 int pvs; 213 217 214 // accumulated depth (used to compute average) 218 215 int accumDepth; … … 230 227 // TODO: computation wrong 231 228 double AvgDepth() const { return accumDepth / (double)Leaves();}; 232 double AvgRays() const { return accumRays / (double)Leaves();};229 233 230 234 231 void Reset() … … 244 241 maxDepthNodes = 0; 245 242 minPvsNodes = 0; 246 minRaysNodes = 0; 247 maxRayContribNodes = 0; 243 248 244 minProbabilityNodes = 0; 249 245 maxCostNodes = 0; … … 254 250 maxPvs = 0; 255 251 invalidLeaves = 0; 256 accumRays = 0;252 objectRefs = 0; 257 253 } 254 258 255 259 256 void Print(ostream &app) const; … … 558 555 public: 559 556 static VspTree* sVspTree; 560 /// parent data557 /// parent node traversal data 561 558 VspTraversalData mParentData; 562 559 … … 619 616 /** Returns box which bounds the whole tree. 620 617 */ 621 AxisAlignedBox3 GetBoundingBox() const;618 AxisAlignedBox3 GetBoundingBox() const; 622 619 623 620 /** Returns root of the view space partitioning tree. … … 1060 1057 /// number of currenly generated view cells 1061 1058 int mCreatedViewCells; 1062 1063 private:1064 1065 /// Generates unique ids for PVS criterium1066 static void GenerateUniqueIdsForPvs();1067 1068 //-- unique ids for PVS criterium1069 static int sFrontId;1070 static int sBackId;1071 static int sFrontAndBackId;1072 1059 }; 1073 1060 … … 1088 1075 public: 1089 1076 /// the current node 1090 Kd Node*mNode;1077 KdLeaf *mNode; 1091 1078 /// current depth 1092 1079 int mDepth; 1093 1080 /// rays piercing this node 1094 RayInfoContainer *mRays;1081 //RayInfoContainer *mRays; 1095 1082 /// the probability that this node contains view point 1096 1083 float mProbability; … … 1106 1093 float mPriority; 1107 1094 1108 1109 /** Returns average ray contribution.1110 */1111 float GetAvgRayContribution() const1112 {1113 return (float)mPvs / ((float)mRays->size() + Limits::Small);1114 }1115 1116 1095 1117 1096 OspTraversalData(): 1118 1097 mNode(NULL), 1119 1098 mDepth(0), 1120 mRays(NULL),1121 1099 mPvs(0), 1122 1100 mProbability(0.0), … … 1126 1104 {} 1127 1105 1128 OspTraversalData(Kd Node*node,1106 OspTraversalData(KdLeaf *node, 1129 1107 const int depth, 1130 RayInfoContainer *rays,1131 1108 const int pvs, 1132 1109 const float p, … … 1134 1111 mNode(node), 1135 1112 mDepth(depth), 1136 mRays(rays),1137 1113 mPvs(pvs), 1138 1114 mProbability(p), … … 1144 1120 1145 1121 OspTraversalData(const int depth, 1146 RayInfoContainer *rays,1147 1122 const AxisAlignedBox3 &box): 1148 1123 mNode(NULL), 1149 1124 mDepth(depth), 1150 mRays(rays),1151 1125 mPvs(0), 1152 1126 mProbability(0), … … 1167 1141 void Clear() 1168 1142 { 1169 DEL_PTR(mRays);1170 1143 } 1171 1144 … … 1189 1162 {}; 1190 1163 1191 int Type() const { return VIEW_SPACE; }1164 int Type() const { return OBJECT_SPACE; } 1192 1165 1193 1166 void EvalPriority() … … 1231 1204 /** Returns bounding box of the specified node. 1232 1205 */ 1233 AxisAlignedBox3 GetB oundingBox(KdNode *node) const;1234 1235 /** Returns list of BSPleaves with pvs smaller than1206 AxisAlignedBox3 GetBBox(KdNode *node) const; 1207 1208 /** Returns list of leaves with pvs smaller than 1236 1209 a certain threshold. 1237 1210 @param onlyUnmailed if only the unmailed leaves should be considered 1238 1211 @param maxPvs the maximal pvs of a leaf to be added (-1 means unlimited) 1239 1212 */ 1240 void CollectLeaves(vector<VspLeaf *> &leaves,1241 const bool onlyUnmailed = false,1242 const int maxPvs = -1) const; 1243 1244 /** Returns bo x which bounds the whole tree.1213 1214 void CollectLeaves(vector<KdLeaf *> &leaves) const; 1215 1216 1217 /** Returns bounding box of the whole tree (= bbox of root node) 1245 1218 */ 1246 1219 AxisAlignedBox3 GetBoundingBox()const; … … 1406 1379 @returns the root of the subdivision 1407 1380 */ 1381 KdInterior *SubdivideNode(KdLeaf *leaf, 1382 const AxisAlignedPlane &splitPlane, 1383 const AxisAlignedBox3 &box, 1384 OspTraversalData &frontData, 1385 OspTraversalData &backData); 1386 1408 1387 void SplitObjects(const AxisAlignedPlane & splitPlane, 1409 1388 const ObjectContainer &objects, 1410 ObjectContainer &back, 1411 ObjectContainer &front); 1412 1413 KdInterior *SubdivideNode(KdLeaf *leaf, 1414 const AxisAlignedPlane &splitPlane, 1415 const AxisAlignedBox3 &box, 1416 AxisAlignedBox3 &backBBox, 1417 AxisAlignedBox3 &frontBBox); 1389 ObjectContainer &front, 1390 ObjectContainer &back); 1418 1391 1419 1392 void ProcessLeafObjects(KdLeaf *leaf, KdLeaf *parent) const; … … 1439 1412 const int axis, 1440 1413 float &position, 1441 int &objects Back,1442 int &objects Front);1414 int &objectsFront, 1415 int &objectsBack); 1443 1416 1444 1417 /** Subdivides the rays into front and back rays according to the split plane. … … 1553 1526 //-- local termination 1554 1527 1555 /// minimal number of rays before subdivision termination1556 int mTermMinRays;1557 1528 /// maximal possible depth 1558 1529 int mTermMaxDepth; 1559 1530 /// mininum probability 1560 1531 float mTermMinProbability; 1561 /// mini num PVS1562 int mTermMin Pvs;1532 /// minimal number of objects 1533 int mTermMinObjects; 1563 1534 /// maximal contribution per ray 1564 1535 float mTermMaxRayContribution; … … 1569 1540 1570 1541 1542 1571 1543 //-- global criteria 1572 1544 float mTermMinGlobalCostRatio; … … 1575 1547 1576 1548 /// maximal number of view cells 1577 int m MaxViewCells;1549 int mTermMaxLeaves; 1578 1550 /// maximal tree memory 1579 1551 float mMaxMemory; … … 1590 1562 /// if only driving axis should be used for split 1591 1563 bool mOnlyDrivingAxis; 1592 /// if random split axis should be used 1593 bool mUseRandomAxis; 1594 /// if vsp bsp tree should simulate octree 1595 bool mCirculatingAxis; 1596 /// minimal relative position where the split axis can be placed 1597 float mMinBand; 1598 /// maximal relative position where the split axis can be placed 1599 float mMaxBand; 1600 1601 1564 1602 1565 /// current time stamp (used for keeping split history) 1603 1566 int mTimeStamp; … … 1616 1579 int mTotalPvsSize; 1617 1580 /// number of currenly generated view cells 1618 int mCreatedViewCells; 1619 1581 int mCreatedLeaves; 1582 1583 /// represents min and max band for sweep 1620 1584 float mSplitBorder; 1621 1622 1623 private:1624 1625 /// Generates unique ids for PVS criterium1626 static void GenerateUniqueIdsForPvs();1627 1628 //-- unique ids for PVS criterium1629 static int sFrontId;1630 static int sBackId;1631 static int sFrontAndBackId;1632 1585 }; 1633 1586 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r1020 r1106 9 9 #include "Polygon3.h" 10 10 #include "VssRay.h" 11 //#include "VspOspTree.h"11 #include "VspOspTree.h" 12 12 #include "VssTree.h" 13 13 #include "VspBspTree.h" … … 538 538 } 539 539 540 #if 0541 bool X3dExporter::ExportVspOspTree(const VspOspTree &tree, const int maxPvs)542 {543 stack<VspKdNode *> tStack;544 545 tStack.push(tree.GetRoot());546 547 //Mesh *mesh = new Mesh;548 549 if (maxPvs > 0)550 mUseForcedMaterial = true;551 552 while (!tStack.empty())553 {554 VspKdNode *node = tStack.top();555 556 tStack.pop();557 558 if (node->IsLeaf())559 {560 AxisAlignedBox3 box = tree.GetBBox(node);561 562 Mesh *mesh = new Mesh;563 564 // add 6 vertices of the box565 int index = (int)mesh->mVertices.size();566 567 for (int i=0; i < 8; ++ i)568 {569 Vector3 v;570 box.GetVertex(i, v);571 mesh->mVertices.push_back(v);572 }573 574 mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) );575 mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) );576 mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) );577 578 mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) );579 mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) );580 mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) );581 582 if (maxPvs > 0)583 {584 VspKdLeaf *leaf = dynamic_cast<VspKdLeaf *>(node);585 586 mForcedMaterial.mDiffuseColor.b = 1.0f;587 588 leaf->UpdatePvsSize();589 590 const float importance = (float)leaf->GetPvsSize() / (float)maxPvs;591 mForcedMaterial.mDiffuseColor.r = importance;592 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r;593 }594 595 ExportMesh(mesh);596 DEL_PTR(mesh);597 }598 else599 {600 VspKdInterior *interior = dynamic_cast<VspKdInterior *>(node);601 tStack.push(interior->GetFront());602 tStack.push(interior->GetBack());603 }604 }605 606 //ExportMesh(mesh);607 //DEL_PTR(mesh);608 609 return true;610 }611 #endif612 540 613 541 bool X3dExporter::ExportKdTree(const KdTree &tree) … … 1309 1237 } 1310 1238 1311 } 1239 1240 bool X3dExporter::ExportOspTree(const OspTree &ospTree) 1241 { 1242 vector<KdLeaf *> leaves; 1243 ospTree.CollectLeaves(leaves); 1244 1245 vector<KdLeaf *>::const_iterator it, it_end = leaves.end(); 1246 1247 for (it = leaves.begin(); it != it_end; ++ it) 1248 { 1249 ExportBox(ospTree.GetBBox(*it)); 1250 } 1251 1252 return true; 1253 } 1254 1255 1256 } -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.h
r1006 r1106 59 59 const Vector3 direction 60 60 ); 61 #if VSP_OPS 61 62 62 bool 63 Export VspOspTree(const VspOspTree &tree, const int maxPvs);64 #endif 63 ExportOspTree(const OspTree &tree); 64 65 65 bool ExportBspTree(const BspTree &tree); 66 66
Note: See TracChangeset
for help on using the changeset viewer.