DGtal 1.3.0
Loading...
Searching...
No Matches
BoundaryPredicate.ih
1/**
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.
6 *
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.
11 *
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/>.
14 *
15 **/
16
17/**
18 * @file BoundaryPredicate.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
21 *
22 * @date 2011/12/10
23 *
24 * Implementation of inline methods defined in BoundaryPredicate.h
25 *
26 * This file is part of the DGtal library.
27 */
28
29///////////////////////////////////////////////////////////////////////////////
30// IMPLEMENTATION of inline methods.
31///////////////////////////////////////////////////////////////////////////////
32
33//////////////////////////////////////////////////////////////////////////////
34#include <cstdlib>
35//////////////////////////////////////////////////////////////////////////////
36
37
38
39///////////////////////////////////////////////////////////////////////////////
40// Implementation of inline methods //
41//-----------------------------------------------------------------------------
42template <typename TKSpace, typename TImage>
43inline
44DGtal::functors::BoundaryPredicate<TKSpace,TImage>::
45~BoundaryPredicate()
46{}
47//-----------------------------------------------------------------------------
48template <typename TKSpace, typename TImage>
49inline
50DGtal::functors::BoundaryPredicate<TKSpace,TImage>::
51BoundaryPredicate( ConstAlias<KSpace> aSpace, ConstAlias<Image> anImage,
52 const Value & l1 )
53 : myPtrSpace( &aSpace ), myPtrImage( &anImage ),
54 myLabel1( l1 )
55{}
56//-----------------------------------------------------------------------------
57template <typename TKSpace, typename TImage>
58inline
59DGtal::functors::BoundaryPredicate<TKSpace,TImage>::
60BoundaryPredicate( const BoundaryPredicate & other )
61 : myPtrSpace( other.myPtrSpace ), myPtrImage( other.myPtrImage ),
62 myLabel1( other.myLabel1 )
63{}
64//-----------------------------------------------------------------------------
65template <typename TKSpace, typename TImage>
66inline
67DGtal::functors::BoundaryPredicate<TKSpace,TImage> &
68DGtal::functors::BoundaryPredicate<TKSpace,TImage>::
69operator=( const BoundaryPredicate & other )
70{
71 if ( this != &other )
72 {
73 myPtrSpace = other.myPtrSpace;
74 myPtrImage = other.myPtrImage;
75 myLabel1 = other.myLabel1;
76 }
77 return *this;
78}
79//-----------------------------------------------------------------------------
80template <typename TKSpace, typename TImage>
81inline
82bool
83DGtal::functors::BoundaryPredicate<TKSpace,TImage>::
84operator()( const Surfel & s ) const
85{
86 Dimension orthDir = myPtrSpace->sOrthDir( s );
87 bool orthDirect = myPtrSpace->sDirect( s, orthDir );
88 SCell int_spel = myPtrSpace->sIncident( s, orthDir, orthDirect );
89 Point int_p = myPtrSpace->sCoords( int_spel );
90 Point out_p = int_p;
91 out_p[ orthDir ] += orthDirect ? -1 : 1;
92 return ( (*myPtrImage)( int_p ) == myLabel1 )
93 && ( (*myPtrImage)( out_p ) != myLabel1 );
94}
95//-----------------------------------------------------------------------------
96template <typename TKSpace, typename TImage>
97inline
98void
99DGtal::functors::BoundaryPredicate<TKSpace,TImage>::
100selfDisplay ( std::ostream & out ) const
101{
102 out << "[BoundaryPredicate]";
103}
104//-----------------------------------------------------------------------------
105template <typename TKSpace, typename TImage>
106inline
107bool
108DGtal::functors::BoundaryPredicate<TKSpace,TImage>::
109isValid() const
110{
111 return true;
112}
113
114
115
116///////////////////////////////////////////////////////////////////////////////
117// Implementation of inline functions and external operators //
118
119/**
120 * Overloads 'operator<<' for displaying objects of class 'BoundaryPredicate'.
121 * @param out the output stream where the object is written.
122 * @param object the object of class 'BoundaryPredicate' to write.
123 * @return the output stream after the writing.
124 */
125template <typename TKSpace, typename TImage>
126inline
127std::ostream&
128DGtal::operator<< ( std::ostream & out,
129 const DGtal::functors::BoundaryPredicate<TKSpace,TImage> & object )
130{
131 object.selfDisplay ( out );
132 return out;
133}
134
135// //
136///////////////////////////////////////////////////////////////////////////////
137
138