- Timestamp:
- 03/15/06 18:13:36 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env
r685 r697 235 235 clipPlaneAxis 1 236 236 clipPlanePos 0.35 237 } 238 239 Filter { 240 width 10.0 241 maxSize 4 237 242 } 238 243 -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r557 r697 1570 1570 } 1571 1571 1572 1573 Plane3 AxisAlignedBox3::GetPlane(const int face) const 1574 { 1575 switch (face) 1576 { 1577 1578 case 0: 1579 return Plane3(Vector3(-1, 0, 0), mMin); 1580 case 1: 1581 return Plane3(Vector3(1, 0, 0), mMax); 1582 case 2: 1583 return Plane3(Vector3(0, -1, 0), mMin); 1584 case 3: 1585 return Plane3(Vector3(0, 1, 0), mMax); 1586 case 4: 1587 return Plane3(Vector3(0, 0, -1), mMin); 1588 case 5: 1589 return Plane3(Vector3(0, 0, 1), mMax); 1590 } 1591 1592 // should not come here 1593 return Plane3(); 1594 } 1595 1596 1572 1597 int 1573 1598 AxisAlignedBox3::GetFaceVisibilityMask(const Rectangle3 &rectangle) const … … 1578 1603 return mask; 1579 1604 } 1605 1580 1606 1581 1607 int -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r647 r697 111 111 void Include(const int &axis, const float &newBound); 112 112 113 113 114 114 int 115 115 Side(const Plane3 &plane) const; … … 277 277 278 278 Rectangle3 GetFace(const int face) const; 279 280 /** Extracts plane of bounding box. 281 */ 282 Plane3 GetPlane(const int face) const; 279 283 280 284 // For a given point returns the region, where the point is located -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r685 r697 1249 1249 "20000"); 1250 1250 1251 RegisterOption("ViewCells.Filter.maxSize", 1252 optInt, 1253 "view_cells_filter_max_size=", 1254 "4"); 1255 1256 RegisterOption("ViewCells.Filter.width", 1257 optFloat, 1258 "view_cells_filter_width=", 1259 "10.0"); 1260 1251 1261 RegisterOption("ViewCells.loadFromFile", 1252 1262 optBool, -
GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.h
r639 r697 40 40 } 41 41 42 enum {BACK_SIDE = -1, INTERSECTS = 0, FRONT_SIDE = 1}; 43 44 42 45 /** Returns 1 if v is on front side, -1 if on back side, 0 if on plane. 43 46 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r694 r697 14 14 15 15 16 16 #define ROTATE_SCENE 1 17 17 // HACK 18 18 static void RotateMesh(Mesh *mesh) … … 158 158 if (meshGrouping != 0 && 159 159 currentMesh->mFaces.size() >= meshGrouping) { 160 if ( 1)160 if (ROTATE_SCENE) 161 161 RotateMesh(currentMesh); 162 162 currentMesh->Preprocess(); … … 177 177 if (1) 178 178 RotateMesh(currentMesh); 179 cout << "here9999" << endl;179 180 180 currentMesh->Preprocess(); 181 181 MeshInstance *mi = new MeshInstance(currentMesh); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r694 r697 2915 2915 2916 2916 2917 void BspNodeGeometry::GetBoundingBox(AxisAlignedBox3 &box) const 2918 { 2919 box.Initialize(); 2920 Polygon3::IncludeInBox(mPolys, box); 2921 } 2922 2923 2924 int BspNodeGeometry::Side(const Plane3 &plane) const 2925 { 2926 PolygonContainer::const_iterator it, it_end = mPolys.end(); 2927 2928 bool onFrontSide = false; 2929 bool onBackSide = false; 2930 2931 for (it = mPolys.begin(); it != it_end; ++ it) 2932 { 2933 const int side = (*it)->Side(plane, 0.0f); 2934 2935 if (side == -1) 2936 onBackSide = true; 2937 else if (side == 1) 2938 onFrontSide = true; 2939 2940 if ((side == 0) || (onBackSide && onFrontSide)) 2941 return 0; 2942 } 2943 2944 if (onFrontSide) 2945 return 1; 2946 2947 return -1; 2948 } 2949 2950 2951 int BspNodeGeometry::ComputeIntersection(const AxisAlignedBox3 &box) const 2952 { 2953 AxisAlignedBox3 boundingBox; 2954 GetBoundingBox(boundingBox); 2955 2956 const bool overlap = Overlap(boundingBox, box); 2957 2958 // no intersections with bounding box 2959 if (!overlap) 2960 { 2961 return 1; 2962 } 2963 int result = -1; 2964 2965 // 1: box does not intersect geometry 2966 // 0: box intersects geometry 2967 // -1: box contains geometry 2968 for (int i = 0; i < 6; ++ i) 2969 { 2970 const int side = Side(box.GetPlane(i)); 2971 2972 // box does not intersects geometry 2973 if (side == 1) 2974 return 1; 2975 2976 if (side == 0) 2977 result = 0; 2978 } 2979 2980 return result; 2981 } 2982 2983 2917 2984 Vector3 BspNodeGeometry::CenterOfMass() const 2918 2985 { … … 3154 3221 3155 3222 3156 void BspNodeGeometry::IncludeInBox(AxisAlignedBox3 &box)3157 {3158 Polygon3::IncludeInBox(mPolys, box);3159 }3160 3161 3162 3223 bool BspTree::Export(ofstream &stream) 3163 3224 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h
r679 r697 54 54 const float epsilon) const; 55 55 56 /** Computes the intersection of the box with the node geometry. 57 */ 58 int ComputeIntersection(const AxisAlignedBox3 &box) const; 59 56 60 /** Computes bounding box of the geometry. 57 61 */ 58 void IncludeInBox(AxisAlignedBox3 &box); 62 void GetBoundingBox(AxisAlignedBox3 &box) const; 63 64 /** Returns 65 1 of geometry in front of plane 66 0 if plane intersects geometry, 67 -1 if geometry in back of plane 68 */ 69 int Side(const Plane3 &plane) const; 59 70 60 71 /** Splits the polygon and returns the part of the polygon inside of the node geometry. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r694 r697 19 19 #define TEST_EMPTY_VIEW_CELLS 0 20 20 21 22 23 template <typename T> class myless 24 { 25 public: 26 //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const 27 bool operator() (T v1, T v2) const 28 { 29 return (v1->GetMergeCost() < v2->GetMergeCost()); 30 } 31 }; 32 33 typedef priority_queue<ViewCell *, vector<ViewCell *>, myless<vector<ViewCell *>::value_type> > FilterQueue; 34 35 36 21 37 ViewCellsManager::ViewCellsManager(): 22 38 mRenderer(NULL), … … 67 83 environment->GetBoolValue("ViewCells.evaluateViewCells", mEvaluateViewCells); 68 84 environment->GetBoolValue("ViewCells.showVisualization", mShowVisualization); 69 85 environment->GetIntValue("ViewCells.Filter.maxSize", mMaxFilterSize); 86 environment->GetFloatValue("ViewCells.Filter.width", mFilterWidth); 87 70 88 char buf[100]; 71 89 environment->GetStringValue("ViewCells.samplingType", buf); … … 118 136 Debug << "sampling type: " << mSamplingType << endl; 119 137 Debug << "show visualization: " << mShowVisualization << endl; 138 Debug << "filter width: " << mFilterWidth << endl; 120 139 121 140 Debug << endl; … … 173 192 { 174 193 Ray *pray = (*it)->mPiercingRays[0]; 175 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << " " << pray->intersections.size() << endl;194 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << " " << (int)pray->intersections.size() << endl; 176 195 177 196 exporter->ExportRays((*it)->mPiercingRays); … … 282 301 disposeRays(initialSamples, outRays); 283 302 303 cout << "testing filter ... "; 304 305 TestFilter(preprocessor->mObjects); 306 307 cout << "finished" << endl; 284 308 285 309 // -- stats after contruction … … 533 557 534 558 return true; 559 } 560 561 562 AxisAlignedBox3 ViewCellsManager::GetFilterBBox(const Vector3 &viewPoint, 563 const float width) const 564 { 565 Vector3 min = viewPoint - width * 0.5f; 566 Vector3 max = viewPoint + width * 0.5; 567 568 return AxisAlignedBox3(min, max); 569 } 570 571 572 void ViewCellsManager::GetPrVS(const Vector3 &viewPoint, PrVs &prvs) 573 { 574 const AxisAlignedBox3 box = GetFilterBBox(viewPoint, mFilterWidth); 575 576 ViewCellContainer viewCells; 577 ComputeBoxIntersections(box, viewCells); 578 579 535 580 } 536 581 … … 2767 2812 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumActiveViewCells); 2768 2813 } 2769 2770 } 2771 2814 } 2772 2815 2773 2816 … … 3524 3567 3525 3568 3569 int VspBspViewCellsManager::ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const 3570 { 3571 return mVspBspTree->ComputeBoxIntersections(box, viewCells); 3572 } 3573 3574 3526 3575 int VspBspViewCellsManager::CastLineSegment(const Vector3 &origin, 3527 3576 const Vector3 &termination, … … 3859 3908 newVol += lVol; 3860 3909 subdivVol += (*it)->GetVolume(); 3910 3911 float thres = 0.9; 3912 if ((lVol < ((*it)->GetVolume() * thres)) || (lVol * thres > ((*it)->GetVolume()))) 3913 Debug << "warning: " << lVol << " " << (*it)->GetVolume() << endl; 3861 3914 } 3862 3915 … … 3874 3927 } 3875 3928 3929 3930 void VspBspViewCellsManager::TestFilter(const ObjectContainer &objects) 3931 { 3932 Exporter *exporter = Exporter::GetExporter("filter.x3d"); 3933 3934 if (exporter) 3935 { 3936 AxisAlignedBox3 testBox = mViewSpaceBox; 3937 Vector3 bsize = mViewSpaceBox.Size(); 3938 3939 testBox.Enlarge(Vector3(-bsize[0] * 0.3, 0, -bsize[2] * 0.4)); 3940 3941 ViewCellContainer viewCells; 3942 3943 mVspBspTree->ComputeBoxIntersections(testBox, viewCells); 3944 cout << "view cells: " << viewCells.size() << endl; 3945 3946 exporter->SetWireframe(); 3947 3948 exporter->SetForcedMaterial(RgbColor(1,1,1)); 3949 exporter->ExportBox(testBox); 3950 3951 exporter->SetFilled(); 3952 exporter->ResetForcedMaterial(); 3953 for (int i = 0; i < viewCells.size(); ++ i) 3954 { 3955 BspNodeGeometry geom; 3956 3957 mVspBspTree->ConstructGeometry(viewCells[i], geom); 3958 exporter->ExportPolygons(geom.GetPolys()); 3959 } 3960 3961 exporter->SetForcedMaterial(RgbColor(1,0,0)); 3962 exporter->ExportGeometry(objects); 3963 3964 delete exporter; 3965 } 3966 } 3876 3967 3877 3968 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r694 r697 35 35 36 36 /** Probably Visible Set */ 37 class PrVs { 37 class PrVs 38 { 39 public: 38 40 /// viewcells 39 ViewCellContainer mV viewCells;40 /// aggregat red pvs41 ViewCellContainer mViewCells; 42 /// aggregated pvs 41 43 ObjectPvs mPvs; 42 44 … … 62 64 }; 63 65 66 64 67 /// view cell container types 65 68 enum {BSP, KD, VSP_KD, VSP_BSP}; … … 94 97 @param storeViewCells true if view cells should be stored in the ray 95 98 */ 96 99 float ComputeSampleContributions(const VssRayContainer &rays, 97 100 const bool addContributions, 98 101 const bool storeViewCells); 99 102 100 101 103 /** Add sample contributions to the viewcells they intersect */ 104 void AddSampleContributions(const VssRayContainer &rays); 102 105 103 106 … … 218 221 virtual void GetPvsStatistics(PvsStatistics &stat); 219 222 220 virtual void GetPrVS(const Vector3 &viewPoint, 221 PrVs &prvs 222 ) {} 223 virtual void GetPrVS(const Vector3 &viewPoint, PrVs &prvs); 223 224 224 /** Get a viewcell containing the specified point */ 225 /** Get a viewcell containing the specified point 226 */ 225 227 virtual ViewCell *GetViewCell(const Vector3 &point) const = 0; 226 228 … … 383 385 void EvalViewCellPartition(Preprocessor *preprocessor); 384 386 387 385 388 protected: 386 389 390 /** Returns the bounding box of filter width. 391 */ 392 AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const; 393 394 /** Intersects box with the tree and returns the number of intersected boxes. 395 @returns number of view cells found 396 */ 397 virtual int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const {return 0;}; 398 399 virtual void TestFilter(const ObjectContainer &objects) {}; 387 400 388 401 /** … … 486 499 /// if rays should be used to collect merge candidates 487 500 bool mUseRaysForMerge; 488 501 /// merge the view cells? 489 502 bool mMergeViewCells; 490 503 504 /// the width of the box filter 505 float mFilterWidth; 506 int mMaxFilterSize; 507 491 508 //-- visualization options 492 509 … … 783 800 void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 784 801 802 /** Returns true if this view cell is equivavalent to a spatial node. 803 */ 785 804 bool EqualToSpatialNode(ViewCell *viewCell) const; 786 805 806 787 807 protected: 788 808 809 int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const; 789 810 790 811 /** Returns node of the spatial hierarchy corresponding to the view cell … … 818 839 ViewCell *ConstructSpatialMergeTree(BspNode *root); 819 840 841 void TestFilter(const ObjectContainer &objects); 842 843 844 820 845 /// the view space partition BSP tree. 821 846 VspBspTree *mVspBspTree; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r694 r697 28 28 int VspBspTree::sFrontAndBackId = 0; 29 29 30 typedef pair<BspNode *, BspNodeGeometry *> bspNodePair; 30 31 31 32 … … 1889 1890 1890 1891 1892 int VspBspTree::ComputeBoxIntersections(const AxisAlignedBox3 &box, 1893 ViewCellContainer &viewCells) const 1894 { 1895 stack<bspNodePair> nodeStack; 1896 BspNodeGeometry *rgeom = new BspNodeGeometry(); 1897 1898 ConstructGeometry(mRoot, *rgeom); 1899 1900 nodeStack.push(bspNodePair(mRoot, rgeom)); 1901 1902 ViewCell::NewMail(); 1903 1904 while (!nodeStack.empty()) 1905 { 1906 BspNode *node = nodeStack.top().first; 1907 BspNodeGeometry *geom = nodeStack.top().second; 1908 nodeStack.pop(); 1909 1910 const int side = geom->ComputeIntersection(box); 1911 1912 switch (side) 1913 { 1914 case -1: 1915 // node geometry is contained in box 1916 CollectViewCells(node, true, viewCells, true); 1917 break; 1918 1919 case 0: 1920 if (node->IsLeaf()) 1921 { 1922 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 1923 1924 if (!leaf->GetViewCell()->Mailed() && leaf->TreeValid()) 1925 { 1926 leaf->GetViewCell()->Mail(); 1927 viewCells.push_back(leaf->GetViewCell()); 1928 } 1929 } 1930 else 1931 { 1932 BspInterior *interior = dynamic_cast<BspInterior *>(node); 1933 1934 BspNode *first = interior->GetFront(); 1935 BspNode *second = interior->GetBack(); 1936 1937 BspNodeGeometry *firstGeom = new BspNodeGeometry(); 1938 BspNodeGeometry *secondGeom = new BspNodeGeometry(); 1939 1940 geom->SplitGeometry(*firstGeom, 1941 *secondGeom, 1942 interior->GetPlane(), 1943 mBox, 1944 //0.0000001f); 1945 mEpsilon); 1946 1947 nodeStack.push(bspNodePair(first, firstGeom)); 1948 nodeStack.push(bspNodePair(second, secondGeom)); 1949 } 1950 1951 break; 1952 default: 1953 // default: cull 1954 break; 1955 } 1956 1957 DEL_PTR(geom); 1958 1959 } 1960 1961 return (int)viewCells.size(); 1962 } 1963 1964 1891 1965 float VspBspTree::EvalAxisAlignedSplitCost(const VspBspTraversalData &data, 1892 1966 const AxisAlignedBox3 &box, … … 2629 2703 } 2630 2704 } 2631 2632 2633 typedef pair<BspNode *, BspNodeGeometry *> bspNodePair;2634 2705 2635 2706 … … 3281 3352 3282 3353 AxisAlignedBox3 box; 3283 box.Initialize(); 3284 geom->IncludeInBox(box); 3354 geom->GetBoundingBox(box); 3285 3355 3286 3356 const int side = beam.ComputeIntersection(box); -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r694 r697 345 345 void CollectRays(VssRayContainer &rays); 346 346 347 347 /** Intersects box with the tree and returns the number of intersected boxes. 348 @returns number of view cells found 349 */ 350 int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const; 351 352 // pointer to the hierarchy of view cells 348 353 ViewCellsTree *mViewCellsTree; 349 354 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r694 r697 852 852 return true; 853 853 } 854 855
Note: See TracChangeset
for help on using the changeset viewer.