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 CanonicDigitalSurfaceEmbedder.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 CanonicDigitalSurfaceEmbedder.h
26 * This file is part of the DGtal library.
29///////////////////////////////////////////////////////////////////////////////
30// IMPLEMENTATION of inline methods.
31///////////////////////////////////////////////////////////////////////////////
33//////////////////////////////////////////////////////////////////////////////
36#include "DGtal/kernel/NumberTraits.h"
37//////////////////////////////////////////////////////////////////////////////
41///////////////////////////////////////////////////////////////////////////////
42// Implementation of inline methods //
43//-----------------------------------------------------------------------------
44template <typename TDigitalSurface>
46DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::
47~CanonicDigitalSurfaceEmbedder()
49//-----------------------------------------------------------------------------
50template <typename TDigitalSurface>
52DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::
53CanonicDigitalSurfaceEmbedder()
56//-----------------------------------------------------------------------------
57template <typename TDigitalSurface>
59DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::
60CanonicDigitalSurfaceEmbedder( ConstAlias<Surface> aSurface )
61 : mySurface( &aSurface )
63//-----------------------------------------------------------------------------
64template <typename TDigitalSurface>
66DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::
67CanonicDigitalSurfaceEmbedder( const Self & other )
68 : mySurface( other.mySurface )
70//-----------------------------------------------------------------------------
71template <typename TDigitalSurface>
73typename DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::Self &
74DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::
75operator=( const Self & other )
77 mySurface = other.mySurface;
80//-----------------------------------------------------------------------------
81template <typename TDigitalSurface>
83const typename DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::Surface &
84DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::surface() const
86 ASSERT( this->isValid() );
89//-----------------------------------------------------------------------------
90template <typename TDigitalSurface>
92typename DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::RealPoint
93DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::embed( const SCell & scell ) const
95 return this->operator()( scell );
97//-----------------------------------------------------------------------------
98template <typename TDigitalSurface>
100typename DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::RealPoint
101DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::operator()( const SCell & scell ) const
103 ASSERT( this->isValid() );
104 Point dp = mySurface->container().space().sKCoords( scell );
106 for ( Dimension i = 0; i < dp.size(); ++i )
107 p[ i ] = NumberTraits<Integer>::castToDouble( dp[ i ] ) / 2;
110//-----------------------------------------------------------------------------
111template <typename TDigitalSurface>
114DGtal::CanonicDigitalSurfaceEmbedder<TDigitalSurface>::isValid( ) const
116 return mySurface != 0;
118///////////////////////////////////////////////////////////////////////////////
119// Implementation of inline functions and external operators //
122 * Overloads 'operator<<' for displaying objects of class 'CanonicDigitalSurfaceEmbedder'.
123 * @param out the output stream where the object is written.
124 * @param object the object of class 'CanonicDigitalSurfaceEmbedder' to write.
125 * @return the output stream after the writing.
127template <typename TDigitalSurface>
130DGtal::operator<< ( std::ostream & out,
131 const CanonicDigitalSurfaceEmbedder<TDigitalSurface> & object )
133 object.selfDisplay ( out );
138///////////////////////////////////////////////////////////////////////////////