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/>.
19 * @author Jocelyn Meyron (\c jocelyn.meyron@liris.cnrs.fr )
20 * Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
24 * Implementation of inline methods defined in DigitalSurfacePredicate.h
26 * This file is part of the DGtal library.
30//////////////////////////////////////////////////////////////////////////////
32//////////////////////////////////////////////////////////////////////////////
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------- Standard services ------------------------------
41//-----------------------------------------------------------------------------
42template <typename TSurface>
44DGtal::DigitalSurfacePredicate<TSurface>::
45DigitalSurfacePredicate ()
48//-----------------------------------------------------------------------------
49template <typename TSurface>
51DGtal::DigitalSurfacePredicate<TSurface>::
52DigitalSurfacePredicate (ConstAlias<Surface> aSurface)
58//-----------------------------------------------------------------------------
59template <typename TSurface>
61DGtal::DigitalSurfacePredicate<TSurface>::
62DigitalSurfacePredicate (const DigitalSurfacePredicate<TSurface>& other)
63 : mySurface(other.mySurface)
68//-----------------------------------------------------------------------------
69template <typename TSurface>
71DGtal::DigitalSurfacePredicate<TSurface>&
72DGtal::DigitalSurfacePredicate<TSurface>::operator= (const DigitalSurfacePredicate<TSurface>& other)
76 mySurface = other.mySurface;
83//-----------------------------------------------------------------------------
84template <typename TSurface>
86DGtal::DigitalSurfacePredicate<TSurface>::
87~DigitalSurfacePredicate ()
90//-------------------- model of concepts::CPointPredicate -----------------------------
92//-----------------------------------------------------------------------------
93template <typename TSurface>
95bool DGtal::DigitalSurfacePredicate<TSurface>::
96operator() (Point const& aPoint) const
98 return myPointSet.count(aPoint) > 0;
101// ------------------------- Internals ------------------------------------
103//-----------------------------------------------------------------------------
104template <typename TSurface>
106typename DGtal::DigitalSurfacePredicate<TSurface>::KSpace const&
107DGtal::DigitalSurfacePredicate<TSurface>::space () const
109 return mySurface->container().space();
112//-----------------------------------------------------------------------------
113template <typename TSurface>
116DGtal::DigitalSurfacePredicate<TSurface>::buildPointSet ()
120 // Extract all the pointels of the digital surface
121 KSpace const& K = space();
122 for (const auto& f: *mySurface) {
123 typename KSpace::Cells faces = K.uFaces(K.unsigns(f));
125 for (const auto& c: faces) {
126 if (K.uDim(c) == 0) {
127 myPointSet.insert(K.uCoords(c));
133///////////////////////////////////////////////////////////////////////////////
134// Interface - public :
137 * Writes/Displays the object on an output stream.
138 * @param out the output stream where the object is written.
140template <typename TSurface>
143DGtal::DigitalSurfacePredicate<TSurface>::selfDisplay ( std::ostream & out ) const
145 out << "[DigitalSurfacePredicate]";
149 * Checks the validity/consistency of the object.
150 * @return 'true' if the object is valid, 'false' otherwise.
152template <typename TSurface>
155DGtal::DigitalSurfacePredicate<TSurface>::isValid() const
162///////////////////////////////////////////////////////////////////////////////
163// Implementation of inline functions //
165template <typename TSurface>
168DGtal::operator<< ( std::ostream & out,
169 const DigitalSurfacePredicate<TSurface> & object )
171 object.selfDisplay( out );
176///////////////////////////////////////////////////////////////////////////////