gstlearn  0.2.1
Geostatistics & Machine Learning toolbox
Polygons Class Reference

#include <Polygons.hpp>

Inheritance diagram for Polygons:
AStringable ASerializable

Public Member Functions

 Polygons ()
 
 Polygons (const Polygons &r)
 
Polygonsoperator= (const Polygons &r)
 
virtual ~Polygons ()
 
virtual String toString (const AStringFormat *strfmt=nullptr) const override
 Interface to AStringable. More...
 
int resetFromDb (const Db *db, double dilate=0., bool verbose=false)
 
int resetFromCSV (const String &filename, const CSVformat &csv, int verbose=false, int ncol_max=-1, int nrow_max=-1)
 
int getPolySetNumber () const
 
void addPolySet (const PolySet &polyset)
 
const std::vector< PolySet > & getPolySets () const
 
const PolySet getPolySet (int ipol) const
 
PolySet getClosedPolySet (int ipol) const
 
const VectorDouble getX (int ipol) const
 
const VectorDouble getY (int ipol) const
 
void setX (int ipol, const VectorDouble &x)
 
void setY (int ipol, const VectorDouble &y)
 
void getExtension (double *xmin, double *xmax, double *ymin, double *ymax) const
 
double getSurface () const
 
bool inside (double xx, double yy, double zz=TEST, bool flag_nested=false)
 
- 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 Polygonscreate ()
 
static PolygonscreateFromNF (const String &neutralFilename, bool verbose=false)
 
static PolygonscreateFromCSV (const String &filename, const CSVformat &csv=CSVformat(), int verbose=false, int ncol_max=-1, int nrow_max=-1)
 
static PolygonscreateFromDb (const Db *db, double dilate=0., bool verbose=false)
 
- Static Public Member Functions inherited from ASerializable
static String buildFileName (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=String(), 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

PolySet _extractFromTab (int ideb, int ifin, int ncol, const VectorDouble &tab)
 
bool _isValidPolySetIndex (int ipol) const
 
VectorInt _getHullIndices (const VectorDouble &x, const VectorDouble &y) const
 
void _getExtend (double ext, VectorDouble &x, VectorDouble &y, int nsect=16)
 
int _buildHull (const Db *db, double dilate, bool verbose)
 
void _polygonHullPrint (const VectorInt &index, const VectorDouble &x, const VectorDouble &y) const
 

Private Attributes

std::vector< PolySet_polysets
 

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

◆ Polygons() [1/2]

Polygons::Polygons ( )

◆ Polygons() [2/2]

Polygons::Polygons ( const Polygons r)

◆ ~Polygons()

Polygons::~Polygons ( )
virtual

Member Function Documentation

◆ _buildHull()

int Polygons::_buildHull ( const Db db,
double  dilate,
bool  verbose 
)
private

Create a polygon from the convex hull of active samples

Returns
Error returned code
Parameters
[in]dbdescriptor of the Db serving for convex hull calculation
[in]dilateRadius of the dilation
[in]verboseVerbose flag

◆ _deserialize()

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

Interface for ASerializable.

Implements ASerializable.

◆ _extractFromTab()

PolySet Polygons::_extractFromTab ( int  ideb,
int  ifin,
int  ncol,
const VectorDouble tab 
)
private

◆ _getExtend()

void Polygons::_getExtend ( double  ext,
VectorDouble x,
VectorDouble y,
int  nsect = 16 
)
private

Create a set of fictitious samples obtained by dilating the initial ones

Parameters
extDilation distance
xVector of X-coordinates or initial samples
yVector of Y-coordinates of initial samples
nsectNumber of discretization points for dilation

◆ _getHullIndices()

VectorInt Polygons::_getHullIndices ( const VectorDouble x,
const VectorDouble y 
) const
private

Create a polygon from the convex hull of active samples

Returns
Error returned code
Parameters
[in]xVector of X coordinates
[in]yVector of Y coordinates

◆ _getNFName()

String Polygons::_getNFName ( ) const
inlineoverrideprotectedvirtual

Implements ASerializable.

◆ _isValidPolySetIndex()

bool Polygons::_isValidPolySetIndex ( int  ipol) const
private

◆ _polygonHullPrint()

void Polygons::_polygonHullPrint ( const VectorInt index,
const VectorDouble x,
const VectorDouble y 
) const
private

◆ _serialize()

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

Implements ASerializable.

◆ addPolySet()

void Polygons::addPolySet ( const PolySet polyset)

◆ create()

Polygons * Polygons::create ( )
static

◆ createFromCSV()

Polygons * Polygons::createFromCSV ( const String filename,
const CSVformat csv = CSVformat(),
int  verbose = false,
int  ncol_max = -1,
int  nrow_max = -1 
)
static

◆ createFromDb()

Polygons * Polygons::createFromDb ( const Db db,
double  dilate = 0.,
bool  verbose = false 
)
static

◆ createFromNF()

Polygons * Polygons::createFromNF ( const String neutralFilename,
bool  verbose = false 
)
static

Create a Polygon by loading the contents of a Neutral File

Parameters
neutralFilenameName of the Neutral File
verboseVerbose flag
Returns

◆ getClosedPolySet()

PolySet Polygons::getClosedPolySet ( int  ipol) const

◆ getExtension()

void Polygons::getExtension ( double *  xmin,
double *  xmax,
double *  ymin,
double *  ymax 
) const

◆ getPolySet()

const PolySet Polygons::getPolySet ( int  ipol) const

◆ getPolySetNumber()

int Polygons::getPolySetNumber ( ) const
inline

◆ getPolySets()

const std::vector<PolySet>& Polygons::getPolySets ( ) const
inline

◆ getSurface()

double Polygons::getSurface ( ) const

◆ getX()

const VectorDouble Polygons::getX ( int  ipol) const

◆ getY()

const VectorDouble Polygons::getY ( int  ipol) const

◆ inside()

bool Polygons::inside ( double  xx,
double  yy,
double  zz = TEST,
bool  flag_nested = false 
)

Check if one point belongs to a Polygons

Returns
1 if the point belongs to the Polygons; 0 otherwise
Parameters
[in]xxcoordinate of the point along X
[in]yycoordinate of the point along Y
[in]zzcoordinate of the point along Z (or TEST)
[in]flag_nestedOption for nested polysets (see details)
Remarks
If flag_nested=TRUE, a sample is masked off if the number of
polysets to which it belongs is odd
If flag_nested=FALSE, a sample is masked off as soon as it
belongs to one PolySet

◆ operator=()

Polygons & Polygons::operator= ( const Polygons r)

◆ resetFromCSV()

int Polygons::resetFromCSV ( const String filename,
const CSVformat csv,
int  verbose = false,
int  ncol_max = -1,
int  nrow_max = -1 
)

Reset the Polygon from a CSV file

Parameters
filenameFilename
csvCSV characteristics
verboseVerbose flag
ncol_maxMaximum number of columns
nrow_maxMaximum number of rows
Returns

◆ resetFromDb()

int Polygons::resetFromDb ( const Db db,
double  dilate = 0.,
bool  verbose = false 
)

◆ setX()

void Polygons::setX ( int  ipol,
const VectorDouble x 
)

◆ setY()

void Polygons::setY ( int  ipol,
const VectorDouble y 
)

◆ toString()

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

Interface to AStringable.

Reimplemented from AStringable.

Member Data Documentation

◆ _polysets

std::vector<PolySet> Polygons::_polysets
private

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