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//-----------------------------------------------------------------------------
42template <typename TKSpace, typename TShape, typename TGeometricFunctor>
44DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
45~TrueDigitalSurfaceLocalEstimator()
48//-----------------------------------------------------------------------------
49template <typename TKSpace, typename TShape, typename TGeometricFunctor>
51DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
52TrueDigitalSurfaceLocalEstimator()
53 : myKSpace( 0 ), myFct( 0 ), myEmbedder(),
54 myShape( 0 ), myH( 1.0 ),
55 myMaxIter( 20 ), myAccuracy( 0.0001 ), myGamma( 0.5 )
58//-----------------------------------------------------------------------------
59template <typename TKSpace, typename TShape, typename TGeometricFunctor>
61DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
62TrueDigitalSurfaceLocalEstimator( 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//-----------------------------------------------------------------------------
69template <typename TKSpace, typename TShape, typename TGeometricFunctor>
71DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>&
72DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
73operator=( 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//-----------------------------------------------------------------------------
90template <typename TKSpace, typename TShape, typename TGeometricFunctor>
92typename DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::Scalar
93DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
98//-----------------------------------------------------------------------------
99template <typename TKSpace, typename TShape, typename TGeometricFunctor>
102DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
103attach( ConstAlias<Shape> aShape )
106 if ( ( myShape != 0 ) && ( myFct != 0 ) ) myFct->attach( myShape );
108//-----------------------------------------------------------------------------
109template <typename TKSpace, typename TShape, typename TGeometricFunctor>
112DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
113setParams( 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//-----------------------------------------------------------------------------
128template <typename TKSpace, typename TShape, typename TGeometricFunctor>
129template <typename SurfelConstIterator>
132DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
133init( const Scalar _h,
134 SurfelConstIterator /* itb */,
135 SurfelConstIterator /* ite */ )
140//-----------------------------------------------------------------------------
141template <typename TKSpace, typename TShape, typename TGeometricFunctor>
142template <typename SurfelConstIterator>
144typename DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::Quantity
145DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
146eval( SurfelConstIterator it ) const
149 BOOST_CONCEPT_ASSERT(( boost::InputIterator<SurfelConstIterator> ));
150 return myFct->operator()( embed( *it ) );
152//-----------------------------------------------------------------------------
153template <typename TKSpace, typename TShape, typename TGeometricFunctor>
154template <typename OutputIterator, typename SurfelConstIterator>
157DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
158eval( 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//-----------------------------------------------------------------------------
169template <typename TKSpace, typename TShape, typename TGeometricFunctor>
171typename DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::RealPoint
172DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
173embed( 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.
190template <typename TKSpace, typename TShape, typename TGeometricFunctor>
193DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
194selfDisplay ( 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.
203template <typename TKSpace, typename TShape, typename TGeometricFunctor>
206DGtal::TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor>::
209 return ( myKSpace != 0 )
212 && ( myEmbedder.isValid() );
217///////////////////////////////////////////////////////////////////////////////
218// Implementation of inline functions //
220template <typename TKSpace, typename TShape, typename TGeometricFunctor>
223DGtal::operator<< ( std::ostream & out,
224 const TrueDigitalSurfaceLocalEstimator<TKSpace, TShape, TGeometricFunctor> & object )
226 object.selfDisplay( out );
231///////////////////////////////////////////////////////////////////////////////