CGAL::HalfedgeDS_const_decorator<HDS>
Definition
The classes CGAL::HalfedgeDS_items_decorator<HDS>,
CGAL::HalfedgeDS_decorator<HDS>, and
CGAL::HalfedgeDS_const_decorator<HDS> provide additional functions
to examine and to modify a halfedge data structure HDS. The class
CGAL::HalfedgeDS_items_decorator<HDS> provides additional functions
for vertices, halfedges, and faces of a halfedge data structure
without knowing the containing halfedge data structure. The class
CGAL::HalfedgeDS_decorator<HDS> stores a reference to the halfedge
data structure and provides functions that modify the halfedge data
structure, for example Euleroperators. The class
CGAL::HalfedgeDS_const_decorator<HDS> stores a const reference to
the halfedge data structure. It contains nonmodifying functions, for
example the test for validness of the data structure.
All these additional functions take care of the different capabilities
a halfedge data structure may have or may not have. The functions
evaluate the type tags of the halfedge data structure to decide on the
actions. If a particular feature is not supported nothing is done.
Note that for example the creation of new halfedges is mandatory for
all halfedge data structures and will not appear here again.
#include <CGAL/HalfedgeDS_const_decorator.h>
Inherits From
CGAL::HalfedgeDS_items_decorator<HDS>
Creation
Validness Checks
A halfedge data structure has no definition of validness of its own,
but a useful set of tests is defined with the following levels:
 Level 0

The number of halfedges is even. All pointers except
the vertex pointer and the face pointer for border halfedges are
unequal to their respective default construction value. For all
halfedges $$h: The opposite halfedge is different from $$h and the
opposite of the opposite is equal to $$h. The next of the previous
halfedge is equal to $$h. For all vertices $$v: the incident vertex
of the incident halfedge of $$v is equal to $$v. The halfedges
around $$v starting with the incident halfedge of $$v form a cycle.
For all faces $$f: the incident face of the incident halfedge of $$f
is equal to $$f. The halfedges around $$f starting with the incident
halfedge of $$f form a cycle. Redundancies among internal variables
are tested, e.g., that iterators enumerate as many items as the
related size value indicates.
 Level 1

All tests of level 0. For all halfedges $$h: The
incident vertex of $$h exists and is equal to the incident vertex of
the opposite of the next halfedge. The incident face (or hole) of
$$h is equal to the incident face (or hole) of the next halfedge.
 Level 2

All tests of level 1. The sum of all halfedges that can
be reached through the vertices must be equal to the number of all
halfedges, i.e., all halfedges incident to a vertex must form a single
cycle.
 Level 3

All tests of level 2. The sum of all halfedges that can
be reached through the faces must be equal to the number of all
halfedges, i.e., all halfedges surrounding a face must form a single
cycle (no holes in faces).
 Level 4

All tests of level 3 and normalized_border_is_valid.
bool

D.is_valid ( bool verbose = false, int level = 0)

 
returns true if the halfedge data structure hds is
valid with respect to the level value as defined above.
If verbose is true, statistics are written to cerr.


bool

D.normalized_border_is_valid ( bool verbose = false)

 
returns true if the border halfedges are in normalized
representation, which is when enumerating all halfedges with the
halfedge iterator the following holds: The nonborder edges precede the
border edges. For border edges, the second halfedge is a border halfedge.
(The first halfedge may or may not be a border halfedge.) The halfedge
iterator border_halfedges_begin() denotes the first border
edge. If verbose is true, statistics are written to cerr.

See Also
CGAL::HalfedgeDS_items_decorator<HDS>
CGAL::HalfedgeDS_decorator<HDS>
Example
The following program fragment illustrates the implementation of a
is_valid() member function for a simplified polyhedron class.
We assume here that the level three check is the appropriate default
for polyhedral surfaces.
namespace CGAL {
template <class Traits>
class Polyhedron {
typedef HalfedgeDS_default<Traits> HDS;
HDS hds;
public:
// ...
bool is_valid( bool verb = false, int level = 0) const {
Verbose_ostream verr(verb);
verr << "begin Polyhedron::is_valid( verb=true, level = " << level
<< "):" << std::endl;
HalfedgeDS_const_decorator<HDS> decorator(hds);
bool valid = decorator.is_valid( verb, level + 3);
// further checks ...
}
};
}