Loading...
Searching...
No Matches
graphVertex.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_STRUCTURE_GRAPHVERTEX_H
#define BALL_STRUCTURE_GRAPHVERTEX_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#ifndef BALL_DATATYPE_HASHSET_H
# include <BALL/DATATYPE/hashSet.h>
#endif
namespace BALL
{
template <typename Vertex, typename Edge, typename Face>
class GraphEdge;
template <typename Vertex, typename Edge, typename Face>
class GraphFace;
template <typename Vertex, typename Edge, typename Face>
class GraphTriangle;
template <typename Vertex, typename Edge, typename Face>
class GraphVertex
{
public:
friend class GraphEdge<Vertex,Edge,Face>;
friend class GraphFace<Vertex,Edge,Face>;
friend class GraphTriangle<Vertex,Edge,Face>;
BALL_CREATE(GraphVertex)
typedef typename HashSet<Edge*>::Iterator EdgeIterator;
typedef typename HashSet<Edge*>::ConstIterator ConstEdgeIterator;
typedef typename HashSet<Face*>::Iterator FaceIterator;
typedef typename HashSet<Face*>::ConstIterator ConstFaceIterator;
GraphVertex()
;
GraphVertex(const GraphVertex<Vertex,Edge,Face>& vertex, bool deep = false)
;
virtual ~GraphVertex()
;
void set(const GraphVertex<Vertex,Edge,Face>& vertex, bool deep = false)
;
GraphVertex<Vertex,Edge,Face>& operator =
(const GraphVertex<Vertex,Edge,Face>& vertex)
;
void insert(Edge* edge)
;
void insert(Face* face)
;
void remove(Edge* edge)
;
void remove(Face* face)
;
Position numberOfEdges() const
;
Position numberOfFaces() const
;
void setIndex(Index index)
;
Index getIndex() const
;
bool join(const Vertex& vertex)
;
bool substitute(Vertex* vertex)
;
virtual bool operator == (const Vertex&) const
;
virtual bool operator != (const Vertex&) const
;
virtual bool operator *= (const Vertex&) const
;
Face* has(Face* face) const
;
Edge* has(Edge* edge) const
;
bool hasEdges() const
;
bool hasFaces() const
;
EdgeIterator beginEdge()
;
ConstEdgeIterator beginEdge() const
;
EdgeIterator endEdge()
;
ConstEdgeIterator endEdge() const
;
FaceIterator beginFace()
;
ConstFaceIterator beginFace() const
;
FaceIterator endFace()
;
ConstFaceIterator endFace() const
;
protected:
/*_ @name Attributes
*/
/*_ The RSEdges the RSVetex belongs to
*/
HashSet<Edge*> edges_;
/*_ The RSFaces the RSVetex belongs to
*/
HashSet<Face*> faces_;
/*_ The index of the GraphVertex
*/
Index index_;
};
template <typename Vertex, typename Edge, typename Face>
GraphVertex<Vertex,Edge,Face>::GraphVertex()
: edges_(),
faces_(),
index_(-1)
{
}
template <typename Vertex, typename Edge, typename Face>
GraphVertex<Vertex,Edge,Face>::GraphVertex
(const GraphVertex<Vertex,Edge,Face>& vertex, bool deep)
: edges_(),
faces_(),
index_(vertex.index_)
{
if (deep)
{
edges_ = vertex.edges_;
faces_ = vertex.faces_;
}
}
template <typename Vertex, typename Edge, typename Face>
GraphVertex<Vertex,Edge,Face>::~GraphVertex()
{
}
template <typename Vertex, typename Edge, typename Face>
void GraphVertex<Vertex,Edge,Face>::set
(const GraphVertex<Vertex,Edge,Face>& vertex, bool deep)
{
if (this != &vertex)
{
if (deep)
{
edges_ = vertex.edges_;
faces_ = vertex.faces_;
}
index_ = vertex.index_;
}
}
template <typename Vertex, typename Edge, typename Face>
GraphVertex<Vertex,Edge,Face>& GraphVertex<Vertex,Edge,Face>::operator =
(const GraphVertex<Vertex,Edge,Face>& vertex)
{
if (this != &vertex)
{
edges_ = vertex.edges_;
faces_ = vertex.faces_;
index_ = vertex.index_;
}
return *this;
}
template <typename Vertex, typename Edge, typename Face>
void GraphVertex<Vertex,Edge,Face>::insert(Edge* edge)
{
edges_.insert(edge);
}
template <typename Vertex, typename Edge, typename Face>
void GraphVertex<Vertex,Edge,Face>::insert(Face* face)
{
faces_.insert(face);
}
template <typename Vertex, typename Edge, typename Face>
void GraphVertex<Vertex,Edge,Face>::remove(Edge* edge)
{
edges_.erase(edge);
}
template <typename Vertex, typename Edge, typename Face>
void GraphVertex<Vertex,Edge,Face>::remove(Face* face)
{
faces_.erase(face);
}
template <typename Vertex, typename Edge, typename Face>
Position GraphVertex<Vertex,Edge,Face>::numberOfEdges() const
{
return edges_.size();
}
template <typename Vertex, typename Edge, typename Face>
Position GraphVertex<Vertex,Edge,Face>::numberOfFaces() const
{
return faces_.size();
}
template <typename Vertex, typename Edge, typename Face>
void GraphVertex<Vertex,Edge,Face>::setIndex(Index index)
{
index_ = index;
}
template <typename Vertex, typename Edge, typename Face>
Index GraphVertex<Vertex,Edge,Face>::getIndex() const
{
return index_;
}
template <typename Vertex, typename Edge, typename Face>
bool GraphVertex<Vertex,Edge,Face>::substitute(Vertex* vertex)
{
if (*this *= *vertex)
{
typename HashSet<Edge*>::Iterator e;
for (e = edges_.begin(); e != edges_.end(); e++)
{
(*e)->substitute((Vertex*)this,vertex);
}
typename HashSet<Face*>::Iterator f;
for (f = faces_.begin(); f != faces_.end(); f++)
{
(*f)->substitute((Vertex*)this,vertex);
}
return true;
}
return false;
}
template <typename Vertex, typename Edge, typename Face>
bool GraphVertex<Vertex,Edge,Face>::join(const Vertex& vertex)
{
if (*this *= vertex)
{
typename HashSet<Edge*>::ConstIterator e;
for (e = vertex.edges_.begin(); e != vertex.edges_.end(); e++)
{
edges_.insert(*e);
}
typename HashSet<Face*>::ConstIterator f;
for (f = vertex.faces_.begin(); f != vertex.faces_.end(); f++)
{
faces_.insert(*f);
}
return true;
}
else
{
return false;
}
}
template <typename Vertex, typename Edge, typename Face>
Face* GraphVertex<Vertex,Edge,Face>::has(Face* face) const
{
typename HashSet<Face*>::ConstIterator f;
for (f = faces_.begin(); f != faces_.end(); f++)
{
if (*(*f) == *face)
{
return *f;
}
}
return NULL;
}
template <typename Vertex, typename Edge, typename Face>
Edge* GraphVertex<Vertex,Edge,Face>::has(Edge* edge) const
{
typename HashSet<Edge*>::ConstIterator e;
for (e = edges_.begin(); e != edges_.end(); e++)
{
if (*(*e) == *edge)
{
return *e;
}
}
return NULL;
}
template <typename Vertex, typename Edge, typename Face>
bool GraphVertex<Vertex,Edge,Face>::hasEdges() const
{
return !edges_.isEmpty();
}
template <typename Vertex, typename Edge, typename Face>
bool GraphVertex<Vertex,Edge,Face>::hasFaces() const
{
return !faces_.isEmpty();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::EdgeIterator
GraphVertex<Vertex,Edge,Face>::beginEdge()
{
return edges_.begin();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::ConstEdgeIterator
GraphVertex<Vertex,Edge,Face>::beginEdge() const
{
return edges_.begin();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::EdgeIterator
GraphVertex<Vertex,Edge,Face>::endEdge()
{
return edges_.end();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::ConstEdgeIterator
GraphVertex<Vertex,Edge,Face>::endEdge() const
{
return edges_.end();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::FaceIterator
GraphVertex<Vertex,Edge,Face>::beginFace()
{
return faces_.begin();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::ConstFaceIterator
GraphVertex<Vertex,Edge,Face>::beginFace() const
{
return faces_.begin();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::FaceIterator
GraphVertex<Vertex,Edge,Face>::endFace()
{
return faces_.end();
}
template <typename Vertex, typename Edge, typename Face>
typename GraphVertex<Vertex,Edge,Face>::ConstFaceIterator
GraphVertex<Vertex,Edge,Face>::endFace() const
{
return faces_.end();
}
template <typename Vertex, typename Edge, typename Face>
bool GraphVertex<Vertex,Edge,Face>::operator == (const Vertex&) const
{
return true;
}
template <typename Vertex, typename Edge, typename Face>
bool GraphVertex<Vertex,Edge,Face>::operator != (const Vertex&) const
{
return false;
}
template <typename Vertex, typename Edge, typename Face>
bool GraphVertex<Vertex,Edge,Face>::operator *= (const Vertex&) const
{
return true;
}
} // namespace BALL
#endif // BALL_STRUCTURE_GRAPHVERTEX_H
BALL::GraphEdge
Definition graphEdge.h:31
BALL::GraphFace
Definition graphFace.h:29
BALL::GraphTriangle
Definition graphFace.h:625
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::set
void set(const GraphVertex< RSVertex, RSEdge, RSFace > &vertex, bool deep=false)
Definition graphVertex.h:309
BALL::GraphVertex::operator!=
virtual bool operator!=(const Vertex &) const
Definition graphVertex.h:579
BALL::GraphVertex::EdgeIterator
HashSet< Edge * >::Iterator EdgeIterator
Definition graphVertex.h:53
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::getIndex
Index getIndex() const
Definition graphVertex.h:396
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::substitute
bool substitute(RSVertex *vertex)
Definition graphVertex.h:404
BALL::GraphVertex::GraphVertex
GraphVertex()
Definition graphVertex.h:275
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::setIndex
void setIndex(Index index)
Definition graphVertex.h:388
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::endEdge
EdgeIterator endEdge()
Definition graphVertex.h:518
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::beginFace
FaceIterator beginFace()
Definition graphVertex.h:536
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::beginEdge
EdgeIterator beginEdge()
Definition graphVertex.h:500
BALL::GraphVertex::ConstEdgeIterator
HashSet< Edge * >::ConstIterator ConstEdgeIterator
Definition graphVertex.h:54
BALL::GraphVertex::index_
Index index_
Definition graphVertex.h:266
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::insert
void insert(RSEdge *edge)
Definition graphVertex.h:340
BALL::GraphVertex::edges_
HashSet< Edge * > edges_
Definition graphVertex.h:260
BALL::GraphVertex::operator==
virtual bool operator==(const Vertex &) const
Definition graphVertex.h:571
BALL::GraphVertex::FaceIterator
HashSet< Face * >::Iterator FaceIterator
Definition graphVertex.h:55
BALL::GraphVertex::ConstFaceIterator
HashSet< Face * >::ConstIterator ConstFaceIterator
Definition graphVertex.h:56
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::hasEdges
bool hasEdges() const
Definition graphVertex.h:483
BALL::GraphVertex::faces_
HashSet< Face * > faces_
Definition graphVertex.h:263
BALL::GraphVertex::operator*=
virtual bool operator*=(const Vertex &) const
Definition graphVertex.h:587
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::join
bool join(const RSVertex &vertex)
Definition graphVertex.h:426
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::has
RSFace * has(RSFace *face) const
Definition graphVertex.h:451
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::numberOfEdges
Position numberOfEdges() const
Definition graphVertex.h:372
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::remove
void remove(RSEdge *edge)
Definition graphVertex.h:356
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::numberOfFaces
Position numberOfFaces() const
Definition graphVertex.h:380
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::hasFaces
bool hasFaces() const
Definition graphVertex.h:491
BALL::GraphVertex< RSVertex, RSEdge, RSFace >::endFace
FaceIterator endFace()
Definition graphVertex.h:554
BALL::GraphVertex::~GraphVertex
virtual ~GraphVertex()
Definition graphVertex.h:301
BALL::Iterator
BALL::HashSet
Definition hashSet.h:46
BALL::HashSet::Iterator
ForwardIterator< HashSet< Key >, ValueType, PointerType, IteratorTraits > Iterator
Definition hashSet.h:280
BALL::HashSet::ConstIterator
ConstForwardIterator< HashSet< Key >, ValueType, PointerType, IteratorTraits > ConstIterator
Definition hashSet.h:283
common.h
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
hashSet.h
BALL
Definition constants.h:13
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105