DGtal  0.9.2
DigitalTopology.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 DigitalTopology.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 2010/07/07
23  *
24  * Implementation of inline methods defined in DigitalTopology.h
25  *
26  * This file is part of the DGtal library.
27  */
28 
29 
30 //////////////////////////////////////////////////////////////////////////////
31 #include <cstdlib>
32 //////////////////////////////////////////////////////////////////////////////
33 
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 // ----------------------- Standard services ------------------------------
40 
41 /**
42  * Destructor.
43  */
44 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
45 inline
46 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
47 ::~DigitalTopology()
48 {
49 }
50 
51 /**
52  * Defines the digital topology (kappa,lambda).
53  *
54  * @param aKappa a const reference to the adjacency object chosen
55  * for the foreground topology.
56  *
57  * @param aLambda a const reference to the adjacency object chosen
58  * for the background topology.
59  *
60  * @param props an hint of the properties of this digital
61  * topology, default is UNKNOWN.
62  */
63 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
64 inline
65 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
66 ::DigitalTopology( ConstAlias<ForegroundAdjacency> aKappa,
67  ConstAlias<BackgroundAdjacency> aLambda,
68  DigitalTopologyProperties props )
69  : myKappa( aKappa ), myLambda( aLambda ),
70  myProps( props )
71 {
72 }
73 
74 
75 
76 /**
77  * Copy constructor.
78  * @param other the object to clone.
79  */
80 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
81 inline
82 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
83 ::DigitalTopology ( const DigitalTopology & other )
84  : myKappa( other.myKappa ), myLambda( other.myLambda ),
85  myProps( other.myProps )
86 {
87 }
88 
89 
90 /**
91  * @return a const reference to the foreground connectedness.
92  */
93 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
94 inline
95 const TForegroundAdjacency &
96 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>::kappa() const
97 {
98  return myKappa;
99 }
100 
101 /**
102  * @return a const reference to the background connectedness.
103  */
104 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
105 inline
106 const TBackgroundAdjacency &
107 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>::lambda() const
108 {
109  return myLambda;
110 }
111 
112 /**
113  * @return JORDAN iff the topology is Jordan, NOT_JORDAN iff the
114  * topology is known to be NOT_JORDAN, UNKNOWN otherwise.
115  */
116 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
117 inline
118 DGtal::DigitalTopologyProperties
119 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>::properties() const
120 {
121  return myProps;
122 }
123 
124 /**
125  * @return a digital topology object which is the reverse
126  * topology of this (ie. \f[ (\lambda,\kappa) \f].
127  */
128 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
129 inline
130 typename DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
131 ::ReverseTopology
132 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
133 ::reverseTopology() const
134 {
135  return ReverseTopology( myLambda, myKappa, myProps );
136 }
137 
138 ///////////////////////////////////////////////////////////////////////////////
139 // Interface - public :
140 
141 /**
142  * Writes/Displays the object on an output stream.
143  * @param out the output stream where the object is written.
144  */
145 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
146 inline
147 void
148 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
149 ::selfDisplay ( std::ostream & out ) const
150 {
151  out << "[DigitalTopology kappa=" << myKappa
152  << " lambda=" << myLambda;
153  if ( properties() == JORDAN_DT ) out << " [Jordan]";
154  else if ( properties() == NOT_JORDAN_DT ) out << " [Not Jordan]";
155  else if ( properties() == UNKNOWN_DT ) out << " [Unknown]";
156  else out << properties();
157  out << " ]";
158 }
159 
160 /**
161  * Checks the validity/consistency of the object.
162  * @return 'true' if the object is valid, 'false' otherwise.
163  */
164 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
165 inline
166 bool
167 DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
168 ::isValid() const
169 {
170  return true;
171 }
172 
173 
174 
175 ///////////////////////////////////////////////////////////////////////////////
176 // Implementation of inline functions //
177 
178 template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
179 inline
180 std::ostream&
181 DGtal::operator<< ( std::ostream & out,
182  const DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency> & object )
183 {
184  object.selfDisplay( out );
185  return out;
186 }
187 
188 // //
189 ///////////////////////////////////////////////////////////////////////////////
190 
191