CGAL is designed in the spirit of the generic programming paradigm
to work together with the Standard Template Library (STL)
[C++96, MS96]. This chapter documents non-geometric
STL-like components that are not provided in the STL standard but
in CGAL: a doubly-connected list managing items in place
(where inserted items are not copied), generic
functions, function objects for projection and creation, classes for
composing function objects and adaptor classes around iterators and
circulators. See also circulators in Chapter .
The class CGAL_In_place_list<T,bool,&T::next,&T::prev> manages a sequence of items in place in a doubly-connected list. Its goals are the flexible handling of memory management and performance optimization. The item type is supposed to provide the two necessary pointers &T::next_link and &T::prev_link. One possibility to obtain these pointers is to inherit them from the base class CGAL_In_place_list_base<T>.
The class CGAL_In_place_list<T> is a container and quite similar to STL containers, with the advantage that it is able to handle the stored elements by reference instead of copying them. It is possible to delete an element only knowing its address and no iterator to it. This simplifies mutually pointered data structures like a halfedge data structure for planar maps or polyhedral surfaces. The usual iterators are also available. Another container with this property of working with pointers to objects is the STL vector (at least in the current STL implementations).
#include <CGAL/In_place_list.h>
CGAL_copy_n() copies items from an input iterator to an output iterator which is useful for possibly infinite sequences of random geometric objects[^1].
#include <CGAL/copy_n.h>
Two kinds of function objects are provided: Projections and Creators.
#include <CGAL/function_objects.h>
|
| |
| ||
|
| |
the identity function for projection objects. argument_type
and result_type are equal to Value.
|
| |
composes two projections:
Fct1Fct2Fct1()( Fct2()(x)).
argument_type is equal to Fct2::argument_type,
result_type to Fct1::result_type.
|
| |
dereferences a pointer. argument_type is equal to
Value* and result_type is equal to Value.
|
| |
Get the address for a reference. argument_type is equal to
Value and result_type is equal to Value*.
|
| |
applies a C-style type cast to its argument. argument_type
is equal to Arg and result_type is equal to
Result.
|
The following function objects are provided with respect to the polyhedral surfaces in the basic library.
| |
calls the member function vertex() on an instance of type
Node. argument_type is equal to Node and
result_type is equal to Node::Vertex.
|
| |
calls the member function facet() on an instance of type
Node. argument_type is equal to Node and
result_type is equal to Node::Facet.
|
| |
calls the member function point() on an instance of type
Node. argument_type is equal to Node and
result_type is equal to Node::Point.
|
| |
calls the member function normal() on an instance of type
Node. argument_type is equal to Node and
result_type is equal to Node::Normal.
|
| |
calls the member function plane() on an instance of type
Node. argument_type is equal to Node and
result_type is equal to Node::Plane.
|
| |
calls the member function next() on an instance of type
Node. argument_type and result_type are equal
to Node*.
|
| |
calls the member function prev() on an instance of type
Node. argument_type and result_type are equal
to Node*.
|
| |
calls the member functions next()->opposite() on an
instance of type Node. argument_type and
result_type are equal to Node*.
|
| |
calls the member functions opposite()->prev() on an
instance of type Node. argument_type and
result_type are equal to Node*.
|
#include <CGAL/function_objects.h>
|
|
| |
applies the constructor Result(Arg). result_type is
equal to Result.
|
| |
applies the constructor Result(Arg1, Arg2, Arg3, Arg4, Arg5)
. result_type is equal to Result.
|
The following creator function objects are available for two to nine arguments (one argument is already captured with CGAL_Creator_1):
| |
applies the constructor Result(Arg,Arg). result_type
is equal to Result.
|
| |
applies the constructor for Result with nine arguments of
type Arg. result_type is equal to Result.
|
Although not mentioned in the ANSI draft(CD2), most STL implementations provide two global functions for composing function objects, compose1 and compose2, defined in function.h. Since for both the resulting function is unary, one can only construct unary function objects in this way. This seems to be quite a limitation, since many (also STL) algorithms can be parameterized with binary (e.g. comparison) functions.
In analogy to STL compose1/2 we define two functions, CGAL_compose1_2 and CGAL_compose2_2, that can be used to construct a binary function object via composition.
#include <CGAL/function_objects.h>
| ||
|
|
Operation1 must be an adaptable unary function, Operation2 an adaptable binary function and Operation2::result_type convertible to Operation1::argument_type. Then CGAL_compose1_2 returns an adaptable binary function object c (of some complicated type Composition) such that
| ||||
|
#include <CGAL/function_objects.h>
| ||||
|
|
Operation1 must be an adaptable binary function, Operation2 and Operation3 must be adaptable unary functions, Operation2::result_type must be convertible to Operation1::first_argument_type and Operation3::result_type must be convertible to Operation1::second_argument_type. Then CGAL_compose2_2 returns an adaptable binary function object c (of some complicated type Composition) such that
| ||||
|
#include <CGAL/Join_input_iterator.h>
| |
the join of a single iterator . Applies
Creator to each item read from .
value_type is equal to Creator::result_type.
|
| |||
the join of five iterators i1 to i5. Applies
Creator with five arguments *i1 up to *i5.
value_type is equal to Creator::result_type.
|