Back to index

salome-med  6.5.0
InterpKernelGeo2DBounds.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __INTERPKERNELGEO2DBOUNDS_HXX__
00021 #define __INTERPKERNELGEO2DBOUNDS_HXX__
00022 
00023 #include "INTERPKERNELDefines.hxx"
00024 
00025 #include <algorithm>
00026 
00027 namespace INTERP_KERNEL
00028 {
00032   typedef enum
00033     {
00034       IN              = 0,
00035       OUT             = 1,
00036       ON_BOUNDARY_POS = 2,
00037       ON_BOUNDARY_NEG = 3
00038     } Position;
00039   
00040   class INTERPKERNEL_EXPORT Bounds
00041   {
00042   public:
00043     Bounds():_x_min(0.),_x_max(0.),_y_min(0.),_y_max(0.) { }
00044     double &operator[](int i);
00045     const double& operator[](int i) const;
00046     double getDiagonal() const;
00047     void getBarycenter(double& xBary, double& yBary) const;
00048     void applySimilarity(double xBary, double yBary, double dimChar);
00049     void unApplySimilarity(double xBary, double yBary, double dimChar);
00050     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; }
00051     Bounds(double xMin, double xMax, double yMin, double yMax):_x_min(xMin),_x_max(xMax),_y_min(yMin),_y_max(yMax) { }
00052     void setValues(double xMin, double xMax, double yMin, double yMax) { _x_min=xMin; _x_max=xMax; _y_min=yMin; _y_max=yMax; }
00053     void prepareForAggregation();
00054     void getInterceptedArc(const double *center, double radius, double& intrcptArcAngle0, double& intrcptArcDelta) const;
00055     int fitXForXFig(double val, int res) const { return (int)fitXForXFigD(val,res); }
00056     int fitYForXFig(double val, int res) const { return (int)fitYForXFigD(val,res); }
00057     double fitXForXFigD(double val, int res) const;
00058     double fitYForXFigD(double val, int res) const;
00059     Bounds *nearlyAmIIntersectingWith(const Bounds& other) const;
00060     Bounds *amIIntersectingWith(const Bounds& other) const;
00062     Position where(double x, double y) const;
00064     Position nearlyWhere(double x, double y) const;
00065     void aggregate(const Bounds& other);
00066     double getCaracteristicDim() const { return std::max(_x_max-_x_min,_y_max-_y_min); }
00067   protected:
00068     double _x_min;
00069     double _x_max;
00070     double _y_min;
00071     double _y_max;
00072   };
00073 }
00074 
00075 #endif