SFCGAL 2.3.0
SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties > Class Template Reference

[private]Represents the vertices and edges for a list of geometries. More...

#include <GeometryGraph.h>

Public Types

using vertex_properties = VertexProperties
 Vertex properties type.
using edge_properties = EdgeProperties
 Edge properties type.
typedef boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, vertex_properties, edge_properties > graph_t
 the wrapped graphEdgeProperties
typedef boost::graph_traits< graph_t >::vertex_descriptor vertex_descriptor
 Vertex descriptor type from boost graph.
typedef boost::graph_traits< graph_t >::edge_descriptor edge_descriptor
 Edge descriptor type from boost graph.
typedef boost::graph_traits< graph_t >::vertex_iterator vertex_iterator
 Vertex iterator type.
typedef boost::graph_traits< graph_t >::edge_iterator edge_iterator
 Edge iterator type.
using directed_edge_descriptor = std::pair<edge_descriptor, EdgeDirection>
 An edge descriptor, with a direction.
typedef boost::graph_traits< graph_t >::in_edge_iterator in_edge_iterator
 Incoming edge iterator type.
typedef boost::graph_traits< graph_t >::out_edge_iterator out_edge_iterator
 Outgoing edge iterator type.

Public Member Functions

size_t numVertices () const
 Returns the number of vertices.
std::pair< vertex_iterator, vertex_iterator > vertices () const
 Return vertex iterator pair.
vertex_descriptor addVertex (const vertex_properties &properties=vertex_properties())
 Add a vertex to the graph.
void removeVertex (const vertex_descriptor &vertex)
 Remove a vertex (and all its adjacent edges).
size_t numEdges () const
 Returns the number of edges.
std::pair< edge_iterator, edge_iterator > edges () const
 Return edge iterator pair.
edge_descriptor addEdge (const vertex_descriptor &source, const vertex_descriptor &target, const EdgeProperties &properties=EdgeProperties())
 Add an Edge to the Graph.
vertex_descriptor source (const edge_descriptor &edge) const
 Get the source vertex for an edge.
vertex_descriptor source (const edge_descriptor &edge, const EdgeDirection &direction) const
 Get the source vertex for an edge with direction.
vertex_descriptor source (const directed_edge_descriptor &edge) const
 Get the source vertex for a directed edge.
vertex_descriptor target (const edge_descriptor &edge) const
 Get the target vertex for an edge.
vertex_descriptor target (const edge_descriptor &edge, const EdgeDirection &direction) const
 Get the target vertex for an edge with direction.
vertex_descriptor target (const directed_edge_descriptor &edge) const
 Get the target vertex for a directed edge.
void removeEdge (const edge_descriptor &edge)
 Remove an edge.
std::vector< directed_edge_descriptor > edges (const vertex_descriptor &a, const vertex_descriptor &b) const
 Get edges from a to b and from b to a.
size_t degree (const vertex_descriptor &vertex) const
 Returns the degree of a vertex.
std::vector< edge_descriptor > inEdges (const vertex_descriptor &vertex)
 Get in edges for a vertex.
std::vector< edge_descriptor > outEdges (const vertex_descriptor &vertex) const
 Get out edges for a vertex.
std::vector< directed_edge_descriptor > inOutEdges (const vertex_descriptor &vertex) const
 Get in/out edges for a vertex.
std::set< vertex_descriptor > adjacentVertices (const vertex_descriptor &vertex, bool withReverseDirection=true)
 Returns the list of the adjacent vertices using both DIRECT and REVERSE direction.
bool areOpposite (const edge_descriptor &a, const edge_descriptor &b) const
 Indicates if edges are opposite.
bool areParallel (const edge_descriptor &a, const edge_descriptor &b) const
 Indicates if edges are parallel.
void reverse (std::vector< edge_descriptor > &edges)
 Revert the order of a list of edges.
const vertex_properties & operator[] (const vertex_descriptor &vertex) const
 Returns the VertexProperties attached to a Vertex.
vertex_properties & operator[] (const vertex_descriptor &vertex)
 Returns the VertexProperties attached to a Vertex.
const edge_properties & operator[] (const edge_descriptor &edge) const
 Returns the EdgeProperties attached to an Edge.
edge_properties & operator[] (const edge_descriptor &edge)
 Returns the EdgeProperties attached to an Edge.
graph_t & graph ()
 Returns the wrapped boost::graph.
const graph_t & graph () const
 Returns the wrapped boost::graph.
 operator graph_t & (void)
 implicit cast to the wrapped boost graph in order to keep boost graph interface
 operator const graph_t & (void) const
 implicit cast to the wrapped boost graph in order to keep boost graph interface

Detailed Description

template<typename VertexProperties, typename EdgeProperties>
class SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >

[private]Represents the vertices and edges for a list of geometries.

A boost::adjancency_list is wrapped in order to be able to annex some information and to provide basic functionalities.

Warning
duplicate matching is performed in GeometryGraphBuilder (allows to modify position once it's done)

Member Typedef Documentation

◆ directed_edge_descriptor

template<typename VertexProperties, typename EdgeProperties>
using SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::directed_edge_descriptor = std::pair<edge_descriptor, EdgeDirection>

An edge descriptor, with a direction.

From the vertex point of view, out edges are DIRECT, in edges are REVERSE.

◆ edge_descriptor

template<typename VertexProperties, typename EdgeProperties>
typedef boost::graph_traits<graph_t>::edge_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::edge_descriptor

Edge descriptor type from boost graph.

◆ edge_iterator

template<typename VertexProperties, typename EdgeProperties>
typedef boost::graph_traits<graph_t>::edge_iterator SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::edge_iterator

Edge iterator type.

◆ edge_properties

template<typename VertexProperties, typename EdgeProperties>
using SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::edge_properties = EdgeProperties

Edge properties type.

◆ graph_t

template<typename VertexProperties, typename EdgeProperties>
typedef boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, vertex_properties, edge_properties> SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::graph_t

the wrapped graphEdgeProperties

◆ in_edge_iterator

template<typename VertexProperties, typename EdgeProperties>
typedef boost::graph_traits<graph_t>::in_edge_iterator SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::in_edge_iterator

Incoming edge iterator type.

◆ out_edge_iterator

template<typename VertexProperties, typename EdgeProperties>
typedef boost::graph_traits<graph_t>::out_edge_iterator SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::out_edge_iterator

Outgoing edge iterator type.

◆ vertex_descriptor

template<typename VertexProperties, typename EdgeProperties>
typedef boost::graph_traits<graph_t>::vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::vertex_descriptor

Vertex descriptor type from boost graph.

◆ vertex_iterator

template<typename VertexProperties, typename EdgeProperties>
typedef boost::graph_traits<graph_t>::vertex_iterator SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::vertex_iterator

Vertex iterator type.

◆ vertex_properties

template<typename VertexProperties, typename EdgeProperties>
using SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::vertex_properties = VertexProperties

Vertex properties type.

Member Function Documentation

◆ addEdge()

template<typename VertexProperties, typename EdgeProperties>
edge_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::addEdge ( const vertex_descriptor & source,
const vertex_descriptor & target,
const EdgeProperties & properties = EdgeProperties() )
inline

Add an Edge to the Graph.

Parameters
sourceThe source vertex descriptor
targetThe target vertex descriptor
propertiesThe properties for the new edge
Returns
The identifier of the edge

◆ addVertex()

template<typename VertexProperties, typename EdgeProperties>
vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::addVertex ( const vertex_properties & properties = vertex_properties())
inline

Add a vertex to the graph.

Parameters
propertiesThe properties for the new vertex
Returns
The identifier of the vertex

◆ adjacentVertices()

template<typename VertexProperties, typename EdgeProperties>
std::set< vertex_descriptor > SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::adjacentVertices ( const vertex_descriptor & vertex,
bool withReverseDirection = true )
inline

Returns the list of the adjacent vertices using both DIRECT and REVERSE direction.

Parameters
vertexInput vertex
withReverseDirectionIndicates if in_edges are used
Returns
Set of adjacent vertex descriptors

◆ areOpposite()

template<typename VertexProperties, typename EdgeProperties>
bool SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::areOpposite ( const edge_descriptor & a,
const edge_descriptor & b ) const
inline

Indicates if edges are opposite.

Parameters
aFirst edge descriptor
bSecond edge descriptor
Returns
True if edges are opposite

◆ areParallel()

template<typename VertexProperties, typename EdgeProperties>
bool SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::areParallel ( const edge_descriptor & a,
const edge_descriptor & b ) const
inline

Indicates if edges are parallel.

Parameters
aFirst edge descriptor
bSecond edge descriptor
Returns
True if edges are parallel

◆ degree()

template<typename VertexProperties, typename EdgeProperties>
size_t SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::degree ( const vertex_descriptor & vertex) const
inline

Returns the degree of a vertex.

Parameters
vertexThe vertex descriptor
Returns
The degree of the vertex

◆ edges() [1/2]

template<typename VertexProperties, typename EdgeProperties>
std::pair< edge_iterator, edge_iterator > SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::edges ( ) const
inline

Return edge iterator pair.

Returns
Pair of edge iterators (begin, end)
for ( boost::tie( it, end ) = g.edges(); it != end; ++it ){
std::cout << g.source(edge) << "," << g.target(edge) << std::endl;
}
vertex_descriptor source(const edge_descriptor &edge) const
Get the source vertex for an edge.
Definition GeometryGraph.h:182
boost::graph_traits< graph_t >::edge_descriptor edge_descriptor
Definition GeometryGraph.h:67
boost::graph_traits< graph_t >::edge_iterator edge_iterator
Definition GeometryGraph.h:72

◆ edges() [2/2]

template<typename VertexProperties, typename EdgeProperties>
std::vector< directed_edge_descriptor > SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::edges ( const vertex_descriptor & a,
const vertex_descriptor & b ) const
inline

Get edges from a to b and from b to a.

Parameters
aFirst vertex descriptor
bSecond vertex descriptor
Returns
Vector of directed edge descriptors connecting the vertices

◆ graph() [1/2]

template<typename VertexProperties, typename EdgeProperties>
graph_t & SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::graph ( )
inline

Returns the wrapped boost::graph.

Returns
Reference to the underlying graph

◆ graph() [2/2]

template<typename VertexProperties, typename EdgeProperties>
const graph_t & SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::graph ( ) const
inline

Returns the wrapped boost::graph.

Returns
Const reference to the underlying graph

◆ inEdges()

template<typename VertexProperties, typename EdgeProperties>
std::vector< edge_descriptor > SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::inEdges ( const vertex_descriptor & vertex)
inline

Get in edges for a vertex.

Parameters
vertexThe vertex descriptor
Returns
Vector of incoming edge descriptors

◆ inOutEdges()

template<typename VertexProperties, typename EdgeProperties>
std::vector< directed_edge_descriptor > SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::inOutEdges ( const vertex_descriptor & vertex) const
inline

Get in/out edges for a vertex.

Parameters
vertexThe vertex descriptor
Returns
Vector of directed edge descriptors (in and out edges)

◆ numEdges()

template<typename VertexProperties, typename EdgeProperties>
size_t SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::numEdges ( ) const
inline

Returns the number of edges.

Returns
The number of edges in the graph

◆ numVertices()

template<typename VertexProperties, typename EdgeProperties>
size_t SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::numVertices ( ) const
inline

Returns the number of vertices.

Returns
The number of vertices in the graph

◆ operator const graph_t &()

template<typename VertexProperties, typename EdgeProperties>
SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::operator const graph_t & ( void ) const
inline

implicit cast to the wrapped boost graph in order to keep boost graph interface

◆ operator graph_t &()

template<typename VertexProperties, typename EdgeProperties>
SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::operator graph_t & ( void )
inline

implicit cast to the wrapped boost graph in order to keep boost graph interface

◆ operator[]() [1/4]

template<typename VertexProperties, typename EdgeProperties>
edge_properties & SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::operator[] ( const edge_descriptor & edge)
inline

Returns the EdgeProperties attached to an Edge.

Parameters
edgeThe edge descriptor
Returns
Reference to edge properties

◆ operator[]() [2/4]

template<typename VertexProperties, typename EdgeProperties>
const edge_properties & SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::operator[] ( const edge_descriptor & edge) const
inline

Returns the EdgeProperties attached to an Edge.

Parameters
edgeThe edge descriptor
Returns
Const reference to edge properties

◆ operator[]() [3/4]

template<typename VertexProperties, typename EdgeProperties>
vertex_properties & SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::operator[] ( const vertex_descriptor & vertex)
inline

Returns the VertexProperties attached to a Vertex.

Parameters
vertexThe vertex descriptor
Returns
Reference to vertex properties

◆ operator[]() [4/4]

template<typename VertexProperties, typename EdgeProperties>
const vertex_properties & SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::operator[] ( const vertex_descriptor & vertex) const
inline

Returns the VertexProperties attached to a Vertex.

Parameters
vertexThe vertex descriptor
Returns
Const reference to vertex properties

◆ outEdges()

template<typename VertexProperties, typename EdgeProperties>
std::vector< edge_descriptor > SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::outEdges ( const vertex_descriptor & vertex) const
inline

Get out edges for a vertex.

Parameters
vertexThe vertex descriptor
Returns
Vector of outgoing edge descriptors

◆ removeEdge()

template<typename VertexProperties, typename EdgeProperties>
void SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::removeEdge ( const edge_descriptor & edge)
inline

Remove an edge.

Parameters
edgeThe edge descriptor to remove

◆ removeVertex()

template<typename VertexProperties, typename EdgeProperties>
void SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::removeVertex ( const vertex_descriptor & vertex)
inline

Remove a vertex (and all its adjacent edges).

Parameters
vertexThe vertex descriptor to remove

◆ reverse()

template<typename VertexProperties, typename EdgeProperties>
void SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::reverse ( std::vector< edge_descriptor > & edges)
inline

Revert the order of a list of edges.

Old edges are removed from the graph, new ones are created.

Parameters
edgesVector of edge descriptors to reverse
Warning
properties are kept but oriented one (left face, right face, etc.) are lost.

◆ source() [1/3]

template<typename VertexProperties, typename EdgeProperties>
vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::source ( const directed_edge_descriptor & edge) const
inline

Get the source vertex for a directed edge.

Parameters
edgeThe directed edge descriptor
Returns
The source vertex descriptor

◆ source() [2/3]

template<typename VertexProperties, typename EdgeProperties>
vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::source ( const edge_descriptor & edge) const
inline

Get the source vertex for an edge.

Parameters
edgeThe edge descriptor
Returns
The source vertex descriptor

◆ source() [3/3]

template<typename VertexProperties, typename EdgeProperties>
vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::source ( const edge_descriptor & edge,
const EdgeDirection & direction ) const
inline

Get the source vertex for an edge with direction.

Parameters
edgeThe edge descriptor
directionThe edge direction
Returns
The source vertex descriptor

◆ target() [1/3]

template<typename VertexProperties, typename EdgeProperties>
vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::target ( const directed_edge_descriptor & edge) const
inline

Get the target vertex for a directed edge.

Parameters
edgeThe directed edge descriptor
Returns
The target vertex descriptor

◆ target() [2/3]

template<typename VertexProperties, typename EdgeProperties>
vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::target ( const edge_descriptor & edge) const
inline

Get the target vertex for an edge.

Parameters
edgeThe edge descriptor
Returns
The target vertex descriptor

◆ target() [3/3]

template<typename VertexProperties, typename EdgeProperties>
vertex_descriptor SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::target ( const edge_descriptor & edge,
const EdgeDirection & direction ) const
inline

Get the target vertex for an edge with direction.

Parameters
edgeThe edge descriptor
directionThe edge direction
Returns
The target vertex descriptor

◆ vertices()

template<typename VertexProperties, typename EdgeProperties>
std::pair< vertex_iterator, vertex_iterator > SFCGAL::graph::GeometryGraphT< VertexProperties, EdgeProperties >::vertices ( ) const
inline

Return vertex iterator pair.

Returns
Pair of vertex iterators (begin, end)
for ( boost::tie( it, end ) = g.vertices(); it != end; ++it ){
typename GeometryGraph<V,E>::vertex_descriptor vertex = *it ;
std::cout << g[ vertex ].coordinate << std::endl;
}
boost::graph_traits< graph_t >::vertex_descriptor vertex_descriptor
Definition GeometryGraph.h:65
boost::graph_traits< graph_t >::vertex_iterator vertex_iterator
Definition GeometryGraph.h:70