DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BoundaryPredicate.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 BoundaryPredicate( const KSpace & aSpace, const Image & anImage,
52  const Value & l1 )
53  : myPtrSpace( &aSpace ), myPtrImage( &anImage ),
54  myLabel1( l1 )
55 {}
56 //-----------------------------------------------------------------------------
57 template <typename TKSpace, typename TImage>
58 inline
61  : myPtrSpace( other.myPtrSpace ), myPtrImage( other.myPtrImage ),
62  myLabel1( other.myLabel1 )
63 {}
64 //-----------------------------------------------------------------------------
65 template <typename TKSpace, typename TImage>
66 inline
69 operator=( 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 //-----------------------------------------------------------------------------
80 template <typename TKSpace, typename TImage>
81 inline
82 bool
84 operator()( 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 //-----------------------------------------------------------------------------
96 template <typename TKSpace, typename TImage>
97 inline
98 void
100 selfDisplay ( std::ostream & out ) const
101 {
102  out << "[BoundaryPredicate]";
103 }
104 //-----------------------------------------------------------------------------
105 template <typename TKSpace, typename TImage>
106 inline
107 bool
109 isValid() const
110 {
111  return true;
112 }
113 
114 
115 
117 // Implementation of inline functions and external operators //
118 
125 template <typename TKSpace, typename TImage>
126 inline
127 std::ostream&
128 DGtal::operator<< ( std::ostream & out,
129  const BoundaryPredicate<TKSpace,TImage> & object )
130 {
131  object.selfDisplay ( out );
132  return out;
133 }
134 
135 // //
137 
138