DGtal  1.4.beta
BasicPointPredicates.h
1 
17 #pragma once
18 
35 #if defined(BasicPointPredicates_RECURSES)
36 #error Recursive header files inclusion detected in BasicPointPredicates.h
37 #else // defined(BasicPointPredicates_RECURSES)
39 #define BasicPointPredicates_RECURSES
40 
41 #if !defined BasicPointPredicates_h
43 #define BasicPointPredicates_h
44 
46 // Inclusions
47 #include <iostream>
48 #include "DGtal/base/Common.h"
49 #include "DGtal/base/BasicBoolFunctors.h"
50 #include "DGtal/base/CPredicate.h"
51 #include "DGtal/base/ConstAlias.h"
52 #include "DGtal/kernel/CPointFunctor.h"
53 #include "DGtal/kernel/CPointPredicate.h"
55 
56 // @since 0.8 In DGtal::functors
57 namespace DGtal {
58  namespace functors {
59 
61  // template class ConstantPointPredicate
69  template <typename TPoint, bool boolCst>
71  {
72  typedef TPoint Point;
73 
78  bool operator()( const Point & p ) const;
79 
80  }; // end of class ConstantPointPredicates
81 
83  // template class TruePointPredicate
90  template <typename TPoint>
91  struct TruePointPredicate : public ConstantPointPredicate<TPoint,true>
92  {
93  };
94 
96  // template class FalsePointPredicate
103  template <typename TPoint>
104  struct FalsePointPredicate : public ConstantPointPredicate<TPoint,false>
105  {
106  };
107 
109  // template class IsLowerPointPredicate
117  template <typename TPoint>
119  {
120  typedef TPoint Point;
121 
125  IsLowerPointPredicate( const Point & upperBound );
126 
131  bool operator()( const Point & p ) const;
132 
135  };
136 
138  // template class IsUpperPointPredicate
146  template <typename TPoint>
148  {
149  typedef TPoint Point;
150 
154  IsUpperPointPredicate( const Point & lowerBound );
155 
160  bool operator()( const Point & p ) const;
161 
164  };
165 
167  // template class IsWithinPointPredicate
174  template <typename TPoint>
176  {
177  typedef TPoint Point;
178 
182  IsWithinPointPredicate( const Point & lowerBound,
183  const Point & upperBound );
184 
189  bool operator()( const Point & p ) const;
190 
195  };
196 
198  // template class NotPointPredicate
206  template <typename TPointPredicate>
208  {
209  typedef TPointPredicate PointPredicate;
211  typedef typename PointPredicate::Point Point;
212 
217 
222  bool operator()( const Point & p ) const;
223 
226  };
227 
229  // template class EqualPointPredicate
237  template <typename TPoint>
239  {
240  typedef TPoint Point;
241 
246 
251  bool operator()( const Point & p ) const;
252 
255  };
256 
258  // template class BinaryPointPredicate
273  template <typename TPointPredicate1, typename TPointPredicate2,
274  typename TBinaryFunctor = BoolFunctor2 >
276  {
277  typedef TPointPredicate1 PointPredicate1;
278  typedef TPointPredicate2 PointPredicate2;
279  typedef typename PointPredicate1::Point Point;
280  typedef typename PointPredicate2::Point Point2;
281 
285  BOOST_STATIC_ASSERT (( boost::is_same< Point, Point2 >::value ));
286 
295 
300  bool operator()( const Point & p ) const;
301 
307  const TBinaryFunctor* myBoolFunctor;
308  };
309 
313  template <typename TPointPredicate1, typename TPointPredicate2>
314  struct BinaryPointPredicate<TPointPredicate1, TPointPredicate2, AndBoolFct2>
315  {
316  typedef TPointPredicate1 PointPredicate1;
317  typedef TPointPredicate2 PointPredicate2;
318  typedef typename PointPredicate1::Point Point;
319  typedef typename PointPredicate2::Point Point2;
320 
323  BOOST_STATIC_ASSERT (( boost::is_same< Point, Point2 >::value ));
324 
326 
327  bool operator()( const Point & p ) const;
328 
332  };
333 
337  template <typename TPointPredicate1, typename TPointPredicate2>
338  struct BinaryPointPredicate<TPointPredicate1, TPointPredicate2, OrBoolFct2>
339  {
340  typedef TPointPredicate1 PointPredicate1;
341  typedef TPointPredicate2 PointPredicate2;
342  typedef typename PointPredicate1::Point Point;
343  typedef typename PointPredicate2::Point Point2;
344 
347  BOOST_STATIC_ASSERT (( boost::is_same< Point, Point2 >::value ));
348 
350 
351  bool operator()( const Point & p ) const;
352 
356  };
357 
359  // template class PointFunctorPredicate
369  template <typename TPointFunctor, typename TPredicate>
371  {
374 
375  typedef TPointFunctor PointFunctor;
376  typedef TPredicate Predicate;
377  typedef typename PointFunctor::Point Point;
378 
385 
390  bool operator()( const Point & p ) const;
391 
396  };
397 
398 } // namespace functors
399 } // namespace DGtal
400 
401 
403 // Includes inline functions.
404 #include "DGtal/kernel/BasicPointPredicates.ih"
405 
406 // //
408 
409 #endif // !defined BasicPointPredicates_h
410 
411 #undef BasicPointPredicates_RECURSES
412 #endif // else defined(BasicPointPredicates_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
boost::function2< bool, bool, bool > BoolFunctor2
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines a functor on points.
Definition: CPointFunctor.h:89
Aim: Defines a predicate on a point.
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:90
BinaryPointPredicate(ConstAlias< PointPredicate1 > pred1, ConstAlias< PointPredicate2 > pred2, ConstAlias< AndBoolFct2 > boolFunctor)
BinaryPointPredicate(ConstAlias< PointPredicate1 > pred1, ConstAlias< PointPredicate2 > pred2, ConstAlias< OrBoolFct2 > boolFunctor)
Aim: The predicate returns true when the given binary functor returns true for the two PointPredicate...
const TBinaryFunctor * myBoolFunctor
aliasing pointer to the binary functor.
BOOST_CONCEPT_ASSERT((boost::BinaryFunction< TBinaryFunctor, bool, bool, bool >))
BinaryPointPredicate(ConstAlias< PointPredicate1 > pred1, ConstAlias< PointPredicate2 > pred2, ConstAlias< TBinaryFunctor > boolFunctor)
BOOST_STATIC_ASSERT((boost::is_same< Point, Point2 >::value))
const PointPredicate2 * myPred2
aliasing pointer to the right predicate.
bool operator()(const Point &p) const
const PointPredicate1 * myPred1
aliasing pointer to the left predicate.
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< PointPredicate2 >))
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< PointPredicate1 >))
Aim: The predicate that returns always the same value boolCst.
bool operator()(const Point &p) const
Aim: The predicate returns true when the point given as argument equals the reference point given at ...
EqualPointPredicate(const Point &aPoint)
bool operator()(const Point &p) const
Aim: The predicate that returns always false.
Aim: The predicate returns true when the point is below (or equal) the given upper bound.
bool operator()(const Point &p) const
IsLowerPointPredicate(const Point &upperBound)
Aim: The predicate returns true when the point is above (or equal) the given lower bound.
bool operator()(const Point &p) const
IsUpperPointPredicate(const Point &lowerBound)
Aim: The predicate returns true when the point is within the given bounds.
IsWithinPointPredicate(const Point &lowerBound, const Point &upperBound)
bool operator()(const Point &p) const
Aim: The predicate returns true when the point predicate given at construction return false....
NotPointPredicate(ConstAlias< PointPredicate > pred)
const PointPredicate * myPred
The PointPredicate that is inversed.
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< PointPredicate >))
bool operator()(const Point &p) const
Aim: The predicate returns true when the predicate returns true for the value assigned to a given poi...
PointFunctorPredicate(ConstAlias< PointFunctor > aFun, ConstAlias< Predicate > aPred)
bool operator()(const Point &p) const
const Predicate * myPred
alias of the predicate.
BOOST_CONCEPT_ASSERT((concepts::CUnaryFunctor< TPredicate, typename TPointFunctor::Value, bool >))
BOOST_CONCEPT_ASSERT((concepts::CPointFunctor< TPointFunctor >))
const PointFunctor * myFun
alias of the PointFunctor.
Aim: The predicate that returns always true.
Go to http://www.sgi.com/tech/stl/BinaryFunction.html.
Definition: Boost.dox:76
MyPointD Point
Definition: testClone2.cpp:383
const Point aPoint(3, 4)