Ignore:
Timestamp:
03/15/06 18:13:36 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r694 r697  
    29152915 
    29162916 
     2917void BspNodeGeometry::GetBoundingBox(AxisAlignedBox3 &box) const 
     2918{ 
     2919        box.Initialize(); 
     2920        Polygon3::IncludeInBox(mPolys, box); 
     2921} 
     2922 
     2923 
     2924int 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 
     2951int 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 
    29172984Vector3 BspNodeGeometry::CenterOfMass() const 
    29182985{ 
     
    31543221 
    31553222 
    3156 void BspNodeGeometry::IncludeInBox(AxisAlignedBox3 &box) 
    3157 { 
    3158         Polygon3::IncludeInBox(mPolys, box); 
    3159 } 
    3160  
    3161  
    31623223bool BspTree::Export(ofstream &stream) 
    31633224{ 
Note: See TracChangeset for help on using the changeset viewer.