DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FrontierPredicate.ih
1 
29 
30 // IMPLEMENTATION of inline methods.
32 
34 #include <cstdlib>
36 
37 
38 
40 // Implementation of inline methods //
41 //-----------------------------------------------------------------------------
42 template <typename TKSpace, typename TImage>
43 inline
46 {}
47 //-----------------------------------------------------------------------------
48 template <typename TKSpace, typename TImage>
49 inline
51 FrontierPredicate( const KSpace & aSpace, const Image & anImage,
52  const Value & l1, const Value & l2 )
53  : myPtrSpace( &aSpace ), myPtrImage( &anImage ),
54  myLabel1( l1 ), myLabel2( l2 )
55 {}
56 //-----------------------------------------------------------------------------
57 template <typename TKSpace, typename TImage>
58 inline
61  : myPtrSpace( other.myPtrSpace ), myPtrImage( other.myPtrImage ),
62  myLabel1( other.myLabel1 ), myLabel2( other.myLabel2 )
63 {}
64 //-----------------------------------------------------------------------------
65 template <typename TKSpace, typename TImage>
66 inline
69 operator=( const FrontierPredicate & other )
70 {
71  if ( this != &other )
72  {
73  myPtrSpace = other.myPtrSpace;
74  myPtrImage = other.myPtrImage;
75  myLabel1 = other.myLabel1;
76  myLabel2 = other.myLabel2;
77  }
78  return *this;
79 }
80 //-----------------------------------------------------------------------------
81 template <typename TKSpace, typename TImage>
82 inline
83 bool
85 operator()( const Surfel & s ) const
86 {
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 );
91  Point out_p = int_p;
92  out_p[ orthDir ] += orthDirect ? -1 : 1;
93  return ( (*myPtrImage)( int_p ) == myLabel1 )
94  && ( (*myPtrImage)( out_p ) == myLabel2 );
95 }
96 //-----------------------------------------------------------------------------
97 template <typename TKSpace, typename TImage>
98 inline
99 void
101 selfDisplay ( std::ostream & out ) const
102 {
103  out << "[FrontierPredicate]";
104 }
105 //-----------------------------------------------------------------------------
106 template <typename TKSpace, typename TImage>
107 inline
108 bool
110 isValid() const
111 {
112  return true;
113 }
114 
116 // Implementation of inline functions and external operators //
117 
124 template <typename TKSpace, typename TImage>
125 inline
126 std::ostream&
127 DGtal::operator<< ( std::ostream & out,
128  const FrontierPredicate<TKSpace,TImage> & object )
129 {
130  object.selfDisplay ( out );
131  return out;
132 }
133 
134 // //
136 
137