1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __INTERPKERNELGEO2DBOUNDS_HXX__
22 #define __INTERPKERNELGEO2DBOUNDS_HXX__
24 #include "INTERPKERNELDefines.hxx"
28 namespace INTERP_KERNEL
41 class INTERPKERNEL_EXPORT Bounds
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 getDiagonal() const;
48 void getBarycenter(double& xBary, double& yBary) const;
49 void applySimilarity(double xBary, double yBary, double dimChar);
50 void unApplySimilarity(double xBary, double yBary, double dimChar);
51 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; }
52 Bounds(double xMin, double xMax, double yMin, double yMax):_x_min(xMin),_x_max(xMax),_y_min(yMin),_y_max(yMax) { }
53 void setValues(double xMin, double xMax, double yMin, double yMax) { _x_min=xMin; _x_max=xMax; _y_min=yMin; _y_max=yMax; }
54 void prepareForAggregation();
55 void getInterceptedArc(const double *center, double radius, double& intrcptArcAngle0, double& intrcptArcDelta) const;
56 int fitXForXFig(double val, int res) const { return (int)fitXForXFigD(val,res); }
57 int fitYForXFig(double val, int res) const { return (int)fitYForXFigD(val,res); }
58 double fitXForXFigD(double val, int res) const;
59 double fitYForXFigD(double val, int res) const;
60 Bounds *nearlyAmIIntersectingWith(const Bounds& other) const;
61 Bounds *amIIntersectingWith(const Bounds& other) const;
62 //! No approximations.
63 Position where(double x, double y) const;
64 //! Idem where method but with approximations.
65 Position nearlyWhere(double x, double y) const;
66 void aggregate(const Bounds& other);
67 double getCaracteristicDim() const { return std::max(_x_max-_x_min,_y_max-_y_min); }