QGpCoreTools/Parallelepiped.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  
00020 **
00021 **  Created: 2012-04-16
00022 **  Authors:
00023 **    Marc Wathelet (ISTerre, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef PARALLELEPIPED_H
00028 #define PARALLELEPIPED_H
00029 
00030 #include "Point.h"
00031 #include "QGpCoreToolsDLLExport.h"
00032 
00033 namespace QGpCoreTools {
00034 
00035   class QGPCORETOOLS_EXPORT Parallelepiped
00036   {
00037   public:
00038     Parallelepiped();
00039     inline Parallelepiped(const Point& p1, const Point& p2);
00040     inline Parallelepiped(double nx1, double ny1, double nz1,
00041                           double nx2, double ny2, double nz2);
00042     Parallelepiped(const Parallelepiped& o);
00043 
00044     void setLimits(double nx1, double ny1, double nz1,
00045                    double nx2, double ny2, double nz2);
00046 
00047     bool includes(const Point & p) const;
00048     bool includes(double x1, double y1, double z1,
00049                   double x2, double y2, double z2) const;
00050     inline bool includes(const Point& p1, const Point& p2) const;
00051 
00052     void add(const Point& p);
00053 
00054     double x1() const {return _x1;}
00055     double x2() const {return _x2;}
00056     double y1() const {return _y1;}
00057     double y2() const {return _y2;}
00058     double z1() const {return _z1;}
00059     double z2() const {return _z2;}
00060     double dx() const {return _x2-_x1;}
00061     double dy() const {return _y2-_y1;}
00062     double dz() const {return _z2-_z1;}
00063 
00064     QList<Point> vertice() const;
00065   protected:
00066     double _x1, _y1, _z1, _x2, _y2, _z2;
00067   };
00068 
00069   inline Parallelepiped::Parallelepiped(double nx1, double ny1, double nz1,
00070                                         double nx2, double ny2, double nz2)
00071   {
00072     setLimits(nx1, ny1, nz1,
00073               nx2, ny2, nz2);
00074   }
00075 
00076   inline Parallelepiped::Parallelepiped(const Point& p1, const Point& p2)
00077   {
00078     setLimits(p1.x(), p1.y(), p1.z(),
00079               p2.x(), p2.y(), p2.z());
00080   }
00081 
00082   inline bool Parallelepiped::includes (const Point& p1, const Point& p2) const
00083   {
00084     return includes(p1.x(), p1.y(), p1.z(),
00085                     p2.x(), p2.y(), p2.z());
00086   }
00087 
00088 } // namespace QGpCoreTools
00089 
00090 #endif // PARALLELEPIPED_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines