This library provides a rich set of function to create, convert, display and process freeform Bezier and NURBs curves and surfaces. The interface of the library is defined in include/cagd_lib.h. This library mainly supports low level freeform curve and surface operations. Supported are curves and surfaces from scalars to five dimensions as E1/P1 to E5/P5 using the CagdPointType. Pi is a rational (projective) version of Ei, with an additional W coefficient. Polynomial in the power basis have some very limited support as well. Different data structures to hold UV parameter values, control points, vectors, planes, bounding boxes, polylines and polygons are defined as well as the data strcutures to hold the curves and surfaces themselves,
typedef struct CagdCrvStruct { struct CagdCrvStruct *Pnext; struct IPAttributeStruct *Attr; CagdGeomType GType; CagdPointType PType; int Length; /* Number of control points (== order in Bezier). */ int Order; /* Order of curve (only for Bspline, ignored in Bezier). */ CagdBType Periodic; /* Valid only for Bspline curves. */ CagdRType *Points[CAGD_MAX_PT_SIZE]; /* Pointer on each axis vector. */ CagdRType *KnotVector; } CagdCrvStruct; typedef struct CagdSrfStruct { struct CagdSrfStruct *Pnext; struct IPAttributeStruct *Attr; CagdGeomType GType; CagdPointType PType; int ULength, VLength; /* Mesh size in the tensor product surface. */ int UOrder, VOrder; /* Order in tensor product surface (Bspline only). */ CagdBType UPeriodic, VPeriodic; /* Valid only for Bspline surfaces. */ CagdRType *Points[CAGD_MAX_PT_SIZE]; /* Pointer on each axis vector. */ CagdRType *UKnotVector, *VKnotVector; } CagdSrfStruct;
Curves and surfaces have a geometric type GType to prescribe the type of entity (such as CAGD_SBEZIER_TYPE for Bezier surface) and a point type PType to prescribe the point type of the entity (such as CAGD_PT_E3_TYPE for three dimensional Euclidean control points). Length and Order slots are used to hold the number of control points in the mesh and or control polygon and the order(s) of the basis functions. Periodic flag(s) are used to denote periodic end conditions. In addition, KnotVector slot(s) are used if the entity exploits Bspline basis functions, or NULL otherwise.
The control polygon and/or mesh itself is organized in the Points slot as a vector of size CAGD_MAX_PT_SIZE of vectors of CagdRTypes. For surfaces, the mesh is ordered U first and the macros of CAGD_NEXT_U CAGD_NEXT_V, and CAGD_MESH_UV can be used to determine indices in the mesh.
All structures in the cagd library can be allocated using New constrcutures (i.e. CagdUVNew or CagdCrfNew, freed using Free destructores (i.e. CagdSrfFree or CagdBBoxFree, linked list free using FreeList destructores (i.e. CagdPolylineFreeList), and copied using copy constructores i.e. CagdPtCopy or CagdCtlPtCopyList).
This library has its own error handler, which by default prints an error message and exit the program called CagdFatalError.
Most globals in this library have a prefix of Cagd for general cagd routines. Prefix of Bzr is used for Bezier routines, prefix of Bsp for Bspline specific routines, prefix of Cnvrt for conversion routines, and Afd for adaptive forward differencing routines.