246 lines
9.7 KiB
C
246 lines
9.7 KiB
C
/*==========================================================
|
|
File: Bezier.h
|
|
Prupose: Handle a Bezier curve
|
|
Author: Yann Le Tensorer
|
|
Creation Date: 23 january 1997
|
|
Version: 1.0
|
|
Revision: YLT - 1.1 - 3 february 1997
|
|
===========================================================*/
|
|
|
|
#ifndef __BEZIER_H__
|
|
#define __BEZIER_H__
|
|
|
|
#ifdef _AI_LIB_
|
|
// #include "AIUseCPA.h"
|
|
#include "dynamic.h"
|
|
#else /* _AI_LIB_ */
|
|
#include "mth3d.h"
|
|
#include "acp_base.h"
|
|
#include "gld.h"
|
|
#include "dynamic.h"
|
|
#endif /* _AI_LIB_ */
|
|
|
|
/* Object creation modes */
|
|
#define C_ucModeNoObject 0 /* no geometric object created */
|
|
#define C_ucModeRealObject 1 /* a geometric object is created */
|
|
|
|
|
|
/* Main bezier structure */
|
|
typedef struct _BezierObject
|
|
{
|
|
unsigned char ucSamplingRate; /* sampling rate of curve */
|
|
MTH3D_tdstVector stStartPoint; /* first point of curve */
|
|
MTH3D_tdstVector stEndPoint; /* last point of curve */
|
|
MTH3D_tdstVector stStartVector; /* first tangent vector*/
|
|
MTH3D_tdstVector stEndVector; /* last tangent vector*/
|
|
ACP_tdxHandleOfObject hObject; /* handle of géométric object*/
|
|
ACP_tdxHandleOfElement hElement; /* handle of "line" element*/
|
|
long color; /* color of the curve (24 bits)*/
|
|
GLD_tdstViewportAttributes *p_ViewPortAttributes; /* pointeur sur les attributs du viewport*/
|
|
unsigned char ucObjectMode; /* object mode C_ucModeNoObject or C_ucModeRealObject*/
|
|
MTH3D_tdstVector *d_stListOfPoints; /* List of bezier Points, in case mode=C_ucModeNoObject*/
|
|
ACP_tdstDynaParam *p_stDynaParams; /* Pointer to dynamic parameters of curve */
|
|
|
|
} tdstBezierObject;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_Calculate
|
|
Description: Calculates the points of the bézier curve according to the
|
|
parameters specified when creating the object.
|
|
Input: p_BezierObject: Pointer to a pre-created bezier object
|
|
Output: none
|
|
Author: Yann Le Tensorer
|
|
Date: 23 january 1997
|
|
Revision:
|
|
==========================================================*/
|
|
void fn_vBezierObject_Calculate(tdstBezierObject *p_BezierObject);
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_Create
|
|
Description: Create Bezier curve (in ram only) between two points
|
|
Input: p_BezierObject: pointer to a preallocated tdstBezierObject
|
|
ucSamplingRate: number of segment to define the curve)
|
|
stStartPoint: First vertex of the curve
|
|
stEndPoint: Last vertex of the curve
|
|
stStartVector: Tangent vector at the first point
|
|
stEndVector: Tangent vector at the last point
|
|
ucObjectMode: Creation mode (C_ucModeNoObject ou C_ucModeRealObject)
|
|
C_ucModeNoObject does not create a geometric object
|
|
whereas C_ucModeRealObject does.
|
|
Output: none
|
|
Author: Yann Le Tensorer
|
|
Date: 23 january 1997
|
|
Revision: YLT - 03 february 1997
|
|
==========================================================*/
|
|
void fn_vBezierObject_Create( tdstBezierObject *p_BezierObject,
|
|
unsigned char ucSamplingRate,
|
|
MTH3D_tdstVector* p_stStartPoint,
|
|
MTH3D_tdstVector* p_stEndPoint,
|
|
MTH3D_tdstVector* p_stStartVector,
|
|
MTH3D_tdstVector* p_stEndVector,
|
|
unsigned char ucObjectMode,
|
|
ACP_tdstDynaParam* p_stDynaParams);
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_SetColor
|
|
Description: Set the color of a bezier object.
|
|
Input: p_BezierObject: pointer to a pre-created tdstBezierObject
|
|
color: 24 bit color of object. (0->7=B; 8->15=G; 16->23=R ; 24->32=Unused)
|
|
Output: none
|
|
Author: Yann Le Tensorer
|
|
Date: 24 january 1997
|
|
Revision:
|
|
==========================================================*/
|
|
void fn_vBezierObject_SetColor(tdstBezierObject *p_BezierObject,long color);
|
|
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_SetViewPortAttributes
|
|
Description: Set the viewportattributes for drawing.
|
|
Input: p_BezierObject: pointer to a pre-created tdstBezierObject
|
|
p_ViewPortAttributes: pointer to pre-defined viewport attributes
|
|
Output: none
|
|
Author: Yann Le Tensorer
|
|
Date: 24 january 1997
|
|
Revision:
|
|
==========================================================*/
|
|
void fn_vBezierObject_SetViewPortAttributes(tdstBezierObject *p_BezierObject,GLD_tdstViewportAttributes *p_ViewPortAttributes);
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_Draw
|
|
Description: Draw Bezier object on screen
|
|
Input: p_BezierObject: pointer to a pre-created tdstBezierObject
|
|
Output: none
|
|
Author: Yann Le Tensorer
|
|
Date: 24 january 1997
|
|
Revision:
|
|
==========================================================*/
|
|
void fn_vBezierObject_Draw(tdstBezierObject *p_BezierObject);
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_Free
|
|
Description: Free memory allocated by the bezier objet
|
|
Input: p_BezierObject: pointer to a tdstBezierObject
|
|
Output: none
|
|
Author: Yann Le Tensorer
|
|
Date: 29 january 1997
|
|
Revision:
|
|
==========================================================*/
|
|
void fn_vBezierObject_Free(tdstBezierObject *p_BezierObject);
|
|
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_ChangeParams
|
|
Description: Changes the parameters of a bezier objet and recalculates the coordinates
|
|
of the points.
|
|
Input: p_BezierObject: Pointer to a pre-created bezier object
|
|
p_stStartPoint: Pointer to the start point
|
|
p_stEndPoint: Pointer to the end Point
|
|
p_stStartVector:Pointer to the start vector
|
|
p_stEndVector: Pointer to the end vector
|
|
Output: none
|
|
Author: Yann Le Tensorer
|
|
Date: 28 january 1997
|
|
Revision:
|
|
|
|
Notes: If an input parameter is 0, this parameter is simply not
|
|
affected. This enables to change easily only one parameter
|
|
==========================================================*/
|
|
void fn_vBezierObject_ChangeParams(tdstBezierObject *p_BezierObject,
|
|
MTH3D_tdstVector* p_stStartPoint,
|
|
MTH3D_tdstVector* p_stEndPoint,
|
|
MTH3D_tdstVector* p_stStartVector,
|
|
MTH3D_tdstVector* p_stEndVector);
|
|
|
|
/*==========================================================
|
|
Function name: fn_vBezierObject_GetParams
|
|
Description: Gets the parameters of a bezier objet
|
|
Input: p_BezierObject: Pointer to a pre-created bezier object
|
|
p_stStartPoint: Pointer to the start point
|
|
p_stEndPoint: Pointer to the end Point
|
|
p_stStartVector:Pointer to the start vector
|
|
p_stEndVector: Pointer to the end vector
|
|
Output: *p_stStartPoint:start point
|
|
*p_stEndPoint: end Point
|
|
*p_stStartVectorstart vector
|
|
*p_stEndVector: end vector
|
|
|
|
Author: Yann Le Tensorer
|
|
Date: 4 february 1997
|
|
Revision:
|
|
|
|
Notes: If an input parameter is 0, this parameter is simply not
|
|
affected.
|
|
==========================================================*/
|
|
void fn_vBezierObject_GetParams(tdstBezierObject *p_BezierObject,
|
|
MTH3D_tdstVector* p_stStartPoint,
|
|
MTH3D_tdstVector* p_stEndPoint,
|
|
MTH3D_tdstVector* p_stStartVector,
|
|
MTH3D_tdstVector* p_stEndVector);
|
|
|
|
/*==========================================================
|
|
Function name: fn_xBezierObject_GetSpeed
|
|
Description: returns the speed at a given sample (n° of the point) of a bezier object
|
|
Input: p_stDynaParam: pointer to a pre-created tdstDynaParam structure
|
|
ucSampleNo: n° of the point to get the speed from.
|
|
Output: return value is the speed.
|
|
Author: Yann Le Tensorer
|
|
Date: 03 february 1997
|
|
Revision:
|
|
==========================================================*/
|
|
MTH_tdxReal fn_xBezierObject_GetSpeed(tdstBezierObject *p_BezierObject,unsigned char ucSampleNo);
|
|
|
|
/*==========================================================
|
|
Function name: fn_xBezierObject_GetPoint
|
|
Description: returns the coordinates in the global repère of the point at a
|
|
given sample (n° of the point) of a bezier object.
|
|
Input: p_stDynaParam: pointer to a pre-created tdstDynaParam structure
|
|
ucSampleNo: n° of the point to get the coordinates from.
|
|
p_ReturnVector: pointer to a vector to be returned.
|
|
Output: *p_ReturnVector is a vector countaining the.coordinates of the point.
|
|
Author: Yann Le Tensorer
|
|
Date: 03 february 1997
|
|
Revision:
|
|
==========================================================*/
|
|
void fn_vBezierObject_GetPoint(tdstBezierObject *p_BezierObject,unsigned char ucSampleNo,MTH3D_tdstVector* p_ReturnVector);
|
|
|
|
/*===============================================================================
|
|
Function name: fn_bBezierObject_SetSamplingRate
|
|
Description: Modifies the sampling rate of a bezier object, and changes all
|
|
the depending parameters (including dynamic sampling rate)
|
|
Input: p_BezierObject: pointer to a preallocated tdstBezierObject
|
|
ucSamplingRate: New sampling rate
|
|
Output: return value is true if sampling rate could be modified,
|
|
false if not.
|
|
Author: Yann Le Tensorer
|
|
Date: 5 february 1997
|
|
Revision:
|
|
Note: The sampling rate can only be modified for objects that have been
|
|
created using C_ucModeNoObject at their creation.
|
|
================================================================================*/
|
|
|
|
ACP_tdxBool fn_bBezierObject_SetSamplingRate(tdstBezierObject *p_BezierObject,
|
|
unsigned char ucSamplingRate);
|
|
|
|
/*==========================================================
|
|
Function name: fn_ucBezierObject_GetSamplingRate
|
|
Description: Gets the sampling rate of a BezierObject objet
|
|
Input: p_BezierObject: Pointer to a pre-created Bezier object
|
|
Output: return value is the sampling rate of the circle arc object
|
|
Author: Yann Le Tensorer
|
|
Date: 5 february 1997
|
|
Revision:
|
|
==========================================================*/
|
|
unsigned char fn_ucBezierObject_GetSamplingRate(tdstBezierObject *p_BezierObject);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|