/*
------------------------------------------------------------------------------------------
IMPLEMENTATION FILE FOR :
  Definition of (way) editor object : bezier curves.
------------------------------------------------------------------------------------------
File Name :
  Edi_Bez.c
------------------------------------------------------------------------------------------
Creation Date : 
  February 20,1997
Author : 
  Albert PAIS
------------------------------------------------------------------------------------------
Contents :
  This file implements structures and functions for the bezier curve used by
  the (way) editor.
------------------------------------------------------------------------------------------
Remarks :
  Code comes from old bezier.c made by Yann Le Tensorer (January-February 1997)
------------------------------------------------------------------------------------------
See Also :
  * Bezier.h for definition.
  * Mth_Bezier.h/.c for mathematical bezier curve definition and implementation.
------------------------------------------------------------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
------------------------------------------------------------------------------------------
*/

/*
------------------------------------------------------------------------------------------
INCLUDE FILES :
------------------------------------------------------------------------------------------
*/

/*
----------------------------------------
File Name :
  acp_base.h
----------------------------------------
Required for :
  Standard CPA definitions
----------------------------------------
*/
#include "acp_base.h"

/*
----------------------------------------
File Name :
  gli.h
----------------------------------------
Required for :
  Graphic Library Interface
----------------------------------------
*/
#include "geo.h"
#include "gli.h"

/*
----------------------------------------
File Name :
  Edi_Bez.h
----------------------------------------
Required for :
  Definition of Bezier editor
  structures and functions
----------------------------------------
*/

#define _EDWAY_BEZ_FRIEND_
#include "Edi_Bez.h"
#undef _EDWAY_BEZ_FRIEND_



/*
----------------------------------------
File Name :
  geoobj.h
----------------------------------------
Required for :
  For geometric object
----------------------------------------
*/
#include "geo.h"

/*
----------------------------------------
File Name :
  Mth_Bez.h
----------------------------------------
Required for :
  For MTH Bezier Curve definitions
----------------------------------------
*/
#include "Mth_Bez.h"


/*
------------------------------------------------------------------------------------------
FUNCTIONS AND MACROS-FUNCTIONS DECLARATION:
------------------------------------------------------------------------------------------
*/

#define M_malloc(pointer,cast,size) (pointer=(cast)malloc(size))
#define M_free(pointer) (free(pointer))


int iJustToLinkBezBidouille;
void fn_vJustToLinkBez (void) {   iJustToLinkBezBidouille=1;  }



/*
---------------------------------------
Contents :
 Allocates a new editor bezier object
 structure.
---------------------------------------
Function Name :
 EDWAY_fnh_BezierObject_CreateStructure
---------------------------------------
Arguments :
  * None
---------------------------------------
Return value :
  * Type :
   EDWAY_tdhBezierObject
  * Possible Value :
    * A valid handle (non-null)
      The function succeded
    * An invalid handle (null value)
      Allocation failed.
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 27,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
---------------------------------------
*/
EDWAY_tdhBezierObject EDWAY_fnh_BezierObject_CreateStructure(void)
{
 EDWAY_tdhBezierObject hNewBezierObject;
 M_malloc(hNewBezierObject,EDWAY_tdhBezierObject,EDWAY_M_uwBezierObjectSizeOf());
 if(hNewBezierObject)
  memset(hNewBezierObject,0,EDWAY_M_uwBezierObjectSizeOf());
 return hNewBezierObject;
}

/*
---------------------------------------
Contents :
 Destroy the structure.
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_DestroyStructure
---------------------------------------
Arguments :
 * Name    : _hOldBezierObject
   Type    : EDWAY_tdhBezierObject
   Meaning : a valid handle on an editor
            bezier object to destroy
---------------------------------------
Return value :
  * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 27,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
Remarks :
  * Allocation done inside the structure
  is not freed in this function. A previous
  call to EDWAY_fnv_BezierObject_Free
  should be done.
----------------------------------------
See Also :
  * EDWAY_fnv_CircleArcObject_Free
----------------------------------------
*/
void EDWAY_fnv_BezierObject_DestroyStructure
(EDWAY_tdhBezierObject _hOldBezierObject)
{
 /* avoid crash :*/
 if(_hOldBezierObject == 0)
  return;
 M_free(_hOldBezierObject);
}

/*
---------------------------------------
Contents :
 Create Bezier curve (in ram only) 
 between two points.
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_Create
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _ucSamplingRate
   unsigned char
   The sampling rate of the curve
 * _pstStartPoint
   MTH3D_tdstVector*
   The starting point of the bezier
   curve
 * _pstEndPoint
   MTH3D_tdstVector*
   The ending point of the bezier
   curve
 * _pstStartVector
   MTH3D_tdstVector*
   The first tangent vector of the bezier
   curve
 * _pstEndVector
   MTH3D_tdstVector*
   The last tangent vector of the bezier
   curve
 * _ucObjectMode
   unsigned char
   The object mode (real or no object)
 * _pstDynaParam
   ACP_tdstDynaParam*
   A pointer to the dynamic parameters
   associated with the bezier curve
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 20,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
Remark :
Codes come from previous Bezier.c made by
Yann Le Tensorer (February 1997)
---------------------------------------
*/
void EDWAY_fnv_BezierObject_Create
(
 EDWAY_tdhBezierObject	_hBezierObject,
 unsigned char _ucSamplingRate,
 MTH3D_tdstVector*_pstStartPoint,
 MTH3D_tdstVector*_pstEndPoint,
 MTH3D_tdstVector*_pstStartVector,
 MTH3D_tdstVector*_pstEndVector,
 unsigned char _ucObjectMode,
 ACP_tdstDynaParam*_pstDynaParams,
 MTH3D_tdstVector** pdstListOfPoints
)
{
 MTH3D_tdhBezierCurve MTH3D_hBezierCurve;
	GEO_tdstDoubledIndex xLineDoubleIndex;
	long xCurVertex;

	if (_hBezierObject==0) return; /* avoid crash */

 /* Create a mathematical bezier object :*/
 MTH3D_hBezierCurve = MTH3D_fnh_BezierCurve_Create();
 if(MTH3D_hBezierCurve==0) return; /* avoid crash */
 MTH3D_fnv_BezierCurve_Init
 (
  MTH3D_hBezierCurve,
  _ucSamplingRate,
  _pstStartPoint,
  _pstEndPoint,
  _pstStartVector,
  _pstEndVector
 );
	/* copies input parameters into objects parameters */
	EDWAY_M_vBezierObjectSetBezierCurve(_hBezierObject,MTH3D_hBezierCurve);
	EDWAY_M_vBezierObjectSetObjectMode(_hBezierObject,_ucObjectMode);
	EDWAY_M_vBezierObjectSetDynaParams(_hBezierObject,_pstDynaParams);
	_hBezierObject->m_pdstListOfPoints = pdstListOfPoints; 


	/* if mode is MODE_NO_OBJECT, allocates ram only for points list and dynamic parameters */
	if (_ucObjectMode==EDWAY_C_ucModeNoObject)
	{
		M_malloc
		(
//			EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject),
//			ENG_fndst_BezierObject_GetListOfPoints ();
			*_hBezierObject->m_pdstListOfPoints,
			MTH3D_tdstVector*,
			(_ucSamplingRate+1)*sizeof(MTH3D_tdstVector)
		);
	}
	else
	/* else mode is EDWAY_C_ucModeRealObject, creates the geometric object*/
	{
		/* This list of points is not used */
//  EDWAY_M_vBezierObjectSetListOfPoints(_hBezierObject,NULL);
		*_hBezierObject->m_pdstListOfPoints = NULL;
		
		/* create object with 1 element (lines only), and ucSamplingRate+1 points) */
		GEO_vCreateGeometricObject
  (
   &(EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject)),
   _ucSamplingRate+1,
   1
  );
  /* create line element*/
		GEO_xCreateElementLines
  (
   EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject),
   &EDWAY_M_hBezierObjectGetLineElement(_hBezierObject),
   _ucSamplingRate
  );
		/* create lines indexes */
		for (xCurVertex=0;xCurVertex<_ucSamplingRate;xCurVertex++)
		{
			/* define start and end vertex of a line */
			xLineDoubleIndex.a2_xIndex[0]=xCurVertex;
			xLineDoubleIndex.a2_xIndex[1]=xCurVertex+1;
   /* set line index */
			GEO_xSetIndexOfElementLines
   (
    EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject),
    EDWAY_M_hBezierObjectGetLineElement(_hBezierObject),
    xCurVertex,
    &xLineDoubleIndex
   );
		}
	}
 /* calculate points of bezier curve */
	EDWAY_fnv_BezierObject_Calculate(_hBezierObject);
}


/*
---------------------------------------
Contents :
 Create Bezier curve (in ram only) 
 between two points.
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_CreateWithCurve
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _ucSamplingRate
   unsigned char
   The sampling rate of the curve
 * _pstStartPoint
   MTH3D_tdstVector*
   The starting point of the bezier
   curve
 * _pstEndPoint
   MTH3D_tdstVector*
   The ending point of the bezier
   curve
 * _pstStartVector
   MTH3D_tdstVector*
   The first tangent vector of the bezier
   curve
 * _pstEndVector
   MTH3D_tdstVector*
   The last tangent vector of the bezier
   curve
 * _ucObjectMode
   unsigned char
   The object mode (real or no object)
 * _pstDynaParam
   ACP_tdstDynaParam*
   A pointer to the dynamic parameters
   associated with the bezier curve
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    April 10,1997
  * Author : 
	Jacques Thénoz
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
Remark :
Codes come from previous Bezier.c made by
Yann Le Tensorer (February 1997)
---------------------------------------
*/
void EDWAY_fnv_BezierObject_CreateWithCurve
( 
	EDWAY_tdhBezierObject	_hBezierObject, 
	MTH3D_tdhBezierCurve	_hBezierCurve,
	unsigned char			_ucObjectMode,
	ACP_tdstDynaParam*		_pstDynaParams,
	MTH3D_tdstVector** pdstListOfPoints
)
{
	unsigned char _ucSamplingRate = MTH3D_fnuc_BezierCurve_GetSamplingRate (_hBezierCurve);
	GEO_tdstDoubledIndex xLineDoubleIndex;
	long xCurVertex;

	/* copies input parameters into objects parameters */
	EDWAY_M_vBezierObjectSetBezierCurve(_hBezierObject, _hBezierCurve);
	EDWAY_M_vBezierObjectSetObjectMode(_hBezierObject,_ucObjectMode);
	EDWAY_M_vBezierObjectSetDynaParams(_hBezierObject,_pstDynaParams);
	_hBezierObject->m_pdstListOfPoints = pdstListOfPoints; 


	/* if mode is MODE_NO_OBJECT, allocates ram only for points list and dynamic parameters */
	if (_ucObjectMode==EDWAY_C_ucModeNoObject)
	{
		M_malloc
		(
//			EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject),
			*_hBezierObject->m_pdstListOfPoints,
			MTH3D_tdstVector*,
			(_ucSamplingRate+1)*sizeof(MTH3D_tdstVector)
		);
	}
	else
	/* else mode is EDWAY_C_ucModeRealObject, creates the geometric object*/
	{
		/* This list of points is not used */
//		EDWAY_M_vBezierObjectSetListOfPoints(_hBezierObject,NULL);
		_hBezierObject->m_pdstListOfPoints = NULL;
		
		/* create object with 1 element (lines only), and ucSamplingRate+1 points) */
		GEO_vCreateGeometricObject
		(
			&(EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject)),
		_ucSamplingRate+1,
		1
		);
  /* create line element*/
	GEO_xCreateElementLines
	(
		EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject),
		&EDWAY_M_hBezierObjectGetLineElement(_hBezierObject),
		_ucSamplingRate
		);
		/* create lines indexes */
		for (xCurVertex=0;xCurVertex<_ucSamplingRate;xCurVertex++)
		{
			/* define start and end vertex of a line */
			xLineDoubleIndex.a2_xIndex[0]=xCurVertex;
			xLineDoubleIndex.a2_xIndex[1]=xCurVertex+1;
   /* set line index */
			GEO_xSetIndexOfElementLines
   (
    EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject),
    EDWAY_M_hBezierObjectGetLineElement(_hBezierObject),
    xCurVertex,
    &xLineDoubleIndex
   );
		}
	}
 /* calculate points of bezier curve */
	EDWAY_fnv_BezierObject_Calculate(_hBezierObject);
	


}


/*
---------------------------------------
Contents :
  Frees memory allocated by the 
  editor bezier object
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_Free
---------------------------------------
Arguments :
 * Name    : _hBezierObject
   Type    : EDWAY_tdhBezierObject
   Meaning : a valid handle on an editor
             bezier object to free
---------------------------------------
Return value :
  * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 27,1997
  * Author : 
    Albert Pais
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
---------------------------------------
*/
void EDWAY_fnv_BezierObject_Free
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject == EDWAY_C_hInvalidBezierObject)
 {
//  if(EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject)!=NULL)
//  {
//   M_free(EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject));
//   EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject) = NULL;
//  }
  /* I disagree with following line, but since it was in the previous version :*/
  if(EDWAY_M_pstBezierObjectGetDynaParams(_hBezierObject))
  {
   M_free(EDWAY_M_pstBezierObjectGetDynaParams(_hBezierObject));
  }
 }
}


/*
---------------------------------------
Contents :
 Computes bezier curve sampling
 points
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_Calculate
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 20,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
Remark :
Codes come from previous Bezier.c made by
Yann Le Tensorer (February 1997)
---------------------------------------
*/
void EDWAY_fnv_BezierObject_Calculate
(EDWAY_tdhBezierObject _hBezierObject)
{
	MTH3D_tdstVector	*p_stPointList;
 
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;/* avoid crash */
	
 if (EDWAY_M_ucBezierObjectGetObjectMode(_hBezierObject)==EDWAY_C_ucModeRealObject)
		p_stPointList=(EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject) -> d_stListOfPoints);
	else
//		p_stPointList=EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject);
		p_stPointList=*_hBezierObject->m_pdstListOfPoints;

 MTH3D_fnv_BezierCurve_CalculatePoint
 (
  EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
  p_stPointList
 );
}

/*
---------------------------------------
Contents :
  Returns the size in bytes of the
  editor bezier structure
---------------------------------------
Function Name :
 EDWAY_fnuw_BezierObject_SizeOf
---------------------------------------
Arguments :
 * None
---------------------------------------
Return value :
 * Type :
  unsigned short
 * Possible Value :
   * Every unsigned short possible value
     The sizeof the editor bezier curve
     structure.
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 25,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
unsigned short EDWAY_fnuw_BezierObject_SizeOf(void)
{
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_uwBezierObjectSizeOf();
}


/*
---------------------------------------
Contents :
 Retrieves the bezier curve from the 
 bezier object
---------------------------------------
Function Name :
 EDWAY_fnh_BezierObject_GetBezierCurve
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  MTH3D_tdhBezierCurve
 * Possible Value :
   * A valid handle on a bezier curve
     The function succeeded
   * MTH3D_C_h_BezierCurveInvalidHandle
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
MTH3D_tdhBezierCurve EDWAY_fnh_BezierObject_GetBezierCurve
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return MTH3D_C_h_BezierCurveInvalidHandle;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Retrieves the geometric element from the 
 bezier object
---------------------------------------
Function Name :
 EDWAY_fnh_BezierObject_GetGeometricObject
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  ACP_tdxHandleOfObject
 * Possible Value :
   * A valid handle on an object
     The function succeeded
   * NULL
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
ACP_tdxHandleOfObject EDWAY_fnh_BezierObject_GetGeometricObject
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return NULL;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Retrieves the line elements from the 
 bezier object
---------------------------------------
Function Name :
 EDWAY_fnh_BezierObject_GetLineElement
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  ACP_tdxHandleOfElement
 * Possible Value :
   * A valid handle on a line element
     The function succeeded
   * NULL
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
ACP_tdxHandleOfElement EDWAY_fnh_BezierObject_GetLineElement
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return NULL;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_hBezierObjectGetLineElement(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Retrieves the color from the 
 bezier object
---------------------------------------
Function Name :
 EDWAY_fnl_BezierObject_GetColor
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  long
 * Possible Value :
   * A non-zero value
     The function succeeded
   * a zero value
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
long EDWAY_fnl_BezierObject_GetColor
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return 0L;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_lBezierObjectGetColor(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Retrieves the pointer to the view port
 attribute associated with the bezier object
---------------------------------------
Function Name :
 EDWAY_fnpst_BezierObject_GetViewPortAttributes
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  GLD_tdstViewportAttributes*
 * Possible Value :
   * A non-null pointer
     The function succeeded
   * NULL
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
GLD_tdstViewportAttributes* EDWAY_fnpst_BezierObject_GetViewPortAttributes
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return NULL;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_pstBezierObjectGetViewPortAttributes(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Retrieves the pointer to the list of points
 associated with the bezier object
---------------------------------------
Function Name :
 EDWAY_fndst_BezierObject_GetListOfPoints
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  MTH3D_tdstVector* 
 * Possible Value :
   * A non-null pointer
     The function succeeded
   * NULL
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
MTH3D_tdstVector* EDWAY_fndst_BezierObject_GetListOfPoints
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return NULL;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
// return EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject);
	return *_hBezierObject->m_pdstListOfPoints;
}

/*
---------------------------------------
Contents :
 Retrieves the pointer to the dynamic parameters
 associated with the bezier object
---------------------------------------
Function Name :
 EDWAY_fnpst_BezierObject_GetDynaParams
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  ACP_tdstDynaParam* 
 * Possible Value :
   * A non-null pointer
     The function succeeded
   * NULL
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
ACP_tdstDynaParam* EDWAY_fnpst_BezierObject_GetDynaParams
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return NULL;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_pstBezierObjectGetDynaParams(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Returns the object mode of the 
 bezier-editor object
---------------------------------------
Function Name :
 EDWAY_fnuc_BezierObject_GetObjectMode
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * Type :
  unsigned char
 * Possible Value :
   * EDWAY_C_ucModeNoObject
     Mode is mode No object
   * EDWAY_C_ucModeRealObject
     Mode is Real object
   * (unsigned char)-1
     The function failed
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
unsigned char EDWAY_fnuc_BezierObject_GetObjectMode
(EDWAY_tdhBezierObject _hBezierObject)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return (unsigned char)-1;

 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 return EDWAY_M_ucBezierObjectGetObjectMode(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Changes the bezier curve of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetBezierCurve
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _hNewBezierCurve
   MTH3D_tdhBezierCurve
   A handle on a bezier curve object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetBezierCurve
(
 EDWAY_tdhBezierObject _hBezierObject,
 MTH3D_tdhBezierCurve _hNewBezierCurve
)
{
 /* avoid crash :*/
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 EDWAY_M_vBezierObjectSetBezierCurve(_hBezierObject,_hNewBezierCurve);
}

/*
---------------------------------------
Contents :
 Changes the geometic object of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetGeometricObject
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _hNewGeometricObject
   ACP_tdxHandleOfObject
   A handle on a geometric object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetGeometricObject
(
 EDWAY_tdhBezierObject _hBezierObject,
 ACP_tdxHandleOfObject _hNewGeometricObject
)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;
 
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 EDWAY_M_vBezierObjectSetGeometricObject(_hBezierObject,_hNewGeometricObject);
}

/*
---------------------------------------
Contents :
 Changes the line element of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetLineElement
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _hNewLineElement
   ACP_tdxHandleOfElement
   A handle on a geometric object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetLineElement
(
 EDWAY_tdhBezierObject _hBezierObject,
 ACP_tdxHandleOfElement _hNewLineElement
)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;
 
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 EDWAY_M_vBezierObjectSetLineElement(_hBezierObject,_hNewLineElement);
}

/*
---------------------------------------
Contents :
 Changes the color of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetColor
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _lNewColor
   long
   The new color of the object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetColor
(
 EDWAY_tdhBezierObject _hBezierObject,
 long _lNewColor
)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 EDWAY_M_vBezierObjectSetColor(_hBezierObject,_lNewColor);
}

/*
---------------------------------------
Contents :
 Changes the view port attributes of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetViewPortAttributes
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _pstNewViewportAttributes
   GLD_tdstViewportAttributes*
   The new viewport attributes of the object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetViewPortAttributes
(
 EDWAY_tdhBezierObject _hBezierObject,
 GLD_tdstViewportAttributes* _pstNewViewportAttributes
)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;

 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 EDWAY_M_vBezierObjectSetViewPortAttributes(_hBezierObject,_pstNewViewportAttributes);
}

/*
---------------------------------------
Contents :
 Changes the list of points of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetListOfPoints
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _dstNewListOfPoints
   MTH3D_tdstVector*
   The new list of poins of the object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetListOfPoints
(
 EDWAY_tdhBezierObject _hBezierObject,
 MTH3D_tdstVector* _dstNewListOfPoints
)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;

 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
// EDWAY_M_vBezierObjectSetListOfPoints(_hBezierObject,_dstNewListOfPoints);
*_hBezierObject->m_pdstListOfPoints = _dstNewListOfPoints;
}

/*
---------------------------------------
Contents :
 Changes the dynamic params of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetDynaParams
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _pstNewDynaParam
   ACP_tdstDynaParam*
   The new dynamic parameters
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetDynaParams
(
 EDWAY_tdhBezierObject _hBezierObject,
 ACP_tdstDynaParam *_pstNewDynaParam
)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 EDWAY_M_vBezierObjectSetDynaParams(_hBezierObject,_pstNewDynaParam);
}

/*
---------------------------------------
Contents :
 Changes the object mode of 
 the bezier editor object given in parmater
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_SetObjectMode
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _ucNewObjectMode
   unsigned char
   The new object mode of the bezier object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_SetObjectMode
(
 EDWAY_tdhBezierObject _hBezierObject,
 unsigned char _ucNewObjectMode
)
{
 if(_hBezierObject == EDWAY_C_hInvalidBezierObject) return;
 /* 
 Using the macro makes it compulsory to define the function 
 with the _EDWAY_BEZ_FRIEND_ compilation directive, in order to
 be sure that the structure is known at this level.
 */
 EDWAY_M_vBezierObjectSetObjectMode(_hBezierObject,_ucNewObjectMode);
}

/*
---------------------------------------
Contents :
 Changes the sampling rate of the bezier 
 curve associaed with the bezier object
 and update bezier-editor object related
 fields
---------------------------------------
Function Name :
 EDWAY_fnb_BezierObject_ChangeSamplingRate
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _ucNewSamplingRate
   unsigned char
   The new sampling rate of the bezier curve
---------------------------------------
Return value :
  * Type :
    ACP_tdxBool
  * Possible Values :
    * FALSE
      The function failed to change
      the sampling rate.
    * TRUE
      The function succeeded to change
      the sampling rate
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
Remark :
  The sampling rate can only be modified 
  for objects that have been created using 
  C_ucModeNoObject at their creation.
----------------------------------------
*/
ACP_tdxBool EDWAY_fnb_BezierObject_ChangeSamplingRate
(
 EDWAY_tdhBezierObject _hBezierObject,
 unsigned char _ucNewSamplingRate
)
{
 if(!_hBezierObject) return FALSE;

 if(!EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject)) return FALSE;

 if(EDWAY_M_ucBezierObjectGetObjectMode(_hBezierObject)==EDWAY_C_ucModeNoObject)
 {
		/* copies new sampling rate value into objects parameters */
  if(_ucNewSamplingRate < 2)
   _ucNewSamplingRate = 2;
		MTH3D_M_vBezierCurveSetSamplingRate
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _ucNewSamplingRate
  );	

		/* free old list of points and allocates new one */
//		if (EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject)!=NULL)
//			M_free(EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject));

		if (*_hBezierObject->m_pdstListOfPoints!=NULL)
			M_free(*_hBezierObject->m_pdstListOfPoints);

		M_malloc
  (
//   EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject),
		*_hBezierObject->m_pdstListOfPoints,
			MTH3D_tdstVector*,
			(_ucNewSamplingRate+1)*sizeof(MTH3D_tdstVector)
		);

		/* calculate points of bezier curve */
  EDWAY_fnv_BezierObject_Calculate(_hBezierObject);

		/* checks if dynamic parameters are attached to the object
		 if yes, changes them to match the new sampling rate */
/*	VL	fn_vDynamicObject_ChangeSamplingRate
  (
   EDWAY_M_pstBezierObjectGetDynaParams(_hBezierObject),
			_ucNewSamplingRate
  );*/
		return TRUE;
 }
 else
  return FALSE;
}

/*
---------------------------------------
Contents :
 Changes some parameters of the bezier 
 curve associaed with the bezier object
 and update related fields of the 
 editor bezier object
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_ChangeParams
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _p_stStartPoint
   MTH3D_tdstVector
   The new starting point of the bezier
   curve.
 * _p_stEndPoint
   MTH3D_tdstVector
   The new ending point of the bezier
   curve.
 * _p_stStartVector
   MTH3D_tdstVector
   The new starting tangent vector
   of the bezier curve
 * _p_stEndVector
   The new ending tangent vector 
   MTH3D_tdstVector
   of the bezier curve
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
Remark :
 If one argument is NULL,the element
 is not changed.
----------------------------------------
*/
void EDWAY_fnv_BezierObject_ChangeParams
(
 EDWAY_tdhBezierObject	_hBezierObject,
 MTH3D_tdstVector*_p_stStartPoint,
 MTH3D_tdstVector*_p_stEndPoint,
 MTH3D_tdstVector*_p_stStartVector,
 MTH3D_tdstVector*_p_stEndVector
)
{
 /* Avoid crash :*/
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;
 /* change start point if necessary :*/
 if(_p_stStartPoint)
 {
  MTH3D_M_vBezierCurveSetStartPoint
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stStartPoint
  );
 }
 /* change end point if necessary */
 if(_p_stEndPoint)
 {
  MTH3D_M_vBezierCurveSetEndPoint
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stEndPoint
  );
 }
 /* Change first tangent vector if necessary */
 if(_p_stStartVector)
 {
  MTH3D_M_vBezierCurveSetStartVector
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stStartVector
  );
 }
 /* Change last tangent vector if necessary */
 if(_p_stEndVector)
 {
  MTH3D_M_vBezierCurveSetEndVector
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stEndVector
  );
 }
  /* Update information :*/
 EDWAY_fnv_BezierObject_Calculate(_hBezierObject);
}

/*
---------------------------------------
Contents :
 Retrieves main parameters of the
 bezier curve associated with
 the bezier object
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_GetParams
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _p_stStartPoint
   MTH3D_tdstVector
   A pointer to a 3D-Point receiving
   the first point.
 * _p_stEndPoint
   MTH3D_tdstVector
   A pointer to a 3D-Point receiving
   the last point.
 * _p_stStartVector
   MTH3D_tdstVector
   A pointer to a 3D-Point receiving
   the first tangent vector.
 * _p_stEndVector
   MTH3D_tdstVector
   A pointer to a 3D-point receiving
   the last tangent vector.
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
Remark :
 If one argument is NULL,it is not
 retrieved. No error is raised in this
 case.
----------------------------------------
*/
void  EDWAY_fnv_BezierObject_GetParams
(
 EDWAY_tdhBezierObject	_hBezierObject,
 MTH3D_tdstVector*_p_stStartPoint,
 MTH3D_tdstVector*_p_stEndPoint,
 MTH3D_tdstVector*_p_stStartVector,
 MTH3D_tdstVector*_p_stEndVector
)
{
 /* Avoid crash : */
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return;
 if(_p_stStartPoint)
 {
  MTH3D_M_vBezierCurveGetStartPoint
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stStartPoint
  );
 }
 if(_p_stEndPoint)
 {
  MTH3D_M_vBezierCurveGetEndPoint
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stEndPoint
  );
 }
 if(_p_stStartVector)
 {
  MTH3D_M_vBezierCurveGetStartVector
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stStartVector
  );
 }
 if(_p_stEndVector)
 {
  MTH3D_M_vBezierCurveGetEndVector
  (
   EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject),
   _p_stEndVector
  );
 }
}

/*
---------------------------------------
Contents :
 Retrieves the speed at a specific
 sample number contained inside the
 dynamic field of the bezier object
---------------------------------------
Function Name :
 fn_xBezierObject_GetSpeed
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _ucSampleNumber
   unsigned char
   The smaple number
---------------------------------------
Return value :
  * Type :
    MTH_tdxReal
  * Possible value :
    MTH_C_InfinitPlus
     The function failed
    Another tdxReal value
     The function succeded
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
MTH_tdxReal fn_xBezierObject_GetSpeed
(
 EDWAY_tdhBezierObject _hBezierObject,
 unsigned char _ucSampleNumber
)
{
 if(_hBezierObject==EDWAY_C_hInvalidBezierObject) return MTH_C_InfinitPlus;

 /* Otherwise, no problemo :*/
 //VL
 return 0;
 //EVL
 /*
 return fn_xDynamicObject_GetSpeed
 (
  EDWAY_M_pstBezierObjectGetDynaParams(_hBezierObject),
  _ucSampleNumber
 );
 */
}

/*
---------------------------------------
Contents :
 Retrieve a sampled point of the bezier
 curve
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_GetPoint
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
 * _ucSampleNumber
   unsigned char
   The smaple number
 * _pstSampledPoint
   MTH3D_tdstVector
   A pointer to a vector that receives
   the sampled point
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_GetPoint
(
 EDWAY_tdhBezierObject _hBezierObject,
 unsigned char _ucSamplingNumber,
 MTH3D_tdstVector*_pstSampledPoint
)
{
 MTH3D_tdstVector	*p_stPointList;
 if
 (
    (_hBezierObject ==EDWAY_C_hInvalidBezierObject)
  ||(_pstSampledPoint == NULL )
 )
 {
  return;
 }
 if(EDWAY_M_ucBezierObjectGetObjectMode(_hBezierObject)==EDWAY_C_ucModeNoObject)
 {
//  p_stPointList = EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject);
  p_stPointList = *_hBezierObject->m_pdstListOfPoints;
 }
 else
 {
  p_stPointList = EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject)-> d_stListOfPoints;
 }
 /* Beware : no check is done on the _ucSamplingNumber */
 if(p_stPointList!=NULL)
  *_pstSampledPoint = p_stPointList[_ucSamplingNumber];
}

/*
---------------------------------------
Contents :
  Draws the bezier object
---------------------------------------
Function Name :
 EDWAY_fnv_BezierObject_Draw
---------------------------------------
Arguments :
 * _hBezierObject
   EDWAY_tdhBezierObject
   A valid handle on a editor bezier
   object
---------------------------------------
Return value :
 * None
---------------------------------------
Error Raised :
  * None
---------------------------------------
Creation :
  * Date : 
    February 21,1997
  * Author : 
    Albert PAIS
---------------------------------------
Modification :
  * Date : 
  * Author : 
  * Modify :
----------------------------------------
*/
void EDWAY_fnv_BezierObject_Draw
(EDWAY_tdhBezierObject _hBezierObject)
{
	POS_tdstCompletePosition stMatrix;
	GEO_tdstColor		ColBidon;
	MTH3D_tdstVector	*p_stPointList;
	MTH3D_tdstVector    *p_stPointListEnd;

	POS_fn_vSetIdentityMatrix(&stMatrix);
	if (_hBezierObject==EDWAY_C_hInvalidBezierObject) return; /* avoid crash */

	/*unsigned long color; */
	ColBidon.xR=(float)0.5;
	ColBidon.xG=(float)0.5;
	ColBidon.xB=(float)0.5;
	ColBidon.xA=(float)0.5;

	if (EDWAY_M_ucBezierObjectGetObjectMode(_hBezierObject)==EDWAY_C_ucModeRealObject)
		p_stPointList=EDWAY_M_hBezierObjectGetGeometricObject(_hBezierObject)->d_stListOfPoints;
	else
//		p_stPointList=EDWAY_M_dstBezierObjectGetListOfPoints(_hBezierObject);
		p_stPointList=*_hBezierObject->m_pdstListOfPoints;


	if (p_stPointList==0) return;

	GLI_xGetCameraMatrix(((GLI_tdstSpecificAttributesFor3D*)((EDWAY_M_pstBezierObjectGetViewPortAttributes(_hBezierObject))->p_vSpecificToXD))->p_stCam,&stMatrix);
	GLI_xLoadMatrix(&stMatrix);
	GLI_vSetFog(100,100,200,&ColBidon);
	p_stPointListEnd=p_stPointList+
  MTH3D_M_ucBezierCurveGetSamplingRate(EDWAY_M_hBezierObjectGetBezierCurve(_hBezierObject));
	
	for (;p_stPointList<p_stPointListEnd;p_stPointList++)
	{
		GLI_xDraw3DLine16
  (
			(struct GLD_tdstViewportAttributes_*)(EDWAY_M_pstBezierObjectGetViewPortAttributes(_hBezierObject)),
			p_stPointList,
			p_stPointList+1,
			EDWAY_M_lBezierObjectGetColor(_hBezierObject)
  );
	}
 GLI_xPopMatrix();
}
