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///////////////////////////////////////////////////////////////////////////////
37template <typename TPoint, bool boolCst>
40DGtal::functors::ConstantPointPredicate<TPoint,boolCst>
41::operator()( const Point & p ) const
43 boost::ignore_unused_variable_warning(p);
46//------------------------------------------------------------------------------
47template <typename TPoint>
49DGtal::functors::IsLowerPointPredicate<TPoint>
50::IsLowerPointPredicate( const Point & upperBound )
51 : myUpperBound( upperBound )
54//------------------------------------------------------------------------------
55template <typename TPoint>
58DGtal::functors::IsLowerPointPredicate<TPoint>
59::operator()( const Point & p ) const
61 return p.isLower( myUpperBound );
64//------------------------------------------------------------------------------
65template <typename TPoint>
67DGtal::functors::IsUpperPointPredicate<TPoint>
68::IsUpperPointPredicate( const Point & lowerBound )
69 : myLowerBound( lowerBound )
72//------------------------------------------------------------------------------
73template <typename TPoint>
76DGtal::functors::IsUpperPointPredicate<TPoint>
77::operator()( const Point & p ) const
79 return p.isUpper( myLowerBound );
82//------------------------------------------------------------------------------
83template <typename TPoint>
85DGtal::functors::IsWithinPointPredicate<TPoint>
86::IsWithinPointPredicate( const Point & lowerBound,
87 const Point & upperBound )
88 : myLowerBound( lowerBound ), myUpperBound( upperBound )
91//------------------------------------------------------------------------------
92template <typename TPoint>
95DGtal::functors::IsWithinPointPredicate<TPoint>
96::operator()( const Point & p ) const
98 return p.isUpper( myLowerBound )
99 && p.isLower( myUpperBound );
102//------------------------------------------------------------------------------
103template <typename TPointPredicate>
105DGtal::functors::NotPointPredicate<TPointPredicate>
106::NotPointPredicate( ConstAlias<PointPredicate> pred )
110//------------------------------------------------------------------------------
111template <typename TPointPredicate>
114DGtal::functors::NotPointPredicate<TPointPredicate>
115::operator()( const Point & p ) const
117 return !(*myPred)( p );
119//------------------------------------------------------------------------------
120template <typename TPointPredicate>
122DGtal::functors::EqualPointPredicate<TPointPredicate>
123::EqualPointPredicate( const Point & aPoint )
127//------------------------------------------------------------------------------
128template <typename TPointPredicate>
131DGtal::functors::EqualPointPredicate<TPointPredicate>
132::operator()( const Point & p ) const
134 return (myPoint == p);
136//------------------------------------------------------------------------------
137template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
139DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,TBinaryFunctor>
140::BinaryPointPredicate( ConstAlias<PointPredicate1> pred1, ConstAlias<PointPredicate2> pred2, ConstAlias<TBinaryFunctor> boolFunctor )
141 : myPred1( &pred1 ), myPred2( &pred2 ), myBoolFunctor( &boolFunctor )
144//------------------------------------------------------------------------------
145template <typename TPointPredicate1, typename TPointPredicate2, typename TBinaryFunctor>
148DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,TBinaryFunctor>
149::operator()( const Point & p ) const
151 return myBoolFunctor->operator()( myPred1->operator()( p ),
152 myPred2->operator()( p ) );
154//------------------------------------------------------------------------------
155template <typename TPointPredicate1, typename TPointPredicate2>
157DGtal::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//------------------------------------------------------------------------------
163template <typename TPointPredicate1, typename TPointPredicate2>
166DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,DGtal::functors::AndBoolFct2>
167::operator()( const Point & p ) const
169 return ( (myPred1->operator()( p )) && (myPred2->operator()( p )) );
171//------------------------------------------------------------------------------
172template <typename TPointPredicate1, typename TPointPredicate2>
174DGtal::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//------------------------------------------------------------------------------
180template <typename TPointPredicate1, typename TPointPredicate2>
183DGtal::functors::BinaryPointPredicate<TPointPredicate1,TPointPredicate2,DGtal::functors::OrBoolFct2>
184::operator()( const Point & p ) const
186 return ( (myPred1->operator()( p )) || (myPred2->operator()( p )) );
188//------------------------------------------------------------------------------
189template <typename TPointFunctor, typename TPredicate>
191DGtal::functors::PointFunctorPredicate<TPointFunctor, TPredicate>
192::PointFunctorPredicate( ConstAlias<PointFunctor> aFun, ConstAlias<Predicate> aPred )
193 : myFun(&aFun), myPred(&aPred)
196//------------------------------------------------------------------------------
197template <typename TPointFunctor, typename TPredicate>
200DGtal::functors::PointFunctorPredicate<TPointFunctor, TPredicate>
201::operator()( const Point & p ) const
203 return (*myPred)( (*myFun)( p ) );
206///////////////////////////////////////////////////////////////////////////////