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 CanonicEmbedder.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 CanonicEmbedder.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 //-----------------------------------------------------------------------------
44 template <typename TSpace>
46 typename DGtal::CanonicEmbedder<TSpace>::Point
47 DGtal::CanonicEmbedder<TSpace>::floor( const RealPoint & p ) const
50 for ( Dimension i = 0; i < dp.size(); ++i )
51 dp[ i ] = (Integer) floor( p[ i ] );
54 //-----------------------------------------------------------------------------
55 template <typename TSpace>
57 typename DGtal::CanonicEmbedder<TSpace>::Point
58 DGtal::CanonicEmbedder<TSpace>::ceil( const RealPoint & p ) const
61 for ( Dimension i = 0; i < dp.size(); ++i )
62 dp[ i ] = (Integer) ceil( p[ i ] );
65 //-----------------------------------------------------------------------------
66 template <typename TSpace>
68 typename DGtal::CanonicEmbedder<TSpace>::Point
69 DGtal::CanonicEmbedder<TSpace>::round( const RealPoint & p ) const
72 for ( Dimension i = 0; i < dp.size(); ++i )
73 dp[ i ] = (Integer) round( p[ i ] );
76 //-----------------------------------------------------------------------------
77 template <typename TSpace>
79 typename DGtal::CanonicEmbedder<TSpace>::RealPoint
80 DGtal::CanonicEmbedder<TSpace>::embed( const Point & dp ) const
82 return this->operator()( dp );
84 //-----------------------------------------------------------------------------
85 template <typename TSpace>
87 typename DGtal::CanonicEmbedder<TSpace>::RealPoint
88 DGtal::CanonicEmbedder<TSpace>::operator()( const Point & dp ) const
91 for ( Dimension i = 0; i < dp.size(); ++i )
92 p[ i ] = NumberTraits<Integer>::castToDouble( dp[ i ] );
95 //-----------------------------------------------------------------------------
96 template <typename TSpace>
99 DGtal::CanonicEmbedder<TSpace>::isValid( ) const
103 ///////////////////////////////////////////////////////////////////////////////
104 // Implementation of inline functions and external operators //
107 * Overloads 'operator<<' for displaying objects of class 'CanonicEmbedder'.
108 * @param out the output stream where the object is written.
109 * @param object the object of class 'CanonicEmbedder' to write.
110 * @return the output stream after the writing.
112 template <typename TSpace>
115 DGtal::operator<< ( std::ostream & out,
116 const CanonicEmbedder<TSpace> & object )
118 object.selfDisplay ( out );
123 ///////////////////////////////////////////////////////////////////////////////