libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNPoint3D.h
Go to the documentation of this file.
1 /* Copyright 2013-2016 INSA Lyon, ENS-Lyon
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNPoint3D.h
19  * \author Jean DUONG
20  */
21 
22 #ifndef CRNPOINT3D_HEADER
23 #define CRNPOINT3D_HEADER
24 
25 #include <CRNObject.h>
26 #include <CRNString.h>
27 
28 namespace crn
29 {
30  /****************************************************************************/
40  template<typename T> class Point3D
41  {
42  public:
44  using value_type = T;
45 
47  Point3D():X(0),Y(0),Z(0) {}
49  Point3D(T x, T y, T z):X(x),Y(y),Z(z) {}
50  Point3D(const Point3D &) = default;
51  Point3D(Point3D &&) = default;
53  virtual ~Point3D() {}
54 
57  Point3D& operator=(const Point3D &) = default;
58  Point3D& operator=(Point3D &&) = default;
60  bool operator==(const Point3D &p) const noexcept { return (X == p.X) && (Y == p.Y) && (Z == p.Z); }
61 
66  class Sorter: public std::binary_function<const Point3D&, const Point3D&, bool>
67  {
68  public:
77  inline bool operator()(const Point3D &p1, const Point3D &p2) const
78  {
79  if (p1.X < p2.X) return true;
80  else if (p1.X > p2.X) return false;
81 
82  if (p1.Y < p2.Y) return true;
83  else if (p1.Y > p2.Y) return false;
84 
85  if (p1.Z < p2.Z) return true;
86 
87  return false;
88  }
89  };
90  };
91 }
92 
93 #endif
Point3D()
Default constructor (sets coordinates to 0)
Definition: CRNPoint3D.h:47
Point3D & operator=(const Point3D &)=default
value_type Y
Definition: CRNPoint3D.h:55
Functor to sort rectangles regarding directions.
Definition: CRNPoint3D.h:66
A 3D point class.
Definition: CRNPoint3D.h:40
T value_type
The value type.
Definition: CRNPoint3D.h:44
virtual ~Point3D()
Destructor.
Definition: CRNPoint3D.h:53
value_type X
Definition: CRNPoint3D.h:55
bool operator==(const Point3D &p) const noexcept
Equality.
Definition: CRNPoint3D.h:60
bool operator()(const Point3D &p1, const Point3D &p2) const
Comparison function.
Definition: CRNPoint3D.h:77
value_type Z
Definition: CRNPoint3D.h:55
Point3D(T x, T y, T z)
Constructor from values.
Definition: CRNPoint3D.h:49