| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeBox.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef  __TERRALIB_INTERNAL_BOX_H
    00027 #define  __TERRALIB_INTERNAL_BOX_H
    00028
    00029 #include "TeDefines.h"
    00030 #include "TeCoord2D.h"
    00031 #include "TeDefines.h"
    00032 #include "float.h"
    00033
    00034 class TeGeometry;
    00035 class TePolygon;
    00036
    00038
    00042 struct TL_DLL TeBox {
    00043
    00044            enum TeBoxCorner { TeLOWERLEFT=0, TeUPPERLEFT=1, TeLOWERRIGHT=2, TeUPPERRIGHT=3 };
    00045
    00047
    00053            TeBox ( const double& x1 = TeMAXFLOAT, const double y1 = TeMAXFLOAT,
    00054                         const double& x2 = -TeMAXFLOAT, const double y2 = -TeMAXFLOAT ):
    00055                         x1_ ( x1 ), y1_ ( y1 ), x2_ ( x2 ), y2_ ( y2 ) {}
    00056
    00058
    00062            TeBox( const TeCoord2D& p1, const TeCoord2D& p2 ):
    00063                       x1_ ( p1.x() ), y1_ ( p1.y() ),
    00064                       x2_ ( p2.x() ), y2_ ( p2.y() )
    00065                       {}
    00066
    00068            TeBox ( const TeBox& rhs )
    00069            {
    00070                       x1_ = rhs.x1_;
    00071                       x2_ = rhs.x2_;
    00072                       y1_ = rhs.y1_;
    00073                       y2_ = rhs.y2_;
    00074            }
    00075
    00077            TeBox& operator=(const TeBox& rhs)
    00078            {
    00079                       if ( this == &rhs )
    00080                                  return *this;
    00081                       else
    00082                       {
    00083                       x1_ = rhs.x1_;
    00084                       x2_ = rhs.x2_;
    00085                       y1_ = rhs.y1_;
    00086                       y2_ = rhs.y2_;
    00087                       }
    00088                       return *this;
    00089            }
    00090
    00092            bool operator== (const TeBox& box) const
    00093            {return (  ( fabs (y1_ - box.y1_) < TePrecision::instance().precision() )
    00094                                  && ( fabs (x1_ - box.x1_) < TePrecision::instance().precision() )
    00095                                  && ( fabs (y2_ - box.y2_) < TePrecision::instance().precision() )
    00096                                  && ( fabs (x2_ - box.x2_) < TePrecision::instance().precision() )
    00097                                  ); }
    00098
    00100   bool operator!= (const TeBox& box) const
    00101   {
    00102     return ( ! operator==( box ) );
    00103   }
    00104
    00106            TeCoord2D center() const
    00107            {
    00108                       TeCoord2D p ( (  ( x1_ + x2_ ) / 2.), ( ( y1_ + y2_ ) / 2.) );
    00109                       return p;
    00110            }
    00111
    00113            bool isValid() const
    00114            {
    00115                       if (x1_ == TeMAXFLOAT || y1_ == TeMAXFLOAT ||
    00116                           x2_ == -TeMAXFLOAT || y2_ == -TeMAXFLOAT  ||
    00117                                  x1_ > x2_ || y1_ > y2_)
    00118                                  return false;
    00119                       if( TeISNAN(x1_) || TeISNAN(y1_) || TeISNAN(x2_) || TeISNAN(y2_))
    00120                                  return false;
    00121                       return true;
    00122            }
    00123
    00125            const double& x1 () const
    00126            { return x1_;}
    00127
    00129            const double& y1 () const
    00130            { return y1_;}
    00131
    00133            const double& x2 () const
    00134            { return x2_;}
    00135
    00137            const double& y2 () const
    00138            { return y2_;}
    00139
    00141            double width () const
    00142            { return x2_ - x1_; }
    00143
    00145            double height () const
    00146            { return y2_ - y1_; }
    00147
    00149            TeCoord2D lowerLeft() const
    00150            { return TeCoord2D ( x1_, y1_ );}
    00151
    00153            TeCoord2D upperRight() const
    00154            { return TeCoord2D (x2_,y2_);}
    00155
    00157            ~TeBox() {}
    00158
    00159            double x1_,
    00160                          y1_,
    00161                          x2_,
    00162                          y2_;
    00163
    00164 };
    00165
    00166 // ALGORITHMS THAT USE A BOX
    00167
    00171 TL_DLL void updateBox ( TeBox& box, const TeCoord2D& pt );
    00172
    00176 TL_DLL void updateBox ( TeBox& box, const TeBox& other );
    00177
    00181 TL_DLL void updateBox ( TeBox& box, const TeGeometry& geo );
    00182
    00183
    00184 // ZOOMING FUNCTIONS
    00185
    00189 TL_DLL void zoomIn ( TeBox& box, double t = .8);
    00190
    00194 TL_DLL void zoomOut ( TeBox& box, double t = .8);
    00195
    00199 TL_DLL TeBox makeBox(double x1, double y1, double x2, double y2, const double& tol = 0.0);
    00200
    00204 TL_DLL TeBox adjustToCut(TeBox& box, double bWidth, double bHeight);
    00205
    00209 TL_DLL TePolygon polygonFromBox( const TeBox& bb );
    00210
    00214 TL_DLL int adjustBox( TeBox& bb );
    00215
    00216 #endif
    00217
    00218

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines