IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Shape2d.h
1 // Shape2d.h:
3 // ----------
4 //
15 
16 #ifndef __IPSDKGEOMETRY_SHAPE2D_H__
17 #define __IPSDKGEOMETRY_SHAPE2D_H__
18 
19 // suppression warnings
20 // warning C4251: 'ipsdk::geom::Shape2d<T>::_polygonColl' : class 'std::vector<ipsdk::geom::PolygonWithHoles2d<T>>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::Shape2d<T>'
21 #pragma warning (push)
22 #pragma warning (disable : 4251)
23 
24 #include <IPSDKGeometry/Entity/2d/BaseTypedGeometryEntity2d.h>
28 
29 namespace ipsdk {
30 namespace geom {
31 
34 
35 class IPSDKGEOMETRY_API Shape2d : public BaseTypedGeometryEntity2d<Shape2dDataType>
36 {
37  // declare 2d geometry entity
39 
40 // predefined public types
41 public:
43  static const eCoordinateSystem2dType::domain g_coordinateSystem2dType = eCoordinateSystem2dType::eCS2DT_Cartesian;
44 
46  static const eEntity2dType::domain g_entity2dType = eEntity2dType::eE2DT_Shape;
47 
50 
53 
56 
59 
62 
64  typedef Shape2dPolygonWithHolesColl::iterator PolygonWithHolesIterator;
65 
66 public:
69  Shape2d();
70  ~Shape2d();
72 
73 // methods
74 public:
76  inline eCoordinateSystem2dType getCoordinateSystem2dType() const;
77 
79  inline eEntity2dType getEntity2dType() const;
80 
81  //------------------------------------------------
84  //------------------------------------------------
85 
87  inline bool hasRowIntersections() const;
88 
90  inline const RowIntersections& getRowIntersections() const;
91 
93  inline RowIntersections& getRowIntersections();
94 
96  inline ipUInt64 getStartY() const;
97 
99  inline ipUInt64 getSizeY() const;
100 
102  inline ipUInt64 getEndY() const;
103 
105  inline bool hasRowIntersection(const ipUInt64 rowIdx) const;
106 
110  const RowSegments& getRowIntersections(const ipUInt64 rowIdx) const;
111 
113  const ipUInt64 getNbPixels() const;
114 
116  void clearRowIntersections();
118 
119  //-------------------------------------------------------------
122  //-------------------------------------------------------------
123 
125  inline bool isPolygonWithHolesCollSet() const;
126 
128  inline const PolygonWithHolesConstColl& getPolygonWithHolesColl() const;
129 
131  inline PolygonWithHolesColl& getPolygonWithHolesColl();
132 
134  ipUInt64 getNbExteriorPoints() const;
135 
138  ipUInt64 getNbTotPoints() const;
139 
141  inline PolygonWithHolesIterator beginPolygonWithHoles();
142 
144  inline PolygonWithHolesIterator endPolygonWithHoles();
145 
147  void clearPolygonWithHolesColl();
149 
151  void clear();
152 
153 // attributes
154 protected:
157 
160 };
161 
164 
167 {
169 }
170 
171 inline eEntity2dType
173 {
174  return g_entity2dType;
175 }
176 
177 IPSDK_FORCEINLINE bool
179 {
180  return _rowIntersections._rowSegColl.empty() == false;
181 }
182 
183 IPSDK_FORCEINLINE const RowIntersections&
185 {
186  return _rowIntersections;
187 }
188 
189 IPSDK_FORCEINLINE RowIntersections&
191 {
192  return _rowIntersections;
193 }
194 
195 IPSDK_FORCEINLINE ipUInt64
197 {
199 }
200 
201 IPSDK_FORCEINLINE ipUInt64
203 {
204  return static_cast<ipUInt64>(_rowIntersections._rowSegColl.size());
205 }
206 
207 IPSDK_FORCEINLINE ipUInt64
209 {
210  return getStartY() + getSizeY();
211 }
212 
213 IPSDK_FORCEINLINE bool
215 {
216  return rowIdx >= getStartY() && rowIdx < getEndY();
217 }
218 
219 IPSDK_FORCEINLINE bool
221 {
222  return _polygonWithHolesColl.empty() == false;
223 }
224 
225 IPSDK_FORCEINLINE const Shape2d::PolygonWithHolesConstColl&
227 {
228  return reinterpret_cast<const Shape2d::PolygonWithHolesConstColl&>(_polygonWithHolesColl);
229 }
230 
231 IPSDK_FORCEINLINE Shape2d::PolygonWithHolesColl&
233 {
234  return _polygonWithHolesColl;
235 }
236 
237 IPSDK_FORCEINLINE Shape2d::PolygonWithHolesIterator
239 {
240  return _polygonWithHolesColl.begin();
241 }
242 
243 IPSDK_FORCEINLINE Shape2d::PolygonWithHolesIterator
245 {
246  return _polygonWithHolesColl.end();
247 }
248 
251 
252 } // end of namespace geom
253 } // end of namespace ipsdk
254 
255 #pragma warning (pop)
256 
257 #endif // __IPSDKGEOMETRY_SHAPE2D_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Shape2dPolygonWithHolesColl PolygonWithHolesColl
collection of polygon with holes
Definition: Shape2d.h:61
PolygonWithHolesIterator endPolygonWithHoles()
iterator used to parse polygon
Definition: Shape2d.h:244
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
Basic operators used for shape 2d management.
RowSegmentsColl _rowSegColl
row intersections collections
Definition: GeometryEntityTypes.h:77
Definition: GeometryEntityTypes.h:71
std::vector< Shape2dPolygonWithHolesPtr > Shape2dPolygonWithHolesColl
collection of polygon with holes
Definition: Shape2dTypes.h:78
IPSDKGEOMETRY_API ipUInt64 getNbPixels(const ipsdk::geom::RowIntersections &)
return the number of pixels in the input RowIntersections data structure
Closed polygon potentially associated to interior polygonal holes.
Definition: PolygonWithHoles2d.h:40
eCoordinateSystem2dType
Enumerate describing coordinate system 2d type.
Definition: GeometryEntity2dTypes.h:76
bool isPolygonWithHolesCollSet() const
check whether polygon with holes collection has been set
Definition: Shape2d.h:220
ipUInt64 getStartY() const
retrieve starting row index for shape
Definition: Shape2d.h:196
PolygonWithHolesIterator beginPolygonWithHoles()
iterator used to parse polygon
Definition: Shape2d.h:238
Shape2dPolygonWithHolesConstColl PolygonWithHolesConstColl
collection of const polygon with holes
Definition: Shape2d.h:58
Shape.
Definition: GeometryEntity2dTypes.h:52
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity2d.h:27
boost::shared_ptr< const Shape2dPolygonWithHoles > Shape2dPolygonWithHolesConstPtr
shared pointer to const polygon with holes associated to shape
Definition: Shape2dTypes.h:72
#define IPSDK_DECLARE_GEOMETRY_ENTITY_2D(libraryName, className)
Macro allowing to declare a geometry entity 2d.
Definition: GeometryEntity2dHdrMacros.h:131
bool hasRowIntersections() const
check whether row intersections have been set
Definition: Shape2d.h:178
PolygonWithHolesColl _polygonWithHolesColl
collection of polygon holes associated to shape 2d
Definition: Shape2d.h:159
std::vector< RowSegment > RowSegments
collection of row segments
Definition: GeometryEntityTypes.h:63
static const eEntity2dType::domain g_entity2dType
type associated to entity
Definition: Shape2d.h:46
bool hasRowIntersection(const ipUInt64 rowIdx) const
check whether shape has an intersection with a given row
Definition: Shape2d.h:214
eEntity2dType getEntity2dType() const
method allowing to retrieve entity 2d type
Definition: Shape2d.h:172
eEntity2dType
Enumerate describing entity 2d type.
Definition: GeometryEntity2dTypes.h:38
Shape2dPolygonWithHolesColl::iterator PolygonWithHolesIterator
iterator to collection of polygon with holes
Definition: Shape2d.h:64
Shape2dPolygonWithHolesConstPtr PolygonWithHolesConstPtr
shared pointer to polygon with holes
Definition: Shape2d.h:55
eCoordinateSystem2dType getCoordinateSystem2dType() const
method allowing to retrieve coordinate system 2d type
Definition: Shape2d.h:166
Shape2dPolygonWithHolesPtr PolygonWithHolesPtr
shared pointer to polygon with holes
Definition: Shape2d.h:52
Shape2dPolygonWithHoles PolygonWithHolesType
polygon with holes type associated to object
Definition: Shape2d.h:49
ipUInt64 getSizeY() const
retrieve number of rows associated to shape
Definition: Shape2d.h:202
Shape 2d associated to one or more closed polygon 2d.
Definition: Shape2d.h:35
Predefined types for shape 2d management.
ipUInt64 _yOffset
y coordinate of first row intersections
Definition: GeometryEntityTypes.h:74
RowIntersections _rowIntersections
structure describing shape/row intersections
Definition: Shape2d.h:156
ipUInt64 getEndY() const
retrieve ending row index for shape
Definition: Shape2d.h:208
static const eCoordinateSystem2dType::domain g_coordinateSystem2dType
coordinate system associated to entity
Definition: Shape2d.h:43
const PolygonWithHolesConstColl & getPolygonWithHolesColl() const
access to polygon with holes collection
Definition: Shape2d.h:226
const RowIntersections & getRowIntersections() const
retrieve row intersections collection
Definition: Shape2d.h:184
std::vector< Shape2dPolygonWithHolesConstPtr > Shape2dPolygonWithHolesConstColl
collection of const polygon with holes
Definition: Shape2dTypes.h:75
Cartesian coordinate system.
Definition: GeometryEntity2dTypes.h:78
boost::shared_ptr< Shape2dPolygonWithHoles > Shape2dPolygonWithHolesPtr
shared pointer to polygon with holes associated to shape
Definition: Shape2dTypes.h:69