DGtal 1.4.0
Loading...
Searching...
No Matches
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 */
44template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
45inline
46DGtal::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 */
63template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
64inline
65DGtal::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 */
80template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
81inline
82DGtal::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 */
93template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
94inline
95const TForegroundAdjacency &
96DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>::kappa() const
97{
98 return myKappa;
99}
100
101/**
102 * @return a const reference to the background connectedness.
103 */
104template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
105inline
106const TBackgroundAdjacency &
107DGtal::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 */
116template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
117inline
118DGtal::DigitalTopologyProperties
119DGtal::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 */
128template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
129inline
130typename DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
131::ReverseTopology
132DGtal::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 */
145template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
146inline
147void
148DGtal::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 */
164template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
165inline
166bool
167DGtal::DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency>
168::isValid() const
169{
170 return true;
171}
172
173
174
175///////////////////////////////////////////////////////////////////////////////
176// Implementation of inline functions //
177
178template <typename TForegroundAdjacency, typename TBackgroundAdjacency>
179inline
180std::ostream&
181DGtal::operator<< ( std::ostream & out,
182 const DigitalTopology<TForegroundAdjacency,TBackgroundAdjacency> & object )
183{
184 object.selfDisplay( out );
185 return out;
186}
187
188// //
189///////////////////////////////////////////////////////////////////////////////
190
191