KSquare Utilities
Point.h
Go to the documentation of this file.
1 /* Point.h -- Represents the coordinates in a Raster image.
2  * Copyright (C) 1994-2014 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _POINT_
6 #define _POINT_
7 
8 #include "KKBaseTypes.h"
9 #include "KKQueue.h"
10 #include "KKStr.h"
11 
12 namespace KKB
13 {
14  /**
15  *@class Point Point.h
16  *@brief Used by Raster class and MorphOp derived classes to denote a single pixel location in Raster image.
17  *@see Raster
18  *@see MorphOp
19  */
20  class Point
21  {
22  public:
23  Point ();
24 
25  Point (const Point& point);
26 
27  Point (kkint16 _row,
28  kkint16 _col
29  );
30 
31  Point (kkint32 _row,
32  kkint32 _col
33  );
34 
35  Point (float _row,
36  float _col
37  );
38 
39  inline kkint32 Row () const {return row;}
40  inline kkint32 Col () const {return col;}
41 
42  void Row (kkint32 _row) {row = _row;}
43  void Col (kkint32 _col) {col = _col;}
44 
45  Point UpOne () const {return Point (row - 1, col );}
46  Point DownOne () const {return Point (row + 1, col );}
47  Point LeftOne () const {return Point (row , col - 1);}
48  Point RightOne () const {return Point (row , col + 1);}
49 
50  bool operator== (Point& r) const;
51 
52  bool operator!= (const Point& r) const;
53 
54  Point operator+ (const Point& r) const;
55 
56  Point operator- (const Point& r) const;
57 
58  Point& operator= (const Point& r);
59 
60  private:
61  kkint32 row;
62  kkint32 col;
63  }; /* Point */
64 
65 
66  typedef Point* PointPtr;
67 
69 
70 
71  /**
72  *@class PointList Point.h
73  *@brief Container object used to maintaining a list of pixel locations.
74  */
75  class PointList: public KKQueue<Point>
76  {
77  public:
79 
80  PointList (const PointList& pointList);
81 
82 
83  PointList (bool _owner);
84 
85  void BoxCoordinites (kkint32& minRow,
86  kkint32& minCol,
87  kkint32& maxRow,
88  kkint32& maxCol
89  );
90 
92 
93  float ComputeSegmentLens (float heightFactor,
94  float widthFactor
95  ) const;
96 
97 
98  KKStr ToDelStr (char del) const;
99 
100  static
101  PointListPtr FromDelStr (const KKStr& s);
102 
103  }; /* PointList */
104 
105 
106 
107  typedef PointList::PointListPtr PointListPtr;
108 
109 
110  KKStr& operator<< (KKStr& left,
111  const Point& right
112  );
113 
114  std::ostream& operator<< (std::ostream& left,
115  const Point& right
116  );
117 } /* namespace KKB; */
118 
119 #endif
__int16 kkint16
16 bit signed integer.
Definition: KKBaseTypes.h:85
__int32 kkint32
Definition: KKBaseTypes.h:88
Point & operator=(const Point &r)
Definition: Point.cpp:84
kkint32 Col() const
Definition: Point.h:40
PointList(const PointList &pointList)
Definition: Point.cpp:93
Point operator+(const Point &r) const
Definition: Point.cpp:72
kkint32 Row() const
Definition: Point.h:39
static PointListPtr FromDelStr(const KKStr &s)
Definition: Point.cpp:176
bool operator!=(const Point &r) const
Definition: Point.cpp:66
Point RightOne() const
Definition: Point.h:48
PointList(bool _owner)
Definition: Point.cpp:105
float ComputeSegmentLens(float heightFactor, float widthFactor) const
Definition: Point.cpp:233
std::vector< Point > VectorPoint
Definition: Point.h:68
Point(float _row, float _col)
Definition: Point.cpp:52
Used by Raster class and MorphOp derived classes to denote a single pixel location in Raster image...
Definition: Point.h:20
void Row(kkint32 _row)
Definition: Point.h:42
KKTHread * KKTHreadPtr
PointList * PointListPtr
Definition: Point.h:78
KKStr ToDelStr(char del) const
Definition: Point.cpp:156
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
void Col(kkint32 _col)
Definition: Point.h:43
Point UpOne() const
Definition: Point.h:45
Point(const Point &point)
Definition: Point.cpp:26
Point(kkint32 _row, kkint32 _col)
Definition: Point.cpp:43
Point DownOne() const
Definition: Point.h:46
Point CalculateCenterPoint()
Definition: Point.cpp:138
Point LeftOne() const
Definition: Point.h:47
Point operator-(const Point &r) const
Definition: Point.cpp:78
Container object used to maintaining a list of pixel locations.
Definition: Point.h:75
void BoxCoordinites(kkint32 &minRow, kkint32 &minCol, kkint32 &maxRow, kkint32 &maxCol)
Definition: Point.cpp:111
Point(kkint16 _row, kkint16 _col)
Definition: Point.cpp:34
bool operator==(Point &r) const
Definition: Point.cpp:60
Point * PointPtr
Definition: Point.h:66