IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
PolygonWithHoles2d.h
1 // PolygonWithHoles2d.h:
3 // ---------------------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_POLYGONWITHHOLES2D_H__
16 #define __IPSDKGEOMETRY_POLYGONWITHHOLES2D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::geom::PolygonWithHoles2d<T>::_exteriorPolygon' : class 'ipsdk::geom::Polygon2d<T>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::PolygonWithHoles2d<T>'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
23 #include <IPSDKGeometry/Entity/2d/BaseTypedGeometryEntity2d.h>
24 #include <IPSDKGeometry/Entity/2d/Polygon/Polygon2d.h>
28 #include <boost/enable_shared_from_this.hpp>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/weak_ptr.hpp>
31 #include <vector>
32 
33 namespace ipsdk {
34 namespace geom {
35 
38 
39 template <typename T>
41  public boost::enable_shared_from_this<PolygonWithHoles2d<T> >
42 {
43  // declare 2d geometry entity
45 
46 // predefined public types
47 public:
49  static const eCoordinateSystem2dType::domain g_coordinateSystem2dType = eCoordinateSystem2dType::eCS2DT_Cartesian;
50 
52  static const eEntity2dType::domain g_entity2dType = eEntity2dType::eE2DT_PolygonWithHoles;
53 
56 
59 
61  typedef boost::shared_ptr<PolygonWithHolesType> PolygonWithHolesPtr;
62 
64  typedef boost::shared_ptr<const PolygonWithHolesType> PolygonWithHolesConstPtr;
65 
67  typedef boost::weak_ptr<const PolygonWithHolesType> PolygonWithHolesConstWeakPtr;
68 
70  typedef std::vector<PolygonWithHolesConstPtr> PolygonConstColl;
71 
73  typedef std::vector<PolygonWithHolesPtr> PolygonColl;
74 
76  typedef typename PolygonColl::iterator HoleIterator;
77 
78 public:
84 
85 // methods
86 public:
88  inline eCoordinateSystem2dType getCoordinateSystem2dType() const;
89 
91  inline eEntity2dType getEntity2dType() const;
92 
94  inline const ePolygon2dType& getPolygon2dType() const;
95 
99  inline PolygonWithHolesConstPtr getParent() const;
100 
102  inline void setParent(const PolygonWithHolesConstPtr& pParent);
103 
106  ipUInt32 getNbTotPolygons() const;
107 
110  ipUInt32 getNbTotPoints() const;
111 
113  inline bool isEmpty() const;
114 
116  inline ipUInt32 getNbExteriorPoints() const;
117 
119  inline const PolygonType& getExteriorPolygon() const;
120 
122  inline PolygonType& getExteriorPolygon();
123 
125  inline bool hasHoles() const;
126 
128  inline ipUInt32 getNbHoles() const;
129 
131  inline const PolygonConstColl& getPolygonHoles() const;
132 
134  inline PolygonColl& getPolygonHoles();
135 
138  inline HoleIterator beginHole();
139  inline HoleIterator endHole();
141 
143  void clearPolygonHoles();
144 
146  void clear();
147 
148 // attributes
149 protected:
152 
155 
158 };
159 
162 
163 template <typename T>
166 {
167  return g_coordinateSystem2dType;
168 }
169 
170 template <typename T>
171 inline eEntity2dType
173 {
174  return g_entity2dType;
175 }
176 
177 template <typename T>
178 inline const ePolygon2dType&
180 {
181  return _exteriorPolygon.getPolygon2dType();
182 }
183 
184 template <typename T>
187 {
188  return _pParent.lock();
189 }
190 
191 template <typename T>
192 inline void
194 {
195  _pParent = pParent;
196 }
197 
198 template <typename T>
199 IPSDK_FORCEINLINE const typename PolygonWithHoles2d<T>::PolygonType&
201 {
202  return _exteriorPolygon;
203 }
204 
205 template <typename T>
206 IPSDK_FORCEINLINE typename PolygonWithHoles2d<T>::PolygonType&
208 {
209  return _exteriorPolygon;
210 }
211 
212 template <typename T>
213 IPSDK_FORCEINLINE bool
215 {
216  return _exteriorPolygon.isEmpty();
217 }
218 
219 template <typename T>
220 IPSDK_FORCEINLINE ipUInt32
222 {
223  return _exteriorPolygon.getNbPoints();
224 }
225 
226 template <typename T>
227 IPSDK_FORCEINLINE const typename PolygonWithHoles2d<T>::PolygonConstColl&
229 {
230  return reinterpret_cast<const PolygonConstColl&>(_polygonHoles);
231 }
232 
233 template <typename T>
234 IPSDK_FORCEINLINE typename PolygonWithHoles2d<T>::PolygonColl&
236 {
237  return _polygonHoles;
238 }
239 
240 template <typename T>
241 IPSDK_FORCEINLINE bool
243 {
244  if (_polygonHoles.empty() == true)
245  return false;
246  else
247  return true;
248 }
249 
250 template <typename T>
251 IPSDK_FORCEINLINE ipUInt32
253 {
254  return static_cast<ipUInt32>(_polygonHoles.size());
255 }
256 
257 template <typename T>
258 IPSDK_FORCEINLINE typename PolygonWithHoles2d<T>::HoleIterator
260 {
261  return _polygonHoles.begin();
262 }
263 
264 template <typename T>
265 IPSDK_FORCEINLINE typename PolygonWithHoles2d<T>::HoleIterator
267 {
268  return _polygonHoles.end();
269 }
270 
273 
274 } // end of namespace geom
275 } // end of namespace ipsdk
276 
277 #pragma warning (pop)
278 
279 #endif // __IPSDKGEOMETRY_POLYGONWITHHOLES2D_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
eEntity2dType getEntity2dType() const
method allowing to retrieve entity 2d type
Definition: PolygonWithHoles2d.h:172
boost::shared_ptr< PolygonWithHolesType > PolygonWithHolesPtr
shared pointer to polygon with holes
Definition: PolygonWithHoles2d.h:61
ePolygon2dType
Enumerate describing polygon type.
Definition: Polygon2dTypes.h:34
Predefined types for neighborhood 2d management.
const PolygonConstColl & getPolygonHoles() const
get interior polygon holes
Definition: PolygonWithHoles2d.h:228
Closed polygon potentially associated to interior polygonal holes.
Definition: PolygonWithHoles2d.h:40
eCoordinateSystem2dType
Enumerate describing coordinate system 2d type.
Definition: GeometryEntity2dTypes.h:76
bool isEmpty() const
method allowing to check whether polygon is empty
Definition: PolygonWithHoles2d.h:214
Basic operators used for polygon with holes 2d management.
boost::shared_ptr< const PolygonWithHolesType > PolygonWithHolesConstPtr
shared pointer to const polygon with holes
Definition: PolygonWithHoles2d.h:64
boost::weak_ptr< const PolygonWithHolesType > PolygonWithHolesConstWeakPtr
weak pointer to polygon with holes
Definition: PolygonWithHoles2d.h:67
Polygon with holes.
Definition: GeometryEntity2dTypes.h:50
eCoordinateSystem2dType getCoordinateSystem2dType() const
method allowing to retrieve coordinate system 2d type
Definition: PolygonWithHoles2d.h:165
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity2d.h:27
PolygonWithHolesConstWeakPtr _pParent
parent polygon associated to instance
Definition: PolygonWithHoles2d.h:151
#define IPSDK_DECLARE_GEOMETRY_ENTITY_2D(libraryName, className)
Macro allowing to declare a geometry entity 2d.
Definition: GeometryEntity2dHdrMacros.h:131
Polygon2d< T > PolygonType
polygon type associated to object
Definition: PolygonWithHoles2d.h:55
PolygonWithHoles2d< T > PolygonWithHolesType
polygon with holes type associated to object
Definition: PolygonWithHoles2d.h:58
void setParent(const PolygonWithHolesConstPtr &pParent)
set parent polygon of instance
Definition: PolygonWithHoles2d.h:193
HoleIterator endHole()
iterator used to parse polygon holes
Definition: PolygonWithHoles2d.h:266
std::vector< PolygonWithHolesConstPtr > PolygonConstColl
collection of const polygons
Definition: PolygonWithHoles2d.h:70
Closed polygon associated to an ordered collection of 2d points.
Definition: Polygon2d.h:38
HoleIterator beginHole()
iterator used to parse polygon holes
Definition: PolygonWithHoles2d.h:259
const ePolygon2dType & getPolygon2dType() const
retrieve polygon 2d type
Definition: PolygonWithHoles2d.h:179
ipUInt32 getNbExteriorPoints() const
retrieve number of exterior points
Definition: PolygonWithHoles2d.h:221
PolygonColl _polygonHoles
collection of interior polygon holes
Definition: PolygonWithHoles2d.h:157
eEntity2dType
Enumerate describing entity 2d type.
Definition: GeometryEntity2dTypes.h:38
PolygonColl::iterator HoleIterator
iterator to collection of polygons
Definition: PolygonWithHoles2d.h:76
ipUInt32 getNbHoles() const
method allowing to retrieve number of holes associated to polygon
Definition: PolygonWithHoles2d.h:252
PolygonType _exteriorPolygon
exterior polygon
Definition: PolygonWithHoles2d.h:154
const PolygonType & getExteriorPolygon() const
get exterior polygon associated to object
Definition: PolygonWithHoles2d.h:200
PolygonWithHolesConstPtr getParent() const
retrieve parent polygon of instance
Definition: PolygonWithHoles2d.h:186
boost::enable_if< typename boost::mpl::and_< typename boost::is_same< boost::mpl::int_< AttributeType::g_attributeType >, boost::mpl::int_< eAttributeType::eAT_DataItem > >::type, typename boost::is_same< boost::mpl::int_< LeafCollType::g_itemType >, boost::mpl::int_< eDataItemType::eDIT_LeafColl > >::type >::type, RulePtr >::type isEmpty(const boost::shared_ptr< AttributeType > &pAttribute)
functions allowing to check that a leaf collection is empty
Definition: LeafCollSizeRuleOperators.h:65
std::vector< PolygonWithHolesPtr > PolygonColl
collection of polygons
Definition: PolygonWithHoles2d.h:73
Cartesian coordinate system.
Definition: GeometryEntity2dTypes.h:78
bool hasHoles() const
method allowing to check whether polygon has holes
Definition: PolygonWithHoles2d.h:242
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53