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 //-----------------------------------------------------------------------------
44 template <typename TSpace, typename TEuclideanShape>
46 DGtal::GaussDigitizer<TSpace,TEuclideanShape>::~GaussDigitizer()
49 //-----------------------------------------------------------------------------
50 template <typename TSpace, typename TEuclideanShape>
52 DGtal::GaussDigitizer<TSpace,TEuclideanShape>::GaussDigitizer()
55 //-----------------------------------------------------------------------------
56 template <typename TSpace, typename TEuclideanShape>
58 DGtal::GaussDigitizer<TSpace,TEuclideanShape> &
59 DGtal::GaussDigitizer<TSpace,TEuclideanShape>::
60 operator=( const GaussDigitizer & other )
64 myEShape = other.myEShape;
65 myPointEmbedder = other.myPointEmbedder;
66 myLowerPoint = other.myLowerPoint;
67 myUpperPoint = other.myUpperPoint;
71 //-----------------------------------------------------------------------------
72 template <typename TSpace, typename TEuclideanShape>
75 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
76 ::attach( ConstAlias<EuclideanShape> shape )
80 //-----------------------------------------------------------------------------
81 template <typename TSpace, typename TEuclideanShape>
84 DGtal::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 //-----------------------------------------------------------------------------
93 template <typename TSpace, typename TEuclideanShape>
96 DGtal::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 //-----------------------------------------------------------------------------
106 template <typename TSpace, typename TEuclideanShape>
108 const typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::PointEmbedder &
109 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
110 ::pointEmbedder() const
112 return myPointEmbedder;
114 //-----------------------------------------------------------------------------
115 template <typename TSpace, typename TEuclideanShape>
117 typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Domain
118 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
121 return Domain( getLowerBound(), getUpperBound() );
124 //-----------------------------------------------------------------------------
125 template <typename TSpace, typename TEuclideanShape>
127 typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point
128 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
129 ::floor( const RealPoint & p ) const
131 return myPointEmbedder.floor( p );
133 //-----------------------------------------------------------------------------
134 template <typename TSpace, typename TEuclideanShape>
136 typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point
137 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
138 ::ceil( const RealPoint & p ) const
140 return myPointEmbedder.ceil( p );
142 //-----------------------------------------------------------------------------
143 template <typename TSpace, typename TEuclideanShape>
145 typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point
146 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
147 ::round( const RealPoint & p ) const
149 return myPointEmbedder.round( p );
151 //-----------------------------------------------------------------------------
152 template <typename TSpace, typename TEuclideanShape>
154 typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::RealPoint
155 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
156 ::embed( const Point & p ) const
158 return myPointEmbedder.embed( p );
160 //-----------------------------------------------------------------------------
161 template <typename TSpace, typename TEuclideanShape>
164 DGtal::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 //-----------------------------------------------------------------------------
172 template <typename TSpace, typename TEuclideanShape>
174 const typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point &
175 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
176 ::getLowerBound() const
180 //-----------------------------------------------------------------------------
181 template <typename TSpace, typename TEuclideanShape>
183 const typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Point &
184 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
185 ::getUpperBound() const
189 //-----------------------------------------------------------------------------
190 template <typename TSpace, typename TEuclideanShape>
192 typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::Vector
193 DGtal::GaussDigitizer<TSpace,TEuclideanShape>
196 return getUpperBound() - getLowerBound();
198 //-----------------------------------------------------------------------------
199 template <typename TSpace, typename TEuclideanShape>
201 typename DGtal::GaussDigitizer<TSpace,TEuclideanShape>::RealVector
202 DGtal::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.
216 template <typename TSpace, typename TEuclideanShape>
219 DGtal::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.
228 template <typename TSpace, typename TEuclideanShape>
231 DGtal::GaussDigitizer<TSpace,TEuclideanShape>::isValid() const
238 ///////////////////////////////////////////////////////////////////////////////
239 // Implementation of inline functions //
241 template <typename TSpace, typename TEuclideanShape>
244 DGtal::operator<< ( std::ostream & out,
245 const GaussDigitizer<TSpace,TEuclideanShape> & object )
247 object.selfDisplay( out );
252 ///////////////////////////////////////////////////////////////////////////////