libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNPoint2DInt.h
Go to the documentation of this file.
1 /* Copyright 2008-2016 INSA Lyon, CoReNum, 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: CRNPoint2DInt.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef CRNPOINT2DINT_HEADER
23 #define CRNPOINT2DINT_HEADER
24 
25 #include <CRNGeometry/CRNPoint2D.h>
26 
27 namespace crn
28 {
29  /****************************************************************************/
39  class Point2DInt: public Point2D<int>
40  {
41  public:
43  Point2DInt() noexcept:Point2D<int>() {}
45  Point2DInt(int x, int y) noexcept:Point2D<int>(x,y) {}
46  Point2DInt(const Point2D<int> &p) noexcept:Point2D<int>(p) {}
47  Point2DInt(const Point2DInt &) = default;
48  Point2DInt(Point2DInt &&) = default;
50  virtual ~Point2DInt() override = default;
51 
52  Point2DInt& operator=(const Point2DInt &) = default;
53  Point2DInt& operator=(Point2DInt &&) = default;
54 
56  void Advance(const Direction &dir, int step = 1);
57 
59  void Deserialize(xml::Element &el);
61  xml::Element Serialize(xml::Element &parent) const;
62  private:
63 
66  };
67  template<> struct IsSerializable<Point2DInt> : public std::true_type {};
68  template<> struct IsClonable<Point2DInt> : public std::true_type {};
69 
71 
72 
73  std::vector<Point2DInt> MakeSegment(const Point2DInt &p_begin, const Point2DInt &p_end);
74 
75 }
76 
77 #endif
78 
Point2DInt(const Point2D< int > &p) noexcept
Definition: CRNPoint2DInt.h:46
virtual ~Point2DInt() override=default
Destructor.
std::vector< Point2DInt > MakeSegment(const Point2DInt &p_begin, const Point2DInt &p_end)
Make a segment between two points.
#define CRN_SERIALIZATION_CONSTRUCTOR(classname)
Defines a default constructor from xml element.
Definition: CRNObject.h:165
XML element.
Definition: CRNXml.h:135
Point2DInt(int x, int y) noexcept
Constructor from values.
Definition: CRNPoint2DInt.h:45
Direction
An enumeration of directions.
Definition: CRNMath.h:122
Point2DInt & operator=(const Point2DInt &)=default
A 2D point class.
Definition: CRNPoint2D.h:45
void Advance(const Direction &dir, int step=1)
Moves the point towards a direction.
Point2DInt() noexcept
Default constructor.
Definition: CRNPoint2DInt.h:43
#define CRN_DECLARE_CLASS_CONSTRUCTOR(classname)
Declares a class constructor.
Definition: CRNObject.h:173
xml::Element Serialize(xml::Element &parent) const
Dumps the object to an XML element. Unsafe.
CRN_ALIAS_SMART_PTR(ImageBW)
void Deserialize(xml::Element &el)
Initializes the object from an XML element. Unsafe.
A 2D point class.
Definition: CRNPoint2DInt.h:39