Salome HOME
Get relevant changes from V7_dev branch (copyright update, adm files etc)
[tools/medcoupling.git] / src / INTERP_KERNEL / Geometric2D / InterpKernelGeo2DBounds.hxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __INTERPKERNELGEO2DBOUNDS_HXX__
22 #define __INTERPKERNELGEO2DBOUNDS_HXX__
23
24 #include "INTERPKERNELDefines.hxx"
25
26 #include <algorithm>
27
28 namespace INTERP_KERNEL
29 {
30   /*!
31    * Relative LOC
32    */
33   typedef enum
34   {
35     IN              = 0,
36     OUT             = 1,
37     ON_BOUNDARY_POS = 2,
38     ON_BOUNDARY_NEG = 3
39   } Position;
40
41   class INTERPKERNEL_EXPORT Bounds
42   {
43   public:
44     Bounds():_x_min(0.),_x_max(0.),_y_min(0.),_y_max(0.) { }
45     double &operator[](int i);
46     const double& operator[](int i) const;
47     double getXMin() const { return _x_min; }
48     double getXMax() const { return _x_max; }
49     double getYMin() const { return _y_min; }
50     double getYMax() const { return _y_max; }
51     double getDiagonal() const;
52     void getBarycenter(double& xBary, double& yBary) const;
53     void applySimilarity(double xBary, double yBary, double dimChar);
54     void unApplySimilarity(double xBary, double yBary, double dimChar);
55     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; }
56     Bounds(double xMin, double xMax, double yMin, double yMax):_x_min(xMin),_x_max(xMax),_y_min(yMin),_y_max(yMax) { }
57     void setValues(double xMin, double xMax, double yMin, double yMax) { _x_min=xMin; _x_max=xMax; _y_min=yMin; _y_max=yMax; }
58     void prepareForAggregation();
59     void getInterceptedArc(const double *center, double radius, double& intrcptArcAngle0, double& intrcptArcDelta) const;
60     int fitXForXFig(double val, int res) const { return (int)fitXForXFigD(val,res); }
61     int fitYForXFig(double val, int res) const { return (int)fitYForXFigD(val,res); }
62     double fitXForXFigD(double val, int res) const;
63     double fitYForXFigD(double val, int res) const;
64     Bounds *nearlyAmIIntersectingWith(const Bounds& other) const;
65     Bounds *amIIntersectingWith(const Bounds& other) const;
66     //! No approximations.
67     Position where(double x, double y) const;
68     //! Idem where method but with approximations.
69     Position nearlyWhere(double x, double y) const;
70     void aggregate(const Bounds& other);
71     double getCaracteristicDim() const { return std::max(_x_max-_x_min,_y_max-_y_min); }
72   protected:
73     double _x_min;
74     double _x_max;
75     double _y_min;
76     double _y_max;
77   };
78 }
79
80 #endif