libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
crn::Stroke Class Reference

A list of points. More...

#include <CRNStroke.h>

+ Inheritance diagram for crn::Stroke:
+ Collaboration diagram for crn::Stroke:

Public Types

using datatype = std::vector< Point2DInt >
 
using iterator = datatype::iterator
 
using const_iterator = datatype::const_iterator
 

Public Member Functions

 Stroke ()
 Default constructor. More...
 
virtual ~Stroke () override
 Destructor. More...
 
 Stroke (const Stroke &other)
 
Strokeoperator= (const Stroke &other)
 
 Stroke (Stroke &&)=default
 
Strokeoperator= (Stroke &&)=default
 
void AddPoint (const Point2DInt &p)
 Adds a point to the stroke. More...
 
void MergeAtEnd (const Stroke &str)
 Adds a batch of points directly at the end of the stroke. More...
 
void MergeWithXInterpolation (const Stroke &str, unsigned int step=1)
 Adds a batch of points at their original position and adds points to interpolate. More...
 
size_t GetNbPoints () const noexcept
 Returns the number of points in the stroke. More...
 
Point2DIntGetPoint (size_t index)
 Returns a reference to a point. More...
 
const Point2DIntGetPoint (size_t index) const
 Returns a reference to a point. More...
 
Point2DIntoperator[] (size_t index)
 Returns a reference to a point (fast and unsafe). More...
 
const Point2DIntoperator[] (size_t index) const
 Returns a reference to a point (fast and unsafe). More...
 
double GetFirstYAtX (double x) const
 Returns the ordinate of the first point with abscissa = x. More...
 
Rect GetBBox () const
 Returns the bounding box using integer values. More...
 
Stroke MakeIntersection (const Rect &rect) const
 Creates a new stroke that is the intersection of the stroke with a rectangle. More...
 
Stroke MakeFirstIntersection (const Rect &rect) const
 Creates a new stroke that is the first intersection of the stroke with a rectangle. More...
 
iterator begin ()
 Returns a new iterator on the first point of the stroke. More...
 
iterator end ()
 Returns a new iterator after the last point of the stroke. More...
 
const_iterator begin () const
 Returns a new const_iterator on the first point of the stroke. More...
 
const_iterator end () const
 Returns a new const_iterator after the last point of the stroke. More...
 
const_iterator cbegin () const
 Returns a new const_iterator on the first point of the stroke. More...
 
const_iterator cend () const
 Returns a new const_iterator after the last point of the stroke. More...
 
void Deserialize (xml::Element &el)
 Initializes the object from an XML element. More...
 
xml::Element Serialize (xml::Element &parent) const
 Dumps the object to an XML element. More...
 
- Public Member Functions inherited from crn::Object
virtual ~Object ()=default
 

Detailed Description

A list of points.

A stroke that is an ordered set of Point2DInt.

Author
Yann LEYDIER
Date
November 2008
Version
0.1

Definition at line 47 of file CRNStroke.h.

Member Typedef Documentation

using crn::Stroke::const_iterator = datatype::const_iterator

Definition at line 97 of file CRNStroke.h.

using crn::Stroke::datatype = std::vector<Point2DInt>

Definition at line 50 of file CRNStroke.h.

using crn::Stroke::iterator = datatype::iterator

Definition at line 92 of file CRNStroke.h.

Constructor & Destructor Documentation

Stroke::Stroke ( )
default

Default constructor.

Default constructor

Stroke::~Stroke ( )
overridevirtualdefault

Destructor.

Destructor

Stroke::Stroke ( const Stroke other)

Definition at line 40 of file CRNStroke.cpp.

crn::Stroke::Stroke ( Stroke &&  )
default

Member Function Documentation

void Stroke::AddPoint ( const Point2DInt p)

Adds a point to the stroke.

Adds a point to the stroke

Parameters
[in]pthe point to add

Definition at line 107 of file CRNStroke.cpp.

iterator crn::Stroke::begin ( )
inline

Returns a new iterator on the first point of the stroke.

Definition at line 94 of file CRNStroke.h.

const_iterator crn::Stroke::begin ( ) const
inline

Returns a new const_iterator on the first point of the stroke.

Definition at line 99 of file CRNStroke.h.

const_iterator crn::Stroke::cbegin ( ) const
inline

Returns a new const_iterator on the first point of the stroke.

Definition at line 103 of file CRNStroke.h.

const_iterator crn::Stroke::cend ( ) const
inline

Returns a new const_iterator after the last point of the stroke.

Definition at line 105 of file CRNStroke.h.

void Stroke::Deserialize ( xml::Element el)

Initializes the object from an XML element.

Initializes the object from an XML element. Unsafe.

Exceptions
ExceptionInvalidArgumentnot a Stroke
ExceptionDomainCDATA not found
Parameters
[in]elthe XML element to read

Definition at line 63 of file CRNStroke.cpp.

iterator crn::Stroke::end ( )
inline

Returns a new iterator after the last point of the stroke.

Definition at line 96 of file CRNStroke.h.

const_iterator crn::Stroke::end ( ) const
inline

Returns a new const_iterator after the last point of the stroke.

Definition at line 101 of file CRNStroke.h.

Rect Stroke::GetBBox ( ) const

Returns the bounding box using integer values.

Returns the bounding box using integer values

Returns
a int rectangle

Definition at line 257 of file CRNStroke.cpp.

double Stroke::GetFirstYAtX ( double  x) const

Returns the ordinate of the first point with abscissa = x.

Returns the ordinate of the first point with abscissa = x

Exceptions
ExceptionDomaincannot reach abscissa
Parameters
[in]xthe abscissa
Returns
the ordinate or NaN if not found

Definition at line 242 of file CRNStroke.cpp.

size_t crn::Stroke::GetNbPoints ( ) const
inlinenoexcept

Returns the number of points in the stroke.

Definition at line 71 of file CRNStroke.h.

Point2DInt & Stroke::GetPoint ( size_t  index)

Returns a reference to a point.

Returns a reference to a point

Exceptions
ExceptionDomainindex out of range
Parameters
[in]indexthe index of the point
Returns
a pointer to the point or nullptr

Definition at line 208 of file CRNStroke.cpp.

const Point2DInt & Stroke::GetPoint ( size_t  index) const

Returns a reference to a point.

Returns a reference to a point

Exceptions
ExceptionDomainindex out of range
Parameters
[in]indexthe index of the point
Returns
a pointer to the point or nullptr

Definition at line 225 of file CRNStroke.cpp.

Stroke Stroke::MakeFirstIntersection ( const Rect rect) const

Creates a new stroke that is the first intersection of the stroke with a rectangle.

Creates a new stroke that is the first intersection of the stroke with a rectangle

Parameters
[in]rectthe bounding box of the resulting stroke
Returns
a new stroke

Definition at line 306 of file CRNStroke.cpp.

Stroke Stroke::MakeIntersection ( const Rect rect) const

Creates a new stroke that is the intersection of the stroke with a rectangle.

Creates a new stroke that is the intersection of the stroke with a rectangle

Parameters
[in]rectthe bounding box of the resulting stroke
Returns
a new stroke

Definition at line 286 of file CRNStroke.cpp.

void Stroke::MergeAtEnd ( const Stroke str)

Adds a batch of points directly at the end of the stroke.

Adds a batch of points directly at the end of the stroke. The first point of the merged stroke is propped on the last point of the current stroke.

Exceptions
ExceptionInvalidArgumentinvalid stroke
Parameters
[in]strthe stoke to append

Definition at line 121 of file CRNStroke.cpp.

void Stroke::MergeWithXInterpolation ( const Stroke str,
unsigned int  step = 1 
)

Adds a batch of points at their original position and adds points to interpolate.

Adds a batch of points at their original position and adds points to interpolate

Exceptions
ExceptionInvalidArgumentnull or invalid stroke
ExceptionDomainnull step
Parameters
[in]strthe stoke to append
[in]stepthe step of the interpolation

Definition at line 152 of file CRNStroke.cpp.

Stroke & Stroke::operator= ( const Stroke other)

Definition at line 47 of file CRNStroke.cpp.

Stroke& crn::Stroke::operator= ( Stroke &&  )
default
Point2DInt& crn::Stroke::operator[] ( size_t  index)
inline

Returns a reference to a point (fast and unsafe).

Definition at line 77 of file CRNStroke.h.

const Point2DInt& crn::Stroke::operator[] ( size_t  index) const
inline

Returns a reference to a point (fast and unsafe).

Definition at line 79 of file CRNStroke.h.

xml::Element Stroke::Serialize ( xml::Element parent) const

Dumps the object to an XML element.

Dumps the object to an XML element. Unsafe.

Parameters
[in]parentthe element in which the new element will be stored
Returns
the newly created element

Definition at line 87 of file CRNStroke.cpp.


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