2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @file BasicPointPredicates.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
24 * Implementation of inline methods defined in BasicPointPredicates.h
26 * This file is part of the DGtal library.
30 //////////////////////////////////////////////////////////////////////////////
32 //////////////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
37 template <typename TPoint, bool boolCst>
40 DGtal::functors::ConstantPointPredicate<TPoint,boolCst>
41 ::operator()( const Point & p ) const
43 boost::ignore_unused_variable_warning(p);
46 //------------------------------------------------------------------------------
47 template <typename TPoint>
49 DGtal::functors::IsLowerPointPredicate<TPoint>
50 ::IsLowerPointPredicate( const Point & upperBound )
51 : myUpperBound( upperBound )
54 //------------------------------------------------------------------------------
55 template <typename TPoint>
58 DGtal::functors::IsLowerPointPredicate<TPoint>
59 ::operator()( const Point & p ) const
61 return p.isLower( myUpperBound );
64 //------------------------------------------------------------------------------
65 template <typename TPoint>
67 DGtal::functors::IsUpperPointPredicate<TPoint>
68 ::IsUpperPointPredicate( const Point & lowerBound )
69 : myLowerBound( lowerBound )
72 //------------------------------------------------------------------------------
73 template <typename TPoint>
76 DGtal::functors::IsUpperPointPredicate<TPoint>
77 ::operator()( const Point & p ) const
79 return p.isUpper( myLowerBound );
82 //------------------------------------------------------------------------------
83 template <typename TPoint>
85 DGtal::functors::IsWithinPointPredicate<TPoint>
86 ::IsWithinPointPredicate( const Point & lowerBound,
87 const Point & upperBound )
88 : myLowerBound( lowerBound ), myUpperBound( upperBound )
91 //------------------------------------------------------------------------------
92 template <typename TPoint>
95 DGtal::functors::IsWithinPointPredicate<TPoint>
96 ::operator()( const Point & p ) const
98 return p.isUpper( myLowerBound )
99 && p.isLower( myUpperBound );
102 //------------------------------------------------------------------------------
103 template <typename TPointPredicate>
105 DGtal::functors::NotPointPredicate<TPointPredicate>
106 ::NotPointPredicate( ConstAlias<PointPredicate> pred )
110 //------------------------------------------------------------------------------
111 template <typename TPointPredicate>
114 DGtal::functors::NotPointPredicate<TPointPredicate>
115 ::operator()( const Point & p ) const
117 return !(*myPred)( p );
119 //------------------------------------------------------------------------------
120 template <typename TPointPredicate>
122 DGtal::functors::EqualPointPredicate<TPointPredicate>
123 ::EqualPointPredicate( const Point & aPoint )
127 //------------------------------------------------------------------------------
128 template <typename TPointPredicate>
131 DGtal::functors::EqualPointPredicate<TPointPredicate>
132 ::operator()( const Point & p ) const
134 return (myPoint == p);
136 //------------------------------------------------------------------------------
137 template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
139 DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,TBinaryFunctor>
140 ::BinaryPointPredicate( ConstAlias<PointPredicate1> pred1, ConstAlias<PointPredicate2> pred2, ConstAlias<TBinaryFunctor> boolFunctor )
141 : myPred1( &pred1 ), myPred2( &pred2 ), myBoolFunctor( &boolFunctor )
144 //------------------------------------------------------------------------------
145 template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
148 DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,TBinaryFunctor>
149 ::operator()( const Point & p ) const
151 return myBoolFunctor->operator()( myPred1->operator()( p ),
152 myPred2->operator()( p ) );
154 //------------------------------------------------------------------------------
155 template <typename TPointPredicate1, typename TPointPredicate2>
157 DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,DGtal::functors::AndBoolFct2>
158 ::BinaryPointPredicate( ConstAlias<PointPredicate1> pred1, ConstAlias<PointPredicate2> pred2, ConstAlias<DGtal::functors::AndBoolFct2> boolFunctor )
159 : myPred1( &pred1 ), myPred2( &pred2 ), myBoolFunctor( &boolFunctor )
162 //------------------------------------------------------------------------------
163 template <typename TPointPredicate1, typename TPointPredicate2>
166 DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,DGtal::functors::AndBoolFct2>
167 ::operator()( const Point & p ) const
169 return ( (myPred1->operator()( p )) && (myPred2->operator()( p )) );
171 //------------------------------------------------------------------------------
172 template <typename TPointPredicate1, typename TPointPredicate2>
174 DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,DGtal::functors::OrBoolFct2>
175 ::BinaryPointPredicate( ConstAlias<PointPredicate1> pred1, ConstAlias<PointPredicate2> pred2, ConstAlias<DGtal::functors::OrBoolFct2> boolFunctor )
176 : myPred1( &pred1 ), myPred2( &pred2 ), myBoolFunctor( &boolFunctor )
179 //------------------------------------------------------------------------------
180 template <typename TPointPredicate1, typename TPointPredicate2>
183 DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,DGtal::functors::OrBoolFct2>
184 ::operator()( const Point & p ) const
186 return ( (myPred1->operator()( p )) || (myPred2->operator()( p )) );
188 //------------------------------------------------------------------------------
189 template <typename TPointFunctor, typename TPredicate>
191 DGtal::functors::PointFunctorPredicate<TPointFunctor, TPredicate>
192 ::PointFunctorPredicate( ConstAlias<PointFunctor> aFun, ConstAlias<Predicate> aPred )
193 : myFun(&aFun), myPred(&aPred)
196 //------------------------------------------------------------------------------
197 template <typename TPointFunctor, typename TPredicate>
200 DGtal::functors::PointFunctorPredicate<TPointFunctor, TPredicate>
201 ::operator()( const Point & p ) const
203 return (*myPred)( (*myFun)( p ) );
206 ///////////////////////////////////////////////////////////////////////////////