Commit 88309669 authored by Mike Kremer's avatar Mike Kremer

Replace VertexOHalfedgeIter by VertexOHalfEdgeIter, added documentation

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@69 66977474-1d4b-4f09-8fe9-267525286df2
parent 4391db53
......@@ -70,6 +70,21 @@ Note also that most of the iterators and circulators rely on these adjacency lis
so, many of them do not work unless OpenVolumeMesh::PolyhedralMesh::update_adjacencies()
is called.
\section index_based Using handles to address the entities of a mesh
%OpenVolumeMesh is an index-based data structure where generally all entities
are stored in linear memory arrays (STL vectors). So, each of the entities
is uniquely defined through its handle which is a simple class that encapsulates
the index of it in the respective array it is stored in. This makes sure
the entities can be accessed in \f$O(1)\f$. Each of the distinct entity
types has its own handle class in order to avoid ambiguity when accessing
elements at compile time. The handle classes are each derived from a common
base class called, OpenVolumeMesh::OpenVolumeMeshHandle. The iterators as well
as the circulators are designed to return a handle to an entity on dereference
rather than a reference to the entity itself. A special constant,
OpenVolumeMesh::PolyhedralMesh::InvalidVertexHandle, etc., for each entity
is used when trying to access non-existing entities.
\section genericity Genericity
\subsection generic_embedding Generic Embedding
......
......@@ -2,4 +2,57 @@
\page tutorial_02 Tutorial 02: Using Iterators
%OpenVolumeMesh is shipped with a set of useful iterators and circulators to
comfortably address the entities (local neighborhood of entities) in a polyhedral mesh.
See Section \ref iterators_and_circulators for a more detailed description of all
available iterators and circulators. In this tutorial, we examine how to use the iterators
that come along with %OpenVolumeMesh.
In the first example, we simply iterate over all half-edges of a mesh using
the OpenVolumeMesh::HalfEdgeIter iterator class:
\code
typedef OpenVolumeMesh::Geometry::Vec3f Vec3f;
// Instantiate e.g. a hexahedral mesh
OpenVolumeMesh::HexahedralMesh<Vec3f> myMesh;
// Fill mesh with geometry
...
// Iterate over all half-edges
for(OpenVolumeMesh::HexahedralMesh<Vec3f>::HalfEdgeIter he_it = myMesh.halfedges_begin();
he_it != myMesh.halfedges_end(); ++he_it) {
// Now dereferencing he_it returns a half-edge handle
...
}
\endcode
In the next example, we iterate over all incident outgoing half-edges of a given
vertex.
\code
typedef OpenVolumeMesh::Geometry::Vec3f Vec3f;
// Instantiate a polyhedral mesh
OpenVolumeMesh::PolyhedralMesh<Vec3f> myMesh;
// Fill mesh with geometry
...
typedef OpenVolumeMesh::PolyhedralMesh<Vec3f>::VertexHandle VertexHandle;
// Get first vertex in mesh
VertexHandle vh = *(myMesh.vertices_begin());
// Iterate over all outgoing half-edges of vertex vh
for(OpenVolumeMesh::PolyhedralMesh<Vec3f>::VertexOHalfEdgeIter voh_it = myMesh.voh_iter(vh);
voh_it.valid(); ++voh_it) {
// Now dereferencing voh_it returns a half-edge handle
...
}
\endcode
**/
......@@ -169,7 +169,7 @@ public:
// Iterators
//=====================================================================
friend class VertexOHalfedgeIter<VecT>;
friend class VertexOHalfEdgeIter<VecT>;
friend class HalfEdgeHalfFaceIter<VecT>;
friend class VertexCellIter<VecT>;
friend class HalfedgeCellIter<VecT>;
......@@ -183,7 +183,7 @@ public:
friend class HalfFaceIter<VecT>;
friend class CellIter<VecT>;
typedef class VertexOHalfedgeIter<VecT> VertexOHalfedgeIter;
typedef class VertexOHalfEdgeIter<VecT> VertexOHalfEdgeIter;
typedef class HalfEdgeHalfFaceIter<VecT> HalfEdgeHalfFaceIter;
typedef class VertexCellIter<VecT> VertexCellIter;
typedef class HalfedgeCellIter<VecT> HalfedgeCellIter;
......@@ -197,8 +197,8 @@ public:
typedef class HalfFaceIter<VecT> HalfFaceIter;
typedef class CellIter<VecT> CellIter;
VertexOHalfedgeIter voh_iter(const VertexHandle& _idx) const {
return VertexOHalfedgeIter(_idx, this);
VertexOHalfEdgeIter voh_iter(const VertexHandle& _idx) const {
return VertexOHalfEdgeIter(_idx, this);
}
HalfEdgeHalfFaceIter hehf_iter(const HalfEdgeHandle& _idx) const {
......@@ -571,7 +571,7 @@ public:
std::cerr << "Error: is_boundary() needs bottom-up adjacencies!" << std::endl;
return false;
}
for(VertexOHalfedgeIter voh_it = voh_iter(_vertexHandle); voh_it.valid(); ++voh_it) {
for(VertexOHalfEdgeIter voh_it = voh_iter(_vertexHandle); voh_it.valid(); ++voh_it) {
if(is_boundary(*voh_it)) return true;
}
return false;
......
......@@ -728,7 +728,7 @@ PolyhedralMesh<VecT>::halfedge(const VertexHandle& _vh1, const VertexHandle& _vh
assert(_vh1.idx() < vertices_.size());
assert(_vh2.idx() < vertices_.size());
for(VertexOHalfedgeIter voh_it = voh_iter(_vh1); voh_it.valid(); ++voh_it) {
for(VertexOHalfEdgeIter voh_it = voh_iter(_vh1); voh_it.valid(); ++voh_it) {
if(halfedge(*voh_it).to_vertex() == _vh2) {
return *voh_it;
}
......@@ -1035,7 +1035,7 @@ void PolyhedralMesh<VecT>::garbage_collection(bool _preserveManifoldness) {
for(typename Vertices::iterator v_it = vertices_.begin(); v_it != vertices_.end();) {
// If neither of the half-edges is incident to a half-face, delete edge
VertexOHalfedgeIter voh_it = voh_iter(vh);
VertexOHalfEdgeIter voh_it = voh_iter(vh);
if(!voh_it.valid()) {
erase_vertex(v_it, vh);
......
......@@ -148,7 +148,7 @@ private:
//===========================================================================
template <class VecT>
class VertexOHalfedgeIter :
class VertexOHalfEdgeIter :
public BaseIterator<VecT,
typename PolyhedralMesh<VecT>::VertexHandle,
typename PolyhedralMesh<VecT>::HalfEdgeHandle> {
......@@ -158,49 +158,49 @@ public:
typename PolyhedralMesh<VecT>::HalfEdgeHandle> BaseIter;
typedef typename PolyhedralMesh<VecT>::VertexHandle VertexHandle;
VertexOHalfedgeIter(const VertexHandle& _vIdx,
VertexOHalfEdgeIter(const VertexHandle& _vIdx,
const PolyhedralMesh<VecT>* _mesh);
// Post increment/decrement operator
VertexOHalfedgeIter operator++(int) {
VertexOHalfedgeIter cpy = *this;
VertexOHalfEdgeIter operator++(int) {
VertexOHalfEdgeIter cpy = *this;
++(*this);
return cpy;
}
VertexOHalfedgeIter operator--(int) {
VertexOHalfedgeIter cpy = *this;
VertexOHalfEdgeIter operator--(int) {
VertexOHalfEdgeIter cpy = *this;
--(*this);
return cpy;
}
VertexOHalfedgeIter operator+(int _n) {
VertexOHalfedgeIter cpy = *this;
VertexOHalfEdgeIter operator+(int _n) {
VertexOHalfEdgeIter cpy = *this;
for(int i = 0; i < _n; ++i) {
++cpy;
}
return cpy;
}
VertexOHalfedgeIter operator-(int _n) {
VertexOHalfedgeIter cpy = *this;
VertexOHalfEdgeIter operator-(int _n) {
VertexOHalfEdgeIter cpy = *this;
for(int i = 0; i < _n; ++i) {
--cpy;
}
return cpy;
}
VertexOHalfedgeIter& operator+=(int _n) {
VertexOHalfEdgeIter& operator+=(int _n) {
for(int i = 0; i < _n; ++i) {
++(*this);
}
return *this;
}
VertexOHalfedgeIter& operator-=(int _n) {
VertexOHalfEdgeIter& operator-=(int _n) {
for(int i = 0; i < _n; ++i) {
--(*this);
}
return *this;
}
VertexOHalfedgeIter& operator++();
VertexOHalfedgeIter& operator--();
VertexOHalfEdgeIter& operator++();
VertexOHalfEdgeIter& operator--();
private:
......
......@@ -72,11 +72,11 @@ BaseIterator<VecT,IH,OH>::BaseIterator(const PolyhedralMesh<VecT>* _mesh) :
}
//================================================================================================
// VertexOHalfedgeIter
// VertexOHalfEdgeIter
//================================================================================================
template <class VecT>
VertexOHalfedgeIter<VecT>::VertexOHalfedgeIter(const VertexHandle& _ref_h,
VertexOHalfEdgeIter<VecT>::VertexOHalfEdgeIter(const VertexHandle& _ref_h,
const PolyhedralMesh<VecT>* _mesh) :
BaseIter(_mesh, _ref_h),
cur_index_(0) {
......@@ -104,7 +104,7 @@ cur_index_(0) {
}
template <class VecT>
VertexOHalfedgeIter<VecT>& VertexOHalfedgeIter<VecT>::operator--() {
VertexOHalfEdgeIter<VecT>& VertexOHalfEdgeIter<VecT>::operator--() {
--cur_index_;
......@@ -119,7 +119,7 @@ VertexOHalfedgeIter<VecT>& VertexOHalfedgeIter<VecT>::operator--() {
}
template <class VecT>
VertexOHalfedgeIter<VecT>& VertexOHalfedgeIter<VecT>::operator++() {
VertexOHalfEdgeIter<VecT>& VertexOHalfEdgeIter<VecT>::operator++() {
++cur_index_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment