DGtal  1.5.beta
ArithmeticalDSSConvexHull.h
1 
17 #pragma once
18 
31 #if defined(ArithmeticalDSSConvexHull_RECURSES)
32 #error Recursive header files inclusion detected in ArithmeticalDSSConvexHull.h
33 #else // defined(ArithmeticalDSSConvexHull_RECURSES)
35 #define ArithmeticalDSSConvexHull_RECURSES
36 
37 #if !defined ArithmeticalDSSConvexHull_h
39 #define ArithmeticalDSSConvexHull_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal
48 {
49 
50  namespace functors {
51 
62  template <typename Vector, typename TPosition>
64  {
65  public:
66  typedef TPosition Position;
67  private:
70  public:
75  PositionFunctorFrom2DPoint(const Vector& aShift): myShift(aShift) {}
82  template <typename PointVector>
83  inline
84  Position operator()(const PointVector& aPointVector) const
85  {
86  return ( - myShift[1] * aPointVector[0]
87  + myShift[0] * aPointVector[1] );
88  }
89  };
90 
100  template <typename Integer>
102  {
103  public:
111  inline
112  Integer operator()(const Integer& a, const Integer& b) const
113  {
114  ASSERT( b != NumberTraits<Integer>::ZERO );
115  return a / b;
116  }
117  };
118 
129  template <typename Integer>
131  {
132  public:
141  inline
142  Integer operator()(const Integer& a, const Integer& b) const
143  {
144  ASSERT( a != NumberTraits<Integer>::ZERO );
145  ASSERT( b != NumberTraits<Integer>::ZERO );
146 
147  Integer i = a / b;
148  if (a == i*b)
149  {
150  if (i >= NumberTraits<Integer>::ZERO)
151  --i;
152  else
153  ++i;
154  }
155  return i;
156  }
157  };
158 
159  } // namespace functors
160 
161 
162  namespace functions {
163 
193  template<typename Position, typename Coordinate, typename PointVector,
194  typename OutputIterator,
195  typename PositionFunctor,
196  typename TruncationFunctor1, typename TruncationFunctor2>
197  inline
198  bool
199  smartCHNextVertex(const Position& positionBound,
200  const Coordinate& remainderBound,
201  PointVector& X,
202  Coordinate& rX,
203  const PointVector& Y,
204  const Coordinate& rY,
205  PointVector& V,
206  Coordinate& rV,
207  OutputIterator ito,
208  const PositionFunctor& pos,
209  const TruncationFunctor1& f1,
210  const TruncationFunctor2& f2);
211 
239  template<typename PointVector, typename Coordinate, typename Position,
240  typename PositionFunctor, typename OutputIterator>
241  inline
243  smartCH(const PointVector& aFirstPoint,
244  const Coordinate& aRemainderBound,
245  const Position& aPositionBound,
246  const PointVector& aStep,
247  const Coordinate& aRStep,
248  const PointVector& aShift,
249  const Coordinate& aRShift,
250  const PositionFunctor& aPositionFunctor,
251  OutputIterator uIto, OutputIterator lIto);
252 
270  template<typename DSL, typename OutputIterator>
271  inline
272  typename DSL::Vector smartCH(const DSL& aDSL,
273  const typename DSL::Point& aFirstPoint,
274  const typename DSL::Position& aLength,
275  OutputIterator uIto, OutputIterator lIto);
276 
277 
306  template<typename PointVector, typename Position,
307  typename OutputIterator,
308  typename TruncationFunctor1, typename TruncationFunctor2,
309  typename PositionFunctor>
310  inline
312  const Position& aFirstPosition, const Position& aLastPosition,
313  OutputIterator ito,
314  const PositionFunctor& pos,
315  const TruncationFunctor1& f1,
316  const TruncationFunctor2& f2);
317 
344  template<typename PointVector, typename Position, typename PositionFunctor, typename OutputIterator>
345  inline
347  const Position& aFirstPosition, const Position& aLastPosition,
348  const PositionFunctor& aPositionFunctor,
349  OutputIterator uIto, OutputIterator lIto);
350 
370  template<typename DSS, typename OutputIterator>
371  inline
372  typename DSS::Vector reversedSmartCH(const DSS& aDSS,
373  const typename DSS::Position& aPositionBound,
374  OutputIterator uIto, OutputIterator lIto);
375 
376  } // namespace functions
377 
378 
379 } // namespace DGtal
380 
381 
383 // Includes inline functions.
384 #include "DGtal/geometry/curves/ArithmeticalDSSConvexHull.ih"
385 
386 // //
388 
389 #endif // !defined ArithmeticalDSSConvexHull_h
390 
391 #undef ArithmeticalDSSConvexHull_RECURSES
392 #endif // else defined(ArithmeticalDSSConvexHull_RECURSES)
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DigitalPlane::Point Vector
PointVector smartCH(const PointVector &aFirstPoint, const Coordinate &aRemainderBound, const Position &aPositionBound, const PointVector &aStep, const Coordinate &aRStep, const PointVector &aShift, const Coordinate &aRShift, const PositionFunctor &aPositionFunctor, OutputIterator uIto, OutputIterator lIto)
Procedure that computes the lower and upper left hull of a DSS of first point aFirstPoint,...
bool smartCHPreviousVertex(PointVector &X, const PointVector &Y, PointVector &V, const Position &aFirstPosition, const Position &aLastPosition, OutputIterator ito, const PositionFunctor &pos, const TruncationFunctor1 &f1, const TruncationFunctor2 &f2)
Procedure that computes the previous vertex of the left hull of a DSS of main direction vector V ,...
bool smartCHNextVertex(const Position &positionBound, const Coordinate &remainderBound, PointVector &X, Coordinate &rX, const PointVector &Y, const Coordinate &rY, PointVector &V, Coordinate &rV, OutputIterator ito, const PositionFunctor &pos, const TruncationFunctor1 &f1, const TruncationFunctor2 &f2)
Procedure that computes the next (lower or upper) vertex of the left hull of a DSS.
PointVector reversedSmartCH(PointVector U, PointVector L, PointVector V, const Position &aFirstPosition, const Position &aLastPosition, const PositionFunctor &aPositionFunctor, OutputIterator uIto, OutputIterator lIto)
Procedure that computes the lower and upper left hull of the left subsegment of a greater DSS charact...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:564
Binary functor that returns the algebraic quotient i of a/b with any fractional part discarded (trunc...
Integer operator()(const Integer &a, const Integer &b) const
Functor that returns the position of any point/vector with respect to a digital straight line of shif...
Position operator()(const PointVector &aPointVector) const
BinaryFunctor that computes the algebraic quotient i of a/b with any non zero fractional part discard...
Integer operator()(const Integer &a, const Integer &b) const
MyPointD Point
Definition: testClone2.cpp:383