gstlearn  1.0.0
CCC
PolyLine2D Class Reference

#include <PolyLine2D.hpp>

Inheritance diagram for PolyLine2D:
AStringable ASerializable PolyElem

Public Member Functions

 PolyLine2D (const VectorDouble &x=VectorDouble(), const VectorDouble &y=VectorDouble())
 
 PolyLine2D (const PolyLine2D &m)
 
PolyLine2Doperator= (const PolyLine2D &m)
 
virtual ~PolyLine2D ()
 
virtual String toString (const AStringFormat *strfmt=nullptr) const override
 Interface of AStringable. More...
 
int getNPoints () const
 
void init (const VectorDouble &x, const VectorDouble &y)
 
const VectorDoublegetX () const
 
const VectorDoublegetY () const
 
double getX (int i) const
 
double getY (int i) const
 
VectorDouble getPoint (int i) const
 
double getXmin () const
 
double getYmin () const
 
double getXmax () const
 
double getYmax () const
 
void addPoint (double x, double y)
 
void setX (const VectorDouble &x)
 
void setY (const VectorDouble &y)
 
PolyPoint2D getPLIndex (const VectorDouble &xy0) const
 
double distanceBetweenPoints (double ap, double al, const VectorDouble &xy1, const VectorDouble &xy2) const
 
double distanceAlongPolyline (const PolyPoint2D &pldist1, const PolyPoint2D &pldist2) const
 
double angleAtPolyline (const PolyPoint2D &pldist, int nb_neigh=0) const
 
double distanceAtPolyline (const PolyPoint2D &pldist, const VectorDouble &target, int nb_neigh) const
 
- Public Member Functions inherited from AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (int level) const final
 
- Public Member Functions inherited from ASerializable
 ASerializable ()
 
 ASerializable (const ASerializable &r)
 
ASerializableoperator= (const ASerializable &r)
 
virtual ~ASerializable ()
 
bool deserialize (std::istream &is, bool verbose=true)
 
bool serialize (std::ostream &os, bool verbose=true) const
 
bool dumpToNF (const String &neutralFilename, bool verbose=false) const
 

Static Public Member Functions

static PolyLine2DcreateFromNF (const String &neutralFilename, bool verbose=true)
 
static PolyLine2Dcreate (const VectorDouble &x=VectorDouble(), const VectorDouble &y=VectorDouble())
 
- Static Public Member Functions inherited from ASerializable
static String buildFileName (int status, const String &filename, bool ensureDirExist=false)
 
static String getHomeDirectory (const String &sub="")
 
static String getWorkingDirectory ()
 
static String getTestData (const String &subdir, const String &filename)
 
static String getFileIdentity (const String &filename, bool verbose=false)
 
static void setContainerName (bool useDefault, const String &containerName="", bool verbose=false)
 
static void unsetContainerName ()
 
static void setPrefixName (const String &prefixName)
 
static void unsetPrefixName ()
 
static const StringgetContainerName ()
 
static const StringgetPrefixName ()
 
static bool createDirectory (const String &dir)
 
static String getExecDirectory ()
 
static String getDirectory (const String &path)
 

Protected Member Functions

virtual bool _deserialize (std::istream &is, bool verbose=false) override
 Interface for ASerializable. More...
 
virtual bool _serialize (std::ostream &os, bool verbose=false) const override
 
String _getNFName () const override
 
- Protected Member Functions inherited from ASerializable
bool _fileOpenWrite (const String &filename, std::ofstream &os, bool verbose=false) const
 
bool _fileOpenRead (const String &filename, std::ifstream &is, bool verbose=false) const
 

Private Member Functions

void _shiftPoint (const VectorDouble &xy1, const VectorDouble &xy2, double ratio, VectorDouble &xy0) const
 
void _getInterval (const PolyPoint2D &pldist, int nb_neigh, int *rfrom, int *rt0) const
 

Private Attributes

VectorDouble _x
 
VectorDouble _y
 

Additional Inherited Members

- Static Protected Member Functions inherited from ASerializable
static bool _commentWrite (std::ostream &os, const String &comment)
 
template<typename T >
static bool _recordWrite (std::ostream &os, const String &title, const T &val)
 
template<typename T >
static bool _recordWriteVec (std::ostream &os, const String &title, const VectorT< T > &vec)
 
template<typename T >
static bool _recordRead (std::istream &is, const String &title, T &val)
 
template<typename T >
static bool _recordReadVec (std::istream &is, const String &title, VectorT< T > &vec, int nvalues)
 
static bool _onlyBlanks (char *string)
 
static bool _tableRead (std::istream &is, const String &string, int ntab, double *tab)
 
static bool _tableWrite (std::ostream &os, const String &string, int ntab, const VectorDouble &tab)
 

Constructor & Destructor Documentation

◆ PolyLine2D() [1/2]

PolyLine2D::PolyLine2D ( const VectorDouble x = VectorDouble(),
const VectorDouble y = VectorDouble() 
)

◆ PolyLine2D() [2/2]

PolyLine2D::PolyLine2D ( const PolyLine2D m)

◆ ~PolyLine2D()

PolyLine2D::~PolyLine2D ( )
virtual

Member Function Documentation

◆ _deserialize()

bool PolyLine2D::_deserialize ( std::istream &  is,
bool  verbose = false 
)
overrideprotectedvirtual

Interface for ASerializable.

Deserialization (by sample)

Parameters
isInput stream
verboseVerbose flag
Returns

Implements ASerializable.

Reimplemented in PolyElem.

◆ _getInterval()

void PolyLine2D::_getInterval ( const PolyPoint2D pldist,
int  nb_neigh,
int *  rfrom,
int *  rt0 
) const
private

◆ _getNFName()

String PolyLine2D::_getNFName ( ) const
inlineoverrideprotectedvirtual

Implements ASerializable.

Reimplemented in PolyElem.

◆ _serialize()

bool PolyLine2D::_serialize ( std::ostream &  os,
bool  verbose = false 
) const
overrideprotectedvirtual

Serialization (by Point rather than by Coordinate) This is maintained for all classes using this interface for serialization

Parameters
osOutput Stream
verboseVerbose flag
Returns

Implements ASerializable.

Reimplemented in PolyElem.

◆ _shiftPoint()

void PolyLine2D::_shiftPoint ( const VectorDouble xy1,
const VectorDouble xy2,
double  ratio,
VectorDouble xy0 
) const
private

Shift a point along a segment

Parameters
[in]xy1Coordinates of the first point
[in]xy2Coordinates of the second point
[in]ratioShifting ratio
[out]xy0Shifted point
Remarks
'ratio' varies between 0 and 1
When 'ratio' =0, (x0,y0) coincides with (x1,y1)
When 'ratio'>=1, (x0,y0) coincides with (x2,y2)

◆ addPoint()

void PolyLine2D::addPoint ( double  x,
double  y 
)

◆ angleAtPolyline()

double PolyLine2D::angleAtPolyline ( const PolyPoint2D pldist,
int  nb_neigh = 0 
) const

◆ create()

PolyLine2D * PolyLine2D::create ( const VectorDouble x = VectorDouble(),
const VectorDouble y = VectorDouble() 
)
static

◆ createFromNF()

PolyLine2D * PolyLine2D::createFromNF ( const String neutralFilename,
bool  verbose = true 
)
static

◆ distanceAlongPolyline()

double PolyLine2D::distanceAlongPolyline ( const PolyPoint2D pldist1,
const PolyPoint2D pldist2 
) const

Find the shortest distance between two points (x1,y1) and (x2,y2) which belong to the current polyline

Returns
Minimum distance
Parameters
[in]pldist1First PolyPoint2D structure
[in]pldist2Second PolyPoint2D structure

◆ distanceAtPolyline()

double PolyLine2D::distanceAtPolyline ( const PolyPoint2D pldist,
const VectorDouble target,
int  nb_neigh 
) const

◆ distanceBetweenPoints()

double PolyLine2D::distanceBetweenPoints ( double  ap,
double  al,
const VectorDouble xy1,
const VectorDouble xy2 
) const

Find the shortest distance between two points (x1,y1) and (x2,y2) passing through a polyline

Returns
Minimum distance
Parameters
[in]apCoefficient applied to the projected distances
[in]alCoefficient applied to the distance along line
[in]xy1Coordinates of the first point
[in]xy2Coordinates of the second point

◆ getNPoints()

int PolyLine2D::getNPoints ( ) const
inline

◆ getPLIndex()

PolyPoint2D PolyLine2D::getPLIndex ( const VectorDouble xy0) const

Returns the point of the PolyLine located at shortest distance from Target

Returns
PolyPoint2D structure
Parameters
[in]xy0Coordinates of the target point

◆ getPoint()

VectorDouble PolyLine2D::getPoint ( int  i) const

◆ getX() [1/2]

const VectorDouble& PolyLine2D::getX ( ) const
inline

◆ getX() [2/2]

double PolyLine2D::getX ( int  i) const
inline

◆ getXmax()

double PolyLine2D::getXmax ( ) const
inline

◆ getXmin()

double PolyLine2D::getXmin ( ) const
inline

◆ getY() [1/2]

const VectorDouble& PolyLine2D::getY ( ) const
inline

◆ getY() [2/2]

double PolyLine2D::getY ( int  i) const
inline

◆ getYmax()

double PolyLine2D::getYmax ( ) const
inline

◆ getYmin()

double PolyLine2D::getYmin ( ) const
inline

◆ init()

void PolyLine2D::init ( const VectorDouble x,
const VectorDouble y 
)

◆ operator=()

PolyLine2D & PolyLine2D::operator= ( const PolyLine2D m)

◆ setX()

void PolyLine2D::setX ( const VectorDouble x)
inline

◆ setY()

void PolyLine2D::setY ( const VectorDouble y)
inline

◆ toString()

String PolyLine2D::toString ( const AStringFormat strfmt = nullptr) const
overridevirtual

Interface of AStringable.

Reimplemented from AStringable.

Reimplemented in PolyElem.

Member Data Documentation

◆ _x

VectorDouble PolyLine2D::_x
private

◆ _y

VectorDouble PolyLine2D::_y
private

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