DGtal  0.9.2
Point2ShapePredicate.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 Point2ShapePredicate.ih
19  * @author Tristan Roussillon (\c tristan.roussillon@liris.cnrs.fr )
20  * Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
21  *
22  * @date 2010/10/27
23  *
24  * Implementation of inline methods defined in Point2ShapePredicate.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 TSurface, bool isUpward, bool isClosed>
43 inline
44 DGtal::functors::Point2ShapePredicate<TSurface,isUpward,isClosed>::~Point2ShapePredicate()
45 {
46 }
47 
48 template <typename TSurface, bool isUpward, bool isClosed>
49 inline
50 DGtal::functors::Point2ShapePredicate<TSurface,isUpward,isClosed>::Point2ShapePredicate(
51  const TSurface& aSurface):
52  myS(aSurface)
53 {
54 }
55 
56 /**
57  * Copy constructor.
58  * @param other the object to clone.
59  */
60 template <typename TSurface, bool isUpward, bool isClosed>
61 inline
62 DGtal::functors::Point2ShapePredicate<TSurface,isUpward,isClosed>::Point2ShapePredicate(
63  const Point2ShapePredicate & other):
64  myS(other.myS)
65 {
66 }
67 
68 
69 template <typename TSurface, bool isUpward, bool isClosed>
70 inline
71 bool
72 DGtal::functors::Point2ShapePredicate<TSurface,isUpward,isClosed>
73 ::operator()(const Point& p) const
74 {
75  DGtal::functors::Point2ShapePredicateComparator<
76  Distance,
77  isUpward,
78  isClosed> theComparator;
79 
80  return theComparator(myS.signedDistance(p),0);
81 }
82 
83 
84 
85 ///////////////////////////////////////////////////////////////////////////////
86 // Interface - public :
87 
88 template <typename TSurface, bool isUpward, bool isClosed>
89 inline
90 void
91 DGtal::functors::Point2ShapePredicate<TSurface,isUpward,isClosed>
92 ::selfDisplay ( std::ostream & out ) const
93 {
94  out << "[Point2ShapePredicate] :\n";
95  myS.selfDisplay(out);
96  out << "\n";
97  std::string orientation = (isUpward)?
98  "upward oriented":"downward oriented";
99  std::string closure = (isClosed)?
100  "closed":"open";
101  out << "(" << orientation << ", " << closure << ")\n";
102 
103 }
104 
105 ///////////////////////////////////////////////////////////////////////////////
106 // Implementation of inline functions //
107 
108 template <typename TSurface, bool isUpward, bool isClosed>
109 inline
110 std::ostream&
111 DGtal::operator<< ( std::ostream & out,
112  const DGtal::functors::Point2ShapePredicate<TSurface,isUpward,isClosed> & object )
113 {
114  object.selfDisplay( out );
115  return out;
116 }
117