CGAL 5.6.1 - Halfedge Data Structures
CGAL::HalfedgeDS_const_decorator< HDS > Class Template Reference

#include <CGAL/HalfedgeDS_const_decorator.h>

Inherits from

CGAL::HalfedgeDS_items_decorator< HDS >.

Definition

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 Euler-operators. The class CGAL::HalfedgeDS_const_decorator<HDS> stores a const reference to the halfedge data structure. It contains non-modifying 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.

Template Parameters
HDSmust be a model of HalfedgeDS

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 ...
}
};
}
See also
CGAL::HalfedgeDS_items_decorator<HDS>
CGAL::HalfedgeDS_decorator<HDS>

Creation

 HalfedgeDS_const_decorator (const HDS &hds)
 keeps internally a const reference to hds.
 

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 is_valid (bool verbose=false, int level=0) const
 returns true if the halfedge data structure hds is valid with respect to the level value as defined above. More...
 
bool normalized_border_is_valid (bool verbose=false) const
 returns true if the border halfedges are in normalized representation, which is when enumerating all halfedges with the halfedge iterator the following holds: The non-border edges precede the border edges. More...
 

Additional Inherited Members

- Public Types inherited from CGAL::HalfedgeDS_items_decorator< HDS >
typedef unspecified_type HalfedgeDS
 halfedge data structure.
 
typedef unspecified_type Vertex
 vertex type of HalfedgeDS.
 
typedef unspecified_type Halfedge
 halfedge type of HalfedgeDS.
 
typedef unspecified_type Face
 face type of HalfedgeDS.
 
typedef unspecified_type Vertex_handle
 
typedef unspecified_type Halfedge_handle
 
typedef unspecified_type Face_handle
 
typedef unspecified_type Vertex_iterator
 
typedef unspecified_type Halfedge_iterator
 
typedef unspecified_type Face_iterator
 
typedef unspecified_type size_type
 
typedef unspecified_type difference_type
 
typedef unspecified_type iterator_category
 
typedef unspecified_type Supports_vertex_halfedge
 
typedef unspecified_type Supports_halfedge_prev
 
typedef unspecified_type Supports_halfedge_vertex
 
typedef unspecified_type Supports_halfedge_face
 
typedef unspecified_type Supports_face_halfedge
 
typedef unspecified_type Supports_removal
 
- Public Member Functions inherited from CGAL::HalfedgeDS_items_decorator< HDS >
 HalfedgeDS_items_decorator ()
 default constructor.
 
Halfedge_handle get_vertex_halfedge (Vertex_handle v)
 returns the incident halfedge of v if supported, Halfedge_handle() otherwise.
 
Vertex_handle get_vertex (Halfedge_handle h)
 returns the incident vertex of h if supported, Vertex_handle() otherwise.
 
Halfedge_handle get_prev (Halfedge_handle h)
 returns the previous halfedge of h if supported, Halfedge_handle() otherwise.
 
Halfedge_handle find_prev (Halfedge_handle h)
 returns the previous halfedge of h. More...
 
Halfedge_handle find_prev_around_vertex (Halfedge_handle h)
 returns the previous halfedge of h. More...
 
Face_handle get_face (Halfedge_handle h)
 returns the incident face of h if supported, Face_handle() otherwise.
 
Halfedge_handle get_face_halfedge (Face_handle f)
 returns the incident halfedge of f if supported, Halfedge_handle() otherwise.
 
void close_tip (Halfedge_handle h) const
 makes h->opposite() the successor of h.
 
void close_tip (Halfedge_handle h, Vertex_handle v) const
 makes h->opposite() the successor of h and sets the incident vertex of h to v.
 
void insert_tip (Halfedge_handle h, Halfedge_handle v) const
 inserts the tip of the edge h into the halfedges around the vertex pointed to by v. More...
 
void remove_tip (Halfedge_handle h) const
 removes the edge h->next()->opposite() from the halfedge circle around the vertex referred to by h. More...
 
void insert_halfedge (Halfedge_handle h, Halfedge_handle f) const
 inserts the halfedge h between f and f->next(). More...
 
void remove_halfedge (Halfedge_handle h) const
 removes edge h->next() from the halfedge circle around the face referred to by h. More...
 
void set_vertex_in_vertex_loop (Halfedge_handle h, Vertex_handle v) const
 loops around the vertex incident to h and sets all vertex pointers to v. More...
 
void set_face_in_face_loop (Halfedge_handle h, Face_handle f) const
 loops around the face incident to h and sets all face pointers to f. More...
 
Halfedge_handle flip_edge (Halfedge_handle h) const
 performs an edge flip. More...
 
void set_vertex_halfedge (Vertex_handle v, Halfedge_handle g) const
 sets the incident halfedge of v to g.
 
void set_vertex_halfedge (Halfedge_handle h) const
 sets the incident halfedge of the vertex v to h.
 
void set_vertex (Halfedge_handle h, Vertex_handle v) const
 sets the incident vertex of h to v.
 
void set_prev (Halfedge_handle h, Halfedge_handle g) const
 sets the previous link of h to g.
 
void set_face (Halfedge_handle h, Face_handle f) const
 sets the incident face of h to f.
 
void set_face_halfedge (Face_handle f, Halfedge_handle g) const
 sets the incident halfedge of f to g.
 
void set_face_halfedge (Halfedge_handle h) const
 sets the incident halfedge of the face f to h.
 

Member Function Documentation

◆ is_valid()

template<typename HDS >
bool CGAL::HalfedgeDS_const_decorator< HDS >::is_valid ( bool  verbose = false,
int  level = 0 
) const

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.

◆ normalized_border_is_valid()

template<typename HDS >
bool CGAL::HalfedgeDS_const_decorator< HDS >::normalized_border_is_valid ( bool  verbose = false) const

returns true if the border halfedges are in normalized representation, which is when enumerating all halfedges with the halfedge iterator the following holds: The non-border 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 HalfedgeDS::border_halfedges_begin() denotes the first border edge. If verbose is true, statistics are written to cerr.