DGtal  0.9.3
Functions
testHalfPlane.cpp File Reference
#include <cstdio>
#include <cmath>
#include <fstream>
#include <vector>
#include <iostream>
#include <iterator>
#include "DGtal/base/Common.h"
#include "DGtal/base/Exceptions.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/DomainPredicate.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/shapes/fromPoints/StraightLineFrom2Points.h"
#include "DGtal/shapes/fromPoints/Point2ShapePredicate.h"
Include dependency graph for testHalfPlane.cpp:

Go to the source code of this file.

Functions

int main (int, char **)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2010/07/02

This file is part of the DGtal library

Definition in file testHalfPlane.cpp.

Function Documentation

◆ main()

int main ( int  ,
char **   
)

[HalfPlaneTypedefUpClosed]

[HalfPlaneTypedefUpClosed]

[HalfPlaneUsage]

[HalfPlaneUsage]

Definition at line 62 of file testHalfPlane.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

63 {
64 
65 
66 
67  typedef int Coordinate;
69  typedef StraightLineFrom2Points<Point> StraightLine;
70 
71  Point p(0,0);
72  Point q(5,2);
73  Point r1(2,0);
74  Point r2(0,2);
75  Point r3(10,4);
76 
77  StraightLine line(p,q);
78 
79 
80  //halfplane upward oriented and closed
82  typedef Point2ShapePredicate<StraightLine,true,true> UpClosedHalfPlane;
84 
85  //halfplane upward oriented and open
86  typedef Point2ShapePredicate<StraightLine,true,false> UpOpenHalfPlane;
87  //halfplane downward oriented and closed
88  typedef Point2ShapePredicate<StraightLine,false,true> DownClosedHalfPlane;
89 
90  //Location
91  trace.beginBlock("Creation of a halfplane and test some points");
92 
93  std::string res;
94 
95  trace.info() << "created line:" << std::endl;
96  trace.info() << line << std::endl;
97 
99  //line is an instance of StraightLine
100  UpClosedHalfPlane hp(line);
101  trace.info() << hp << std::endl;
102  trace.info() << "Does " << r1 << " belongs to hp (no)?" << std::endl;
103  res = hp(r1)?"yes":"no";
104  trace.info() << res << std::endl;
106 
107  trace.info() << "Does " << r2 << " belongs to hp (yes)?" << std::endl;
108  res = hp(r2)?"yes":"no";
109  trace.info() << res << std::endl;
110 
111  trace.info() << "Does " << r3 << " belongs to hp (yes)?" << std::endl;
112  res = hp(r3)?"yes":"no";
113  trace.info() << res << std::endl;
114 
115 
116  UpOpenHalfPlane hp2(line);
117  trace.info() << hp2 << std::endl;
118 
119  trace.info() << "Does " << r1 << " belongs to hp2 (no)?" << std::endl;
120  res = hp2(r1)?"yes":"no";
121  trace.info() << res << std::endl;
122 
123  trace.info() << "Does " << r2 << " belongs to hp2 (yes)?" << std::endl;
124  res = hp2(r2)?"yes":"no";
125  trace.info() << res << std::endl;
126 
127  trace.info() << "Does " << r3 << " belongs to hp2 (no)?" << std::endl;
128  res = hp2(r3)?"yes":"no";
129  trace.info() << res << std::endl;
130 
131  DownClosedHalfPlane hp3(line);
132  trace.info() << hp3 << std::endl;
133 
134  trace.info() << "Does " << r1 << " belongs to hp3 (yes)?" << std::endl;
135  res = hp3(r1)?"yes":"no";
136  trace.info() << res << std::endl;
137 
138  trace.info() << "Does " << r2 << " belongs to hp3 (no)?" << std::endl;
139  res = hp3(r2)?"yes":"no";
140  trace.info() << res << std::endl;
141 
142  trace.info() << "Does " << r3 << " belongs to hp3 (yes)?" << std::endl;
143  res = hp3(r3)?"yes":"no";
144  trace.info() << res << std::endl;
145 
146  trace.endBlock();
147 
148 
149  return 0;
150 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
Aim: Represents a straight line uniquely defined by two 2D points and that is able to return for any ...
double endBlock()
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
Aim: Predicate returning &#39;true&#39; iff a given point is in the &#39;interior&#39; of a given shape...
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()