DGtal  1.2.0
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 "DGtalCatch.h"
Include dependency graph for testHalfPlane.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("HalfplaneUnit tests")
 

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

◆ TEST_CASE()

TEST_CASE ( "HalfplaneUnit tests"  )

[HalfPlaneTypedefUpClosed]

[HalfPlaneTypedefUpClosed]

[HalfPlaneUsage]

[HalfPlaneUsage]

Definition at line 56 of file testHalfPlane.cpp.

57 {
58  typedef int Coordinate;
60  typedef StraightLineFrom2Points<Point> StraightLine;
61 
62  Point p(0,0);
63  Point q(5,2);
64  Point r1(2,0);
65  Point r2(0,2);
66  Point r3(10,4);
67  StraightLine line(p,q);
68 
69  //halfplane upward oriented and closed
71  typedef Point2ShapePredicate<StraightLine,true,true> UpClosedHalfPlane;
73 
74  //halfplane upward oriented and open
75  typedef Point2ShapePredicate<StraightLine,true,false> UpOpenHalfPlane;
76  //halfplane downward oriented and closed
77  typedef Point2ShapePredicate<StraightLine,false,true> DownClosedHalfPlane;
78 
79  //Location
80  trace.beginBlock("Creation of a halfplane and test some points");
81  std::string res;
82  trace.info() << "created line:" << std::endl;
83  trace.info() << line << std::endl;
84 
86  //line is an instance of StraightLine
87  UpClosedHalfPlane hp(line);
88  trace.info() << hp << std::endl;
89  trace.info() << "Does " << r1 << " belongs to hp (no)?" << std::endl;
90  REQUIRE( !hp(r1) );
92  REQUIRE(hp(r2));
93  REQUIRE(hp(r3));
94 
95 
96  UpOpenHalfPlane hp2(line);
97  REQUIRE(! hp2(r1));
98  REQUIRE(hp2(r2));
99  REQUIRE( ! hp2(r3) );
100 
101  DownClosedHalfPlane hp3(line);
102  REQUIRE(hp3(r1));
103  REQUIRE(!hp3(r2));
104  REQUIRE(hp3(r3));
105 }
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Aim: Represents a straight line uniquely defined by two 2D points and that is able to return for any ...
void beginBlock(const std::string &keyword="")
std::ostream & info()
Trace trace
Definition: Common.h:154
Struct representing a 2D point.
Definition: Point.h:27
MyPointD Point
Definition: testClone2.cpp:383
REQUIRE(domain.isInside(aPoint))

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