DGtal  0.9.2
MelkmanConvexHull.h
1 
17 #pragma once
18 
31 #if defined(MelkmanConvexHull_RECURSES)
32 #error Recursive header files inclusion detected in MelkmanConvexHull.h
33 #else // defined(MelkmanConvexHull_RECURSES)
34 
35 #define MelkmanConvexHull_RECURSES
36 
37 #if !defined MelkmanConvexHull_h
38 
39 #define MelkmanConvexHull_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/Alias.h"
46 #include "DGtal/base/CountedConstPtrOrConstPtr.h"
47 #include "DGtal/base/IteratorCirculatorTraits.h"
48 #include "DGtal/base/FrontInsertionSequenceToStackAdapter.h"
49 #include "DGtal/base/BackInsertionSequenceToStackAdapter.h"
50 
51 #include "DGtal/geometry/tools/determinant/COrientationFunctor2.h"
52 #include "DGtal/geometry/tools/determinant/PredicateFromOrientationFunctor2.h"
53 
54 #include "DGtal/geometry/tools/Hull2DHelpers.h"
56 
57 namespace DGtal
58 {
59 
61  // template class MelkmanConvexHull
87  template <typename TPoint,
88  typename TOrientationFunctor >
90  {
91  // ----------------------- Types ------------------------------------------
92  public:
93 
98 
102  typedef TPoint Point;
106  typedef TOrientationFunctor Functor;
108  //the two types of points must be the same
109  BOOST_STATIC_ASSERT (( boost::is_same< Point, typename Functor::Point >::value ));
110 
119 
123  typedef typename std::deque<Point>::const_iterator ConstIterator;
124 
125  // ----------------------- Standard services ------------------------------
126  public:
127 
128  MelkmanConvexHull( Alias<Functor> aFunctor);
130 
131  // ----------------------- Interface --------------------------------------
132  public:
133 
140  void add ( const Point& aPoint );
141 
150  ConstIterator begin() const;
151 
156  ConstIterator end() const;
157 
162  void selfDisplay ( std::ostream & out ) const;
163 
168  bool isValid() const;
169 
176  Self & operator= ( const Self & mch );
177 
182  const Point & operator[](unsigned int i) const;
183 
187  unsigned int size() const;
188 
192  void clear();
193 
200  void reverse();
201 
202 
203  // ------------------------- Private Datas --------------------------------
204  private:
209  std::deque<Point> myContainer;
213  BackwardPredicate myBackwardPredicate;
217  ForwardPredicate myForwardPredicate;
225  Point myFirstPoint;
226 
227  // ------------------------- Internals ------------------------------------
228  private:
229 
230  }; // end of class MelkmanConvexHull
231 
238  template <typename TPoint, typename TOrientationFunctor>
239  std::ostream&
240  operator<< ( std::ostream & out, const MelkmanConvexHull<TPoint, TOrientationFunctor> & object );
241 
242  namespace functions
243  {
244  namespace Hull2D
245  {
264  template <typename ForwardIterator,
265  typename OutputIterator,
266  typename Functor >
267  void melkmanConvexHullAlgorithm(const ForwardIterator& itb,
268  const ForwardIterator& ite,
269  OutputIterator res,
270  Functor& aFunctor );
271  } //namespace Hull2D
272  } //namespace functions
273 
274 } // namespace DGtal
275 
276 
278 // Includes inline functions.
279 #include "DGtal/geometry/tools/MelkmanConvexHull.ih"
280 
281 // //
283 
284 #endif // !defined MelkmanConvexHull_h
285 
286 #undef MelkmanConvexHull_RECURSES
287 #endif // else defined(MelkmanConvexHull_RECURSES)
unsigned int size() const
std::deque< Point >::const_iterator ConstIterator
BOOST_STATIC_ASSERT((boost::is_same< Point, typename Functor::Point >::value))
MelkmanConvexHull< TPoint, TOrientationFunctor > Self
Self & operator=(const Self &mch)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:182
TOrientationFunctor Functor
ForwardPredicate myForwardPredicate
Aim: This concept is a refinement of COrientationFunctor, useful for simple algebraic curves that can...
Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of...
PredicateFromOrientationFunctor2< Functor, true, false > ForwardPredicate
std::deque< Point > myContainer
BackwardPredicate myBackwardPredicate
DGtal is the top-level namespace which contains all DGtal functions and types.
void add(const Point &aPoint)
BOOST_CONCEPT_ASSERT((concepts::COrientationFunctor2< Functor >))
PredicateFromOrientationFunctor2< Functor, false, false > BackwardPredicate
void melkmanConvexHullAlgorithm(const ForwardIterator &itb, const ForwardIterator &ite, OutputIterator res, Functor &aFunctor)
Procedure that retrieves the vertices of the hull of a set of 2D points given by the range [ itb ...
ConstIterator end() const
void selfDisplay(std::ostream &out) const
const Point & operator[](unsigned int i) const
ConstIterator begin() const