DGtal  0.9.3
DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed > Class Template Reference

#include <DGtal/shapes/fromPoints/Point2ShapePredicate.h>

## Public Types

typedef TSurface::Point Point

typedef TSurface::Distance Distance

## Public Member Functions

Point2ShapePredicate (const TSurface &aSurface)

Point2ShapePredicate (const Point2ShapePredicate &other)

bool operator() (const Point &p) const

void selfDisplay (std::ostream &out) const

~Point2ShapePredicate ()

TSurface myS

## Detailed Description

### template<typename TSurface, bool isUpward, bool isClosed> class DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >

Aim: Predicate returning 'true' iff a given point is in the 'interior' of a given shape, 'false' otherwise.

Template Parameters
 TSurface a type that is a model of COrientableHypersurface. Must separate the space in two disjoints parts (the 'interior' and the 'exterior') and must be able to return for any given point (of type TSurface::Point) the signed distance to itself (of type TSurface::Distance) by a method called signedDistance() isUpward a bool for the orientation ('true' means that the interior is the set of points of positive distance) isClosed a bool for the closure ('true' means that the surface is included)

For instance, in 2d, you can define four shapes from one straight line of equation $$y = ax + b$$:

• the set $$\{(x,y) | y > ax + b \}$$
• $$\{(x,y) | y \geq ax + b \}$$
• $$\{(x,y) | y < ax + b \}$$
• $$\{(x,y) | y \leq ax + b \}$$

The second set can be defined as follows:

typedef Point2ShapePredicate<StraightLine,true,true> UpClosedHalfPlane;

Then, you can create and use your half-plane as shown below:

//line is an instance of StraightLine
UpClosedHalfPlane hp(line);
trace.info() << hp << std::endl;
trace.info() << "Does " << r1 << " belongs to hp (no)?" << std::endl;
res = hp(r1)?"yes":"no";
trace.info() << res << std::endl;

You should get:

[StraightLine] passing through:
[PointVector] {0, 0}[PointVector] {5, 2}
(upward oriented, closed)
Does [PointVector] {2, 0} belongs to hp (no)?
no

This class is a model of concepts::CPointPredicate.

See also
testHalfPlane.cpp

Definition at line 95 of file Point2ShapePredicate.h.

## ◆ Distance

template<typename TSurface, bool isUpward, bool isClosed>
 typedef TSurface::Distance DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::Distance

Definition at line 101 of file Point2ShapePredicate.h.

## ◆ Point

template<typename TSurface, bool isUpward, bool isClosed>
 typedef TSurface::Point DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::Point

Definition at line 100 of file Point2ShapePredicate.h.

## ◆ Point2ShapePredicate() [1/2]

template<typename TSurface, bool isUpward, bool isClosed>
 DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::Point2ShapePredicate ( const TSurface & aSurface )

Constructor.

Parameters
 aSurface any Surface

## ◆ Point2ShapePredicate() [2/2]

template<typename TSurface, bool isUpward, bool isClosed>
 DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::Point2ShapePredicate ( const Point2ShapePredicate< TSurface, isUpward, isClosed > & other )

Copy constructor.

Parameters
 other the object to clone.

## ◆ ~Point2ShapePredicate()

template<typename TSurface, bool isUpward, bool isClosed>
 DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::~Point2ShapePredicate ( )

Destructor. Does nothing

## ◆ operator()()

template<typename TSurface, bool isUpward, bool isClosed>
 bool DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::operator() ( const Point & p ) const
Parameters
 p any point.
Returns
true iff p is in the interior of the shape.

## ◆ selfDisplay()

template<typename TSurface, bool isUpward, bool isClosed>
 void DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::selfDisplay ( std::ostream & out ) const

Writes/Displays the object on an output stream.

Parameters
 out the output stream where the object is written.

## ◆ myS

template<typename TSurface, bool isUpward, bool isClosed>
 TSurface DGtal::functors::Point2ShapePredicate< TSurface, isUpward, isClosed >::myS
private

The surface with respect to the points have to be located

Definition at line 141 of file Point2ShapePredicate.h.

The documentation for this class was generated from the following file: