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 DomainMetricAdjacency.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
24 * Implementation of inline methods defined in DomainMetricAdjacency.h
26 * This file is part of the DGtal library.
30//////////////////////////////////////////////////////////////////////////////
32//////////////////////////////////////////////////////////////////////////////
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------- Standard services ------------------------------
42 * Constructor from a domain.
43 * @param aDomain any domain.
45template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
47DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>
48::DomainMetricAdjacency( ConstAlias<Domain> aDomain )
55 * @param other the object to clone.
57template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
59DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>
60::DomainMetricAdjacency( const DomainMetricAdjacency & other )
61 : myDomain( other.myDomain )
68template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
70DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>
71::~DomainMetricAdjacency()
76///////////////////////////////////////////////////////////////////////////////
77// ----------------------- Adjacency services -----------------------------
80 * @param p1 any point in this space.
81 * @param p2 any point in this space.
83 * @return 'true' iff p1 is adjacent to p2 according to this
86template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
89DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>::isAdjacentTo
90( const Point & p1, const Point & p2 ) const
92 ASSERT( myDomain.isInside( p1 ) && myDomain.isInside( p2 ) );
94 return ( v.normInfinity() <= 1 ) && ( v.norm1() <= maxNorm1 );
98 * @param p1 any point in this space.
99 * @param p2 any point in this space.
101 * @return 'true' iff p1 is adjacent to p2 according to this
102 * adjacency relation and p1 != p2.
104template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
107DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>::isProperlyAdjacentTo
108( const Point & p1, const Point & p2 ) const
110 ASSERT( myDomain.isInside( p1 ) && myDomain.isInside( p2 ) );
112 if ( v.normInfinity() <= 1 )
114 typename Vector::UnsignedComponent n1 = v.norm1();
115 return ( n1 <= maxNorm1 ) && ( n1 != 0 );
121 * Outputs the whole neighborhood of point [p] as a sequence of
124 * @tparam OutputIterator any output iterator (like
125 * std::back_insert_iterator< std::vector<int> >).
127 * @param p any point of this space.
128 * @param out_it any output iterator.
130template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
131template <typename OutputIterator>
133DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>::writeNeighborhood
134( const Point & p, OutputIterator & out_it ) const
137 for ( typename Point::Iterator it = p1.begin(); it != p1.end(); ++it )
140 for ( typename Point::Iterator it = p2.begin(); it != p2.end(); ++it )
142 typedef HyperRectDomain<Space> LocalDomain;
143 LocalDomain domain( p1, p2 );
144 for ( typename LocalDomain::ConstIterator it = domain.begin();
148 if ( myDomain.isInside( *it ) )
151 typename Vector::UnsignedComponent n1 = v.norm1();
152 if ( n1 <= maxNorm1 )
159 * Outputs the whole proper neighborhood of point [p] (thus
160 * without [p] itself) as a sequence of *out_it++ = ...
162 * @tparam OutputIterator any output iterator (like
163 * std::back_insert_iterator< std::vector<int> >).
165 * @param p any point of this space.
166 * @param out_it any output iterator.
168template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
169template <typename OutputIterator>
171DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>::writeProperNeighborhood
172( const Point & p, OutputIterator & out_it ) const
175 for ( typename Point::Iterator it = p1.begin(); it != p1.end(); ++it )
178 for ( typename Point::Iterator it = p2.begin(); it != p2.end(); ++it )
180 typedef HyperRectDomain<Space> LocalDomain;
181 LocalDomain domain( p1, p2 );
182 for ( typename LocalDomain::ConstIterator it = domain.begin();
186 if ( myDomain.isInside( *it ) )
189 typename Vector::UnsignedComponent n1 = v.norm1();
190 if ( ( n1 <= maxNorm1 ) && ( n1 != 0 ) )
198///////////////////////////////////////////////////////////////////////////////
199// Interface - public :
202 * Writes/Displays the object on an output stream.
203 * @param out the output stream where the object is written.
205template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
208DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>::selfDisplay ( std::ostream & out ) const
210 out << "[DomainMetricAdjacency domain="
215 * Checks the validity/consistency of the object.
216 * @return 'true' if the object is valid, 'false' otherwise.
218template <typename Domain, DGtal::Dimension maxNorm1, DGtal::Dimension dimension>
221DGtal::deprecated::DomainMetricAdjacency<Domain,maxNorm1,dimension>::isValid() const
228///////////////////////////////////////////////////////////////////////////////
229// Implementation of inline functions //
231template <typename Domain, DGtal::Dimension maxNorm1>
234DGtal::deprecated::operator<< ( std::ostream & out,
235 const DomainMetricAdjacency<Domain,maxNorm1,
236 Domain::Space::dimension> & object )
238 object.selfDisplay( out );
243///////////////////////////////////////////////////////////////////////////////