DGtal  1.5.beta
PlaneProbingHNeighborhood.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/04
23  *
24  * Implementation of inline methods defined in PlaneProbingHNeighborhood.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 // ------------------------------------------------------------------------
42 template < typename TPredicate >
43 inline
44 DGtal::PlaneProbingHNeighborhood<TPredicate>::
45 PlaneProbingHNeighborhood(Predicate const& aPredicate, Point const& aQ, Triangle const& aM)
46  : DGtal::PlaneProbingNeighborhood<TPredicate>(aPredicate, aQ, aM)
47 {}
48 
49 // ------------------------------------------------------------------------
50 template < typename TPredicate >
51 inline
52 DGtal::PlaneProbingHNeighborhood<TPredicate>::
53 ~PlaneProbingHNeighborhood()
54 {}
55 
56 ///////////////////////////////////////////////////////////////////////////////
57 // ----------------------- Plane Probing services ------------------------------
58 
59 // ------------------------------------------------------------------------
60 template < typename TPredicate >
61 inline
62 typename DGtal::PlaneProbingHNeighborhood<TPredicate>::HexagonState
63 DGtal::PlaneProbingHNeighborhood<TPredicate>::hexagonState ()
64 {
65  this->myCandidates.clear();
66 
67  std::array<bool, 6> state({ false, false, false, false, false, false });
68  for (int i = 0; i < 6; ++i)
69  {
70  PointOnProbingRay r = this->myNeighborhood[i].getBase();
71 
72  if (this->isNeighbor(r)) {
73  state[i] = this->myPredicate(this->absolutePoint(r));
74 
75  if (state[i])
76  {
77  this->myCandidates.push_back(r);
78  }
79  }
80  }
81 
82  return this->classify(state);
83 }
84 
85 ///////////////////////////////////////////////////////////////////////////////
86 // Interface - public :
87 
88 /**
89  * Writes/Displays the object on an output stream.
90  * @param out the output stream where the object is written.
91  */
92 template <typename TPredicate>
93 inline
94 void
95 DGtal::PlaneProbingHNeighborhood<TPredicate>::selfDisplay ( std::ostream & out ) const
96 {
97  out << "[PlaneProbingHNeighborhood]";
98 }
99 
100 /**
101  * Checks the validity/consistency of the object.
102  * @return 'true' if the object is valid, 'false' otherwise.
103  */
104 template <typename TPredicate>
105 inline
106 bool
107 DGtal::PlaneProbingHNeighborhood<TPredicate>::isValid() const
108 {
109  return true;
110 }
111 
112 
113 
114 ///////////////////////////////////////////////////////////////////////////////
115 // Implementation of inline functions //
116 
117 template <typename TPredicate>
118 inline
119 std::ostream&
120 DGtal::operator<< ( std::ostream & out,
121  const PlaneProbingHNeighborhood<TPredicate> & object )
122 {
123  object.selfDisplay( out );
124  return out;
125 }
126 
127 // //
128 ///////////////////////////////////////////////////////////////////////////////
129 
130