Up: Home page for Qhull
Up: Qhull manual: Table of Contents
Up: Qhull options: Table of Contents
Up: Qhull internals: Table of Contents

To: Qhull files (please wait while loading)
To: GeomGlobalIoMemMergePolyQhullSetStatUser


Qhull functions, macros, and data structures

The following sections provide an overview and index to Qhull's functions, macros, and data structures.

Each section starts with an introduction.

Qhull uses the following conventions:

When reading the code, please note that the global data structure, 'qh', is a macro. It either expands to "qh_qh." or to "qh_qh->". The later is used for applications which run concurrent calls to qh_qhull().

When reading code with an editor, a search for "procedure will locate the header of qh_procedure. A search for * procedure will locate the tail of qh_procedure.

If your web browser loads .c and .h files with an external application, change the MIME type of .c and .h files to "text/html". Do not use the Opera browser (it treats all '<' characters as HTML tags).

Please report documentation and link errors to qhull-bug@geom.umn.edu. If you have a program that checks internal links ("#..."), please send the results of running the program on qhull.

Brad Barber, Cambridge MA, August 3, 1998

Copyright © 1997-1998 The Geometry Center, Minneapolis MN


»Qhull files

This sections lists the .c and .h files for Qhull. Please refer to these files for detailed information.

qhull.h
Include file for the Qhull library, qhull.a. Data structures are documented under Poly. Global variables are documented under Global. Other data structures and variables are documented under Qhull or Geom.
 
Geom, geom.h, geom.c, geom2.c
Geometric routines. These routines implement mathematical functions such as Gaussian elimination and geometric routines needed for Qhull. Frequently used routines are in geom.c while infrequent ones are in geom2.c.
 
Global, global.c, qhull.h
Global routines. Qhull uses a global data structure, qh, to store globally defined constants, lists, sets, and variables. global.c initializes and frees these structures.
 
Io, io.h, io.c
Input and output routines. Qhull provides a wide range of input and output options.
 
Mem, mem.h, mem.c
Memory routines. Qhull provides memory allocation and deallocation. It uses quick-fit allocation.
 
Merge, merge.h, merge.c
Merge routines. Qhull handles precision problems by merging facets. These routines merge simplicial facets, merge non-simplicial facets, merge cycles of facets, and rename redundant vertices.
 
Poly, poly.h, poly.c, poly2.c, qhull.h
Polyhedral routines. Qhull produces a polyhedron as a list of facets with vertices, neighbors, ridges, and geometric information. Qhull.h defines the main data structures. Frequently used routines are in poly.c while infrequent ones are in poly2.c.
 
Qhull, qhull.c, qhull.h, qhull_a.h, unix.c
Top-level routines. The Quickhull algorithm is implemented by qhull.c. qhull_a.h includes all header files.
 
Set, qset.h, qset.c
Set routines. Qhull implements its data structures as sets. A set is an array of pointers that is expanded as needed. This is a separate package that may be used in other applications.
 
Stat, stat.h, stat.c
Statistical routines. Qhull maintains statistics about its implementation.
 
User, user.h, user.c, user_eg.c
User-defined routines. Qhull allows the user to configure the code with defined constants and specialized routines.

» Geom GlobalIoMemMergePolyQhullSetStatUser

geom.c, geom2.c -- geometric and floating point routines

Geometrically, a vertex is a point with d coordinates and a facet is a halfspace. A halfspace is defined by an oriented hyperplane through the facet's vertices. A hyperplane is defined by d normalized coefficients and an offset. A point is above a facet if its distance to the facet is positive.

Qhull uses floating point coordinates for input points, vertices, halfspace equations, centrums, and an interior point.

Qhull may be configured for single precision or double precision floating point arithmetic (see realT ).

Each floating point operation may incur round-off error (see Merge). The maximum error for distance computations is determined at initialization. The roundoff error in halfspace computation is accounted for by computing the distance from vertices to the halfspace.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to geom.c, geom2.c, and geom.h

»geometric data types and constants

»mathematical macros

»mathematical functions

»computational geometry functions

»point array functions

»geometric facet functions

»geometric roundoff functions


» Geom GlobalIoMemMergePolyQhullSetStatUser

global.c -- global variables and their functions

Qhull uses a global data structure, qh, to store globally defined constants, lists, sets, and variables. This allows multiple instances of Qhull to execute at the same time. The structure may be statically allocated or dynamically allocated with malloc(). See QHpointer.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to global.c and qhull.h

»Qhull's global variables

»Global variable and initialization routines


» Geom GlobalIoMemMergePolyQhullSetStatUser

io.c -- input and output operations

Qhull provides a wide range of input and output options. To organize the code, most output formats use the same driver:

    qh_printbegin( fp, format, facetlist, facets, printall );

    FORALLfacet_( facetlist )
      qh_printafacet( fp, format, facet, printall );

    FOREACHfacet_( facets )
      qh_printafacet( fp, format, facet, printall );

    qh_printend( fp, format );

Note the 'printall' flag. It selects whether or not qh_skipfacet() is tested.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to io.c and io.h

»io.h constants and types

»User level functions

»Print functions for all output formats

»Text output functions

»Text utility functions

»Geomview output functions

»Geomview utility functions


» Geom GlobalIoMemMergePolyQhullSetStatUser

mem.c -- memory operations

Qhull uses quick-fit memory allocation. It maintains a set of free lists for a variety of small allocations. A small request returns a block from the best fitting free list. If the free list is empty, Qhull allocates a block from a reserved buffer.

Use 'T5' to trace memory allocations.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to mem.c and mem.h

»mem.h data types and constants

»mem.h macros

»User level functions

»Initialization and termination functions


» Geom GlobalIoMemMergePolyQhullSetStatUser

merge.c -- facet merge operations

Qhull handles precision problems by merging facets. Except for redundant vertices, it corrects a problem by merging two facets. When done, all facets are clearly convex. See Imprecision in Qhull for further information.

Users may joggle the input ('QJn') instead of merging facets.

Qhull detects and corrects the following problems:

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to merge.c and merge.h

»merge.h data types, macros, and global sets

»merge.h constants

»top-level merge functions

»functions for identifying merges

»functions for determining the best merge

»functions for merging facets

»functions for merging a cycle of facets

If a point is coplanar with an horizon facet, the corresponding new facets are linked together (a samecycle) for merging.

»functions for renaming a vertex

»functions for identifying vertices for renaming

»functions for check and trace


» Geom GlobalIoMemMergePolyQhullSetStatUser

poly.c, poly2.c -- polyhedron operations

Qhull uses dimension-free terminology. Qhull builds a polyhedron in dimension d. A polyhedron is a simplicial complex of faces with geometric information for the top and bottom-level faces. A (d-1)-face is a facet, a (d-2)-face is a ridge, and a 0-face is a vertex. For example in 3-d, a facet is a polygon and a ridge is an edge. A facet is built from a ridge (the base) and a vertex (the apex). See Qhull's data structures.

Qhull's primary data structure is a polyhedron. A polyhedron is a list of facets. Each facet has a set of neighoring facets and a set of vertices. Each facet has a hyperplane. For example, a tetrahedron has four facets. If its vertices are a, b, c, d, and its facets are 1, 2, 3, 4, the tetrahedron is

A facet may be simplicial or non-simplicial. In 3-d, a simplicial facet has three vertices and three neighbors. A nonsimplicial facet has more than three vertices and more than three neighbors. A nonsimplicial facet has a set of ridges and a centrum.

A simplicial facet has an orientation. An orientation is either top or bottom. The flag, facet->toporient, defines the orientation of the facet's vertices. For example in 3-d, 'top' is left-handed orientation (i.e., the vertex order follows the direction of the left-hand fingers when the thumb is pointing away from the center). Except for axis-parallel facets in 5-d and higher, topological orientation determines the geometric orientation of the facet's hyperplane.

A nonsimplicial facet is due to merging two or more facets. The facet's ridge set determine a simplicial decomposition of the facet. Each ridge is a 1-face (i.e., it has two vertices and two neighboring facets). The orientation of a ridge is determined by the order of the neighboring facets. The flag, facet->toporient,is ignored.

A nonsimplicial facet has a centrum for testing convexity. A centrum is a point on the facet's hyperplane that is near the center of the facet. Except for large facets, it is the arithmetic average of the facet's vertices.

A nonsimplicial facet is an approximation that is defined by offsets from the facet's hyperplane. When Qhull finishes, the outer plane is above all points while the inner plane is below the facet's vertices. This guarantees that any exact convex hull passes between the inner and outer planes. The outer plane is defined by facet->maxoutside while the inner plane is computed from the facet's vertices.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to poly.c, poly2.c, poly.h, and qhull.h

»Data types and global lists for polyhedrons

»poly.h constants

»Global FORALL macros

»FORALL macros

»FOREACH macros

»Indexed FOREACH macros

»Other macros for polyhedrons

»Facetlist functions

»Facet functions

»Vertex, ridge, and point functions

»Hashtable functions

»Allocation and deallocation functions

»Check functions


» Geom GlobalIoMemMergePolyQhullSetStatUser

qhull.c -- top-level functions and basic data types

Qhull implements the Quickhull algorithm for computing the convex hull. The Quickhull algorithm combines two well-known algorithms: the 2-d quickhull algorithm and the n-d beneath-beyond algorithm. See Description of Qhull.

This section provides an index to the top-level functions and base data types. The top-level header file, qhull.h, contains prototypes for these functions.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to qhull.c, qhull.h, and unix.c

»qhull.h other data types and constants

»qhull.h other macros

»Quickhull routines in call order

»Top-level routines for initializing and terminating Qhull

»Top-level routines for reading and modifying the input

»Top-level routines for calling Qhull

»Top-level routines for returning results

»Top-level routines for testing and debugging


» Geom GlobalIoMemMergePolyQhullSetStatUser

qset.c -- set data type and operations

Qhull's data structures are constructed from sets. The functions and macros in qset.c construct, iterate, and modify these sets. They are the most frequently called functions in Qhull. For this reason, efficiency is the primary concern.

In Qhull, a set is represented by an unordered array of pointers with a maximum size and a NULL terminator (setT). Most sets correspond to mathematical sets (i.e., the pointers are unique). Some sets are sorted to enforce uniqueness. Some sets are ordered. For example, the order of vertices in a ridge determine the ridge's orientation. If you reverse the order of adjacent vertices, the orientation reverses. Some sets are not mathematical sets. They may be indexed as an array and they may include NULL pointers.

The most common operation on a set is to iterate its members. This is done with a 'FOREACH...' macro. Each set has a custom macro. For example, 'FOREACHvertex_' iterates over a set of vertices. Each vertex is assigned to the variable 'vertex' from the pointer 'vertexp'.

Most sets are constructed by appending elements to the set. The last element of a set is either NULL or the index of the terminating NULL for a partially full set. If a set is full, appending an element copies the set to a larger array.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to qset.c and qset.h

»Data types and constants

»FOREACH macros

»Access and size macros

»Internal macros

»address macros

»Allocation and deallocation functions

»Access and predicate functions

»Add functions

»Check and print functions

»Copy, compact, and zero functions

»Delete functions

»Temporary set functions


» Geom GlobalIoMemMergePolyQhullSetStatUser

stat.c -- statistical operations

Qhull records many statistics. These functions and macros make it inexpensive to add a statistic.

As with Qhull's global variables, the statistics data structure is accessed by a macro, 'qhstat'. If qh_QHpointer is defined, the macro is 'qh_qhstat->', otherwise the macro is 'qh_qhstat.'. Statistics may be turned off in user.h. If so, all but the 'zz' statistics are ignored.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to stat.c and stat.h

»stat.h types

»stat.h constants

»stat.h macros

»stat.c functions


» Geom GlobalIoMemMergePolyQhullSetStatUser

user.c -- user-definable operations

This section contains functions and constants that the user may want to change.

» Geom GlobalIoMemMergePolyQhullSetStatUser

Index to user.c and user.h

»user.h data types and configuration macros

»joggle constants

»performance related constants

»memory and other constants

»conditional compilation

»merge constants

»user.c functions


Up: Home page for Qhull
Up: Qhull manual: Table of Contents
Up: Qhull options: Table of Contents
Up: Qhull internals: Table of Contents

To: Qhull files
To: GeomGlobalIoMemMergePolyQhullSetStatUser


The Geometry Center Home Page

Comments to: qhull@geom.umn.edu
Created: May 2, 1997 --- Last modified: see top