void cvxAxisTransform
(
svxMatrix *Mat,   /* I: tranformation matrix */
svxAxis *Axis     /* I/O: axis */
)
/*
DESCRIPTION:
Applies transformation matrix "Mat" to "Axis".
*/
________________________________________________________________________________

void cvxBndBoxAdd
(
svxBndBox *Box,   /* I/O: pointer to bounding box data */
svxPoint *Pnt     /* I: point to add to bounding box */
)
/*
DESCRIPTION:
"Grows" the specified bounding box to envelop the specified point.
*/
________________________________________________________________________________

void cvxBndBoxInit
(
svxBndBox *Box    /* I/O: pointer to bounding box data */
)
/*
DESCRIPTION:
Initializes the specified bounding box to all values set to zero.
*/
________________________________________________________________________________

void cvxBndBoxInit2
(
svxBndBox *Box    /* I/O: pointer to bounding box data */
)
/*
DESCRIPTION:
Initializes the specified bounding box "min" values to "positive infinity"
and "max" values to "negative infinity".
*/
________________________________________________________________________________

void cvxBndBoxMerge
(
const svxBndBox *Box1, /* I: the first bounding box */
svxBndBox *Box2        /* I/O: the second bounding box */
)
/*
DESCRIPTION:
Merge two bounding boxes and output results to the second bounding box.
*/
________________________________________________________________________________

void cvxBndBoxPnts
(
svxBndBox *Box,      /* I: pointer to bounding box data */
svxPoint *Pnts       /* I/O: pointer to array of 8 point structures */
)
/*
DESCRIPTION:
Outputs the corner points of the specified bounding box to the array
referenced by "Pnts".  Memory for the array must be allocated by the
calling procedure.  "Pnts" is a pointer to the start of the memory and
must reference at least enough memory for 8 svxPoint structures.

The corners are assigned to "Pnts" as follows, where "min" and "max"
refer to the bounding box's minimum and maximum limits in the
specified coordinate direction:

  Pnts[0] = Xmin,Ymin,Zmin
  Pnts[1] = Xmax,Ymin,Zmin
  Pnts[2] = Xmax,Ymax,Zmin
  Pnts[3] = Xmin,Ymax,Zmin
  Pnts[4] = Xmin,Ymin,Zmax
  Pnts[5] = Xmax,Ymin,Zmax
  Pnts[6] = Xmax,Ymax,Zmax
  Pnts[7] = Xmin,Ymax,Zmax

*/
________________________________________________________________________________

double cvxBndBoxSize
(
svxBndBox *Box    /* I: pointer to bounding box data */
)
/*
DESCRIPTION:
Returns the "size" of the specified bounding box -- that is,
the length of its diagonal.
*/
________________________________________________________________________________

void cvxBndBoxTransform
(
svxMatrix *Mat,    /* I: transformation matrix */
svxBndBox*Box      /* I/O: bounding box */
)

/*
DESCRIPTION:
Apply the specified transform to the specified bounding box.

If the bounding box has not been modified since initialized, do nothing.
*/
________________________________________________________________________________

int cvxCrvEval
(
int idCurve,      /* I: curve entity id */
double T,         /* I: t parameter value on curve */
svxPoint *Point,  /* O: point on curve */
svxVector *Normal /* O: normal at point on curve */
)
/*
DESCRIPTION:
Evaluates the NURBS representation of the curve entity
specified by "idCurve".  Outputs the point coordinates (Point) 
and normal direction (Normal) at the specified "t" parameter 
value.   Use cvxCrvParam() to get the curve's parameter limits.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvEval2
(
const int idCurve,         /* I: curve entity id */
const double t,            /* I: t parameter value on curve */
const int level,           /* I: level of evaluation. See description below */
svxEvalCurv* eval          /* O: Result */
)
/*
DESCRIPTION:
Evaluates a curve at a specified parameter value.

"level" specifies the level of evaluation. The higher the level, more
data gets returned (at the expense of greater computation).
                     level
      |  0  |     1     |     2      |    3
      +-----+-----------+------------+--------
      | pnt |  deriv_1  |  deriv_2   | deriv_3

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvEvalCrvtr
(
const int idCurve,       /* I: curve entity id */
const double t,          /* I : parameter at which the curvature is evaluated */
svxPoint *point,         /* O : point at the specified parameter (input NULL to ignore). */
svxPoint *normal,        /* O : unit pricipal normal vector at the specified parameter
                                 (input NULL to ignore). */
double *curvature        /* O : curvature at the specified parameter (input NULL to ignore). */
)
/*
DESCRIPTION:
Evaluates curvature, point and unit pricipal normal vector of a given curve
at the specified parameter.Use cvxCrvParam() to get the curve's parameter limits.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvExtremum
(
int         idCurve, /* I: id of curve entity */
int         *Count,  /* O: extremum point count */
svxPoint    **Pnts,  /* O: list of extremum points */
svxBndBox   *BndBox  /* O: optional curve tight bounding box (or NULL) */
)
/*
DESCRIPTION:
Return the extremum points of specified curve and its bounding box.
Return 1 if error, else 0.

The list of extremum points must be freed by caller.
*/
________________________________________________________________________________

int cvxCrvGetCusps
(
int idCurve,      /* I: id of curve in the active object */
int *Count,       /* O: number of cusps found */
double **T,       /* O: T parameter value of each cusps (NULL to ignore) */
svxPoint **Cusps  /* O: the array of cusps found (NULL to ignore) */
)
/*
DESCRIPTION:
Find cusps of the specified curve and outputs the list of
parameter value and coordinates of cusps.The calling 
procedure MUST deallocate the output list.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvGetInflections
(
int idCurve,         /* I: id of curve in the active object */
int *Count,          /* O: number of inflection points found */
double **T,          /* O: T parameter value of each inflection points (NULL to ignore) */
svxPoint **InfPnts   /* O: the array of inflection points (NULL to ignore) */
)
/*
DESCRIPTION:
Calculates inflection points of the specified curve and outputs the list of
parameter value and coordinates of inflection points found.The calling 
procedure MUST deallocate the output list.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvGetPntAtDist
(
int idCurve,      /* I: curve entity id */
double StartT,    /* I: T parameter value of starting point */
double Length,    /* I: Length of interval */
double *T,        /* O: T parameter value of output point(NULL to ignore) */
svxPoint *Point   /* O: output point on curve(NULL to ignore) */
)
/*
DESCRIPTION:
Get point on a curve at a specified distance from the specified
start point of the curve.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvInqContinuity
(
int Count,         /* I: number of curves */
int *Curves,       /* I: list of curves */
int *Continuity    /* O: continuity flag (0 to discontinuous; 
                                          1 to position continuous; 
                                          2 to tangent continuous) */
)
/*
DESCRIPTION:
Get the flag of continuity of curves.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvIsLine
(
int idCurve    /* I: index of curve */
)
/*
DESCRIPTION:
Check if the specified curve is a straight line.

RETURN:
0: the specified curve is not a straight line
1: the specified curve is a straight line
-1: the id is not a curve or function fails
*/
________________________________________________________________________________

int cvxCrvLen
(
int idCurve,   /* I: id of curve in the active object */
double *Len    /* O: curve length (mm) */
)
/*
DESCRIPTION:
Calculates the length of the specified curve and outputs it via "Len".

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvLen2
(
int idCurve,    /* I: curve entity id */
double T1,      /* I: T parameter value of start point */
double T2,      /* I: T parameter value of end point */
double *Length  /* O: length of a NURBS curve from T1 to T2 */
)
/*
DESCRIPTION:
Calculates the curve length of a NURBS curve from the parameter T1 to T2.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvMinMaxRad
(
int idCurve,       /* I: id of curve */
double* minRad,    /* O: minimum radius(NULL to ignore) */
double* maxRad,    /* O: maximum radius(NULL to ignore) */
int* isFlat        /* O: 1 if the curve is flat, else 0(NULL to ignore) */
)
/*
DESCRIPTION:
Get the maximum and minimum radius of the curve.
If curvature of curve = 0, Rad = -1 (the radius of curvature is infinite).

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvParam
(
int idCurve,      /* I: curve entity id */
svxLimit *T       /* O: min/max T values */
)
/*
DESCRIPTION:
Outputs the minimum and maximum t parameter values of the
NURBS representation of the specified curve entity. 

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxCrvPntProj
(
int idCurve,      /* I: id of curve entity */
svxPoint *Pnt,    /* I: coordinates of point to project onto curve */
double *T,        /* O: T parameter value of point-on-curve */
svxPoint *ProjPnt /* O: XYZ coordinates of projected point */
)
/*
DESCRIPTION:
Outputs the T parameter value of the projection of the input XYZ
point onto the NURBS representation of the specified curve.  It 
is assumed that "Pnt" lies on or very close to the curve.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

void cvxCrvTransform
(
svxMatrix *Mat,      /* I: tranformation matrix */
svxCurve *Crv     /* I/O: curve */
)
/*
DESCRIPTION:
Applies transformation matrix "Mat" to "Crv".
Assumes "Mat" is an affine transform.
*/
________________________________________________________________________________

int cvxFaceEval
(
int idFace,       /* I: face entity id */
double U,         /* I: U parameter value on face */
double V,         /* I: V parameter value on face */
svxPoint *Point,  /* O: point on face (input NULL to ignore) */
svxVector *Normal /* O: normal at point on face (input NULL to ignore) */
)
/*
DESCRIPTION:
Evaluates the NURBS representation of the face entity
specified by "idFace".  Outputs the 3D point coordinates (Point)
and normal direction (Normal) at the specified U,V location
on the surface.  Use cvxFaceParam() to get the face's parameter 
limits.

Note that the direction of "Normal" is set to reflect the outward
normal of the face, where "outward" means the direction that points
towards the outside of the shape that the face is associated with.
This may be opposite the natural normal of the NURBS surface associated
with the face.

If you want the natural normal of the NURBS surface associated with
the face, call cvxFaceEval2() and take the cross product of "Utan" 
and "Vtan" (cvxVecCross), which are first derivatives of the natural 
surface at the specified U,V location on the surface.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceEval2
(
int idFace,       /* I: face entity id */
double U,         /* I: U parameter value on face */
double V,         /* I: V parameter value on face */
svxPoint *Point,  /* O: point on face (input NULL to ignore) */
svxVector *Normal,/* O: normal at point on face (input NULL to ignore) */
svxVector *Utan,  /* O: U tangent direction (input NULL to ignore) */
svxVector *Vtan   /* O: V tangent direction (input NULL to ignore) */
)
/*
DESCRIPTION:
Evaluates the NURBS representation of the face entity
specified by "idFace".  Outputs the 3D point coordinates (Point),
normal direction (Normal) and UV tangent directions at the 
specified U,V location on the surface.   Use cvxFaceParam() to 
get the face's parameter limits.

Note that the direction of "Normal" is set to reflect the outward
normal of the face, where "outward" means the direction that points
towards the outside of the shape that the face is associated with.
This may be opposite the natural normal of the NURBS surface associated
with the face.


If you want the natural normal of the NURBS surface associated with
the face, take the cross product of "Utan" and "Vtan" (cvxVecCross), 
which are first derivatives of the natural surface at the specified 
U,V location on the surface.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceGetArea
(
const int faceId,           /* I: The face id in the db */
const double tolerance,     /* I: The tolerance */
double *area                /* O: The area of the face to return */
)
/*
DESCRIPTION:
Get the face area of the face which id is "faceId" in the db.

Returns 1 if function fails; 0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceGetMaxCurvature
(
const int faceId,                   /* I: face Id in the db */
const svxPoint2 uvPoint,            /* I: U,V coordinate to evaluate */
svxPoint *point,                    /* O: 3D point on surface at the uv location (NULL to ignore) */
svxPoint *normal,                   /* O: Surface normal at UV location (NULL to ignore) */
svxPoint *direction,                /* O: Surface direction(NULL to ignore) */
double *minCurvature,               /* O: minimum curvature at the uv location (NULL to ignore)*/
double *maxCurvature,               /* O: maximum curvature at the uv location (NULL to ignore) */
double *curvature,                  /* O: curvature (NULL to ignore) */
svxPoint *curvatureDirection,       /* O: curvature direction vector (NULL to ignore) */
svxPoint *curvatureCenter           /* O: curvature center (NULL to ignore) */
)
/*
DESCRIPTION:
Evaluate curvature information on a surface at a specified uv
location in the maximum curvature direction.

Returns 1 if function fails; 0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceInqBend
(
int idFace,         /* I: index of face */
int *bendFlag,      /* O: whether the face is a bending surface (1 to yes; 0 to no) */
double *bendRad,    /* O: bend radius (NULL to ignore) */
double *neutralRad, /* O: neutral radius (NULL to ignore) */
double *angle,      /* O: bend angle (NULL to ignore) */
double *thick,      /* O: thickness (NULL to ignore) */
double *kFactor,    /* O: K-factor (NULL to ignore) */
double *flatTol     /* O: flat tolerance (NULL to ignore) */
)
/*
DESCRIPTION:
Get bend information of specified face.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceIsConcave
(
int idFace  /* I: index of face */
)
/*
DESCRIPTION:
Check if the specified face is a concave or convex face. the function
is only applicable to a small subset of surfaces are universally convex
or concave, such as surfaces approximating cylinders and cones and spheres.

RETURN:
0: the specified face is a convex face
1: the specified face is a concave face
-1: the id is not a face or function fails
*/
________________________________________________________________________________

int cvxFaceIsPlanar
(
int idFace     /* I: index of face */
)
/*
DESCRIPTION:
Check if the specified face is planar.

RETURN:
0: the specified face is not planar
1: the specified face is planar
-1: the id is not a face or function fails
*/
________________________________________________________________________________

int cvxFaceParam
(
int idFace,       /* I: face entity id */
svxLimit *U,      /* O: min/max U values */
svxLimit *V       /* O: min/max V values */
)
/*
DESCRIPTION:
Outputs the minimum and maximum parameter values of the
NURBS representation of the specified face entity. 

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFacePntLoc
(
int idFace,             /* I: face entity id */
double U,               /* I: U parameter value on face */
double V,               /* I: V parameter value on face */
evxPntLocation *Loc     /* O: point location relative to face boundaries */
)
/*
DESCRIPTION:
Determines the location of the specified point on the specified face
relative to the face's trim boundaries.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFacePntProj
(
int idFace,       /* I: face entity id */
svxPoint *Point,  /* I: XYZ point on/near face */
double *U,        /* O: U coordinate of point-on-face */
double *V         /* O: V coordinate of point-on-face */
)
/*
DESCRIPTION:
Outputs the UV coordinates of the projection of the input XYX
point onto the NURBS representation of the specified face.  
It is assumed that "Point" lies on or very close to the face.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceRadialIntegrity
(
int idFace,        /* I: face entity id */
double *URatio,    /* O: radial integrity ratio value in U */
double *VRatio     /* O: radial integrity ratio value in V */
)
/*
DESCRIPTION:
Get radial integrity ratio value of specified surface. the ratio value 
is set to 0.0 when it is invalid, and then function is only applicable to 
cylinder, cone and torus.

Return 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceRadius
(
int idFace,      /* I: face entity id */
double *Radius   /* O: radius */
)
/*
DESCRIPTION:
Get the radius of specified face, only revolved surfaces 
(cylinder and sphere) are valid.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceReverse
(
int numFaces,  /* I: number of faces in input list */
int *idFaces   /* I: pointer to array of integer face id's */
)
/*
DESCRIPTION:
Reverses the direction of the natural normal of the input faces by swapping the U and V parameter 
directions of each face's surface. Each face's normal direction also reverses to keep it consistently 
oriented with respect to the surface normal and ensure a closed shape's inside and outside remain unchanged.
This function also modifies each face's pre-edges to keep them properly located in the modified UV domain. 
This function ignores any face ID that is less than 1.

See also cvxFaceReverseDir.

Returns 1 if function fails; 0 if it succeeds.
*/
________________________________________________________________________________

int cvxFaceReverseDir
(
int numFaces,   /* I: number of faces in input list */
int *idFaces    /* I: pointer to array of integer face id's */
)
/*
DESCRIPTION:
Reverses the normal direction of each input face, without changing its surface or trim loops.
If a face initially bounds a closed shape, this flips the inside and outside with respect to that shape.

Each ID in the idFaces array may refer to a face or a shape. 
When an ID refers to a shape, this function reverses all of the shape's faces.

See also cvxFaceReverse.

Returns 1 if function fails; 0 if it succeeds.
*/
________________________________________________________________________________

int cvxIsectCrvCrv
(
int idCurve1,     /* I: first curve */
int idCurve2,     /* I: second curve */
int TangentOk,    /* I: 1 to include points of tangency; else 0 */
int *Count,       /* O: number of intersection points */
svxPoint **Points /* O: list of intersection points */
)
/*
DESCRIPTION:
Outputs a list of the points where the two input curves intersect.
The calling procedure MUST deallocate the output list.

Returns 1 if function fails or no intersection point is found.
Returns 0 if one or more intersection points are found.
*/
________________________________________________________________________________

int cvxIsectCrvFace
(
int idCurve,      /* I: id of curve entity in active file */
int idFace,       /* I: id of face entity in active file */
int Trim,         /* I: 1 to intersect trimmed face; 0 to intersect entire untrimmed surface */
int TangentOk,    /* I: 1 to include points of tangency; else 0 */
int *Count,       /* O: number of intersection points */
svxPoint **Points /* O: list of intersection points */
)
/*
DESCRIPTION:
Outputs a list of the points where the input curve and face intersect.
The calling procedure MUST deallocate the output list.

Returns 1 if function fails or no intersection point is found.
Returns 0 if one or more intersection points are found.
*/
________________________________________________________________________________

int cvxIsectFaceFace
(
int idFace1,      /* I: id of the first face entity in active file */
int idFace2,      /* I: id of the second face entity in active file */
evxFaceTrim Trim, /* I: face trim-curve option */
int TangentOk,    /* I: 1 to include curves of tangency; else 0 */
int *Count,       /* O: number of intersection curves */
svxCurve **Curves /* O: list of intersection curves */
)
/*
DESCRIPTION:
Outputs a list of curves where the two input faces intersect.
the output Curves data can be added to the active part with 
the cvxPartCurve function.

The calling procedure MUST deallocate the internal data in each
element of the output list by calling cvxCurveFree, after which the
output list MUST be deallocated using cvxMemFree((void**)Curves).

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxIsectRayComp
(
int idComp,       /* I: component id */
evxFaceTrim Trim, /* I: face trim option */
svxAxis *Ray,     /* I: ray defined by a point and a direction */
svxPoint *Point   /* O: closest intersection point (NULL to ignore) */
)
/*
DESCRIPTION:
Intersects the input ray with the specified component in the
active part and outputs the point closest to the ray 
startpoint (Ray->Pnt). The output point coordinates are given
in the space of the active part.  Note that the ray only extends 
in the specified direction from the startpoint.  Intersections 
in the other direction are not considered. 

The "Trim" option is used to determine what portions of
the component's faces are checked against the ray.

Returns 1 if function fails or no intersection is found.
Returns 0 if intersection point succesfully found.
*/
________________________________________________________________________________

int cvxIsectRayComps
(
int nComps,             /* I: number of components */
svxEntPath *CompPaths,  /* I: pick path of components */
evxFaceTrim Trim,       /* I: face trim option */
svxAxis *Ray,           /* I: ray defined by a point and a direction */
int *Number,            /* O: number of intersection point */
svxPoint **Points,      /* O: list of intersection points (NULL to ignore) */
svxEntPath** FacePaths  /* O: list of face pick paths that intersection 
                              point lies (NULL to ignore) */
)
/*
DESCRIPTION:
Intersects the input ray with the input components and outputs the intersection points.
Note the positive and negative directions of the ray will be involved in the calculation.

The "Trim" option is used to determine what portions of the shape's faces are 
checked against the ray.

This function allocates memory for the array output via "Points" and "FacePaths". 
The calling procedure is responsible for deallocating the memory.

Returns 1 if function fails, else returns 0.
*/
________________________________________________________________________________

int cvxIsectRayCrv
(
svxAxis *Ray,     /* I: ray defined by a point and a direction */
int idCurve,      /* I: curve entity */
int TangentOk,    /* I: 1 to include points of tangency; else 0 */
int *Count,       /* O: number of intersection points */
svxPoint **Points /* O: list of intersection points */
)
/*
DESCRIPTION:
Outputs a list of the points where the input ray and curve intersect.
The calling procedure MUST deallocate the output list.

Returns 1 if function fails or no intersection point is found.
Returns 0 if one or more intersection points are found.
*/
________________________________________________________________________________

int cvxIsectRayFace
(
int idFace,       /* I: id of face in active file */
evxFaceTrim Trim, /* I: face trim option */
svxAxis *Ray,     /* I: ray defined by a point and a direction */
svxPoint *Point,  /* O: intersection point (NULL to ignore) */
svxPoint2 *UV     /* O: U,V coordinates (NULL to ignore) */
)
/*
DESCRIPTION:
Intersects the input ray with the input face and outputs the
point closest to the ray startpoint (Ray->Pnt).  Note that the
ray only extends in the specified direction from the startpoint.
Intersections in the other direction are not considered.

The "Trim" option is used to determine what portions of
the face are checked against the ray.

Returns 1 if function fails or no intersection is found.
Returns 0 if intersection point succesfully found.
*/
________________________________________________________________________________

int cvxIsectRayPart
(
evxFaceTrim Trim, /* I: face trim option */
svxAxis *Ray,     /* I: ray defined by a point and a direction */
svxPoint *Point,  /* O: closest intersection point (NULL to ignore) */
int *idFace       /* O: id of face that intersection point lies on */
                  /*    (input NULL to ignore this output) */
)
/*
DESCRIPTION:
Intersects the input ray with all faces of the active part and 
outputs the point closest to the ray startpoint (Ray->Pnt).  
Note that the ray only extends in the specified direction from 
the startpoint.  Intersections in the other direction are not 
considered.  If an intersection is found, the id of the intersected 
face is optionally output.  Use cvxPartInqFaceShape() to get the 
id of the face's parent shape.

The "Trim" option is used to determine what portions of
the parts's faces are checked against the ray.

Returns 1 if function fails or no intersection is found.
Returns 0 if intersection point succesfully found.
*/
________________________________________________________________________________

int cvxIsectRayPartVis
(
evxFaceTrim Trim, /* I: face trim option */
svxAxis *Ray,     /* I: ray defined by a point and a direction */
svxPoint *Point,  /* O: closest intersection point (NULL to ignore) */
int *idFace       /* O: id of face that intersection point lies on */
                  /*    (input NULL to ignore this output) */
)
/*
This function is the same as cvxIsectRayPart(), except that it
only considers visible faces.  That is, it ignores faces that
belong to blanked shapes.
*/
________________________________________________________________________________

int cvxIsectRayPlane
(
svxAxis *Ray,     /* I: ray defined by a point and a direction */
svxMatrix *Plane, /* I: plane transformation matrix (XY plane) */
svxPoint *Point   /* O: intersection point */
)
/*
DESCRIPTION:
Intersects the input ray with the XY plane of the specified 
transformation matrix and outputs the point of intersection.

Returns 0 if intersection point succesfully found.
Returns 1 if the ray is parallel to, and on the plane.
Returns 2 if the ray is parallel to, but off the plane.
*/
________________________________________________________________________________

int cvxIsectRayShape
(
int idShape,      /* I: id of shape in active part */
evxFaceTrim Trim, /* I: face trim option */
svxAxis *Ray,     /* I: ray defined by a point and a direction */
svxPoint *Point,  /* O: closest intersection point (NULL to ignore) */
int *idFace       /* O: id of face that intersection point lies on */
                  /*    (input NULL to ignore this output) */
)
/*
DESCRIPTION:
Intersects the input ray with the input shape and outputs the
point closest to the ray startpoint (Ray->Pnt).  Note that the
ray only extends in the specified direction from the startpoint.  
Intersections in the other direction are not considered.  If an
intersection is found, the id of the intersected face is
optionally output.

The "Trim" option is used to determine what portions of
the shapes's faces are checked against the ray.

Returns 1 if function fails or no intersection is found.
Returns 0 if intersection point succesfully found.
*/
________________________________________________________________________________

int cvxIsectRayShapes
(
int nShapes,        /* I: number of shapes */
int *idShapes,      /* I: index of shapes */
evxFaceTrim Trim,   /* I: face trim option */
svxAxis *Ray,       /* I: ray defined by a point and a direction */
int *Number,        /* O: number of intersection point */
svxPoint **Points,  /* O: list of intersection points (NULL to ignore) */
int **idFaces       /* O: list of face ids that intersection point lies (NULL to ignore) */
)
/*
DESCRIPTION:
Intersects the input ray with the input shapes and outputs the intersection points.  
Note the positive and negative directions of the ray will be involved in the calculation. 

The "Trim" option is used to determine what portions of the shape's faces are 
checked against the ray.

This function allocates memory for the array output via "Points" and "FacePaths".
The calling procedure is responsible for deallocating the memory.

Returns 1 if function fails, else returns 0.
*/
________________________________________________________________________________

int cvxMatEigen
(
const double Mat3x3[3][3], /* I: matrix */
double *Values,            /* O: three real-valued eigenvalues (or NULL) */
svxVector *Vectors         /* O: three eigenvectors for the eigenvalues (or NULL) */
)
/*
Calculates the eigenvalues and eigenvectors of a 3x3 matrix.

Three real-valued eigenvalues are output in Values, which is an array
that must be provided by the caller and must be dimensioned large
enough to hold at least 3 double precision numbers.  The caller may
pass NULL for the Values argument if the eigenvalues are not wanted.
This function always computes three eigenvalues, repeating values in
the Values array if necessary.

The eigenvectors corresponding to the eigenvalues are output in
Vectors, which is an array that must be provided by the caller and
must be dimensioned large enough to hold at least 3 svxVector
structures.  The caller may pass NULL for the Vectors argument if the
eigenvectors are not wanted.

Vectors[i] is the eigenvector corresponding to the eigenvalue
Values[i], but the eigenvalues are not sorted.  The largest or
smallest eigenvalue may be in any element of the Values array.

Returns 1 if three real eigenvalues (not necessarily distinct) cannot
be determined, otherwise returns 0.
*/
________________________________________________________________________________

int cvxMatFromEuler
(
evxEulerAngSeq Seq,                /* I: rotation sequence type, see description */
const svxMatEuler *pzMatEuler,     /* I: Euler angles and translate vector */
svxMatrix *pMat                    /* O: transformation matrix */
)
/*
DESCRIPTION:
   Conversion from Euler Angles to Transform Matrix. Two categories of rotation sequence:
   1. Proper Euler Angle - when the first and third rotation are around the same axes.
      121: X-axis, Y-axis, X-axis
      131: X-axis, Z-axis, X-axis
      212: Y-axis, X-axis, Y-axis
      232: Y-axis, Z-axis, Y-axis
      313: Z-axis, X-axis, Z-axis
      323: Z-axis, Y-axis, Z-axis
   2. Tait-Bryan or Roll-Pitch-Yaw Angles - when three rotations are around different axes.
      123: X-axis (Roll), Y-axis (Pitch), Z-axis (Yaw)
      132: X-axis (Roll), Z-axis (Yaw), Y-axis (Pitch)
      213: Y-axis (Pitch), X-axis (Roll), Z-axis (Yaw)
      231: Y-axis (Pitch), Z-axis (Yaw), X-axis (Roll)
      312: Z-axis (Yaw), X-axis (Roll), Y-axis (Pitch)
      321: Z-axis (Yaw), Y-axis (Pitch), X-axis (Roll)
RETURN:
   (0) OK; (1) Failed.
*/
________________________________________________________________________________

void cvxMatInit
(
svxMatrix *Mat    /* I/O: transformation matrix */
)
/*
DESCRIPTION:
Initializes "Mat" to the identity matrix.
*/
________________________________________________________________________________

void cvxMatInvert
(
svxMatrix *Mat,      /* I: tranformation matrix */
svxMatrix *InvMat    /* O: inverted tranformation matrix */
)
/*
DESCRIPTION:
Output an inverted version of "Mat" via "InvMat".
*/
________________________________________________________________________________

void cvxMatMult
(
svxMatrix *Mat1,     /* I: first tranformation matrix */
svxMatrix *Mat2,     /* I: second tranformation matrix */
svxMatrix *Mat3      /* O: resulting matrix */
)
/*
DESCRIPTION:
Matrix multiply (Mat3 = Mat1 * Mat2).
*/
________________________________________________________________________________

void cvxMatPntVec
(
svxPoint *Origin, /* I: origin */
svxVector *zAxis, /* I: direction of Z axis */
svxMatrix *Mat    /* O: transformation matrix */
)
/*
DESCRIPTION:
Composes a transformation matrix that defines a reference
frame whose origin coincides with "Origin", whose Z axis
points in the direction of "zAxis", with arbitrary X and
Y axes.
*/
________________________________________________________________________________

int cvxMatPntVecs
(
svxPoint *Origin,   /* I: origin, optional */
svxVector *xAxis,   /* I: direction of x axis */
svxVector *yAxis,   /* I: direction of y axis */
svxMatrix *Mat      /* O: transformation matrix */
)
/*
DESCRIPTION:
Compose a transformation matrix that defines a reference frame
with an origin coinciding with "Origin" and X and Y axes being
aligned to the directions given by "xAxis" and "yAxis", respectively.
The "xAxis" and "yAxis" inputs need not be unit vectors, and as 
long as they are not parallel, they do not have to be perpendicular.

Return 1 if function fails, else returns 0.
*/
________________________________________________________________________________

void cvxMatRotate
(
svxMatrix *Mat,      /* I/O: transformation matrix */
double Angle,        /* I: rotation angle (deg) */
svxAxis *Axis        /* I: axis of rotation */
)
/*
DESCRIPTION:
Initializes a transformation matrix "Mat" to perform rotations
by the specified angle about the specified axis.
*/
________________________________________________________________________________

void cvxMatScale
(
svxMatrix *Mat,   /* I/O: transformation matrix */
svxPoint *Point,  /* I: reference point */
double sX,        /* I: X scale */
double sY,        /* I: Y scale */
double sZ         /* I: Z scale */
)
/*
DESCRIPTION:
Initializes "Mat" so that it will scale points by sX, sY, sZ
relative to "Point".
*/
________________________________________________________________________________

void cvxMatSetIdentity
(
svxMatrix *Mat    /* I/O: transformation matrix */
)
/*
DESCRIPTION:
Make sure "identity" flag associated with "Mat" is set correctly.
*/
________________________________________________________________________________

int cvxMatToEuler
(
evxEulerAngSeq Seq,         /* I: rotation sequence type, see description */
svxMatrix *pMat,            /* I: transformation matrix */
svxMatEuler *pzMatEuler     /* O: Euler angles and translate vector */
)
/*
DESCRIPTION:
   Conversion Transform Matrix to Euler Angles. Two categories of rotation sequence:
   1. Proper Euler Angle - when the first and third rotation are around the same axes.
      121: X-axis, Y-axis, X-axis
      131: X-axis, Z-axis, X-axis
      212: Y-axis, X-axis, Y-axis
      232: Y-axis, Z-axis, Y-axis
      313: Z-axis, X-axis, Z-axis
      323: Z-axis, Y-axis, Z-axis
   2. Tait-Bryan or Roll-Pitch-Yaw Angles - when three rotations are around different axes.
      123: X-axis (Roll), Y-axis (Pitch), Z-axis (Yaw)
      132: X-axis (Roll), Z-axis (Yaw), Y-axis (Pitch)
      213: Y-axis (Pitch), X-axis (Roll), Z-axis (Yaw)
      231: Y-axis (Pitch), Z-axis (Yaw), X-axis (Roll)
      312: Z-axis (Yaw), X-axis (Roll), Y-axis (Pitch)
      321: Z-axis (Yaw), Y-axis (Pitch), X-axis (Roll)
RETURN:
   (0) OK; (1) Failed.
*/
________________________________________________________________________________

void cvxMatTransform
(
svxMatrix *Mat,      /* I: tranformation matrix */
svxMatrix *Frame  /* I/O: coordinate frame (i.e. tranform) */
)
/*
DESCRIPTION:
Applies transformation matrix "Mat" to "Frame".
*/
________________________________________________________________________________

void cvxMatTranslate
(
svxMatrix *Mat,   /* I/O: transformation matrix */
double dX,        /* I: X distance */
double dY,        /* I: Y distance */
double dZ         /* I: Z distance */
)
/*
DESCRIPTION:
Initializes "Mat" so that it will translate points by dX, dY, dZ.
*/
________________________________________________________________________________

void cvxMatView
(
svxMatrix *Mat,   /* I/O: transformation matrix */
evxViewStd Type   /* I: standard view type */
)
/*
DESCRIPTION:
Initializes "Mat" to the specified standard view.
*/
________________________________________________________________________________

int cvxPlnThruPnts
(
int PntCount,        /* I: number of points in point list */
svxPoint *PntList,   /* I: list of points */
svxVector *Normal,   /* O: unit length vector normal to the plane */
double *D            /* O: the last term in the plane equation (see description below) */
)
/*
DESCRIPTION:

Given "PntCount" points, this function computes the least squares plane
fitted through these points. It then checks to see if the points are 
contained within this plane such that for any point (X,Y,Z) in the plane,
the following equation holds true:

Normal.x * X + Normal.y * Y + Normal.z * Z + D = 0

Return values :

-2 : line or point in xy-plane (points do not define a plane).
-1 : line or point not in xy-plane (points do not define a plane).
0 : points do not lie in a unique plane.
1 : points lie in a unique plane (not the xy-plane).
2 : points lie in the xy-plane.
*/
________________________________________________________________________________

double cvxPntDist
(
const svxPoint *Point1,    /* I: first point */
const svxPoint *Point2     /* I: second point */
)
/*
DESCRIPTION:
Returns the distance between two points.
*/
________________________________________________________________________________

int cvxPntEntLoc
(
svxPoint *Pnt,         /* I: point coordinates of the inquiry */
int idEntity,          /* I: entity id (only curve, edge, face and shape are supported) */
evxPntLocation *PntLoc /* O: returned status of the point on the entity */
)
/*
DESCRIPTION:
Determine if a given point lies inside, outside or on the boundary of a given curve,
edge, face or shape.

Return 1 if function fails, 0 if it succeeds.
*/
________________________________________________________________________________

int cvxPntIsCritical
(
svxPoint *pnt,    /* I: point */
int idCurve       /* I: index of 2D curve*/
)
/*
DESCRIPTION:
This function is to determine whether the pnt is the critical point of
the 2D curve with index idCurve in Drawing Sheet.

Returning 1 indicates it is a critical point, else, it is NOT. Meaning
of critical point is the point with start, end, middle or center position
of the curve.
*/
________________________________________________________________________________

int cvxPntIsOn
(
svxPoint *Pnt,    /* I: point */
int idEntity      /* I: id of curve, edge, face or plane entity */
)
/*
DESCRIPTION:
Returns 1 if the input point lies within the active proximity tolerance
of the input entity. If not, this function returns 0.
*/
________________________________________________________________________________

int cvxPntOnCrv
(
int idCurve,      /* I: id of curve in the active object */
double Fraction,  /* I: fraction of curve length (0.0 to 1.0) */
svxPoint *Point   /* O: point on curve */
)
/*
DESCRIPTION:
Calculates a 3D point on the specified curve entity
(in the active object) at the input fraction of the 
curve's length from its startpoint.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxPntOnFace
(
int idComp,       /* I: id of component that contains face (0 if undefined) */
int idFace,       /* I: id of face in active part or specified component */
double Param[2],  /* O: u,v parameter values */
svxPoint *Point   /* O: point on face (NULL to ignore) */
)
/*
DESCRIPTION:
Calculates a point on the specified face at the midpoint of 
the face's bounding box in UV parameter space.  The 3D point 
coordinates are output in the space of the active part, even 
if the face belongs to a child component of the part (idComp > 0).  
The corresponding U,V parameters are output as Param[0] and Param[1].

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxPntProject
(
svxPoint *Pnt,    /* I: point to project */
int idEntity,     /* I: id of curve, edge, face or plane entity */
svxPoint *ProjPnt /* O: projected point on entity */
)
/*
DESCRIPTION:
Projects "Pnt" onto the specified curve, edge, face or plane 
and outputs the result as "ProjPnt".

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

void cvxPntTransform
(
svxMatrix *Mat,      /* I: tranformation matrix */
svxPoint *Point      /* I/O: point */
)
/*
DESCRIPTION:
Applies transformation matrix "Mat" to "Point".
*/
________________________________________________________________________________

void cvxPntTransformList
(
svxMatrix *Mat,      /* I: tranformation matrix */
int Count,           /* I: number of points to transform */
svxPoint *Points     /* I: list of points to transform */
)
/*
DESCRIPTION:
Applies transformation matrix "Mat" to "Point".
*/
________________________________________________________________________________

void cvxPntTranslate
(
svxPoint *Point,     /* I/O: point */
svxVector *Vector,   /* I: direction vector */
double Distance      /* I: distance */
)
/*
DESCRIPTION:
Translates "Point" along "Vector" by "Distance".
This function assumes that "Vector" is normalized.
*/
________________________________________________________________________________

int cvxPolyToTri
(
int PntCount,        /* I: number of points in point list */
svxPoint *PntList,   /* I: point list of polygon vertex coordinates */
int *VtxCount,       /* O: number of triangle vertex indices in vertex list */
int **VtxList        /* O: vertex list of triangle vertex indices (see description below) */
)
/*
DESCRIPTION:

Given an array of points "PntList" defining the coordinates of a
polygon's vertices, this function decomposes the polygon into
triangles.  The triangles are defined by an array of vertex indices
"VtxList", which is an int list of indices into the PntList array.
Every three elements in the output list define one triangle,
i.e. VtxList[0], VtxList[1] and VtxList[2] contain the PntList array
indices of the first triangle's vertices, VtxList[3], VtxList[4] and
VtxList[5] contain the PntList array indices of the second triangle,
and so on.  The total number of triangle vertices is output in
VtxCount.  The total number of triangles for the given polygon will be
(*VtxCount)/3.

The points in PntList are assumed to be in vertex order around the
perimeter of the polygon.  The polygon may be concave.

This function allocates the output array VtxList.  The caller is
responsible for freeing VtxList using cvxMemFree.

Return 0 if the polygon is successfully tessellated into triangles.
Return 1 if an error occurs.
*/
________________________________________________________________________________

double cvxRoundNumber
(
double Num,  /* I: Number to round. */
double Step, /* I: Incremental step size, may be 0. */
double Tol,  /* I: Tolerance for two values to be the same. */
int    Dir   /* I: Rounding direction (0 nearest, -1 down, +1 up). */
)
/*
DESCRIPTION:
Return rounded number.  "Rounding" in this case means the number is
adjusted to a value that is a whole-number multiple of the incremental
step size Step.  For example, if Step is 0.25, this function returns
values such as -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 1.0, and so on.  To
round a number to the nearest integer value, set Step to 1.

If Step is effectively 0 or negative, the incremental step size is so
small that no rounding occurs and the return value is Num.

If the rounding direction Dir is 0, Num is rounded to the nearest
whole-number multiple of Step, which may be greater or less than Num.
For example, if Step is 1, an input value of 3.4 is rounded down to
3.0, and an input value of 3.6 is rounded up to 4.0.

If Dir is +1, the magnitude of Num is rounded up.  For example, if
Step is 1, an input value of 3.4 is rounded to 4.0, and an input value
of -3.4 is rounded to -4.0.

If Dir is -1, the magnitude of Num is rounded down.  For example, if
Step is 1, an input value of 3.6 is rounded to 3.0, and an input value
of -3.6 is rounded to -3.0.

The tolerance Tol helps to avoid unintended rounding.  If Num is
within Tol of a whole-number multiple of Step, Num is rounded to the
latter value regardless of the rounding direction specified by Dir.
For example, suppose Step is 1 and Dir is -1, but Num is 3.99999 when
Tol is 0.01.  The result will be rounded up to 4.0 because Num is is
effectively the same as 4.0 within the given tolerance, despite Dir
indicating that Num should be rounded down.

The step size Step should be much larger than the tolerance Tol.

If Num is a value that represents a distance or an angle, all three
inputs Num, Step and Tol should have the same units.
*/
________________________________________________________________________________

int cvxSrfAxis
(
svxSurface *Srf,       /* I: pointer to NURBS surface data structure */
svxPoint *startPnt,    /* O: start point of axis line */
svxPoint *endPnt       /* O: end point of axis line */
)
/*
DESCRIPTION:
Get the axis of the specified surface. the surface type must be 
one of the following: Cylinder, Torus and Cone.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxSrfDiameterEval
(
svxSurface *Srf,  /* I: pointer to NURB surface data structure */
double U,         /* I: U parameter value on face */
double V,         /* I: V parameter value on face */
double *Diameter  /* O: diameter of specified point */
)
/*
DESCRIPTION:
Get the surface diameter in the specified UV point. the surface type
must be one of the following:
1.Cylinder: the cylinder diameter.
2.Torus: the distance of the point specified from the axis.
3.Cone: the distance of the point specified from the axis.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxSrfEval
(
svxSurface *Srf,  /* I: pointer to NURBS surface data structure */
double U,         /* I: U parameter value on face */
double V,         /* I: V parameter value on face */
svxPoint *Point,  /* O: point on face (input NULL to ignore) */
svxVector *Normal,/* O: normal at point on face (input NULL to ignore) */
svxVector *Utan,  /* O: U tangent direction (input NULL to ignore) */
svxVector *Vtan   /* O: V tangent direction (input NULL to ignore) */
)
/*
DESCRIPTION:
Evaluates a point in the space of the specified NURBS surface.  Outputs 
the 3D point coordinates (Point), normal direction (Normal) and UV tangent 
directions at the specified U,V location on the surface.  

Note that the direction of "Normal" is set to reflect the outward
normal of the face, where "outward" means the direction that points
towards the outside of the shape that the face is associated with.
This may be opposite the natural normal of the NURBS surface associated
with the face.


If you want the natural normal of the NURBS surface associated with
the face, take the cross product of "Utan" and "Vtan" (cvxVecCross), 
which are first derivatives of the natural surface at the specified 
U,V location on the surface.

Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

int cvxSrfFindPoles
(
svxSurface *srf,    /* I: pointer to NURBS surface data structure */
double tol,         /* I: the tolerance */
int poles[4]        /* O : poles[i] = 0 means the i-th boundary is not a pole.
                           poles[i] = 1 means it is a pole.
                           The boundaries are numbered counterclockwise, starting at
                           the bottom (v=0).
                           fPoles[0] -> pole at loV
                           fPoles[1] -> pole at hiU
                           fPoles[2] -> pole at hiV
                           fPoles[3] -> pole at loU */
)
/*
DESCRIPTION
This routine determines which, if any, boundaries of srf are poles.
It sets the flags in the array poles appropriately.

RETURN:
  0 - No poles found
  1 - At least one pole found
*/
________________________________________________________________________________

int cvxSrfGetPole
(
svxSurface*srf,           /* I: pointer to NURBS surface data structure */
const svxPoint *dir,      /* I: direction */
svxPoint*pnt              /* O: pole point*/
)
/*
DESCRIPTION
Get the pole point of the specified surface in a specified direction.

RETURN:
   Returns 1 if function fails,  0 if it succeeds.
*/
________________________________________________________________________________

void cvxSrfTransform
(
svxMatrix *Mat,      /* I: tranformation matrix */
svxSurface *Srf      /* I/O: surface */
)
/*
DESCRIPTION:
Applies transformation matrix "Mat" to "Srf".
Assumes "Mat" is an affine transform.
*/
________________________________________________________________________________

void cvxVecAngle
(
svxVector *V1,    /* I: first vector */
svxVector *V2,    /* I: second vector */
double *Angle     /* O: angle (radians) between vectors */
)
/*
DESCRIPTION:
Calculates the angle (radians) between the input vectors.
*/
________________________________________________________________________________

void cvxVecCross
(
svxVector *V1,    /* I: first vector */
svxVector *V2,    /* I: second vector */
svxVector *Cross  /* O: cross product of V1 and V2 */
)
/*
DESCRIPTION:
Gets the cross product of two vectors.
*/
________________________________________________________________________________

void cvxVecInit
(
svxPoint *Point1,    /* I: first point */
svxPoint *Point2,    /* I: second point */
svxVector *Vector    /* O: direction vector */
)
/*
DESCRIPTION:
Initializes a normalized "Vector" that points along
the direction from "Point1" to "Point2".
*/
________________________________________________________________________________

void cvxVecNormalize
(
svxVector *Vector    /* I/O: direction vector */
)
/*
DESCRIPTION:
Normalizes a direction vector to unit magnitude (1.0).
*/
________________________________________________________________________________

int cvxVecParallelChk
(
int Orient,      /* I: 0 = parallel vectors can be in same or opposite direction
                       1 = Parallel vectors must point in same direction
                       2 = Parallel vectors must point in opposite directions */
svxVector *V1,   /* I: first vector */
svxVector *V2,   /* I: second vector */
double CosTol    /* I: cosine of maximum angle allowed for parallelism */
)
/*
DESCRIPTION:
Determine whether two vectors are parallel within a specified angular tolerance.

The CosTol tolerance is the cosine of the maximum angle allowed between the 
vectors for them to be considered parallel. The table below shows the maximum 
angle allowed between the vectors (right) for several values of CosTol (left):
                     CosTol               degrees
                     0.9          -        25.84 
                     0.9848       -          10
                     0.9962       -          5
                     0.9986       -          3
                     0.9994       -          2
                     0.99985      -          1
                     0.99996      -         0.5
                     0.999998     -         0.1

RETURN VALUE:
1: vectors are parallel; if Orient is 1, the vectors also point in the same 
   direction; if Orient is 2, the vectors point in opposite directions.
0: vectors are NOT parallel, or are not oriented with respect to each other
   as required by Orient, or at least one vector degenerates to zero length.
 */
________________________________________________________________________________

void cvxVecPerp
(
svxVector *Vector,   /* I: reference vector */
svxVector *Perp      /* O: vector perpendicular to input "Vector" */
)
/*
DESCRIPTION:
Creates a vector that is perpendicular to another vector.
*/
________________________________________________________________________________

void cvxVecReverse
(
svxVector *Vector    /* I: vector */
)
/*
DESCRIPTION:
Reverses the direction of the input vector.
*/
________________________________________________________________________________

void cvxVecTransform
(
svxMatrix *Mat,      /* I: tranformation matrix */
svxVector *Vector    /* I/O: vector */
)
/*
DESCRIPTION:
Applies transformation matrix "Mat" to "Vector".
*/
________________________________________________________________________________