DGtal  1.5.beta
SurfelAdjacency.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 SurfelAdjacency.ih
19  * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20  * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
21  *
22  * @date 2011/03/18
23  *
24  * Implementation of inline methods defined in SurfelAdjacency.h
25  *
26  * This file is part of the DGtal library.
27  */
28 
29 ///////////////////////////////////////////////////////////////////////////////
30 // IMPLEMENTATION of inline methods.
31 ///////////////////////////////////////////////////////////////////////////////
32 
33 //////////////////////////////////////////////////////////////////////////////
34 #include <cstdlib>
35 //////////////////////////////////////////////////////////////////////////////
36 
37 
38 
39 ///////////////////////////////////////////////////////////////////////////////
40 // Implementation of inline methods //
41 //-----------------------------------------------------------------------------
42 template <DGtal::Dimension dim>
43 inline
44 DGtal::SurfelAdjacency<dim>::
45 ~SurfelAdjacency()
46 {}
47 //-----------------------------------------------------------------------------
48 template <DGtal::Dimension dim>
49 inline
50 DGtal::SurfelAdjacency<dim>::
51 SurfelAdjacency( bool int2ext )
52  : myInt2Ext()
53 {
54  DGtal::Dimension offset = 0;
55  for ( DGtal::Dimension j = 0; j < dim; ++j )
56  for ( DGtal::Dimension i = 0; i < dim; ++i )
57  myInt2Ext[ offset++ ] = int2ext;
58 }
59 
60 //-----------------------------------------------------------------------------
61 template <DGtal::Dimension dim>
62 inline
63 DGtal::SurfelAdjacency<dim>::
64 SurfelAdjacency ( const SurfelAdjacency & other )
65  : myInt2Ext( other.myInt2Ext )
66 {
67 }
68 //-----------------------------------------------------------------------------
69 template <DGtal::Dimension dim>
70 inline
71 DGtal::SurfelAdjacency<dim> &
72 DGtal::SurfelAdjacency<dim>::
73 operator= ( const SurfelAdjacency & other )
74 {
75  if ( this != &other )
76  myInt2Ext = other.myInt2Ext;
77  return *this;
78 }
79 //-----------------------------------------------------------------------------
80 template <DGtal::Dimension dim>
81 inline
82 void
83 DGtal::SurfelAdjacency<dim>::
84 setAdjacency( DGtal::Dimension i, DGtal::Dimension j, bool int2ext )
85 {
86  myInt2Ext[ i * dim + j ] = int2ext;
87  myInt2Ext[ j * dim + i ] = int2ext;
88 }
89 //-----------------------------------------------------------------------------
90 template <DGtal::Dimension dim>
91 inline
92 bool
93 DGtal::SurfelAdjacency<dim>::
94 getAdjacency( DGtal::Dimension i, DGtal::Dimension j ) const
95 {
96  return myInt2Ext[ i * dim + j ];
97 }
98 //-----------------------------------------------------------------------------
99 template <DGtal::Dimension dim>
100 inline
101 void
102 DGtal::SurfelAdjacency<dim>::
103 selfDisplay ( std::ostream & out ) const
104 {
105  out << "[SurfelAdjacency]";
106 }
107 //-----------------------------------------------------------------------------
108 template <DGtal::Dimension dim>
109 inline
110 bool
111 DGtal::SurfelAdjacency<dim>::
112 isValid() const
113 {
114  return true;
115 }
116 
117 
118 
119 ///////////////////////////////////////////////////////////////////////////////
120 // Implementation of inline functions and external operators //
121 
122 /**
123  * Overloads 'operator<<' for displaying objects of class 'SurfelAdjacency'.
124  * @param out the output stream where the object is written.
125  * @param object the object of class 'SurfelAdjacency' to write.
126  * @return the output stream after the writing.
127  */
128 template <DGtal::Dimension dim>
129 inline
130 std::ostream&
131 DGtal::operator<< ( std::ostream & out,
132  const SurfelAdjacency<dim> & object )
133 {
134  object.selfDisplay ( out );
135  return out;
136 }
137 
138 // //
139 ///////////////////////////////////////////////////////////////////////////////
140 
141