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 TrueDigitalSurfaceLocalEstimator.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
24 * Implementation of inline methods defined in TrueDigitalSurfaceLocalEstimator.h
26 * This file is part of the DGtal library.
30 //////////////////////////////////////////////////////////////////////////////
32 //////////////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
39 // ----------------------- Standard services ------------------------------
41 //-----------------------------------------------------------------------------
42 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
44 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
45 ~TrueDigitalSurfaceLocalEstimator()
48 //-----------------------------------------------------------------------------
49 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
51 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
52 TrueDigitalSurfaceLocalEstimator()
53 : myKSpace( 0 ), myFct( 0 ), myEmbedder(),
54 myShape( 0 ), myH( 1.0 ),
55 myMaxIter( 20 ), myAccuracy( 0.0001 ), myGamma( 0.5 )
58 //-----------------------------------------------------------------------------
59 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
61 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
62 TrueDigitalSurfaceLocalEstimator( const Self& other )
63 : myKSpace( other.myKSpace ), myFct( other.myFct ), myEmbedder( other.myEmbedder ),
64 myShape( other.myShape ), myH( other.myH ),
65 myMaxIter( other.myMaxIter ), myAccuracy( other.myAccuracy ), myGamma( other.myGamma )
68 //-----------------------------------------------------------------------------
69 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
71 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>&
72 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
73 operator=( const Self& other )
77 myKSpace = other.myKSpace;
79 myEmbedder = other.myEmbedder;
80 myShape = other.myShape;
82 myMaxIter = other.myMaxIter;
83 myAccuracy = other.myAccuracy;
84 myGamma = other.myGamma;
89 //-----------------------------------------------------------------------------
90 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
92 typename DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::Scalar
93 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
98 //-----------------------------------------------------------------------------
99 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
102 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
103 attach( ConstAlias<Shape> aShape )
106 if ( ( myShape != 0 ) && ( myFct != 0 ) ) myFct->attach( myShape );
108 //-----------------------------------------------------------------------------
109 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
112 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
113 setParams( ConstAlias<KSpace> ks,
114 Clone<GeometricFunctor> fct,
116 const Scalar accuracy,
121 if ( ( myShape != 0 ) && ( myFct != 0 ) ) myFct->attach( myShape );
122 myEmbedder = SCellEmbedder( *myKSpace );
124 myAccuracy = accuracy;
127 //-----------------------------------------------------------------------------
128 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
129 template <typename SurfelConstIterator>
132 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
133 init( const Scalar _h,
134 SurfelConstIterator /* itb */,
135 SurfelConstIterator /* ite */ )
140 //-----------------------------------------------------------------------------
141 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
142 template <typename SurfelConstIterator>
144 typename DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::Quantity
145 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
146 eval( SurfelConstIterator it ) const
149 BOOST_CONCEPT_ASSERT(( boost::InputIterator<SurfelConstIterator> ));
150 return myFct->operator()( embed( *it ) );
152 //-----------------------------------------------------------------------------
153 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
154 template <typename OutputIterator, typename SurfelConstIterator>
157 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
158 eval( SurfelConstIterator itb,
159 SurfelConstIterator ite,
160 OutputIterator result ) const
162 BOOST_CONCEPT_ASSERT(( boost::InputIterator<SurfelConstIterator> ));
163 BOOST_CONCEPT_ASSERT(( boost::OutputIterator<OutputIterator,Quantity> ));
164 for ( ; itb != ite; ++itb )
165 *result++ = this->eval( itb );
168 //-----------------------------------------------------------------------------
169 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
171 typename DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::RealPoint
172 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
173 embed( Surfel surfel ) const
176 RealPoint p = myEmbedder( surfel );
178 return ( myMaxIter > 0 )
179 ? myShape->nearestPoint( p, myAccuracy, myMaxIter, myGamma )
183 ///////////////////////////////////////////////////////////////////////////////
184 // Interface - public :
187 * Writes/Displays the object on an output stream.
188 * @param out the output stream where the object is written.
190 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
193 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
194 selfDisplay ( std::ostream & out ) const
196 out << "[TrueDigitalSurfaceLocalEstimator]";
200 * Checks the validity/consistency of the object.
201 * @return 'true' if the object is valid, 'false' otherwise.
203 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
206 DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
209 return ( myKSpace != 0 )
212 && ( myEmbedder.isValid() );
217 ///////////////////////////////////////////////////////////////////////////////
218 // Implementation of inline functions //
220 template <typename TKSpace, typename TShape, typename TGeometricFunctor>
223 DGtal::operator<< ( std::ostream & out,
224 const TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor> & object )
226 object.selfDisplay( out );
231 ///////////////////////////////////////////////////////////////////////////////