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