DGtal 1.3.0
Loading...
Searching...
No Matches
VCMDigitalSurfaceLocalEstimator.ih
1/**
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.
6 *
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.
11 *
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/>.
14 *
15 **/
16
17/**
18 * @file VCMDigitalSurfaceLocalEstimator.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
21 *
22 * @date 2014/02/13
23 *
24 * Implementation of inline methods defined in VCMDigitalSurfaceLocalEstimator.h
25 *
26 * This file is part of the DGtal library.
27 */
28
29
30//////////////////////////////////////////////////////////////////////////////
31#include <cstdlib>
32//////////////////////////////////////////////////////////////////////////////
33
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
37
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------- Standard services ------------------------------
40
41//-----------------------------------------------------------------------------
42template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
43 typename TKernelFunction, typename TVCMGeometricFunctor>
44inline
45DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
46~VCMDigitalSurfaceLocalEstimator()
47{
48}
49
50//-----------------------------------------------------------------------------
51template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
52 typename TKernelFunction, typename TVCMGeometricFunctor>
53inline
54DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
55VCMDigitalSurfaceLocalEstimator()
56 : mySurface( 0 ),
57 mySurfelEmbedding( InnerSpel ),
58 myVCMOnSurface( 0 ),
59 myGeomFct(),
60 myH( 1.0 )
61{
62}
63
64//-----------------------------------------------------------------------------
65template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
66 typename TKernelFunction, typename TVCMGeometricFunctor>
67inline
68DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
69VCMDigitalSurfaceLocalEstimator( const Self& other )
70 : mySurface( other.mySurface ),
71 mySurfelEmbedding( other.mySurfelEmbedding ),
72 myVCMOnSurface( other.myVCMOnSurface ),
73 myGeomFct( other.myGeomFct ),
74 myH( other.myH )
75{
76}
77
78//-----------------------------------------------------------------------------
79template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
80 typename TKernelFunction, typename TVCMGeometricFunctor>
81inline
82typename DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::Self&
83DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
84operator=( const Self& other )
85{
86 if ( this != &other )
87 {
88 mySurface = other.mySurface;
89 mySurfelEmbedding = other.mySurfelEmbedding;
90 myVCMOnSurface = other.myVCMOnSurface;
91 myGeomFct = other.myGeomFct;
92 myH = other.myH;
93 }
94 return *this;
95}
96
97//-----------------------------------------------------------------------------
98template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
99 typename TKernelFunction, typename TVCMGeometricFunctor>
100inline
101DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
102VCMDigitalSurfaceLocalEstimator( ConstAlias< VCMOnSurface > vcmSurface )
103 : mySurface( vcmSurface->surface() ),
104 mySurfelEmbedding( vcmSurface->surfelEmbedding() ),
105 myVCMOnSurface( vcmSurface ),
106 myGeomFct( vcmSurface ),
107 myH( 1.0 )
108{
109}
110//-----------------------------------------------------------------------------
111template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
112 typename TKernelFunction, typename TVCMGeometricFunctor>
113inline
114DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
115VCMDigitalSurfaceLocalEstimator( ConstAlias< Surface > surface )
116 : mySurface( surface ),
117 mySurfelEmbedding( InnerSpel ),
118 myVCMOnSurface( 0 ),
119 myGeomFct(),
120 myH( 1.0 )
121{
122}
123
124//-----------------------------------------------------------------------------
125template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
126 typename TKernelFunction, typename TVCMGeometricFunctor>
127inline
128void
129DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
130attach( ConstAlias<Surface> surface )
131{
132 mySurface = surface;
133 myVCMOnSurface = CountedConstPtrOrConstPtr<VCMOnSurface>( 0,false );
134}
135
136//-----------------------------------------------------------------------------
137template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
138 typename TKernelFunction, typename TVCMGeometricFunctor>
139inline
140void
141DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
142setParams( Surfel2PointEmbedding surfelEmbedding,
143 const Scalar R, const Scalar r, KernelFunction chi_r,
144 const Scalar t, Metric aMetric, bool verbose )
145{
146 mySurfelEmbedding = surfelEmbedding;
147 myVCMOnSurface = CountedConstPtrOrConstPtr<VCMOnSurface>
148 ( new VCMOnSurface( mySurface, mySurfelEmbedding,
149 R, r, chi_r, t, aMetric, verbose ), true );
150 myGeomFct.attach( myVCMOnSurface );
151}
152//-----------------------------------------------------------------------------
153template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
154 typename TKernelFunction, typename TVCMGeometricFunctor>
155template <typename SurfelConstIterator>
156inline
157void
158DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
159init( const Scalar _h,
160 SurfelConstIterator /* itb */,
161 SurfelConstIterator /* ite */ )
162{
163 ASSERT( mySurface != 0 );
164 ASSERT( myVCMOnSurface != 0 );
165 // Unused. The VCM is necessarily initialized on the whole surface.
166 myH = _h;
167}
168//-----------------------------------------------------------------------------
169template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
170 typename TKernelFunction, typename TVCMGeometricFunctor>
171template <typename SurfelConstIterator>
172inline
173typename DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::Quantity
174DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
175eval( SurfelConstIterator it ) const
176{
177 BOOST_CONCEPT_ASSERT(( boost::InputIterator<SurfelConstIterator> ));
178 ASSERT( mySurface != 0 );
179 ASSERT( myVCMOnSurface != 0 );
180 return myGeomFct( *it );
181}
182//-----------------------------------------------------------------------------
183template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
184 typename TKernelFunction, typename TVCMGeometricFunctor>
185template <typename SurfelConstIterator, typename OutputIterator>
186inline
187OutputIterator
188DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
189eval( SurfelConstIterator itb,
190 SurfelConstIterator ite,
191 OutputIterator result ) const
192{
193 BOOST_CONCEPT_ASSERT(( boost::InputIterator<SurfelConstIterator> ));
194 BOOST_CONCEPT_ASSERT(( boost::OutputIterator<OutputIterator,Quantity> ));
195 ASSERT( myVCMOnSurface != 0 );
196 for ( ; itb != ite; ++itb )
197 {
198 *result++ = myGeomFct( *itb );
199 }
200 return result;
201}
202
203//-----------------------------------------------------------------------------
204template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
205 typename TKernelFunction, typename TVCMGeometricFunctor>
206inline
207typename DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::Scalar
208DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
209h() const
210{
211 return myH;
212}
213
214///////////////////////////////////////////////////////////////////////////////
215// Interface - public :
216
217/**
218 * Writes/Displays the object on an output stream.
219 * @param out the output stream where the object is written.
220 */
221template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
222 typename TKernelFunction, typename TVCMGeometricFunctor>
223inline
224void
225DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
226selfDisplay ( std::ostream & out ) const
227{
228 out << "[VCMDigitalSurfaceLocalEstimator]";
229}
230
231/**
232 * Checks the validity/consistency of the object.
233 * @return 'true' if the object is valid, 'false' otherwise.
234 */
235template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
236 typename TKernelFunction, typename TVCMGeometricFunctor>
237inline
238bool
239DGtal::VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor>::
240isValid() const
241{
242 return true;
243}
244
245
246
247///////////////////////////////////////////////////////////////////////////////
248// Implementation of inline functions //
249
250template <typename TDigitalSurfaceContainer, typename TSeparableMetric,
251 typename TKernelFunction, typename TVCMGeometricFunctor>
252inline
253std::ostream&
254DGtal::operator<<( std::ostream & out,
255 const VCMDigitalSurfaceLocalEstimator<TDigitalSurfaceContainer, TSeparableMetric, TKernelFunction, TVCMGeometricFunctor> & object )
256{
257 object.selfDisplay( out );
258 return out;
259}
260
261// //
262///////////////////////////////////////////////////////////////////////////////
263
264