]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/INTERP_KERNEL/Geometric2D/Bounds.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[tools/medcoupling.git] / src / INTERP_KERNEL / Geometric2D / Bounds.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef __BOUNDS_HXX__
20 #define __BOUNDS_HXX__
21
22 #include "INTERPKERNELGEOMETRIC2DDefines.hxx"
23
24 #include <numeric>
25
26 namespace INTERP_KERNEL
27 {
28   /*!
29    * Relative LOC
30    */
31   typedef enum
32     {
33       IN              = 0,
34       OUT             = 1,
35       ON_BOUNDARY_POS = 2,
36       ON_BOUNDARY_NEG = 3
37     } Position;
38   
39   class INTERPKERNELGEOMETRIC2D_EXPORT Bounds
40   {
41   public:
42     Bounds():_x_min(0.),_x_max(0.),_y_min(0.),_y_max(0.) { }
43     double &operator[](int i);
44     const double& operator[](int i) const;
45     double getDiagonal() const;
46     void getBarycenter(double& xBary, double& yBary) const;
47     void applySimilarity(double xBary, double yBary, double dimChar);
48     Bounds& operator=(const Bounds& other) { _x_min=other._x_min; _x_max=other._x_max; _y_min=other._y_min; _y_max=other._y_max; return *this; }
49     Bounds(double xMin, double xMax, double yMin, double yMax):_x_min(xMin),_x_max(xMax),_y_min(yMin),_y_max(yMax) { }
50     void setValues(double xMin, double xMax, double yMin, double yMax) { _x_min=xMin; _x_max=xMax; _y_min=yMin; _y_max=yMax; }
51     void prepareForAggregation();
52     void getInterceptedArc(const double *center, double radius, double& intrcptArcAngle0, double& intrcptArcDelta) const;
53     int fitXForXFig(double val, int res) const { return (int)fitXForXFigD(val,res); }
54     int fitYForXFig(double val, int res) const { return (int)fitYForXFigD(val,res); }
55     double fitXForXFigD(double val, int res) const;
56     double fitYForXFigD(double val, int res) const;
57     Bounds *nearlyAmIIntersectingWith(const Bounds& other) const;
58     Bounds *amIIntersectingWith(const Bounds& other) const;
59     //! No approximations.
60     Position where(double x, double y) const;
61     //! Idem where method but with approximations.
62     Position nearlyWhere(double x, double y) const;
63     void aggregate(const Bounds& other);
64     double getCaracteristicDim() const { return std::max(_x_max-_x_min,_y_max-_y_min); }
65   protected:
66     double _x_min;
67     double _x_max;
68     double _y_min;
69     double _y_max;
70   };
71 }
72
73 #endif