## BzrSrfNormal

(trng_lib/trngeval.c:173)
Prototype:

      * KEYWORDS:
      *   TrngTriSrfEval, evaluation, triangular surfaces
      *****************************************************************************/
      CagdVecStruct *TrngTriSrfNrml(TrngTriangSrfStruct *TriSrf,
                                    CagdRType u,
                                    CagdRType v)

Description:
Evaluates the normal of the given triangular surface at a given point.
Parameters:

TriSrf: | To evaluate at given (u, v, w) parametric location.
--- | ---
u, v, w: | Parametric location to evaluate normal of TriSrf at.

Returned Value:

CagdVecStruct *: A pointer to a static vector holding the unit normal information.

See Also:
CagdSrfNormal BzrSrfNormal BspSrfNormal SymbSrfNormalSrf
Keywords:
normal

## TrimSrfSubdivAtParam

(trng_lib/trng_sub.c:33)
Prototype:

      TrngTriangSrfStruct *TrngSrfSubdivAtParam(TrngTriangSrfStruct *TriSrf,
                                                CagdRType t,
                                                CagdSrfDirType Dir)

Description:
Given a triangulare surface - subdivides it into two three sub-surfaces at given parametric values u, v, w. Returns pointer to a list of two trngmed surfaces, at most. It can very well may happen that the subdivided surface is completely trimmed out and hence nothing is returned for it.
Parameters:

TrngSrf: | To subdivide at the prescibed parameter value t.
--- | ---
t: | The parameter to subdivide the curve Crv at.
Dir: | Direction of subdivision. Either U or V.

Returned Value:

TrimSrfStruct *: The subdivided surfaces. Usually two, but can have only one, if other is totally trimmed away.

Keywords:
subdivision

## TrngBspTriSrfDerive

(trng_lib/trng_der.c:162)
Prototype:

      TrngTriangSrfStruct *TrngBspTriSrfDerive(TrngTriangSrfStruct *TriSrf,
                                               TrngTriSrfDirType Dir)

Description:
Given a Bspline triangular surface, computes its partial derivative triangular surface in direction Dir.
Parameters:

TriSrf: | Triangular Surface to differentiate.
--- | ---
Dir: | Direction of differentiation. Either U or V or W.

Returned Value:

TrngTriangSrfStruct *: Differentiated triangular surface in direction Dir. A Bspline triangular surface.

Keywords:
triangular surfaces

## TrngBspTriSrfHasOpenEC

(trng_lib/trng_aux.c:195)
Prototype:

      CagdBType TrngBspTriSrfHasOpenEC(TrngTriangSrfStruct *TriSrf)

Description:
Returns TRUE iff the given triangular Bspline surface has open end coditions.
Parameters:

TriSrf: | To check for open end conditions.
--- | ---

Returned Value:

CagdBType: TRUE, if given Bspline triangular surface has open end conditions, FALSE otherwise.

Keywords:
open end conditions

## TrngBspTriSrfNew

(trng_lib/trng_gen.c:75)
Prototype:

      TrngTriangSrfStruct *TrngBspTriSrfNew(int Length,
                                            int Order,
                                            CagdPointType PType)

Description:
Allocates the memory required for a new Bspline triangular surface.
Parameters:

Length: | Number of control points along the edge of the triangle.
--- | ---
Order: | Order of triangular surface in all U,V,W directions.
PType: | Type of control points (E2, P3, etc.).

Returned Value:

TrngTriangSrfStruct *: An uninitialized freeform triangular surface Bspline.

Keywords:
triangular surfaces allocation

## TrngBspTriSrfOpenEnd

(trng_lib/trng_aux.c:215)
Prototype:

      TrngTriangSrfStruct *TrngBspTriSrfOpenEnd(TrngTriangSrfStruct *TriSrf)

Description:
Returns TRUE iff the given triangular Bspline surface has open end coditions.
Parameters:

TriSrf: | To check for open end conditions.
--- | ---

Returned Value:

TrngTriangSrfStruct: A triangular Bspline surface with open end cond.

Keywords:
open end conditions

## TrngBzrTriSrfDerive

(trng_lib/trng_der.c:64)
Prototype:

      TrngTriangSrfStruct *TrngBzrTriSrfDerive(TrngTriangSrfStruct *TriSrf,
                                               TrngTriSrfDirType Dir)

Description:
Given a Bezier triangular surface, computes its principal derivative in direction Dir.
Parameters:

TriSrf: | Triangular Surface to differentiate.
--- | ---
Dir: | Direction of differentiation. Either U or V or W.

Returned Value:

TrngTriangSrfStruct *: Differentiated triangular surface in direction Dir. A Bezier triangular surface.

See Also:
TrngBzrTriSrfDerive
Keywords:
triangular surfaces derivatives

## TrngBzrTriSrfDirecDerive

(trng_lib/trng_der.c:112)
Prototype:

      TrngTriangSrfStruct *TrngBzrTriSrfDirecDerive(TrngTriangSrfStruct *TriSrf,
                                                    CagdVType DirecDeriv)

Description:
Given a Bezier triangular surface, computes its directional derivative in parametric direction DirectionalDeriv.
Parameters:

TriSrf: | Triangular Surface to differentiate.
--- | ---
DirecDeriv: | erivative direction vector (coefficients must sum to zero!).

Returned Value:

TrngTriangSrfStruct *: Differentiated triangular surface in direction Dir. A Bezier triangular surface.

See Also:
TrngBzrTriSrfDerive
Keywords:
triangular surfaces derivatives

## TrngBzrTriSrfNew

(trng_lib/trng_gen.c:108)
Prototype:

      TrngTriangSrfStruct *TrngBzrTriSrfNew(int Length, CagdPointType PType)

Description:
Allocates the memory required for a new Bezier triangular surface.
Parameters:

Length: | Number of control points along the edge of the triangle.
--- | ---
PType: | Type of control points (E2, P3, etc.).

Returned Value:

TrngTriangSrfStruct *: An uninitialized freeform triangular surface Bezier.

Keywords:
triangular surfaces allocation

## TrngCnvrtBezier2BsplineTriSrf

(trng_lib/trng_gen.c:335)
Prototype:

      TrngTriangSrfStruct *TrngCnvrtBezier2BsplineTriSrf(TrngTriangSrfStruct *TriSrf)

Description:
Converts a Bezier triangular surface into a Bspline triangular surface by adding open end uniform knot vector to it.
Parameters:

TriSrf: | A Bezier triangular surface to convert to a Bspline TriSrf.
--- | ---

Returned Value:

TrngTriangSrfStruct *: A Bspline triangular surface representing the same geometry as the given Bezier TriSrf.

Keywords:
conversion triangular surface

## TrngCoerceTriSrfTo

(trng_lib/trngcoer.c:26)
Prototype:

      TrngTriangSrfStruct *TrngCoerceTriSrfTo(TrngTriangSrfStruct *TriSrf,
                                              CagdPointType PType)

Description:
Coerces a triangular surface to point type PType.
Parameters:

TriSrf: | To coerce to a new point type PType.
--- | ---
PType: | New point type for TriSrf.

Returned Value:

TrngTriangSrfStruct *: A new trngariate with PType as its point type.

Keywords:
coercion

## TrngCrvFromTriSrf

(trng_lib/trng_iso.c:294)
Prototype:

      CagdCrvStruct *TrngCrvFromTriSrf(TrngTriangSrfStruct *TriSrf,
                                       CagdRType t,
                                       TrngTriSrfDirType Dir)

Description:
Extracts an isoparametric curve from the triangular surface TriSrf in direction Dir at the parameter value of t.
Parameters:

TriSrf: | To extract an isoparametric curve from.
--- | ---
t: | Parameter value of extracted isoparametric curve.
Dir: | Direction of extracted isocurve. Either U or V or W.

Returned Value:

CagdCrvStruct *: An isoparametric curve of TriSrf. This curve inherit the order and continuity of TriSrf in direction Dir.

See Also:
BzrSrfCrvFromSrf BspSrfCrvFromSrf CagdCrvFromMesh BzrSrfCrvFromMesh BspSrfCrvFromMesh CagdCrvFromSrf TrngTriBzrSrf2Curves
Keywords:
isoparametric curves curve from surface

## TrngDbg

(trng_lib/trng_dbg.c:26)
Prototype:

      void TrngDbg(void *Obj)

Description:
Prints triangular surface to stderr. Should be linked to programs for debugging purposes, so triangular surfaces may be inspected from a debugger.
Parameters:

Obj: | A triangular surface - to be printed to stderr.
--- | ---

Returned Value:

void

Keywords:
debugging

## TrngDescribeError

(trng_lib/trng_err.c:44)
Prototype:

      char *TrngDescribeError(TrngFatalErrorType ErrorNum)

Description:
Returns a string describing a the given error. Errors can be raised by any member of this trng library as well as other users. Raised error will cause an invokation of TrngFatalError function which decides how to handle this error. TrngFatalError can for example, invoke this routine with the error type, print the appropriate message and quit the program.
Parameters:

ErrorNum: | Type of the error that was raised.
--- | ---

Returned Value:

char *: A string describing the error type.

Keywords:
error handling

## TrngFatalError

(trng_lib/trng_ftl.c:27)
Prototype:

      void TrngFatalError(TrngFatalErrorType ErrID)

Description:
Trap Trng_lib errors right here. Provides a default error handler for the trng library. Gets an error description using TrngDescribeError, prints it and exit the program using exit.
Parameters:

ErrID: | Error type that was raised.
--- | ---

Returned Value:

void

Keywords:
error handling

## TrngParamInDomain

(trng_lib/trng_aux.c:80)
Prototype:

      CagdBType TrngParamInDomain(TrngTriangSrfStruct *TriSrf,
                                  CagdRType t,
                                  TrngTriSrfDirType Dir)

Description:
Given a triangular surface and a domain - validate it.
Parameters:

TriSrf: | To make sure t is in its Dir domain.
--- | ---
t: | Parameter value to verify.
Dir: | Direction. Either U or V or W.

Returned Value:

CagdBType: TRUE if in domain, FALSE otherwise.

Keywords:
triangular surfaces

## TrngParamsInDomain

(trng_lib/trng_aux.c:116)
Prototype:

      CagdBType TrngParamsInDomain(TrngTriangSrfStruct *TriSrf,
                                   CagdRType u,
                                   CagdRType v,
                                   CagdRType w)

Description:
Given a triangular surface and a domain - validate it.
Parameters:

TriSrf: | To make sure (u, v, w) is in its domain.
--- | ---
u, v, w: | To verify if it is in TriSrf's parametric domain.

Returned Value:

CagdBType: TRUE if in domain, FALSE otherwise.

Keywords:
triangular surfaces

## TrngTriBzrSrf2Curves

(trng_lib/trng_iso.c:164)
Prototype:

      CagdCrvStruct *TrngTriBzrSrf2Curves(TrngTriangSrfStruct *TriSrf,
                                          int NumOfIsocurves[3],
                                          RealType Val)

Description:
Routine to extract from a triangular surface NumOfIsoline isocurve list in each param. direction. Iso parametric curves are sampled equally spaced in parametric space. If, however, oout of the three NumOfIsocurves values, two are zero and one NumOfIsocurves values equals to one, extarct one isocurve at that direction, at value Val. NULL is returned in case of an error, otherwise list of CagdCrvStruct. Consider isoparametric curve of Bezier triangular surface at fixed u = u0:

          __
          \          n!             i   j              n-i-j
          /  -------------------  u0   v   (1 - u0 - v)      b    =
          --  i! j! (n - i - j)!                              ijk

     __             __
     \     n!     i \      (n - i)!       j             n-i-j
     /  ------- u0  /  ----------------  v  (1 - u0 - v)      b    =
     -- i!(n-i)!    --  j! (n - i - j)!                        ijk

    __                       __
    \     n!     i       n-i \     (n - i)!       v   j       v   n-i-j
    /  ------- u0  (1-u0)    /  --------------- (----)  (1 - ----)      b
    -- i!(n-i)!              -- j! (n - i - j)!  1-u0        1-u0        ijk

Hence, the isoparametric curve of u = u0 is a weighted sum of a sequence of Bezier curves of degree 1 to n-1, each defined over a row of the triangular mesh, over the domain of v = [0, 1-u0].
Parameters:

TriSrf: | To extract isoparametric curves from.
--- | ---
NumOfIsocurves: | In each (U or V or W) direction.
Val: | If only one isocurve to extract - do so at value Val.

Returned Value:

CagdCrvStruct *: List of extracted isoparametric curves. These curves inherit the order and continuity of the original Srf. NULL is returned in case of an error.

See Also:
TrngTriSrf2Curves TrngCrvFromTriSrf
Keywords:
curves isoparametric curves

## TrngTriSrf2Curves

(trng_lib/trng_iso.c:342)
Prototype:

      CagdCrvStruct *TrngTriSrf2Curves(TrngTriangSrfStruct *TriSrf,
                                       int NumOfIsocurves[3])

Description:
Routine to extract from a triangular surface NumOfIsoline isocurve list in each param. direction. Iso parametric curves are sampled equally spaced in parametric space. NULL is returned in case of an error, otherwise list of CagdCrvStruct.
Parameters:

TriSrf: | To extract isoparametric curves from.
--- | ---
NumOfIsocurves: | In each (U or V or W) direction.

Returned Value:

CagdCrvStruct *: List of extracted isoparametric curves. These curves inherit the order and continuity of the original Srf. NULL is returned in case of an error.

See Also:
TrngTriBzrSrf2Curves TrngCrvFromTriSrf
Keywords:
curves isoparametric curves

## TrngTriSrf2Polygons

(trng_lib/trng2ply.c:41)
Prototype:

      CagdPolygonStruct *TrngTriSrf2Polygons(TrngTriangSrfStruct *TriSrf,
                                             int FineNess,
                                             CagdBType ComputeNormals,
                                             CagdBType ComputeUV)

Description:
Routine to convert a single triangular surface to a set of triangles approximating it. FineNess is a fineness control on result and the larger it is more triangles may result. A value of 10 is a good starting value. NULL is returned in case of an error, otherwise list of CagdPolygonStruct.
Parameters:

TriSrf: | To approximate into triangles.
--- | ---
FineNess: | Control on accuracy, the higher the finer.
ComputeNormals: | If TRUE, normal information is also computed.
ComputeUV: | If TRUE, UV values are stored and returned as well.

Returned Value:

CagdPolygonStruct *: A list of polygons with optional normal and/or UV parametric information. NULL is returned in case of an error.

Keywords:
polygonization surface approximation

## TrngTriSrf2Polylines

(trng_lib/trng_iso.c:40)
Prototype:

      CagdPolylineStruct *TrngTriSrf2Polylines(TrngTriangSrfStruct *TriSrf,
                                               int NumOfIsocurves[3],
                                               int SamplesPerCurve,
                                               int Optimal)

Description:
Routine to convert a single triangular surface to NumOfIsolines polylines in each parametric direction with SamplesPerCurve in each isoparametric curve. Polyline are always E3 of CagdPolylineStruct type. Iso parametric curves are sampled equally spaced in parametric space. NULL is returned in case of an error, otherwise list of CagdPolylineStruct. Attempt is made to extract isolines along C1 discontinuities first.
Parameters:

TriSrf: | To extract isoparametric curves from.
--- | ---
NumOfIsocurves: | In each (U or V or W) direction.
SamplesPerCurve: | Fineness control on piecewise linear curve approximation.
Optimal: | Use optimal approximation of isocurves.

Returned Value:

CagdPolylineStruct *: List of polylines representing a piecewise linear approximation of the extracted isoparamteric curves or NULL is case of an error.

Keywords:
isoparametric curves

## TrngTriSrfBBox

(trng_lib/trng_aux.c:141)
Prototype:

      void TrngTriSrfBBox(TrngTriangSrfStruct *TriSrf, CagdBBoxStruct *BBox)

Description:
Computes a bounding box for a triangular surfaces.
Parameters:

TriSrf: | To compute a bounding box for.
--- | ---
BBox: | Where bounding information is to be saved.

Returned Value:

void

Keywords:
bbox bounding box

## TrngTriSrfCopy

(trng_lib/trng_gen.c:133)
Prototype:

      TrngTriangSrfStruct *TrngTriSrfCopy(TrngTriangSrfStruct *TriSrf)

Description:
Allocates and duplicates all slots of a triangular surface structure.
Parameters:

TriSrf: | triangular surface to duplicate
--- | ---

Returned Value:

TrngTriangSrfStruct *: Duplicated triangular surface.

Keywords:
triangular surfaces

## TrngTriSrfCopyList

(trng_lib/trng_gen.c:181)
Prototype:

      TrngTriangSrfStruct *TrngTriSrfCopyList(TrngTriangSrfStruct *TriSrfList)

Description:
Duplicates a list of triangular surface structures.
Parameters:

TriSrfList: | List of triangular surfaces to duplicate.
--- | ---

Returned Value:

TrngTriangSrfStruct *: Duplicated list of triangular surfaces.

Keywords:
triangular surfaces

## TrngTriSrfDerive

(trng_lib/trng_der.c:31)
Prototype:

      TrngTriangSrfStruct *TrngTriSrfDerive(TrngTriangSrfStruct *TriSrf,
                                            TrngTriSrfDirType Dir)

Description:
Given a triangular surface, computes its partial derivative triangular surface in direction Dir.
Parameters:

TV: | Triangular Surface to differentiate.
--- | ---
Dir: | Direction of differentiation. Either U or V or W.

Returned Value:

TrngTriangSrfStruct *: Differentiated triangular surface in direction Dir.

Keywords:
triangular surfaces.

## TrngTriSrfDomain

(trng_lib/trng_aux.c:33)
Prototype:

      void TrngTriSrfDomain(TrngTriangSrfStruct *TriSrf,
                            CagdRType *UMin,
                            CagdRType *UMax,
                            CagdRType *VMin,
                            CagdRType *VMax,
                            CagdRType *WMin,
                            CagdRType *WMax)

Description:
Given a triangular surface, returns its parametric domain.
Parameters:

TriSrf: | Triangular surface function to consider.
--- | ---
UMin, UMax: | U Domain of TriSrf will be placed herein.
VMin, VMax: | V Domain of TriSrf will be placed herein.
WMin, WMax: | W Domain of TriSrf will be placed herein.

Returned Value:

void

Keywords:
triangular surfaces

## TrngTriSrfEval

(trng_lib/trngeval.c:74)
Prototype:

      CagdRType *TrngTriSrfEval(TrngTriangSrfStruct *TriSrf,
                                CagdRType u,
                                CagdRType v,
                                CagdRType w)

Description:
Evaluates the given triangular surface at a given point.
Parameters:

TriSrf: | To evaluate at given (u, v, w) parametric location.
--- | ---
u, v, w: | Parametric location to evaluate TriSrf at.

Returned Value:

CagdRType *: A vector holding all the coefficients of all components of the triangualr surface's point type. If for example point type is P2, the W, X, and Y will be saved in the first three locations of the returned vector. The first location (index 0) of the returned vector is reserved for the rational coefficient W and XYZ always starts at second location of the returned vector (index 1).

Keywords:
evaluation triangular surfaces

## TrngTriSrfEval2

(trng_lib/trngeval.c:137)
Prototype:

      CagdRType *TrngTriSrfEval2(TrngTriangSrfStruct *TriSrf,
                                 CagdRType u,
                                 CagdRType v)

Description:
Evaluates the given triangular surface at a given point. Same as function TrngTriSrfEval with w computed using 'w = 1 - u - v' for Bezier triangular surfaces.
Parameters:

TriSrf: | To evaluate at given (u, v) parametric location.
--- | ---
u, v: | Parametric location to evaluate TriSrf at.

Returned Value:

CagdRType *: A vector holding all the coefficients of all components of the triangualr surface's point type. If for example point type is P2, the W, X, and Y will be saved in the first three locations of the returned vector. The first location (index 0) of the returned vector is reserved for the rational coefficient W and XYZ always starts at second location of the returned vector (index 1).

Keywords:
evaluation triangular surfaces

## TrngTriSrfFree

(trng_lib/trng_gen.c:210)
Prototype:

      void TrngTriSrfFree(TrngTriangSrfStruct *TriSrf)

Description:
Deallocates and frees all slots of a triangular surface structure.
Parameters:

TriSrf: | triangular surface to free.
--- | ---

Returned Value:

void

Keywords:
triangular surfaces

## TrngTriSrfFreeList

(trng_lib/trng_gen.c:242)
Prototype:

      void TrngTriSrfFreeList(TrngTriangSrfStruct *TriSrfList)

Description:
Deallocates and frees a list of triangular surface structures.
Parameters:

TriSrfList: | triangular surface list to free.
--- | ---

Returned Value:

void

Keywords:
triangular surfaces

## TrngTriSrfListBBox

(trng_lib/trngmesh.c:26)
Prototype:

      CagdPolylineStruct *TrngTriSrf2CtrlMesh(TrngTriangSrfStruct *TriSrf)

Description:
Computes a polyline representation to the control mesh of the triangular surface
Parameters:

TriSrf: | To compute a bounding box for.
--- | ---
BBox: | Where bounding information is to be saved.

Returned Value:

void

Keywords:
bbox bounding box

## TrngTriSrfListBBox

(trng_lib/trng_aux.c:168)
Prototype:

      void TrngTriSrfListBBox(TrngTriangSrfStruct *TriSrfs, CagdBBoxStruct *BBox)

Description:
Computes a bounding box for a list of triangular surfaces.
Parameters:

TriSrfs: | To compute a bounding box for.
--- | ---
BBox: | Where bounding information is to be saved.

Returned Value:

void

Keywords:
bbox bounding box

## TrngTriSrfMatTransform

(trng_lib/trng_gen.c:303)
Prototype:

      void TrngTriSrfMatTransform(TrngTriangSrfStruct *TriSrf, CagdMType Mat)

Description:
Transforms, in place, the given TV as specified by homogeneous matrix Mat.
Parameters:

TriSrf: | Triangular surface to transform.
--- | ---
Mat: | Homogeneous transformation to apply to TriSrf.

Returned Value:

void

Keywords:
triangular surfaces

## TrngTriSrfNew

(trng_lib/trng_gen.c:31)
Prototype:

      TrngTriangSrfStruct *TrngTriSrfNew(TrngGeomType GType,
                                         CagdPointType PType,
                                         int Length)

Description:
Allocates the memory required for a new triangular surface.
Parameters:

GType: | Type of geometry the curve should be - Bspline, Bezier etc.
--- | ---
PType: | Type of control points (E2, P3, etc.).
Length: | Number of control points along the edge of the triangle.

Returned Value:

TrngTriangSrfStruct *: An uninitialized freeform triangular surface.

Keywords:
triangular surfaces allocation

## TrngTriSrfTransform

(trng_lib/trng_gen.c:271)
Prototype:

      void TrngTriSrfTransform(TrngTriangSrfStruct *TriSrf,
                               CagdRType *Translate,
                               CagdRType Scale)

Description:
Linearly transforms, in place, given TriSrf as specified by Translate and Scale.
Parameters:

TriSrf: | Triangular surface to transform.
--- | ---
Translate: | Translation factor.
Scale: | Scaling factor.

Returned Value:

void

Keywords:
triangular surfaces