DGtal  0.9.2
DigitalSetDomain.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 DigitalSetDomain.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/10
23  *
24  * Implementation of inline methods defined in DigitalSetDomain.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 template <typename TDigitalSet>
42 inline
43 DGtal::DigitalSetDomain<TDigitalSet>
44 ::~DigitalSetDomain()
45 {
46 }
47 //------------------------------------------------------------------------------
48 template <typename TDigitalSet>
49 inline
50 DGtal::DigitalSetDomain<TDigitalSet>
51 ::DigitalSetDomain ( ConstAlias<DigitalSet> aSet )
52  : mySet( &aSet )
53 {
54  mySet->computeBoundingBox( myLowerBound, myUpperBound );
55 }
56 //------------------------------------------------------------------------------
57 template <typename TDigitalSet>
58 inline
59 DGtal::DigitalSetDomain<TDigitalSet>
60 ::DigitalSetDomain ( const DigitalSetDomain & other )
61  : mySet( other.mySet ),
62  myUpperBound( other.myUpperBound ),
63  myLowerBound( other.myLowerBound )
64 {}
65 
66 // ----------------------- Domain services --------------------------------
67 //------------------------------------------------------------------------------
68 template <typename TDigitalSet>
69 inline
70 typename DGtal::DigitalSetDomain<TDigitalSet>::ConstIterator
71 DGtal::DigitalSetDomain<TDigitalSet>
72 ::begin(const Point &aPoint) const
73 {
74  return mySet->find(aPoint);
75 }
76 //------------------------------------------------------------------------------
77 template <typename TDigitalSet>
78 inline
79 typename DGtal::DigitalSetDomain<TDigitalSet>::ConstIterator
80 DGtal::DigitalSetDomain<TDigitalSet>
81 ::begin() const
82 {
83  return mySet->begin();
84 }
85 //------------------------------------------------------------------------------
86 template <typename TDigitalSet>
87 inline
88 typename DGtal::DigitalSetDomain<TDigitalSet>::ConstIterator
89 DGtal::DigitalSetDomain<TDigitalSet>
90 ::end() const
91 {
92  return mySet->end();
93 }
94 //------------------------------------------------------------------------------
95 template <typename TDigitalSet>
96 inline
97 const typename DGtal::DigitalSetDomain<TDigitalSet>::Point &
98 DGtal::DigitalSetDomain<TDigitalSet>
99 ::lowerBound() const
100 {
101  return myLowerBound;
102 }
103 //------------------------------------------------------------------------------
104 template <typename TDigitalSet>
105 inline
106 const typename DGtal::DigitalSetDomain<TDigitalSet>::Point &
107 DGtal::DigitalSetDomain<TDigitalSet>
108 ::upperBound() const
109 {
110  return myUpperBound;
111 }
112 //------------------------------------------------------------------------------
113 template <typename TDigitalSet>
114 inline
115 typename DGtal::DigitalSetDomain<TDigitalSet>::Size
116 DGtal::DigitalSetDomain<TDigitalSet>
117 ::size() const
118 {
119  return mySet->size();
120 }
121 //------------------------------------------------------------------------------
122 template <typename TDigitalSet>
123 inline
124 bool
125 DGtal::DigitalSetDomain<TDigitalSet>
126 ::isInside( const Point & p ) const
127 {
128  return p.isLower( myUpperBound )
129  && p.isUpper( myLowerBound )
130  && (*mySet)( p );
131 }
132 //------------------------------------------------------------------------------
133 template <typename TDigitalSet>
134 inline
135 const typename DGtal::DigitalSetDomain<TDigitalSet>::Predicate &
136 DGtal::DigitalSetDomain<TDigitalSet>
137 ::predicate() const
138 {
139  return *mySet;
140 }
141 
142 //------------------------------------------------------------------------------
143 template <typename TDigitalSet>
144 inline
145 void
146 DGtal::DigitalSetDomain<TDigitalSet>::selfDisplay ( std::ostream & out ) const
147 {
148  out << "[DigitalSetDomain set=" << *mySet << "]";
149 }
150 //------------------------------------------------------------------------------
151 template <typename TDigitalSet>
152 inline
153 bool
154 DGtal::DigitalSetDomain<TDigitalSet>::isValid() const
155 {
156  return true;
157 }
158 //------------------------------------------------------------------------------
159 template <typename TDigitalSet>
160 inline
161 std::ostream&
162 DGtal::operator<< ( std::ostream & out,
163  const DigitalSetDomain<TDigitalSet> & object )
164 {
165  object.selfDisplay( out );
166  return out;
167 }
168 
169 // //
170 ///////////////////////////////////////////////////////////////////////////////
171 
172