Changeset 678 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 03/07/06 11:09:10 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r676 r678 2303 2303 { 2304 2304 BspNode *lastNode; 2305 2305 2306 do 2306 2307 { … … 2355 2356 2356 2357 PolygonContainer candidates; 2358 vector<Plane3> candidatePlanes; 2357 2359 2358 2360 // bounded planes are added to the polygons (reverse polygons 2359 2361 // as they have to be outfacing 2362 // comment: why is this? 2360 2363 for (int i = 0; i < (int)halfSpaces.size(); ++ i) 2361 2364 { … … 2365 2368 { 2366 2369 candidates.push_back(p->CreateReversePolygon()); 2370 2371 Plane3 candidatePlane = p->GetSupportingPlane();//halfSpaces[i]; 2372 //candidatePlane.ReverseOrientation(); 2373 candidatePlanes.push_back(candidatePlane); 2374 2367 2375 DEL_PTR(p); 2368 2376 } … … 2377 2385 vertices.push_back(mBox.GetFace(i).mVertices[j]); 2378 2386 2387 Polygon3 *poly = new Polygon3(vertices); 2379 2388 candidates.push_back(new Polygon3(vertices)); 2380 } 2389 candidatePlanes.push_back(poly->GetSupportingPlane()); 2390 } 2391 2381 2392 2382 2393 for (int i = 0; i < (int)candidates.size(); ++ i) … … 2426 2437 2427 2438 if (candidates[i]) 2428 geom.mPolys.push_back(candidates[i]); 2439 { 2440 geom.Add(candidates[i], candidatePlanes[i]); 2441 // geom.mPolys.push_back(candidates[i]); 2442 } 2429 2443 } 2430 2444 } … … 2476 2490 { 2477 2491 const int cf = 2478 Polygon3::ClassifyPlane(geom-> mPolys,2492 Polygon3::ClassifyPlane(geom->GetPolys(), 2479 2493 halfSpaces[i], 2480 2494 mEpsilon); … … 2490 2504 // TODO: why is this wrong?? 2491 2505 // test all planes of current node if still adjacent 2492 for (int i = 0; (i < (int)nodeGeom.mPolys.size()) && isAdjacent; ++ i)2506 for (int i = 0; (i < nodeGeom.Size()) && isAdjacent; ++ i) 2493 2507 { 2494 Polygon3 *poly = nodeGeom. mPolys[i];2508 Polygon3 *poly = nodeGeom.GetPolys()[i]; 2495 2509 2496 2510 const int cf = 2497 Polygon3::ClassifyPlane(geom-> mPolys,2511 Polygon3::ClassifyPlane(geom->GetPolys(), 2498 2512 poly->GetSupportingPlane(), 2499 2513 mEpsilon); … … 2516 2530 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2517 2531 2518 const int cf = Polygon3::ClassifyPlane(nodeGeom. mPolys,2532 const int cf = Polygon3::ClassifyPlane(nodeGeom.GetPolys(), 2519 2533 interior->GetPlane(), 2520 2534 mEpsilon); … … 2584 2598 ConstructGeometry(interior, geom); 2585 2599 2586 const int cf = Polygon3::ClassifyPlane(geom. mPolys,2600 const int cf = Polygon3::ClassifyPlane(geom.GetPolys(), 2587 2601 halfspace, 2588 2602 mEpsilon); … … 2880 2894 2881 2895 PolygonContainer::const_iterator it, it_end = rhs.mPolys.end(); 2896 2897 int i = 0; 2898 2882 2899 for (it = rhs.mPolys.begin(); it != it_end; ++ it) 2883 2900 { 2884 2901 Polygon3 *poly = *it; 2885 mPolys.push_back(new Polygon3(*poly));2902 Add(new Polygon3(*poly), rhs.mPlanes[i ++]); 2886 2903 } 2887 2904 } … … 2891 2908 { 2892 2909 CLEAR_CONTAINER(mPolys); 2910 } 2911 2912 2913 int BspNodeGeometry::Size() const 2914 { 2915 return (int)mPolys.size(); 2916 } 2917 2918 2919 const PolygonContainer &BspNodeGeometry::GetPolys() 2920 { 2921 return mPolys; 2922 } 2923 2924 2925 void BspNodeGeometry::Add(Polygon3 *p, const Plane3 &plane) 2926 { 2927 mPolys.push_back(p); 2928 mPlanes.push_back(plane); 2893 2929 } 2894 2930 … … 2923 2959 const Vector3 v2 = poly->mVertices[i + 1] - center; 2924 2960 2925 volume += f * (DotProd(v0, CrossProd(v1, v2))); 2961 // more robust version using abs and the center of mass 2962 volume += fabs (f * (DotProd(v0, CrossProd(v1, v2)))); 2926 2963 } 2927 2964 } … … 2953 2990 2954 2991 return center / (float)n; 2992 } 2993 2994 2995 bool BspNodeGeometry::Valid() const 2996 { 2997 if (mPolys.size() < 4) 2998 return false; 2999 3000 return true; 2955 3001 } 2956 3002 … … 3003 3049 3004 3050 if (frontPoly->Valid(epsilon)) 3005 front.mPolys.push_back(frontPoly); 3051 { 3052 front.Add(frontPoly, mPlanes[i]); 3053 } 3006 3054 else 3055 { 3007 3056 DEL_PTR(frontPoly); 3008 3057 } 3009 3058 if (backPoly->Valid(epsilon)) 3010 back.mPolys.push_back(backPoly); 3059 { 3060 back.Add(backPoly, mPlanes[i]); 3061 } 3011 3062 else 3063 { 3012 3064 DEL_PTR(backPoly); 3065 } 3013 3066 } 3014 3067 3015 3068 break; 3016 3069 case Polygon3::BACK_SIDE: 3017 back.mPolys.push_back(new Polygon3(mPolys[i]->mVertices)); 3070 3071 back.Add(new Polygon3(mPolys[i]->mVertices), mPlanes[i]); 3018 3072 break; 3019 3073 case Polygon3::FRONT_SIDE: 3020 front.mPolys.push_back(new Polygon3(mPolys[i]->mVertices)); 3074 3075 front.Add(new Polygon3(mPolys[i]->mVertices), mPlanes[i]); 3021 3076 break; 3077 // only put into back container (split should have no effect ...) 3022 3078 case Polygon3::COINCIDENT: 3079 3080 back.Add(new Polygon3(mPolys[i]->mVertices), mPlanes[i]); 3023 3081 //front.mPolys.push_back(CreateReversePolygon(mPolys[i])); 3024 back.mPolys.push_back(new Polygon3(mPolys[i]->mVertices));3025 3082 break; 3026 3083 default: … … 3033 3090 { 3034 3091 // add polygon with normal pointing into positive half space to back cell 3035 back.mPolys.push_back(planePoly); 3092 back.Add(planePoly, splitPlane); 3093 //back.mPolys.push_back(planePoly); 3094 3036 3095 // add polygon with reverse orientation to front cell 3037 front.mPolys.push_back(planePoly->CreateReversePolygon()); 3096 Plane3 reversePlane(splitPlane); 3097 reversePlane.ReverseOrientation(); 3098 front.Add(planePoly->CreateReversePolygon(), reversePlane); 3099 //front.mPolys.push_back(planePoly->CreateReversePolygon()); 3038 3100 } 3039 3101 } … … 3049 3111 for (int i = 0; (i < (int)mPolys.size()) && planePoly; ++ i) 3050 3112 { 3113 #if 0 3051 3114 Plane3 plane = mPolys[i]->GetSupportingPlane(); 3052 3115 #else 3116 Plane3 plane = mPlanes[i]; 3117 3118 #endif 3053 3119 /// don't use epsilon here to get exact split planes 3054 3120 const int cf = 3055 planePoly->ClassifyPlane(plane, Limits::Small);3121 planePoly->ClassifyPlane(plane, epsilon); 3056 3122 3057 3123 // split new polygon with all previous planes -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h
r666 r678 40 40 */ 41 41 float GetArea() const; 42 42 /** Returns volume of this node geometry. 43 */ 43 44 float GetVolume() const; 44 45 … … 69 70 Vector3 CenterOfMass() const; 70 71 71 /** The polygons the geometry consists of. 72 */ 73 PolygonContainer mPolys; 74 72 bool Valid() const; 73 74 75 75 friend ostream &operator<<(ostream &s, const BspNodeGeometry &a) 76 76 { … … 82 82 } 83 83 84 int Size() const; 85 const PolygonContainer &GetPolys(); 86 87 void Add(Polygon3 *p, const Plane3 &plane); 88 89 protected: 90 /** The polygons the geometry consists of. 91 */ 92 PolygonContainer mPolys; 93 94 /** The corresponding set of planes for the polygons. 95 Need this because of precision issues. 96 */ 97 vector<Plane3> mPlanes; 84 98 }; 85 99 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r667 r678 1716 1716 0.0001f); 1717 1717 1718 if ( (int)back.mPolys.size() >= 3)1719 exporter->ExportPolygons(back. mPolys);1718 if (back.Size() >= 3) 1719 exporter->ExportPolygons(back.GetPolys()); 1720 1720 } 1721 1721 else 1722 1722 { 1723 1723 1724 exporter->ExportPolygons(geom. mPolys);1724 exporter->ExportPolygons(geom.GetPolys()); 1725 1725 } 1726 1726 } … … 3164 3164 BspNodeGeometry geom; 3165 3165 mVspBspTree->ConstructGeometry(leaf, geom); 3166 exporter->ExportPolygons(geom. mPolys);3166 exporter->ExportPolygons(geom.GetPolys()); 3167 3167 } 3168 3168 } … … 3486 3486 0.0001f); 3487 3487 3488 if ( (int)back.mPolys.size() >= 3)3489 exporter->ExportPolygons(back. mPolys);3488 if (back.Size() >= 3) 3489 exporter->ExportPolygons(back.GetPolys()); 3490 3490 } 3491 3491 } … … 3495 3495 mVspBspTree->ConstructGeometry(vc, geom); 3496 3496 3497 exporter->ExportPolygons(geom. mPolys);3497 exporter->ExportPolygons(geom.GetPolys()); 3498 3498 } 3499 3499 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r676 r678 186 186 mSplitCandidates = new vector<SortableEntry>; 187 187 188 Debug << "here3" << endl;189 188 Debug << endl; 190 189 } … … 463 462 464 463 // first node is kd node, i.e. an axis aligned box 465 if ( 1)464 if (0) 466 465 tData.mIsKdNode = true; 467 466 else … … 1348 1347 if (1) 1349 1348 { 1350 PolygonContainer::const_iterator it, it_end = tData.mGeometry-> mPolys.end();1351 1352 for(it = tData.mGeometry-> mPolys.begin(); it < it_end; ++ it)1349 PolygonContainer::const_iterator it, it_end = tData.mGeometry->GetPolys().end(); 1350 1351 for(it = tData.mGeometry->GetPolys().begin(); it < it_end; ++ it) 1353 1352 box.Include(*(*it)); 1354 1353 } … … 1402 1401 pos = box.Max(); pos[axis] = nPosition[axis]; 1403 1402 AxisAlignedBox3 bBox(box.Min(), pos); 1404 bBox.ExtractPolys(nBackGeom[axis]->mPolys); 1405 1403 // TODO 1404 #if 0 1405 bBox.ExtractPolys(nBackGeom[axis]->GetPolys()); 1406 #endif 1406 1407 pos = box.Min(); pos[axis] = nPosition[axis]; 1407 1408 AxisAlignedBox3 fBox(pos, box.Max()); 1408 fBox.ExtractPolys(nFrontGeom[axis]->mPolys); 1409 // TODO 1410 #if 0 1411 fBox.ExtractPolys(nFrontGeom[axis]->GetPolys()); 1412 #endif 1409 1413 } 1410 1414 else … … 1569 1573 DEL_PTR(bGeom); 1570 1574 } 1571 1572 1573 #ifdef _DEBUG 1575 1576 1577 if (lowestCost > 10) 1578 Debug << "warning!! lowest cost: " << lowestCost << endl; 1579 1580 //#ifdef _DEBUG 1574 1581 Debug << "plane lowest cost: " << lowestCost << endl; 1575 #endif1582 //#endif 1576 1583 1577 1584 if (lowestCost > mTermMaxCostRatio) … … 1716 1723 Debug << "vol f " << pFront << " b " << pBack << " p " << pOverall << endl; 1717 1724 Debug << "real vol f " << pFront << " b " << geomBack.GetVolume() << " p " << pOverall << endl; 1718 Debug << "polys f " << (int)geomFront.mPolys.size() << " b " << (int)geomFront.mPolys.size() << " data " << (int)data.mGeometry->mPolys.size() << endl;1725 Debug << "polys f " << geomFront.Size() << " b " << geomBack.Size() << " data " << data.mGeometry->Size() << endl; 1719 1726 } 1720 1727 … … 1807 1814 candidatePlane, 1808 1815 mBox, 1809 0.000000 1f);1816 0.000000001f); 1810 1817 //mEpsilon); 1811 1818 … … 1820 1827 if (1) 1821 1828 { 1822 if (pFront <= 0) 1823 { 1824 //Debug << "error f: " << pFront << endl; 1825 return 999; 1826 } 1827 1828 if (pBack <= 0) 1829 { 1830 //Debug << "error b: " << pBack << endl; 1829 if ((pFront <= 0) || (pBack <= 0) || 1830 !geomFront.Valid() || !geomBack.Valid()) 1831 { 1832 Debug << "error f: " << pFront << " b: " << pBack << endl; 1831 1833 return 999; 1832 1834 } … … 2527 2529 2528 2530 PolygonContainer candidatePolys; 2531 vector<Plane3> candidatePlanes; 2529 2532 2530 2533 // bounded planes are added to the polygons (reverse polygons 2531 // as they have to be outfacing 2534 // as they have to be outfacing) 2532 2535 for (int i = 0; i < (int)halfSpaces.size(); ++ i) 2533 2536 { … … 2537 2540 { 2538 2541 candidatePolys.push_back(p->CreateReversePolygon()); 2542 // Why? 2543 Plane3 candidatePlane = p->GetSupportingPlane(); //halfSpaces[i]; 2544 //candidatePlane.ReverseOrientation(); 2545 candidatePlanes.push_back(candidatePlane); 2546 2539 2547 DEL_PTR(p); 2540 2548 } … … 2549 2557 vertices.push_back(mBox.GetFace(i).mVertices[j]); 2550 2558 2551 candidatePolys.push_back(new Polygon3(vertices)); 2559 Polygon3 *poly = new Polygon3(vertices); 2560 2561 candidatePolys.push_back(poly); 2562 candidatePlanes.push_back(poly->GetSupportingPlane()); 2552 2563 } 2553 2564 … … 2587 2598 DEL_PTR(backPoly); 2588 2599 break; 2600 2589 2601 case Polygon3::BACK_SIDE: 2590 2602 DEL_PTR(candidatePolys[i]); … … 2599 2611 2600 2612 if (candidatePolys[i]) 2601 geom.mPolys.push_back(candidatePolys[i]); 2613 { 2614 geom.Add(candidatePolys[i], candidatePlanes[i]); 2615 // geom.mPolys.push_back(candidates[i]); 2616 } 2602 2617 } 2603 2618 } … … 2667 2682 { 2668 2683 const int cf = 2669 Polygon3::ClassifyPlane(geom-> mPolys,2684 Polygon3::ClassifyPlane(geom->GetPolys(), 2670 2685 halfSpaces[i], 2671 2686 mEpsilon); … … 2681 2696 // TODO: why is this wrong?? 2682 2697 // test all planes of current node if still adjacent 2683 for (int i = 0; (i < (int)nodeGeom.mPolys.size()) && isAdjacent; ++ i)2698 for (int i = 0; (i < nodeGeom.Size()) && isAdjacent; ++ i) 2684 2699 { 2685 Polygon3 *poly = nodeGeom. mPolys[i];2700 Polygon3 *poly = nodeGeom.GetPolys()[i]; 2686 2701 2687 2702 const int cf = 2688 Polygon3::ClassifyPlane(geom-> mPolys,2703 Polygon3::ClassifyPlane(geom->GetPolys(), 2689 2704 poly->GetSupportingPlane(), 2690 2705 mEpsilon); … … 2707 2722 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2708 2723 2709 const int cf = Polygon3::ClassifyPlane(nodeGeom. mPolys,2724 const int cf = Polygon3::ClassifyPlane(nodeGeom.GetPolys(), 2710 2725 interior->GetPlane(), 2711 2726 mEpsilon); … … 2799 2814 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2800 2815 2801 const int cf = Polygon3::ClassifyPlane(nodeGeom. mPolys,2816 const int cf = Polygon3::ClassifyPlane(nodeGeom.GetPolys(), 2802 2817 interior->GetPlane(), 2803 2818 mEpsilon); … … 2870 2885 2871 2886 const int cf = 2872 Polygon3::ClassifyPlane(geom. mPolys, halfspace, mEpsilon);2887 Polygon3::ClassifyPlane(geom.GetPolys(), halfspace, mEpsilon); 2873 2888 2874 2889 if (cf == Polygon3::BACK_SIDE) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r676 r678 129 129 float GetCost() const 130 130 { 131 //cout << "here " <<mPriority << endl;131 //cout << mPriority << endl; 132 132 return mPriority; 133 133 } -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r580 r678 277 277 } 278 278 279 ExportPolygons(cell-> mPolys);279 ExportPolygons(cell->GetPolys()); 280 280 } 281 281 … … 971 971 tree.ConstructGeometry(*it, geom); 972 972 973 ExportPolygons(geom. mPolys);973 ExportPolygons(geom.GetPolys()); 974 974 } 975 975 }
Note: See TracChangeset
for help on using the changeset viewer.