SFCGAL  1.3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SFCGAL::Geometry Class Referenceabstract

OGC/SFA based Geometry abstract class. More...

#include <Geometry.h>

Inheritance diagram for SFCGAL::Geometry:
SFCGAL::GeometryCollection SFCGAL::LineString SFCGAL::Point SFCGAL::Solid SFCGAL::Surface SFCGAL::MultiLineString SFCGAL::MultiPoint SFCGAL::MultiPolygon SFCGAL::MultiSolid SFCGAL::Polygon SFCGAL::PolyhedralSurface SFCGAL::Triangle SFCGAL::TriangulatedSurface

Public Member Functions

virtual ~Geometry ()
 
virtual Geometryclone () const =0
 Get a deep copy of the geometry. More...
 
virtual std::string geometryType () const =0
 [OGC/SFA]returns the geometry type More...
 
virtual GeometryType geometryTypeId () const =0
 Returns a code corresponding to the type. More...
 
virtual int dimension () const =0
 [OGC/SFA]Dimension of the Geometry ( 0 : punctual, 1 : curve, ...) More...
 
virtual int coordinateDimension () const =0
 [OGC/SFA]returns the dimension of the coordinates More...
 
virtual bool isEmpty () const =0
 [OGC/SFA]test if geometry is empty More...
 
virtual bool is3D () const =0
 [OGC/SFA]test if geometry is 3d More...
 
virtual bool isMeasured () const =0
 [OGC/SFA]test if geometry is measured (has an m) More...
 
void forceValidityFlag (bool validity)
 Force the state of the validity flag. More...
 
bool hasValidityFlag () const
 Returns the validity flag. More...
 
std::string asText (const int &numDecimals=-1) const
 [OGC/SFA]returns the WKT string More...
 
Envelope envelope () const
 [OGC/SFA]Returns a polygon representing the BBOX of the geometry More...
 
virtual std::auto_ptr< Geometryboundary () const
 [OGC/SFA]Returns the boundary of the geometry More...
 
double distance (const Geometry &other) const
 Computes the distance to an other geometry. More...
 
double distance3D (const Geometry &other) const
 Computes the 3D distance to an other geometry. More...
 
void round (const long &scale=1)
 round the geometry with a corresponding scale factor More...
 
virtual size_t numGeometries () const
 [OGC/SFA]Gets the number of geometries in a collection of geometries More...
 
virtual const GeometrygeometryN (size_t const &n) const
 [OGC/SFA]Returns the n-th geometry More...
 
virtual GeometrygeometryN (size_t const &n)
 [OGC/SFA]Returns the n-th geometry More...
 
template<typename Derived >
bool is () const
 Tests if geometry is of "Derived" type given as template parameter. More...
 
template<typename Derived >
const Derived & as () const
 Downcast to a "Derived" class. More...
 
template<typename Derived >
Derived & as ()
 Downcast to a "Derived" class. More...
 
virtual void accept (GeometryVisitor &visitor)=0
 [visitor]dispatch visitor

  More...
 
virtual void accept (ConstGeometryVisitor &visitor) const =0
 [visitor]dispatch visitor

  More...
 
template<class Archive >
void serialize (Archive &, const unsigned int)
 Serializer

. More...

 

Protected Member Functions

 Geometry ()
 
 Geometry (const Geometry &)
 
const Geometryoperator= (const Geometry &)
 

Protected Attributes

bool validityFlag_
 

Detailed Description

OGC/SFA based Geometry abstract class.

Constructor & Destructor Documentation

SFCGAL::Geometry::~Geometry ( )
virtual
SFCGAL::Geometry::Geometry ( )
protected
SFCGAL::Geometry::Geometry ( const Geometry other)
protected

Member Function Documentation

template<typename Derived >
const Derived& SFCGAL::Geometry::as ( ) const
inline

Downcast to a "Derived" class.

Warning
performs check if boost assertions are enabled
Precondition
The cast must be doable
template<typename Derived >
Derived& SFCGAL::Geometry::as ( )
inline

Downcast to a "Derived" class.

Warning
performs check if boost assertions are enabled
Precondition
The cast must be doable
std::string SFCGAL::Geometry::asText ( const int &  numDecimals = -1) const

[OGC/SFA]returns the WKT string

Parameters
numDecimalsextension specify fix precision output
std::auto_ptr< Geometry > SFCGAL::Geometry::boundary ( ) const
virtual

[OGC/SFA]Returns the boundary of the geometry

virtual Geometry* SFCGAL::Geometry::clone ( ) const
pure virtual
virtual int SFCGAL::Geometry::coordinateDimension ( ) const
pure virtual

[OGC/SFA]returns the dimension of the coordinates

Precondition
suppose no mix of 2D/3D coordinates

Implemented in SFCGAL::Point, SFCGAL::Polygon, SFCGAL::Solid, SFCGAL::Triangle, SFCGAL::PolyhedralSurface, SFCGAL::LineString, SFCGAL::TriangulatedSurface, and SFCGAL::GeometryCollection.

virtual int SFCGAL::Geometry::dimension ( ) const
pure virtual

[OGC/SFA]Dimension of the Geometry ( 0 : punctual, 1 : curve, ...)

Warning
empty geometries provide the dimension corresponding to the object

Implemented in SFCGAL::Point, SFCGAL::Solid, SFCGAL::PolyhedralSurface, SFCGAL::LineString, SFCGAL::TriangulatedSurface, SFCGAL::GeometryCollection, and SFCGAL::Surface.

double SFCGAL::Geometry::distance ( const Geometry other) const

Computes the distance to an other geometry.

double SFCGAL::Geometry::distance3D ( const Geometry other) const

Computes the 3D distance to an other geometry.

Envelope SFCGAL::Geometry::envelope ( ) const

[OGC/SFA]Returns a polygon representing the BBOX of the geometry

Todo:
In order to adapt to 3D, would be better to define an "Envelope type", otherway would lead to Polygon and PolyhedralSurface
void SFCGAL::Geometry::forceValidityFlag ( bool  validity)

Force the state of the validity flag.

The validity flag allows to bypass validity checks If the flag is true, it means the geometry is considered valid If the flag is false, it means the validity state of the geometry is unknown The flag is only changed for this geometry and not the internal geometries.

See also
propagateValidityFlag
const Geometry & SFCGAL::Geometry::geometryN ( size_t const &  n) const
virtual

[OGC/SFA]Returns the n-th geometry

Warning
*this for Point, LineString, Polygon, Triangle

Reimplemented in SFCGAL::PolyhedralSurface, SFCGAL::TriangulatedSurface, and SFCGAL::GeometryCollection.

Geometry & SFCGAL::Geometry::geometryN ( size_t const &  n)
virtual

[OGC/SFA]Returns the n-th geometry

Warning
*this for Point, LineString, Polygon, Triangle

Reimplemented in SFCGAL::PolyhedralSurface, SFCGAL::TriangulatedSurface, and SFCGAL::GeometryCollection.

virtual std::string SFCGAL::Geometry::geometryType ( ) const
pure virtual
virtual GeometryType SFCGAL::Geometry::geometryTypeId ( ) const
pure virtual
bool SFCGAL::Geometry::hasValidityFlag ( ) const

Returns the validity flag.

template<typename Derived >
bool SFCGAL::Geometry::is ( ) const
inline

Tests if geometry is of "Derived" type given as template parameter.

Warning
not optimized (slow with dynamic_cast)
virtual bool SFCGAL::Geometry::is3D ( ) const
pure virtual

[OGC/SFA]test if geometry is 3d

Precondition
suppose no mix of 2D/3D coordinates

Implemented in SFCGAL::Point, SFCGAL::Polygon, SFCGAL::Solid, SFCGAL::Triangle, SFCGAL::PolyhedralSurface, SFCGAL::LineString, SFCGAL::TriangulatedSurface, and SFCGAL::GeometryCollection.

virtual bool SFCGAL::Geometry::isEmpty ( ) const
pure virtual
virtual bool SFCGAL::Geometry::isMeasured ( ) const
pure virtual

[OGC/SFA]test if geometry is measured (has an m)

Precondition
suppose no mix of M/!M points

Implemented in SFCGAL::Point, SFCGAL::Polygon, SFCGAL::Solid, SFCGAL::Triangle, SFCGAL::PolyhedralSurface, SFCGAL::LineString, SFCGAL::TriangulatedSurface, and SFCGAL::GeometryCollection.

size_t SFCGAL::Geometry::numGeometries ( ) const
virtual

[OGC/SFA]Gets the number of geometries in a collection of geometries

Warning
1 for Point, LineString, Polygon, Triangle

Reimplemented in SFCGAL::PolyhedralSurface, SFCGAL::TriangulatedSurface, and SFCGAL::GeometryCollection.

const Geometry& SFCGAL::Geometry::operator= ( const Geometry )
protected
void SFCGAL::Geometry::round ( const long &  scale = 1)

round the geometry with a corresponding scale factor

Parameters
scalethe scale factor (1 corresponds to the nearest integer, 1000 to a 0.001 tolerance)

Member Data Documentation

bool SFCGAL::Geometry::validityFlag_
protected