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 DigitalPlanePredicate.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 TSpace>
44 DGtal::DigitalPlanePredicate<TSpace>::
45 DigitalPlanePredicate (Vector const& aNormal, Integer const& aMu, Integer const& aNu)
46 : myNormal(aNormal), myMu(aMu), myNu(aNu)
49 //-----------------------------------------------------------------------------
50 template <typename TSpace>
52 DGtal::DigitalPlanePredicate<TSpace>::
53 DigitalPlanePredicate (const DGtal::DigitalPlanePredicate<TSpace> & other)
54 : myNormal(other.normal()), myMu(other.mu()), myNu(other.nu())
57 //-----------------------------------------------------------------------------
58 template <typename TSpace>
60 DGtal::DigitalPlanePredicate<TSpace>::
61 DigitalPlanePredicate (DGtal::DigitalPlanePredicate<TSpace> && other)
62 : myNormal(other.normal()), myMu(other.mu()), myNu(other.nu())
65 //-----------------------------------------------------------------------------
66 template <typename TSpace>
68 DGtal::DigitalPlanePredicate<TSpace>&
69 DGtal::DigitalPlanePredicate<TSpace>::operator= (const DGtal::DigitalPlanePredicate<TSpace> & other)
73 myNormal = other.normal();
81 //-----------------------------------------------------------------------------
82 template <typename TSpace>
84 DGtal::DigitalPlanePredicate<TSpace>&
85 DGtal::DigitalPlanePredicate<TSpace>::operator= (DGtal::DigitalPlanePredicate<TSpace> && other)
87 myNormal = other.normal();
94 ///////////////////////////////////////////////////////////////////////////////
95 //-------------------- plane services -----------------------------
97 //-----------------------------------------------------------------------------
98 template <typename TSpace>
100 typename DGtal::DigitalPlanePredicate<TSpace>::Vector const&
101 DGtal::DigitalPlanePredicate<TSpace>::normal () const
106 //-----------------------------------------------------------------------------
107 template <typename TSpace>
109 typename DGtal::DigitalPlanePredicate<TSpace>::Integer
110 DGtal::DigitalPlanePredicate<TSpace>::mu () const
115 //-----------------------------------------------------------------------------
116 template <typename TSpace>
118 typename DGtal::DigitalPlanePredicate<TSpace>::Integer
119 DGtal::DigitalPlanePredicate<TSpace>::nu () const
124 ///////////////////////////////////////////////////////////////////////////////
125 //-------------------- model of concepts::CPointPredicate -----------------------------
127 //-----------------------------------------------------------------------------
128 template <typename TSpace>
130 bool DGtal::DigitalPlanePredicate<TSpace>::
131 operator() (Point const& aPoint) const
133 Integer height = aPoint.dot(myNormal);
134 return (height >= mu() && height < mu() + nu());
137 ///////////////////////////////////////////////////////////////////////////////
138 // Interface - public :
141 * Writes/Displays the object on an output stream.
142 * @param out the output stream where the object is written.
144 template <typename TSpace>
147 DGtal::DigitalPlanePredicate<TSpace>::selfDisplay ( std::ostream & out ) const
149 out << "[DigitalPlanePredicate ";
150 out << mu() << " <= ";
151 out << "(" << myNormal[0];
152 for (Dimension i = 1; i < TSpace::dimension; ++i) {
153 out << ", " << myNormal[i];
156 out << " < " << (mu() + nu());
161 * Checks the validity/consistency of the object.
162 * @return 'true' if the object is valid, 'false' otherwise.
164 template <typename TSpace>
167 DGtal::DigitalPlanePredicate<TSpace>::isValid() const
169 return normal().norm1() > NumberTraits<Integer>::ZERO;
174 ///////////////////////////////////////////////////////////////////////////////
175 // Implementation of inline functions //
177 template <typename TSpace>
180 DGtal::operator<< ( std::ostream & out,
181 const DigitalPlanePredicate<TSpace> & object )
183 object.selfDisplay( out );
188 ///////////////////////////////////////////////////////////////////////////////