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 LocalEstimatorFromSurfelFunctorAdapter.ih
19 * @author David Coeurjolly (\c david.coeurjolly@liris.cnrs.fr )
20 * Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
24 * Implementation of inline methods defined in LocalEstimatorFromSurfelFunctorAdapter.h
26 * This file is part of the DGtal library.
29//////////////////////////////////////////////////////////////////////////////
31//////////////////////////////////////////////////////////////////////////////
33///////////////////////////////////////////////////////////////////////////////
34// IMPLEMENTATION of inline methods.
35///////////////////////////////////////////////////////////////////////////////
37template <typename TDigitalSurfaceContainer, typename TMetric,
38 typename TFunctorOnSurfel, typename TConvolutionFunctor>
40DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
41 TFunctorOnSurfel, TConvolutionFunctor>::
42LocalEstimatorFromSurfelFunctorAdapter()
47template <typename TDigitalSurfaceContainer, typename TMetric,
48 typename TFunctorOnSurfel, typename TConvolutionFunctor>
50DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
51 TFunctorOnSurfel, TConvolutionFunctor>::
52LocalEstimatorFromSurfelFunctorAdapter
53( ConstAlias< Surface > aSurf,
54 ConstAlias< Metric> aMetric,
55 Alias< FunctorOnSurfel > aFunctor,
56 ConstAlias< ConvolutionFunctor > aConvolutionFunctor)
57 : mySurface(aSurf), myFunctor(&aFunctor), myMetric(aMetric),
58 myEmbedder(Embedder( mySurface->container().space())), myConvFunctor(aConvolutionFunctor)
62///////////////////////////////////////////////////////////////////////////////
63template <typename TDigitalSurfaceContainer, typename TMetric,
64 typename TFunctorOnSurfel, typename TConvolutionFunctor>
66DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
67 TFunctorOnSurfel, TConvolutionFunctor>::
68~LocalEstimatorFromSurfelFunctorAdapter()
72///////////////////////////////////////////////////////////////////////////////
73template <typename TDigitalSurfaceContainer, typename TMetric,
74 typename TFunctorOnSurfel, typename TConvolutionFunctor>
77DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
78 TFunctorOnSurfel, TConvolutionFunctor>::
79selfDisplay ( std::ostream & out ) const
81 out << "[LocalEstimatorFromSurfelFunctorAdapter]";
83///////////////////////////////////////////////////////////////////////////////
84template <typename TDigitalSurfaceContainer, typename TMetric,
85 typename TFunctorOnSurfel, typename TConvolutionFunctor>
88DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
89 TFunctorOnSurfel, TConvolutionFunctor>::
96//-----------------------------------------------------------------------------
97template <typename TDigitalSurfaceContainer, typename TMetric,
98 typename TFunctorOnSurfel, typename TConvolutionFunctor>
101DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
102 TFunctorOnSurfel, TConvolutionFunctor>::
103attach( ConstAlias<Surface> aSurface )
105 mySurface = aSurface;
106 myEmbedder = Embedder( mySurface->container().space());
109//-----------------------------------------------------------------------------
110template <typename TDigitalSurfaceContainer, typename TMetric,
111 typename TFunctorOnSurfel, typename TConvolutionFunctor>
114DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
115 TFunctorOnSurfel, TConvolutionFunctor>::
116setParams( ConstAlias<TMetric> aMetric,
117 Alias<FunctorOnSurfel> aFunctor,
118 ConstAlias<ConvolutionFunctor> aConvolutionFunctor,
122 myFunctor = &aFunctor;
124 myConvFunctor = aConvolutionFunctor;
128//-----------------------------------------------------------------------------
129template <typename TDigitalSurfaceContainer, typename TMetric,
130 typename TFunctorOnSurfel, typename TConvolutionFunctor>
132typename DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric, TFunctorOnSurfel, TConvolutionFunctor>::Scalar
133DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
134 TFunctorOnSurfel, TConvolutionFunctor>::
140///////////////////////////////////////////////////////////////////////////////
141template <typename TDigitalSurfaceContainer, typename TMetric,
142 typename TFunctorOnSurfel, typename TConvolutionFunctor>
144template<typename SurfelIt>
147DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
148 TFunctorOnSurfel, TConvolutionFunctor>::
157///////////////////////////////////////////////////////////////////////////////
158template <typename TDigitalSurfaceContainer, typename TMetric,
159 typename TFunctorOnSurfel, typename TConvolutionFunctor>
160template <typename SurfelConstIterator>
162typename DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
163 TFunctorOnSurfel, TConvolutionFunctor>::Quantity
164DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
165 TFunctorOnSurfel, TConvolutionFunctor>::
166eval( const SurfelConstIterator& it ) const
168 ASSERT_MSG( isValid(), "Missing init() before evaluation" );
169 const MetricToPoint metricToPoint = std::bind( *myMetric, myEmbedder( *it ), std::placeholders::_1 );
170 const VertexFunctor vfunctor( myEmbedder, metricToPoint);
171 Visitor visitor( *mySurface, vfunctor, *it);
172 ASSERT( ! visitor.finished() );
173 double currentDistance = 0.0;
174 while ( (! visitor.finished() ) && (currentDistance < myRadius) )
176 typename Visitor::Node node = visitor.current();
177 currentDistance = node.second;
178 if ( currentDistance < myRadius )
179 myFunctor->pushSurfel( node.first , myConvFunctor->operator()((myRadius - currentDistance)/myRadius));
183 Quantity val = myFunctor->eval();
187///////////////////////////////////////////////////////////////////////////////
188template <typename TDigitalSurfaceContainer, typename TMetric,
189 typename TFunctorOnSurfel, typename TConvolutionFunctor>
190template <typename SurfelConstIterator, typename OutputIterator>
193DGtal::LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
194 TFunctorOnSurfel, TConvolutionFunctor>::
195eval ( const SurfelConstIterator& itb,
196 const SurfelConstIterator& ite,
197 OutputIterator result ) const
199 for ( SurfelConstIterator it = itb; it != ite; ++it )
201 Quantity q = eval( it );
206///////////////////////////////////////////////////////////////////////////////
207template <typename TDigitalSurfaceContainer, typename TMetric,
208 typename TFunctorOnSurfel, typename TConvolutionFunctor>
211DGtal::operator<< ( std::ostream & out,
212 const LocalEstimatorFromSurfelFunctorAdapter<TDigitalSurfaceContainer, TMetric,
213 TFunctorOnSurfel, TConvolutionFunctor> & object )
215 object.selfDisplay( out );
218///////////////////////////////////////////////////////////////////////////////