DGtal 1.4.0
Loading...
Searching...
No Matches
DigitalPlanePredicate.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
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
21 *
22 * @date 2020/12/03
23 *
24 * Implementation of inline methods defined in DigitalPlanePredicate.h
25 *
26 * This file is part of the DGtal library.
27 */
28
29
30//////////////////////////////////////////////////////////////////////////////
31#include <cstdlib>
32//////////////////////////////////////////////////////////////////////////////
33
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
37
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------- Standard services ------------------------------
40
41//-----------------------------------------------------------------------------
42template <typename TSpace>
43inline
44DGtal::DigitalPlanePredicate<TSpace>::
45DigitalPlanePredicate (Vector const& aNormal, Integer const& aMu, Integer const& aNu)
46 : myNormal(aNormal), myMu(aMu), myNu(aNu)
47{}
48
49//-----------------------------------------------------------------------------
50template <typename TSpace>
51inline
52DGtal::DigitalPlanePredicate<TSpace>::
53DigitalPlanePredicate (const DGtal::DigitalPlanePredicate<TSpace> & other)
54 : myNormal(other.normal()), myMu(other.mu()), myNu(other.nu())
55{}
56
57//-----------------------------------------------------------------------------
58template <typename TSpace>
59inline
60DGtal::DigitalPlanePredicate<TSpace>::
61DigitalPlanePredicate (DGtal::DigitalPlanePredicate<TSpace> && other)
62 : myNormal(other.normal()), myMu(other.mu()), myNu(other.nu())
63{}
64
65//-----------------------------------------------------------------------------
66template <typename TSpace>
67inline
68DGtal::DigitalPlanePredicate<TSpace>&
69DGtal::DigitalPlanePredicate<TSpace>::operator= (const DGtal::DigitalPlanePredicate<TSpace> & other)
70{
71 if (this != &other)
72 {
73 myNormal = other.normal();
74 myMu = other.mu();
75 myNu = other.nu();
76 }
77
78 return *this;
79}
80
81//-----------------------------------------------------------------------------
82template <typename TSpace>
83inline
84DGtal::DigitalPlanePredicate<TSpace>&
85DGtal::DigitalPlanePredicate<TSpace>::operator= (DGtal::DigitalPlanePredicate<TSpace> && other)
86{
87 myNormal = other.normal();
88 myMu = other.mu();
89 myNu = other.nu();
90
91 return *this;
92}
93
94///////////////////////////////////////////////////////////////////////////////
95//-------------------- plane services -----------------------------
96
97//-----------------------------------------------------------------------------
98template <typename TSpace>
99inline
100typename DGtal::DigitalPlanePredicate<TSpace>::Vector const&
101DGtal::DigitalPlanePredicate<TSpace>::normal () const
102{
103 return myNormal;
104}
105
106//-----------------------------------------------------------------------------
107template <typename TSpace>
108inline
109typename DGtal::DigitalPlanePredicate<TSpace>::Integer
110DGtal::DigitalPlanePredicate<TSpace>::mu () const
111{
112 return myMu;
113}
114
115//-----------------------------------------------------------------------------
116template <typename TSpace>
117inline
118typename DGtal::DigitalPlanePredicate<TSpace>::Integer
119DGtal::DigitalPlanePredicate<TSpace>::nu () const
120{
121 return myNu;
122}
123
124///////////////////////////////////////////////////////////////////////////////
125//-------------------- model of concepts::CPointPredicate -----------------------------
126
127//-----------------------------------------------------------------------------
128template <typename TSpace>
129inline
130bool DGtal::DigitalPlanePredicate<TSpace>::
131operator() (Point const& aPoint) const
132{
133 Integer height = aPoint.dot(myNormal);
134 return (height >= mu() && height < mu() + nu());
135}
136
137///////////////////////////////////////////////////////////////////////////////
138// Interface - public :
139
140/**
141 * Writes/Displays the object on an output stream.
142 * @param out the output stream where the object is written.
143 */
144template <typename TSpace>
145inline
146void
147DGtal::DigitalPlanePredicate<TSpace>::selfDisplay ( std::ostream & out ) const
148{
149 out << "[DigitalPlanePredicate ";
150 out << mu() << " <= ";
151 out << "(" << myNormal[0];
152 for (Dimension i = 1; i < TSpace::dimension; ++i) {
153 out << ", " << myNormal[i];
154 }
155 out << ").X";
156 out << " < " << (mu() + nu());
157 out << " ]";
158}
159
160/**
161 * Checks the validity/consistency of the object.
162 * @return 'true' if the object is valid, 'false' otherwise.
163 */
164template <typename TSpace>
165inline
166bool
167DGtal::DigitalPlanePredicate<TSpace>::isValid() const
168{
169 return normal().norm1() > NumberTraits<Integer>::ZERO;
170}
171
172
173
174///////////////////////////////////////////////////////////////////////////////
175// Implementation of inline functions //
176
177template <typename TSpace>
178inline
179std::ostream&
180DGtal::operator<< ( std::ostream & out,
181 const DigitalPlanePredicate<TSpace> & object )
182{
183 object.selfDisplay( out );
184 return out;
185}
186
187// //
188///////////////////////////////////////////////////////////////////////////////
189
190