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 //-----------------------------------------------------------------------------
42 template <typename TSurface>
44 DGtal::DigitalSurfacePredicate<TSurface>::
45 DigitalSurfacePredicate ()
48 //-----------------------------------------------------------------------------
49 template <typename TSurface>
51 DGtal::DigitalSurfacePredicate<TSurface>::
52 DigitalSurfacePredicate (ConstAlias<Surface> aSurface)
58 //-----------------------------------------------------------------------------
59 template <typename TSurface>
61 DGtal::DigitalSurfacePredicate<TSurface>::
62 DigitalSurfacePredicate (const DigitalSurfacePredicate<TSurface>& other)
63 : mySurface(other.mySurface)
68 //-----------------------------------------------------------------------------
69 template <typename TSurface>
71 DGtal::DigitalSurfacePredicate<TSurface>&
72 DGtal::DigitalSurfacePredicate<TSurface>::operator= (const DigitalSurfacePredicate<TSurface>& other)
76 mySurface = other.mySurface;
83 //-----------------------------------------------------------------------------
84 template <typename TSurface>
86 DGtal::DigitalSurfacePredicate<TSurface>::
87 ~DigitalSurfacePredicate ()
90 //-------------------- model of concepts::CPointPredicate -----------------------------
92 //-----------------------------------------------------------------------------
93 template <typename TSurface>
95 bool DGtal::DigitalSurfacePredicate<TSurface>::
96 operator() (Point const& aPoint) const
98 return myPointSet.count(aPoint) > 0;
101 // ------------------------- Internals ------------------------------------
103 //-----------------------------------------------------------------------------
104 template <typename TSurface>
106 typename DGtal::DigitalSurfacePredicate<TSurface>::KSpace const&
107 DGtal::DigitalSurfacePredicate<TSurface>::space () const
109 return mySurface->container().space();
112 //-----------------------------------------------------------------------------
113 template <typename TSurface>
116 DGtal::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.
140 template <typename TSurface>
143 DGtal::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.
152 template <typename TSurface>
155 DGtal::DigitalSurfacePredicate<TSurface>::isValid() const
162 ///////////////////////////////////////////////////////////////////////////////
163 // Implementation of inline functions //
165 template <typename TSurface>
168 DGtal::operator<< ( std::ostream & out,
169 const DigitalSurfacePredicate<TSurface> & object )
171 object.selfDisplay( out );
176 ///////////////////////////////////////////////////////////////////////////////