DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BasicPointPredicates.ih
1 
30 
31 #include <cstdlib>
33 
35 // IMPLEMENTATION of inline methods.
37 template <typename TPoint, bool boolCst>
38 inline
39 bool
41 ::operator()( const Point & p ) const
42 {
43  return boolCst;
44 }
45 //------------------------------------------------------------------------------
46 template <typename TPoint>
47 inline
49 ::IsLowerPointPredicate( const Point & upperBound )
50  : myUpperBound( upperBound )
51 {}
52 //------------------------------------------------------------------------------
53 template <typename TPoint>
54 inline
55 bool
57 ::operator()( const Point & p ) const
58 {
59  return p.isLower( myUpperBound );
60 }
61 
62 //------------------------------------------------------------------------------
63 template <typename TPoint>
64 inline
66 ::IsUpperPointPredicate( const Point & lowerBound )
67  : myLowerBound( lowerBound )
68 {}
69 //------------------------------------------------------------------------------
70 template <typename TPoint>
71 inline
72 bool
74 ::operator()( const Point & p ) const
75 {
76  return p.isUpper( myLowerBound );
77 }
78 
79 //------------------------------------------------------------------------------
80 template <typename TPoint>
81 inline
83 ::IsWithinPointPredicate( const Point & lowerBound,
84  const Point & upperBound )
85  : myLowerBound( lowerBound ), myUpperBound( upperBound )
86 {}
87 //------------------------------------------------------------------------------
88 template <typename TPoint>
89 inline
90 bool
92 ::operator()( const Point & p ) const
93 {
94  return p.isUpper( myLowerBound )
95  && p.isLower( myUpperBound );
96 }
97 
98 //------------------------------------------------------------------------------
99 template <typename TPointPredicate>
100 inline
103  : myPred( pred )
104 {
105 }
106 //------------------------------------------------------------------------------
107 template <typename TPointPredicate>
108 inline
109 bool
111 ::operator()( const Point & p ) const
112 {
113  return ! myPred( p );
114 }
115 //------------------------------------------------------------------------------
116 template <typename TPointPredicate>
117 inline
119 ::EqualPointPredicate( const Point & aPoint )
120  : myPoint( aPoint )
121 {
122 }
123 //------------------------------------------------------------------------------
124 template <typename TPointPredicate>
125 inline
126 bool
128 ::operator()( const Point & p ) const
129 {
130  return (myPoint == p);
131 }
132 //------------------------------------------------------------------------------
133 template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
134 inline
137  const PointPredicate2 & pred2,
138  const TBinaryFunctor & boolFunctor )
139  : myPred1( &pred1 ), myPred2( &pred2 ), myBoolFunctor( &boolFunctor )
140 {
141 }
142 //------------------------------------------------------------------------------
143 template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
144 inline
147  : myPred1( other.pred1 ), myPred2( other.pred2 ), myBoolFunctor( other.boolFunctor )
148 {
149 }
150 //------------------------------------------------------------------------------
151 template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
152 inline
156 {
157  if (this != &other)
158  {
159  myPred1 = other.myPred1;
160  myPred2 = other.myPred2;
161  myBoolFunctor = other.myBoolFunctor;
162  }
163  return *this;
164 }
165 //------------------------------------------------------------------------------
166 template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
167 inline
170 {
171 }
172 //------------------------------------------------------------------------------
173 template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
174 inline
175 bool
177 ::operator()( const Point & p ) const
178 {
179  return myBoolFunctor->operator()( myPred1->operator()( p ),
180  myPred2->operator()( p ) );
181 }
182 
183 //------------------------------------------------------------------------------
184 template <typename TPointFunctor, typename TPredicate>
185 inline
188  const Predicate & aPred)
189  : myFun( &aFun ), myPred( &aPred )
190 {
191 }
192 //------------------------------------------------------------------------------
193 template <typename TPointFunctor, typename TPredicate>
194 inline
197  : myFun( other.myFun), myPred( other.myPred )
198 {
199 }
200 //------------------------------------------------------------------------------
201 template <typename TPointFunctor, typename TPredicate>
202 inline
206 {
207  if (this != &other)
208  {
209  myFun = other.myFun;
210  myPred = other.myPred;
211  }
212  return *this;
213 }
214 //------------------------------------------------------------------------------
215 template <typename TPointFunctor, typename TPredicate>
216 inline
219 {
220 }
221 //------------------------------------------------------------------------------
222 template <typename TPointFunctor, typename TPredicate>
223 inline
224 bool
226 ::operator()( const Point & p ) const
227 {
228  return myPred->operator()( myFun->operator()( p ) );
229 }
230 // //
232 
233