DGtal 1.4.0
Loading...
Searching...
No Matches
DigitalSurfaceEmbedderWithNormalVectorEstimator.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 DigitalSurfaceEmbedderWithNormalVectorEstimator.ih
19 * @author David Coeurjolly (\c david.coeurjolly@liris.cnrs.fr )
20 * Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
21 *
22 * @date 2012/02/14
23 *
24 * Implementation of inline methods defined in DigitalSurfaceEmbedderWithNormalVectorEstimator.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 TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
43inline
44DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
45~DigitalSurfaceEmbedderWithNormalVectorEstimator()
46{}
47
48//-----------------------------------------------------------------------------
49template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
50inline
51DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
52DigitalSurfaceEmbedderWithNormalVectorEstimator()
53 : myDSEmbedder( 0 ), myEstimator( 0 )
54{}
55
56//-----------------------------------------------------------------------------
57template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
58inline
59DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
60DigitalSurfaceEmbedderWithNormalVectorEstimator
61( ConstAlias<DigitalSurfaceEmbedder> aDSEmbedder,
62 ConstAlias<NormalVectorEstimator> anEstimator )
63 : myDSEmbedder( &aDSEmbedder ),
64 myEstimator( &anEstimator )
65{}
66
67//-----------------------------------------------------------------------------
68template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
69inline
70DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
71DigitalSurfaceEmbedderWithNormalVectorEstimator
72( const Self & other )
73 : myDSEmbedder( other.myDSEmbedder ),
74 myEstimator( other.myEstimator )
75{}
76
77//-----------------------------------------------------------------------------
78template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
79inline
80typename DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::Self &
81DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
82operator=
83( const Self & other )
84{
85 myDSEmbedder = other.myDSEmbedder;
86 myEstimator = other.myEstimator;
87 return *this;
88}
89
90//-----------------------------------------------------------------------------
91template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
92inline
93const typename DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::Surface &
94DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
95surface() const
96{
97 ASSERT( this->isValid() );
98 return myDSEmbedder->surface();
99}
100
101//-----------------------------------------------------------------------------
102template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
103inline
104typename DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::RealPoint
105DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
106operator()( const SCell & scell ) const
107{
108 ASSERT( this->isValid() );
109 return myDSEmbedder->operator()( scell );
110}
111
112//-----------------------------------------------------------------------------
113template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
114inline
115typename DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::RealVector
116DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
117gradient( const SCell & scell ) const
118{
119 ASSERT( this->isValid() );
120 return myEstimator->eval( scell );
121}
122
123//-----------------------------------------------------------------------------
124template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
125inline
126typename DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::GradientMap
127DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
128gradientMap() const
129{
130 ASSERT( this->isValid() );
131 return GradientMap( *this );
132}
133
134///////////////////////////////////////////////////////////////////////////////
135// Interface - public :
136
137/**
138 * Writes/Displays the object on an output stream.
139 * @param out the output stream where the object is written.
140 */
141template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
142inline
143void
144DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
145selfDisplay ( std::ostream & out ) const
146{
147 out << "[DigitalSurfaceEmbedderWithNormalVectorEstimator]";
148}
149
150/**
151 * Checks the validity/consistency of the object.
152 * @return 'true' if the object is valid, 'false' otherwise.
153 */
154template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
155inline
156bool
157DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
158isValid() const
159{
160 return ( myEstimator != 0 ) && ( myDSEmbedder != 0 )
161 && ( myEstimator->isValid() ) && ( myDSEmbedder->isValid() );
162}
163
164///////////////////////////////////////////////////////////////////////////////
165// class DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap
166
167//-----------------------------------------------------------------------------
168template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
169inline
170DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
171~DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap()
172{}
173
174//-----------------------------------------------------------------------------
175template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
176inline
177DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
178DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap()
179 : myEmbedder( 0 )
180{}
181
182//-----------------------------------------------------------------------------
183template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
184inline
185DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
186DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap
187( ConstAlias<Embedder> embedder )
188 : myEmbedder( &embedder )
189{}
190
191//-----------------------------------------------------------------------------
192template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
193inline
194DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
195DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap
196( const Self & other )
197 : myEmbedder( other.myEmbedder )
198{}
199
200//-----------------------------------------------------------------------------
201template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
202inline
203typename DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::Self &
204DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
205operator=
206( const Self & other )
207{
208 myEmbedder = other.myEmbedder;
209 return *this;
210}
211
212//-----------------------------------------------------------------------------
213template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
214inline
215typename DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::Value
216DGtal::DigitalSurfaceEmbedderWithNormalVectorEstimatorGradientMap<TDigitalSurfaceEmbedder, TNormalVectorEstimator>::
217operator()( const Argument & arg ) const
218{
219 ASSERT( myEmbedder != 0 );
220 return myEmbedder->gradient( arg );
221}
222
223
224///////////////////////////////////////////////////////////////////////////////
225// Implementation of inline functions //
226
227template < typename TDigitalSurfaceEmbedder, typename TNormalVectorEstimator >
228inline
229std::ostream&
230DGtal::operator<< ( std::ostream & out,
231 const DigitalSurfaceEmbedderWithNormalVectorEstimator<TDigitalSurfaceEmbedder, TNormalVectorEstimator> & object )
232{
233 object.selfDisplay( out );
234 return out;
235}
236
237// //
238///////////////////////////////////////////////////////////////////////////////
239
240