DGtal  0.9.2
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)
38 
39 #define BasicPointPredicates_RECURSES
40 
41 #if !defined BasicPointPredicates_h
42 
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 
225  const PointPredicate* myPred;
226  };
227 
229  // template class EqualPointPredicate
237  template <typename TPoint>
239  {
240  typedef TPoint Point;
241 
245  EqualPointPredicate( const Point & aPoint );
246 
251  bool operator()( const Point & p ) const;
252 
254  Point myPoint;
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 
303  const PointPredicate1* myPred1;
305  const PointPredicate2* myPred2;
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 
329  const PointPredicate1* myPred1;
330  const PointPredicate2* myPred2;
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 
353  const PointPredicate1* myPred1;
354  const PointPredicate2* myPred2;
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 
393  const PointFunctor* myFun;
395  const Predicate* myPred;
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)
const PointFunctor * myFun
alias of the PointFunctor.
Aim: The predicate returns true when the point predicate given at construction return false...
bool operator()(const Point &p) const
bool operator()(const Point &p) const
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< PointPredicate >))
Aim: The predicate returns true when the point is within the given bounds.
BinaryPointPredicate(ConstAlias< PointPredicate1 > pred1, ConstAlias< PointPredicate2 > pred2, ConstAlias< TBinaryFunctor > boolFunctor)
IsLowerPointPredicate(const Point &upperBound)
Aim: The predicate returns true when the point given as argument equals the reference point given at ...
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
bool operator()(const Point &p) const
bool operator()(const Point &p) const
IsUpperPointPredicate(const Point &lowerBound)
NotPointPredicate(ConstAlias< PointPredicate > pred)
const TBinaryFunctor * myBoolFunctor
aliasing pointer to the binary functor.
Aim: The predicate returns true when the point is above (or equal) the given lower bound...
boost::function2< bool, bool, bool > BoolFunctor2
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:89
EqualPointPredicate(const Point &aPoint)
Aim: The predicate that returns always false.
IsWithinPointPredicate(const Point &lowerBound, const Point &upperBound)
Aim: Defines a predicate on a point.
PointFunctorPredicate(ConstAlias< PointFunctor > aFun, ConstAlias< Predicate > aPred)
BOOST_STATIC_ASSERT((boost::is_same< Point, Point2 >::value))
bool operator()(const Point &p) const
Go to http://www.sgi.com/tech/stl/BinaryFunction.html.
Definition: Boost.dox:76
bool operator()(const Point &p) const
bool operator()(const Point &p) const
DGtal is the top-level namespace which contains all DGtal functions and types.
const PointPredicate2 * myPred2
aliasing pointer to the right predicate.
const PointPredicate * myPred
The PointPredicate that is inversed.
Aim: The predicate that returns always the same value boolCst.
BOOST_CONCEPT_ASSERT((concepts::CPointFunctor< TPointFunctor >))
Aim: Defines a functor on points.
Definition: CPointFunctor.h:88
Aim: The predicate returns true when the point is below (or equal) the given upper bound...
Aim: The predicate returns true when the given binary functor returns true for the two PointPredicate...
const PointPredicate1 * myPred1
aliasing pointer to the left predicate.
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< PointPredicate1 >))
Aim: The predicate that returns always true.
bool operator()(const Point &p) const
Aim: The predicate returns true when the predicate returns true for the value assigned to a given poi...
const Predicate * myPred
alias of the predicate.