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 FrontierPredicate.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 FrontierPredicate.h
26 * This file is part of the DGtal library.
29 ///////////////////////////////////////////////////////////////////////////////
30 // IMPLEMENTATION of inline methods.
31 ///////////////////////////////////////////////////////////////////////////////
33 //////////////////////////////////////////////////////////////////////////////
35 //////////////////////////////////////////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////////////////
40 // Implementation of inline methods //
41 //-----------------------------------------------------------------------------
42 template <typename TKSpace, typename TImage>
44 DGtal::functors::FrontierPredicate<TKSpace,TImage>::
47 //-----------------------------------------------------------------------------
48 template <typename TKSpace, typename TImage>
50 DGtal::functors::FrontierPredicate<TKSpace,TImage>::
51 FrontierPredicate( ConstAlias<KSpace> aSpace, ConstAlias<Image> anImage,
52 const Value & l1, const Value & l2 )
53 : myPtrSpace( &aSpace ), myPtrImage( &anImage ),
54 myLabel1( l1 ), myLabel2( l2 )
56 //-----------------------------------------------------------------------------
57 template <typename TKSpace, typename TImage>
59 DGtal::functors::FrontierPredicate<TKSpace,TImage>::
60 FrontierPredicate( const FrontierPredicate & other )
61 : myPtrSpace( other.myPtrSpace ), myPtrImage( other.myPtrImage ),
62 myLabel1( other.myLabel1 ), myLabel2( other.myLabel2 )
64 //-----------------------------------------------------------------------------
65 template <typename TKSpace, typename TImage>
67 DGtal::functors::FrontierPredicate<TKSpace,TImage> &
68 DGtal::functors::FrontierPredicate<TKSpace,TImage>::
69 operator=( const FrontierPredicate & other )
73 myPtrSpace = other.myPtrSpace;
74 myPtrImage = other.myPtrImage;
75 myLabel1 = other.myLabel1;
76 myLabel2 = other.myLabel2;
80 //-----------------------------------------------------------------------------
81 template <typename TKSpace, typename TImage>
84 DGtal::functors::FrontierPredicate<TKSpace,TImage>::
85 operator()( const Surfel & s ) const
87 Dimension orthDir = myPtrSpace->sOrthDir( s );
88 bool orthDirect = myPtrSpace->sDirect( s, orthDir );
89 SCell int_spel = myPtrSpace->sIncident( s, orthDir, orthDirect );
90 Point int_p = myPtrSpace->sCoords( int_spel );
92 out_p[ orthDir ] += orthDirect ? -1 : 1;
93 return ( (*myPtrImage)( int_p ) == myLabel1 )
94 && ( (*myPtrImage)( out_p ) == myLabel2 );
96 //-----------------------------------------------------------------------------
97 template <typename TKSpace, typename TImage>
100 DGtal::functors::FrontierPredicate<TKSpace,TImage>::
101 selfDisplay ( std::ostream & out ) const
103 out << "[FrontierPredicate]";
105 //-----------------------------------------------------------------------------
106 template <typename TKSpace, typename TImage>
109 DGtal::functors::FrontierPredicate<TKSpace,TImage>::
115 ///////////////////////////////////////////////////////////////////////////////
116 // Implementation of inline functions and external operators //
119 * Overloads 'operator<<' for displaying objects of class 'FrontierPredicate'.
120 * @param out the output stream where the object is written.
121 * @param object the object of class 'FrontierPredicate' to write.
122 * @return the output stream after the writing.
124 template <typename TKSpace, typename TImage>
127 DGtal::operator<< ( std::ostream & out,
128 const DGtal::functors::FrontierPredicate<TKSpace,TImage> & object )
130 object.selfDisplay ( out );
135 ///////////////////////////////////////////////////////////////////////////////