Changeset 678 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
- Timestamp:
- 03/07/06 11:09:10 (19 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.