DGtal  0.9.2
NormalVectorEstimatorLinearCellEmbedder.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 NormalVectorEstimatorLinearCellEmbedder.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 NormalVectorEstimatorLinearCellEmbedder.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 //-----------------------------------------------------------------------------
42 template < typename TKSpace, typename TNormalEstimator, typename TEmbedder >
43 inline
44 DGtal::NormalVectorEstimatorLinearCellEmbedder<TKSpace, TNormalEstimator, TEmbedder>::
45 ~NormalVectorEstimatorLinearCellEmbedder()
46 {}
47 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
49 template < typename TDigitalSurface, typename TNormalEstimator, typename TEmbedder >
50 inline
51 DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::
52 NormalVectorEstimatorLinearCellEmbedder( ConstAlias<DigitalSurface> aSurface,
53  ConstAlias<NormalVectorEstimator> anEstim,
54  ConstAlias<Embedder> aEmb )
55  : mySurface(aSurface ),
56  myPtrFct( anEstim ),
57  myPtrEmbedder( aEmb )
58 {}
59 //-----------------------------------------------------------------------------
60 template < typename TDigitalSurface, typename TNormalEstimator, typename TEmbedder >
61 inline
62 typename DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::RealPoint
63 DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::
64 embed( const Point & p ) const
65 {
66  //ASSERT( myPtrEmbedder.isValid() );
67  return myPtrEmbedder.embed( p );
68 }
69 //-----------------------------------------------------------------------------
70 template < typename TDigitalSurface, typename TNormalEstimator, typename TEmbedder >
71 inline
72 typename DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::RealPoint
73 DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::
74 embedSurfel( const ConstIterator & surfelIt ) const
75 {
76  ASSERT( this->isValid() );
77 
78  // embed first the spel related to the cell.
79  Point p1( mySurface.container().space().sCoords( *surfelIt ) );
80  RealPoint x1( embed( p1 ) );
81  return x1;
82 }
83 
84 //-----------------------------------------------------------------------------
85 template < typename TDigitalSurface, typename TNormalEstimator, typename TEmbedder >
86 inline
87 void
88 DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::
89 embedSurfel( const ConstIterator & surfelIt , RealPoint &p, RealVector &v) const
90 {
91  ASSERT( this->isValid() );
92  ASSERT( myPtrFct.isValid() );
93  // embed first the spel related to the cell.
94  p = embedSurfel( surfelIt );
95  v = myPtrFct.eval(surfelIt);
96 }
97 
98 ///////////////////////////////////////////////////////////////////////////////
99 // Interface - public :
100 
101 /**
102  * Writes/Displays the object on an output stream.
103  * @param out the output stream where the object is written.
104  */
105 template < typename TDigitalSurface, typename TNormalEstimator, typename TEmbedder >
106 inline
107 void
108 DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::
109 selfDisplay ( std::ostream & out ) const
110 {
111  out << "[NormalVectorEstimatorLinearCellEmbedder]";
112 }
113 
114 /**
115  * Checks the validity/consistency of the object.
116  * @return 'true' if the object is valid, 'false' otherwise.
117  */
118 template < typename TDigitalSurface, typename TNormalEstimator, typename TEmbedder >
119 inline
120 bool
121 DGtal::NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder>::
122 isValid() const
123 {
124  return ( mySurface.isValid() ) && ( myPtrFct.isValid() );
125  //&& ( myPtrEmbedder.isValid() );
126 }
127 
128 
129 
130 ///////////////////////////////////////////////////////////////////////////////
131 // Implementation of inline functions //
132 
133 template < typename TDigitalSurface, typename TNormalEstimator, typename TEmbedder >
134 inline
135 std::ostream&
136 DGtal::operator<< ( std::ostream & out,
137  const NormalVectorEstimatorLinearCellEmbedder<TDigitalSurface, TNormalEstimator, TEmbedder> & object )
138 {
139  object.selfDisplay( out );
140  return out;
141 }
142 
143 // //
144 ///////////////////////////////////////////////////////////////////////////////
145 
146