Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __DIRECTEDBOUNDINGBOX_HXX__
00021 #define __DIRECTEDBOUNDINGBOX_HXX__
00022
00023 #include "INTERPKERNELDefines.hxx"
00024
00025 #include <vector>
00026
00027 namespace INTERP_KERNEL
00028 {
00029
00034 class INTERPKERNEL_EXPORT DirectedBoundingBox
00035 {
00036 public:
00037
00038 DirectedBoundingBox();
00039
00040 DirectedBoundingBox(const double* pts, const unsigned numPts, const unsigned dim);
00041
00042 DirectedBoundingBox(const double** pts, const unsigned numPts, const unsigned dim);
00043
00044
00045
00046 void enlarge(const double tol);
00047
00048 bool isDisjointWith(const DirectedBoundingBox& box) const;
00049
00050 bool isDisjointWith(const double* box) const;
00051
00052 bool isOut(const double* point) const;
00053
00054
00055
00056 std::vector<double> getData() const;
00057
00058
00059 void setData(const double* data);
00060
00061
00062 static int dataSize(int dim);
00063
00064 private:
00065
00066
00067
00068
00069
00070 inline void addPointToBox(const double* coord);
00071
00072 void toLocalCS(const double* p, double* pLoc) const;
00073
00074 void fromLocalCS(const double* p, double* pGlob) const;
00075
00076 inline bool isLocalOut(const double* pLoc) const;
00077
00078 void getCorners(std::vector<double>& corners, const double* minmax) const;
00079
00080 unsigned _dim;
00081
00082 std::vector<double> _axes;
00083 std::vector<double> _minmax;
00084
00085 };
00086
00087
00092
00093
00094 inline bool DirectedBoundingBox::isLocalOut(const double* pLoc) const
00095 {
00096 for ( int i = 0; i < (int)_dim; ++i )
00097 if ( pLoc[i] < _minmax[i*2] || pLoc[i] > _minmax[i*2+1] )
00098 return true;
00099 return false;
00100 }
00101
00102
00106
00107
00108 inline void DirectedBoundingBox::addPointToBox(const double* coord)
00109 {
00110 for ( int i = 0; i < (int)_dim; ++i )
00111 {
00112 double c = 0;
00113 for ( int j = 0; j < (int)_dim; ++j ) c += coord[j]*_axes[i*_dim+j];
00114 if ( c < _minmax[i*2] ) _minmax[i*2] = c;
00115 if ( c > _minmax[i*2+1] ) _minmax[i*2+1] = c;
00116 }
00117 }
00118 }
00119 #endif