Changeset 1418 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 09/19/06 22:33:29 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1416 r1418 1274 1274 "view_cells_evaluation_stats_prefix=", 1275 1275 "viewCells"); 1276 1276 1277 RegisterOption("ViewCells.Evaluation.histogram", 1277 1278 optBool, … … 1490 1491 1491 1492 1492 /**************************************************************************** ********/1493 /* Render simulation related options*/1494 /**************************************************************************** ********/1493 /****************************************************************************/ 1494 /* Render simulation related options */ 1495 /****************************************************************************/ 1495 1496 1496 1497 -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1416 r1418 106 106 bool Exporter::ExportBvHierarchy(const BvHierarchy &bvHierarchy, 107 107 const int maxPvs, 108 const AxisAlignedBox3 *box) 108 const AxisAlignedBox3 *box, 109 const bool exportBoundingBoxes) 109 110 { 110 111 vector<BvhLeaf *> leaves; … … 122 123 { 123 124 BvhLeaf *leaf = *it; 124 if (leaf->mObjects.empty()) 125 126 if (leaf->mObjects.empty() || 127 (box && !Overlap(*box, leaf->GetBoundingBox()))) 125 128 continue; 126 129 127 if (box && !Overlap(*box, leaf->GetBoundingBox())) 128 continue; 129 130 SetWireframe(); 131 SetForcedMaterial(white); 132 ExportBox(leaf->GetBoundingBox()); 133 SetFilled(); 134 135 if (maxPvs) // color code pvs 130 if (exportBoundingBoxes) 131 { 132 SetWireframe(); 133 SetForcedMaterial(white); 134 ExportBox(leaf->GetBoundingBox()); 135 } 136 137 if (maxPvs) // color code pvs 136 138 { 137 139 mForcedMaterial.mDiffuseColor.b = 1.0f; … … 146 148 } 147 149 148 if (1) 149 { 150 SetFilled(); 151 ExportGeometry(leaf->mObjects, true); 152 } 153 } 150 SetFilled(); 151 ExportGeometry(leaf->mObjects, true); 152 } 153 154 SetFilled(); 154 155 155 156 return true; … … 176 177 { 177 178 const Triangle3 triangle = dynamic_cast<TriangleIntersectable *>(object)->GetItem(); 178 179 VertexContainer vertices; 180 vertices.push_back(triangle.mVertices[0]); 181 vertices.push_back(triangle.mVertices[1]); 182 vertices.push_back(triangle.mVertices[2]); 183 184 Polygon3 poly(vertices); 179 Polygon3 poly(triangle); 185 180 ExportPolygon(&poly); 186 181 break; 187 182 } 183 case Intersectable::BVH_INTERSECTABLE: 184 { 185 BvhNode *node = dynamic_cast<BvhIntersectable *>(object)->GetItem(); 186 if (node->IsLeaf()) 187 ExportGeometry(dynamic_cast<BvhLeaf *>(node)->mObjects, true); 188 break; 189 } 188 190 default: 189 191 cerr << "Sorry the export for object type " << Intersectable::GetTypeName(object) << " is not available yet" << endl; … … 191 193 } 192 194 } 195 193 196 194 197 void Exporter::ExportMeshInstance(MeshInstance *object) … … 234 237 for (oit = objects.begin(); oit != oit_end; ++ oit) 235 238 { 236 if ( bbox &&Overlap(*bbox, (*oit)->GetBox()))239 if (!bbox || Overlap(*bbox, (*oit)->GetBox())) 237 240 { 238 241 if (0) SetForcedMaterial(RandomMaterial()); … … 240 243 } 241 244 } 242 243 245 return; 244 246 } 245 246 247 247 /////////////////////////////////////////// 248 249 /////////////////////// 248 250 //-- all objects exported as one mesh 249 //-- hack: currently works only for triangles251 //-- warning: currently works only for triangles 250 252 251 253 PolygonContainer polys; … … 255 257 Intersectable *obj = *oit; 256 258 257 if (bbox && !Overlap(*bbox, (*oit)->GetBox())) 259 if (bbox && !Overlap(*bbox, obj->GetBox())) 260 { 261 //cout << *bbox << " " << obj->GetBox() << endl; 258 262 continue; 263 } 259 264 260 265 switch (obj->Type()) … … 266 271 break; 267 272 } 273 case Intersectable::MESH_INSTANCE: 274 { 275 MeshInstance *mi = dynamic_cast<MeshInstance *>(obj); 276 ExportMesh(mi->GetMesh()); 277 //polys.push_back(new Polygon3(ti->GetItem())); 278 break; 279 } 268 280 default: 269 281 cout << "merging of object type " << obj->Type() << " not implemented yet" << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
r1416 r1418 154 154 const BvHierarchy &bvHierarchy, 155 155 const int maxPvs, 156 const AxisAlignedBox3 *box = NULL); 156 const AxisAlignedBox3 *box = NULL, 157 const bool exportBoundingBoxes = true); 157 158 158 159 virtual void ExportMeshInstance(MeshInstance *mi); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1416 r1418 281 281 RunConstruction(sampleRays, objects, forcedViewSpace); 282 282 283 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 284 283 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 284 285 cout << "here5 " << GetViewSpaceBox() << endl; 286 cout << "here6 " << GetObjectSpaceBox() << endl; 285 287 mHierarchyStats.Stop(); 286 288 mVspTree->mVspStats.Stop(); 287 FinishObjectSpaceSubdivision( );289 FinishObjectSpaceSubdivision(objects); 288 290 289 291 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; … … 762 764 void HierarchyManager::ExportObjectSpaceHierarchy(Exporter *exporter, 763 765 const ObjectContainer &objects, 764 const AxisAlignedBox3 *bbox) const 766 const AxisAlignedBox3 *bbox, 767 const bool exportBounds) const 765 768 { 766 769 switch (mObjectSpaceSubdivisionType) … … 773 776 case BV_BASED_OBJ_SUBDIV: 774 777 { 775 ExportBvHierarchy(exporter, objects, bbox);778 exporter->ExportBvHierarchy(*mBvHierarchy, 0, bbox, exportBounds); 776 779 break; 777 780 } … … 779 782 break; 780 783 } 781 }782 783 784 void HierarchyManager::ExportBvHierarchy(Exporter *exporter,785 const ObjectContainer &objects,786 const AxisAlignedBox3 *bbox) const787 {788 exporter->SetWireframe();789 exporter->ExportBvHierarchy(*mBvHierarchy, 0, bbox);790 784 } 791 785 … … 801 795 802 796 797 Intersectable *HierarchyManager::GetIntersectable(const VssRay &ray, 798 const bool isTermination) const 799 { 800 801 Intersectable *obj; 802 Vector3 pt; 803 KdNode *node; 804 805 ray.GetSampleData(isTermination, pt, &obj, &node); 806 807 if (!obj) return NULL; 808 809 switch (mObjectSpaceSubdivisionType) 810 { 811 case HierarchyManager::KD_BASED_OBJ_SUBDIV: 812 { 813 KdLeaf *leaf = mOspTree->GetLeaf(pt, node); 814 return mOspTree->GetOrCreateKdIntersectable(leaf); 815 } 816 case HierarchyManager::BV_BASED_OBJ_SUBDIV: 817 { 818 BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 819 return mBvHierarchy->GetOrCreateBvhIntersectable(leaf); 820 } 821 default: 822 return obj; 823 } 824 } 825 826 803 827 void HierarchyStatistics::Print(ostream &app) const 804 828 { … … 823 847 824 848 825 void HierarchyManager::FinishObjectSpaceSubdivision() const 849 static void RemoveRayRefs(const ObjectContainer &objects) 850 { 851 ObjectContainer::const_iterator oit, oit_end = objects.end(); 852 for (oit = objects.begin(); oit != oit_end; ++ oit) 853 { 854 (*oit)->mVssRays.clear(); 855 } 856 } 857 858 859 void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects) const 826 860 { 827 861 switch (mObjectSpaceSubdivisionType) … … 835 869 { 836 870 mBvHierarchy->mBvhStats.Stop(); 871 RemoveRayRefs(objects); 837 872 break; 838 873 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1416 r1418 206 206 Exporter *exporter, 207 207 const ObjectContainer &objects, 208 const AxisAlignedBox3 *bbox) const; 209 208 const AxisAlignedBox3 *bbox, 209 const bool exportBounds = true) const; 210 211 212 Intersectable *GetIntersectable( 213 const VssRay &ray, 214 const bool isTermination) const; 210 215 211 216 protected: … … 254 259 void ExportOspTree(Exporter *exporter, const ObjectContainer &objects) const; 255 260 256 void ExportBvHierarchy(257 Exporter *exporter,258 const ObjectContainer &objects,259 const AxisAlignedBox3 *box) const;260 261 void PrepareBvHierarchy(262 const VssRayContainer &sampleRays,263 const ObjectContainer &objects);264 265 void PrepareOspTree(266 const VssRayContainer &sampleRays,267 const ObjectContainer &objects);268 269 261 void ParseEnvironment(); 270 262 … … 272 264 bool StartViewSpaceSubdivision() const; 273 265 266 void PrepareBvHierarchy( 267 const VssRayContainer &sampleRays, 268 const ObjectContainer &objects); 269 270 void PrepareOspTree( 271 const VssRayContainer &sampleRays, 272 const ObjectContainer &objects); 273 274 274 void PrepareViewSpaceSubdivision( 275 275 const VssRayContainer &sampleRays, … … 281 281 void ResetQueue(); 282 282 283 void FinishObjectSpaceSubdivision( ) const;283 void FinishObjectSpaceSubdivision(const ObjectContainer &objects) const; 284 284 285 285 int GetObjectSpaceSubdivisionDepth() const; -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1344 r1418 476 476 477 477 Plane3 478 Mesh::GetFacePlane(const int faceIndex) 478 Mesh::GetFacePlane(const int faceIndex) const 479 479 { 480 480 Face *face = mFaces[faceIndex]; … … 521 521 522 522 523 Vector3 Mesh::GetNormal(const int idx) const 524 { 525 return GetFacePlane(idx).mNormal; 526 } 527 528 523 529 void 524 530 Mesh::AddTriangle(const Triangle3 &triangle) … … 728 734 Vector3 MeshInstance::GetNormal(const int idx) const 729 735 { 730 return mMesh->Get FacePlane(idx).mNormal;736 return mMesh->GetNormal(idx); 731 737 } 732 738 -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r1344 r1418 187 187 ); 188 188 189 Plane3 GetFacePlane(const int faceIndex) ;189 Plane3 GetFacePlane(const int faceIndex) const; 190 190 191 191 AxisAlignedBox3 GetFaceBox(const int faceIndex); … … 207 207 } 208 208 209 210 Vector3 GetNormal(const int idx) const; 211 209 212 virtual ostream &Describe(ostream &s) { 210 213 return s<<"Mesh #vertices="<<(int)mVertices.size()<<" #faces="<<(int)mFaces.size(); -
GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.h
r1076 r1418 77 77 AxisAlignedPlane(){} 78 78 AxisAlignedPlane(const int axis, const float position): 79 mAxis(axis), mPosition(position) 79 mAxis(axis), mPosition(position), mOrientation(false) 80 80 { 81 81 } 82 82 Plane3 GetPlane() const 83 83 { 84 Vector3 normal(0,0,0); normal[mAxis] = 1;84 Vector3 normal(0,0,0); normal[mAxis] = mOrientation ? 1.0f : -1.0f; 85 85 Vector3 point(0,0,0); point[mAxis] = mPosition; 86 86 … … 92 92 /// the absolute position of the split axis 93 93 float mPosition; 94 /// the plane orientation 95 bool mOrientation; 96 97 friend ostream &operator<<(ostream &s, const AxisAlignedPlane &p) 98 { 99 s << "a: " << p.mAxis << " p: " << p.mPosition; 100 return s; 101 } 94 102 }; 95 96 97 103 } 98 99 104 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
r1404 r1418 66 66 mVertices.push_back(tri.mVertices[1]); 67 67 mVertices.push_back(tri.mVertices[2]); 68 69 //cout << "poly n: " << GetNormal() << " t normal: " << tri.GetNormal() << endl; 68 70 } 69 71 … … 539 541 while (i < k) 540 542 { 541 triangles.push_back(Triangle3(mVertices[i], mVertices[j], mVertices[k])); 543 if (0) // matt: I don't know why i made it like this because the normals are wrong!! 544 triangles.push_back(Triangle3(mVertices[i], mVertices[j], mVertices[k])); 545 else 546 triangles.push_back(Triangle3(mVertices[k], mVertices[j], mVertices[i])); 542 547 543 548 if ((count ++) % 2) -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1416 r1418 788 788 789 789 790 bool Preprocessor::InitRayCast(const string externKdTree) 791 { 792 bool loadKdTree, exportKdTree; 793 790 bool Preprocessor::InitRayCast(const string externKdTree, const string internkdtree) 791 { 792 bool loadKdTree; 794 793 Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree); 795 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree);796 797 char kdtreename[100];798 Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", kdtreename);799 800 794 801 795 if (!loadKdTree) 802 { //////796 { 803 797 //-- build new kd tree from scene geometry 804 798 BuildKdTree(); … … 808 802 { 809 803 const long startTime = GetTime(); 810 cout << "loading kd tree file " << kdtreename << " ... ";811 812 if (!LoadKdTree( kdtreename))804 cout << "loading kd tree file " << internkdtree << " ... "; 805 806 if (!LoadKdTree(internkdtree)) 813 807 { 814 cout << "error loading kd tree with filename " << kdtreename << endl; 815 return false; 808 cout << "error loading kd tree with filename " << internkdtree << ", rebuilding it instead ..." << endl; 809 810 BuildKdTree(); 811 KdTreeStatistics(cout); 816 812 } 817 813 … … 827 823 delete exporter; 828 824 } 829 }830 }831 832 if (exportKdTree)833 {834 const long startTime = GetTime();835 cout << "exporting kd tree ... ";836 if (!ExportKdTree(kdtreename))837 {838 cout << " error exporting kd tree with filename " << kdtreename << endl;839 }840 else841 {842 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;843 825 } 844 826 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1415 r1418 168 168 GlRendererBuffer *GetRenderer() { return renderer;} 169 169 170 bool InitRayCast(const string externKdTree );170 bool InitRayCast(const string externKdTree, const string internKdTree); 171 171 172 172 int CastRay( -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1291 r1418 130 130 { 131 131 DEL_PTR(mPvs); 132 133 VssRayContainer::const_iterator vit, vit_end = mVssRays.end(); 134 for (vit = mVssRays.begin(); vit != vit_end; ++ vit) 135 { 136 VssRay *ray = *vit; 137 ray->Unref(); 138 139 if (!ray->IsActive()) 140 delete ray; 141 } 132 142 } 133 143 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1416 r1418 181 181 182 182 183 184 Debug << "************ View Cells options ***************" << endl; 183 Debug << "************ View Cells Manager options ***************" << endl; 185 184 Debug << "color code: " << mColorCode << endl; 186 185 … … 211 210 Debug << "export bounding boxes: " << mExportBboxesForPvs << endl; 212 211 Debug << "export pvs for view cells: " << mExportPvs << endl; 213 214 212 Debug << endl; 215 213 } … … 511 509 512 510 513 AxisAlignedPlane * 511 AxisAlignedPlane *ViewCellsManager::GetClipPlane() 514 512 { 515 513 return mUseClipPlaneForViz ? &mClipPlaneForViz : NULL; … … 1696 1694 int axis = 0; 1697 1695 float pos; 1696 bool orientation; 1697 Vector3 absPos; 1698 1698 1699 1699 Environment::GetSingleton()->GetFloatValue("ViewCells.Visualization.clipPlanePos", pos); 1700 Vector3 absPos = mViewSpaceBox.Min() + mViewSpaceBox.Size() * pos;1701 1702 1700 Environment::GetSingleton()->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis); 1703 1701 1702 if (axis < 0) 1703 { 1704 axis = -axis; 1705 orientation = false; 1706 absPos = mViewSpaceBox.Max() - mViewSpaceBox.Size() * pos; 1707 } 1708 else 1709 { 1710 orientation = true; 1711 absPos = mViewSpaceBox.Min() + mViewSpaceBox.Size() * pos; 1712 } 1713 1704 1714 mClipPlaneForViz = AxisAlignedPlane(axis, absPos[axis]); 1715 mClipPlaneForViz.mOrientation = orientation; 1705 1716 } 1706 1717 … … 2658 2669 2659 2670 2660 //////////////////////// /////////////////2671 //////////////////////// 2661 2672 //-- visualization and statistics 2662 2673 … … 2729 2740 if (1) FinalizeViewCells(true); 2730 2741 2731 // write view cells to disc 2732 if ( mExportViewCells)2742 // write view cells to disc (this moved to preprocessor) 2743 if (0 && mExportViewCells) 2733 2744 { 2734 2745 char filename[100]; … … 2843 2854 2844 2855 // sort view cells in order to find the largest view cells 2845 if (0) 2846 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 2856 if (0) stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 2847 2857 2848 2858 int limit = min(leafOut, (int)mViewCells.size()); … … 3840 3850 } 3841 3851 3842 3843 3852 // view cells already finished before post processing step 3844 3853 // (i.e. because they were loaded) … … 3885 3894 if (0) FinalizeViewCells(false); 3886 3895 3887 ////////////////// ////////////////////3896 ////////////////// 3888 3897 //-- merge the individual view cells 3889 3898 MergeViewCells(postProcessRays, objects); … … 3893 3902 if (0) RefineViewCells(postProcessRays, objects); 3894 3903 3895 ////////////////// /////////////////////////3904 ////////////////// 3896 3905 //-- render simulation after merge + refine 3897 3906 … … 3904 3913 3905 3914 3906 //////////// ///////3915 //////////// 3907 3916 //-- compression 3908 3917 … … 3927 3936 // compute final meshes and volume / area 3928 3937 if (1) FinalizeViewCells(true); 3929 3938 cout << "here09*******************" << endl; 3930 3939 // write view cells to disc 3931 if ( mExportViewCells)3932 { 3940 if (0 && mExportViewCells) 3941 {cout << "here77*******************" << endl; 3933 3942 char filename[100]; 3934 3943 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); … … 4832 4841 } 4833 4842 4834 4835 // take this step only if 4836 // view cells already constructed before post processing step 4837 // (e.g., because they were loaded) 4843 // if view cells were already constructed before post processing step 4844 // (e.g., because they were loaded), we are finished 4838 4845 if (mViewCellsFinished) 4839 4846 { … … 4881 4888 mViewCellsTree->SetRoot(root); 4882 4889 4883 //////////////////////////////////// 4890 4891 ////////////////////////// 4884 4892 //-- update pvs in the whole hierarchy 4885 4893 ObjectPvs pvs; … … 4887 4895 4888 4896 4889 ////////////////////// /////////////////////4897 ////////////////////// 4890 4898 //-- render simulation after merge + refine 4891 4899 … … 4896 4904 cout << ss << endl; 4897 4905 4898 /////////////// ////////4906 /////////////// 4899 4907 //-- compression 4900 4908 … … 4910 4918 } 4911 4919 4912 /////////////// //////////////////////4920 /////////////// 4913 4921 //-- compute final meshes and volume / area 4914 4922 if (1) FinalizeViewCells(true); 4915 4923 4916 4917 // write out view cells4918 if (mExportViewCells)4919 {4924 // write out view cells (this moved to preprocessor) 4925 if (0 && mExportViewCells) 4926 { 4927 cout << "here5" << endl; 4920 4928 char filename[100]; 4921 4929 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); … … 5005 5013 { 5006 5014 ViewCellContainer leaves; 5007 5008 5015 mViewCellsTree->CollectLeaves(vc, leaves); 5009 5016 ViewCellContainer::const_iterator it, it_end = leaves.end(); 5010 5017 5011 5018 Plane3 plane; 5012 5013 5019 if (clipPlane) 5020 { 5021 // arbitrary plane definition 5014 5022 plane = clipPlane->GetPlane(); 5023 } 5015 5024 5016 5025 for (it = leaves.begin(); it != it_end; ++ it) … … 5022 5031 mHierarchyManager->GetVspTree()->GetBoundingBox(vspVc->mLeaf); 5023 5032 5024 if ( !Overlap(*sceneBox, box))5033 if (sceneBox && !Overlap(*sceneBox, box)) 5025 5034 continue; 5026 5035 … … 5033 5042 else if (box.Side(plane) == 0) 5034 5043 { 5044 // intersection 5035 5045 AxisAlignedBox3 fbox, bbox; 5036 bbox.Split(clipPlane->mAxis, clipPlane->mPosition, fbox, bbox); 5037 5046 box.Split(clipPlane->mAxis, clipPlane->mPosition, fbox, bbox); 5038 5047 exporter->ExportBox(bbox); 5039 5048 } … … 5083 5092 cout << "exporting final view cells (after initial construction + post process) ... "; 5084 5093 5085 // matt: hack 5094 // matt: hack for clamping scene 5086 5095 AxisAlignedBox3 bbox = mHierarchyManager->GetViewSpaceBox(); 5087 5096 bbox.Scale(Vector3(0.5, 1, 0.5)); 5088 5089 if (mExportGeometry) 5097 5098 exporter->SetWireframe(); 5099 exporter->ExportBox(bbox); 5100 exporter->SetFilled(); 5101 5102 5103 if (0 && mExportGeometry) 5090 5104 { 5091 5105 exporter->ExportGeometry(objects, true, &bbox); … … 5097 5111 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 5098 5112 } 5099 5113 5114 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, &bbox, false); 5100 5115 ExportViewCellsForViz(exporter, &bbox, GetClipPlane()); 5101 5102 5116 delete exporter; 5103 5117 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; … … 5145 5159 Debug << "\nOutput view cells: " << endl; 5146 5160 5147 const bool sortViewCells = true; 5148 5149 if (sortViewCells) 5150 { 5151 //stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 5161 const bool sortedViewCells = false; 5162 5163 if (sortedViewCells) 5164 { 5152 5165 // sort view cells to visualize the view cells with highest render cost 5153 5166 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); … … 5157 5170 int raysOut = 0; 5158 5171 5159 /////////////// ////////////5172 /////////////// 5160 5173 //-- some rays for output 5161 5174 … … 5163 5176 { 5164 5177 cout << "creating output for view cell " << i << " ... "; 5165 5166 ViewCell *vc; 5167 5168 if (sortViewCells) // largest view cell pvs first 5169 vc = mViewCells[i]; 5170 else // random view cell 5171 vc = mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 5172 5178 5179 // largest view cell pvs first of random view cell 5180 ViewCell *vc = sortedViewCells ? 5181 mViewCells[i] : mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 5182 5173 5183 ObjectPvs pvs; 5174 5184 mViewCellsTree->GetPvs(vc, pvs); … … 5179 5189 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 5180 5190 5191 //////////// 5181 5192 //-- export the sample rays 5193 5182 5194 if (1 || mExportRays) 5183 5195 { … … 5199 5211 { 5200 5212 VspLeaf *vcLeaf = dynamic_cast<VspViewCell *>(*vit)->mLeaf; 5201 5202 5213 VssRayContainer::const_iterator rit, rit_end = vcLeaf->mVssRays.end(); 5203 5214 … … 5212 5223 for (rit = collectRays.begin(); rit != rit_end; ++ rit) 5213 5224 { 5214 float p = RandomValue(0.0f, (float)collectRays.size());5225 const float p = RandomValue(0.0f, (float)collectRays.size()); 5215 5226 5216 5227 if (p < raysOut) 5217 5228 vcRays.push_back(*rit); 5218 5229 } 5219 5230 5220 5231 //-- export rays piercing this view cell 5221 5232 exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 5233 5234 //-- export objects seen from the rays 5235 Intersectable::NewMail(); 5236 VssRayContainer::const_iterator vcit, vcit_end = vcRays.end(); 5237 for (vcit = vcRays.begin(); vcit != vcit_end; ++ vcit) 5238 { 5239 VssRay *ray = *vcit; 5240 //Intersectable *obj = ray->mTerminationObject; 5241 Intersectable *obj = mHierarchyManager->GetIntersectable(*ray, true); 5242 5243 if (obj && !obj->Mailed()) 5244 { 5245 obj->Mail(); 5246 // exporter->ExportIntersectable(obj); 5247 } 5248 } 5222 5249 } 5223 5224 // associate new rays with output view cell 5225 if (0) 5226 { 5227 VssRayContainer vcRays; 5228 raysOut = min((int)rays.size(), mVisualizationSamples); 5229 5230 // check whether we can add the current ray to the output rays 5231 for (int k = 0; k < raysOut; ++ k) 5232 { 5233 VssRay *ray = rays[k]; 5234 for (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 5235 { 5236 ViewCell *rayvc = ray->mViewCells[j]; 5237 5238 if (rayvc == vc) 5239 vcRays.push_back(ray); 5240 } 5241 } 5242 5243 // export rays piercing this view cell 5244 exporter->ExportRays(vcRays, RgbColor(1, 1, 0)); 5245 } 5246 } 5247 5250 } 5248 5251 5249 5252 ///////////////// … … 5259 5262 exporter->SetFilled(); 5260 5263 5261 #if 05262 //////////5263 //-- export pvs5264 5265 Intersectable::NewMail();5266 KdLeaf::NewMail();5267 5268 vector<KdLeaf *> kdLeaves;5269 5270 ObjectPvsMap::const_iterator oit, oit_end = pvs.mEntries.end();5271 5272 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit)5273 {5274 Intersectable *obj = (*oit).first;5275 5276 if (obj->Type() == Intersectable::KD_INTERSECTABLE)5277 {5278 m.mDiffuseColor = RgbColor(1, 1, 1);5279 exporter->SetForcedMaterial(m);5280 5281 // export bounding box of node5282 KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj);5283 AxisAlignedBox3 box = mOspTree->GetBoundingBox(kdObj->GetItem());5284 5285 exporter->SetWireframe();5286 exporter->ExportBox(box);5287 exporter->SetFilled();5288 }5289 5290 m.mDiffuseColor = RgbColor(1, 0, 0);5291 exporter->SetForcedMaterial(m);5292 5293 // export pvs entry5294 if (!obj->Mailed())5295 {5296 exporter->ExportIntersectable(obj);5297 obj->Mail();5298 }5299 }5300 #endif5301 5302 5264 DEL_PTR(exporter); 5303 5265 cout << "finished" << endl; … … 5398 5360 if (!ViewCellsConstructed()) 5399 5361 return NULL; 5400 5401 5362 if (!mViewSpaceBox.IsInside(point)) 5402 return NULL; 5403 5363 return NULL; 5404 5364 return mHierarchyManager->GetVspTree()->GetViewCell(point, active); 5405 5365 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1302 r1418 1281 1281 if (madeContrib) 1282 1282 ++ contributingSamples; 1283 1284 // note: vss rays are never deleted1285 if (0) leaf->mVssRays.push_back(new VssRay(*ray));1286 1283 } 1287 1284 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1415 r1418 305 305 { 306 306 DEL_PTR(mPvs); 307 CLEAR_CONTAINER(mVssRays); 307 308 VssRayContainer::const_iterator vit, vit_end = mVssRays.end(); 309 for (vit = mVssRays.begin(); vit != vit_end; ++ vit) 310 { 311 VssRay *ray = *vit; 312 ray->Unref(); 313 314 if (!ray->IsActive()) 315 delete ray; 316 } 317 //CLEAR_CONTAINER(mVssRays); 308 318 } 309 319 … … 357 367 mRoot(NULL), 358 368 mOutOfBoundsCell(NULL), 359 mStoreRays( false),369 mStoreRays(true), 360 370 mTimeStamp(1), 361 371 mHierarchyManager(NULL) … … 588 598 } 589 599 590 591 //-- store additional info592 600 if (mStoreRays) 593 601 { 602 /////////// 603 //-- store sampling rays 594 604 RayInfoContainer::const_iterator it, it_end = tData.mRays->end(); 595 605 … … 684 694 685 695 #if 0 696 ///////////// 686 697 //-- store pvs optained from rays 687 698 AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); … … 694 705 mVspStats.sampleContributions += (int)sampCon; 695 706 #endif 696 //-- store additional info697 707 if (mStoreRays) 698 708 { 709 ////////// 710 //-- store rays piercing this view cell 699 711 RayInfoContainer::const_iterator it, it_end = tData.mRays->end(); 700 712 for (it = tData.mRays->begin(); it != it_end; ++ it) … … 702 714 (*it).mRay->Ref(); 703 715 leaf->mVssRays.push_back((*it).mRay); 716 //leaf->mVssRays.push_back(new VssRay(*(*it).mRay)); 704 717 } 705 718 } … … 767 780 VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 768 781 769 /////////////// /////////////////////////////////////////770 //-- the front and back traversal data are filled with the newvalues782 /////////////// 783 //-- new traversal values 771 784 772 785 frontData.mDepth = tData.mDepth + 1; … … 782 795 *backData.mRays); 783 796 797 ///////////// 784 798 //-- compute pvs 785 799 frontData.mPvs = EvalPvsSize(*frontData.mRays); … … 2741 2755 { 2742 2756 leaf->Mail(); 2743 if (leaf->GetSubdivisionCandidate()) // a candidate still attached to this node 2757 // a candidate still attached to this node 2758 if (leaf->GetSubdivisionCandidate()) 2744 2759 { 2745 2760 dirtyList.push_back(leaf->GetSubdivisionCandidate()); -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1414 r1418 331 331 332 332 bool exportViewCells = false; 333 334 333 if (exportViewCells) 335 334 { … … 477 476 mViewCellsManager->PrintStatistics(Debug); 478 477 } 479 #if 1478 #if 0 480 479 else 481 480 { -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1415 r1418 238 238 ApplyTransformations(mTransformations, &tempMesh); 239 239 240 FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end(); 241 242 for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit) 240 FaceContainer::const_iterator fit, fit_begin = tempMesh.mFaces.begin(), 241 fit_end = tempMesh.mFaces.end(); 242 243 for (fit = fit_begin; fit != fit_end; ++ fit) 243 244 { 244 245 //cout << "f"; … … 253 254 for (tit = triangles.begin(); tit != tit_end; ++ tit) 254 255 { 255 //cout << "triangle: " << *tit << endl;256 256 TriangleIntersectable *ti = new TriangleIntersectable(*tit); 257 257 mCurrentNode->mGeometry.push_back(ti); -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1415 r1418 163 163 } 164 164 165 string rayCastFile = ReplaceSuffix(filename, ".obj", ".kdf"); 165 166 string externKdTree = ReplaceSuffix(filename, ".obj", ".kdf"); 167 char internKdTree[100]; 168 Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", internKdTree); 166 169 167 170 //-- initialize external ray casters 168 if (preprocessor->InitRayCast( rayCastFile))171 if (preprocessor->InitRayCast(externKdTree, internKdTree)) 169 172 { 170 173 cout << "ray casting initialized!" << endl; … … 175 178 Cleanup(); 176 179 exit(1); 180 } 181 182 // export kd tree? 183 bool exportKdTree; 184 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree); 185 if (exportKdTree) 186 { 187 const long startTime = GetTime(); 188 cout << "exporting kd tree ... "; 189 190 if (!preprocessor->ExportKdTree(internKdTree)) 191 { 192 cout << " error exporting kd tree with filename " << internKdTree << endl; 193 } 194 else 195 { 196 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 197 } 177 198 } 178 199 … … 198 219 #endif 199 220 200 201 221 bool guiSupported = false; 202 222 if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger)
Note: See TracChangeset
for help on using the changeset viewer.