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.
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.
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/>.
18 * @file GaussDigitizer.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
24 * Implementation of inline methods defined in GaussDigitizer.h
26 * This file is part of the DGtal library.
30//////////////////////////////////////////////////////////////////////////////
33#include "DGtal/kernel/NumberTraits.h"
34//////////////////////////////////////////////////////////////////////////////
36///////////////////////////////////////////////////////////////////////////////
37// IMPLEMENTATION of inline methods.
38///////////////////////////////////////////////////////////////////////////////
40///////////////////////////////////////////////////////////////////////////////
41// ----------------------- Standard services ------------------------------
43//-----------------------------------------------------------------------------
44template <typename TSpace, typename TEuclideanShape>
46DGtal::GaussDigitizer<TSpace,TEuclideanShape>::~GaussDigitizer()
49//-----------------------------------------------------------------------------
50template <typename TSpace, typename TEuclideanShape>
52DGtal::GaussDigitizer<TSpace,TEuclideanShape>::GaussDigitizer()
55//-----------------------------------------------------------------------------
56template <typename TSpace, typename TEuclideanShape>
58DGtal::GaussDigitizer<TSpace,TEuclideanShape> &
59DGtal::GaussDigitizer<TSpace,TEuclideanShape>::
60operator=( const GaussDigitizer & other )
64 myEShape = other.myEShape;
65 myPointEmbedder = other.myPointEmbedder;
66 myLowerPoint = other.myLowerPoint;
67 myUpperPoint = other.myUpperPoint;
71//-----------------------------------------------------------------------------
72template <typename TSpace, typename TEuclideanShape>
75DGtal::GaussDigitizer<TSpace,TEuclideanShape>
76::attach( ConstAlias<EuclideanShape> shape )
80//-----------------------------------------------------------------------------
81template <typename TSpace, typename TEuclideanShape>
84DGtal::GaussDigitizer<TSpace,TEuclideanShape>
85::init( const RealPoint & xLow, const RealPoint & xUp,
86 typename RealVector::Component gridStep )
88 myPointEmbedder.init( gridStep );
89 myLowerPoint = myPointEmbedder.floor( xLow );
90 myUpperPoint = myPointEmbedder.ceil( xUp );
92//-----------------------------------------------------------------------------
93template <typename TSpace, typename TEuclideanShape>
96DGtal::GaussDigitizer<TSpace,TEuclideanShape>
97::init( const RealPoint & xLow, const RealPoint & xUp,
98 const RealVector & aGridSteps )
100 myPointEmbedder.init( aGridSteps );
101 myLowerPoint = myPointEmbedder.floor( xLow );
102 myUpperPoint = myPointEmbedder.ceil( xUp );
105//-----------------------------------------------------------------------------
106template <typename TSpace, typename TEuclideanShape>
108const typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::PointEmbedder &
109DGtal::GaussDigitizer<TSpace,TEuclideanShape>
110::pointEmbedder() const
112 return myPointEmbedder;
114//-----------------------------------------------------------------------------
115template <typename TSpace, typename TEuclideanShape>
117typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Domain
118DGtal::GaussDigitizer<TSpace,TEuclideanShape>
121 return Domain( getLowerBound(), getUpperBound() );
124//-----------------------------------------------------------------------------
125template <typename TSpace, typename TEuclideanShape>
127typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point
128DGtal::GaussDigitizer<TSpace,TEuclideanShape>
129::floor( const RealPoint & p ) const
131 return myPointEmbedder.floor( p );
133//-----------------------------------------------------------------------------
134template <typename TSpace, typename TEuclideanShape>
136typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point
137DGtal::GaussDigitizer<TSpace,TEuclideanShape>
138::ceil( const RealPoint & p ) const
140 return myPointEmbedder.ceil( p );
142//-----------------------------------------------------------------------------
143template <typename TSpace, typename TEuclideanShape>
145typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point
146DGtal::GaussDigitizer<TSpace,TEuclideanShape>
147::round( const RealPoint & p ) const
149 return myPointEmbedder.round( p );
151//-----------------------------------------------------------------------------
152template <typename TSpace, typename TEuclideanShape>
154typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::RealPoint
155DGtal::GaussDigitizer<TSpace,TEuclideanShape>
156::embed( const Point & p ) const
158 return myPointEmbedder.embed( p );
160//-----------------------------------------------------------------------------
161template <typename TSpace, typename TEuclideanShape>
164DGtal::GaussDigitizer<TSpace,TEuclideanShape>
165::operator()( const Point & p ) const
167 ASSERT( myEShape != 0 );
168 return ((myEShape->orientation( embed( p ) ) == INSIDE)
169 || (myEShape->orientation( embed( p ) ) == ON));
171//-----------------------------------------------------------------------------
172template <typename TSpace, typename TEuclideanShape>
174const typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point &
175DGtal::GaussDigitizer<TSpace,TEuclideanShape>
176::getLowerBound() const
180//-----------------------------------------------------------------------------
181template <typename TSpace, typename TEuclideanShape>
183const typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point &
184DGtal::GaussDigitizer<TSpace,TEuclideanShape>
185::getUpperBound() const
189//-----------------------------------------------------------------------------
190template <typename TSpace, typename TEuclideanShape>
192typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Vector
193DGtal::GaussDigitizer<TSpace,TEuclideanShape>
196 return getUpperBound() - getLowerBound();
198//-----------------------------------------------------------------------------
199template <typename TSpace, typename TEuclideanShape>
201typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::RealVector
202DGtal::GaussDigitizer<TSpace,TEuclideanShape>
205 return myPointEmbedder.gridSteps();
209///////////////////////////////////////////////////////////////////////////////
210// Interface - public :
213 * Writes/Displays the object on an output stream.
214 * @param out the output stream where the object is written.
216template <typename TSpace, typename TEuclideanShape>
219DGtal::GaussDigitizer<TSpace,TEuclideanShape>::selfDisplay ( std::ostream & out ) const
221 out << "[GaussDigitizer]";
225 * Checks the validity/consistency of the object.
226 * @return 'true' if the object is valid, 'false' otherwise.
228template <typename TSpace, typename TEuclideanShape>
231DGtal::GaussDigitizer<TSpace,TEuclideanShape>::isValid() const
238///////////////////////////////////////////////////////////////////////////////
239// Implementation of inline functions //
241template <typename TSpace, typename TEuclideanShape>
244DGtal::operator<< ( std::ostream & out,
245 const GaussDigitizer<TSpace,TEuclideanShape> & object )
247 object.selfDisplay( out );
252///////////////////////////////////////////////////////////////////////////////