next up previous contents index
Next: Polygon, a variant of Up: Set of planar curves Previous: Related file (external) types   Contents   Index


Functions Summary

The following is a description of all the functions related to the Curves type. The list is in alphabetical order.

$ \bigcirc$Name


mw_change_curves - Define the curves structure, if not defined




$ \bigcirc$Summary


Curves mw_change_curves(curves)

Curves curves;




$ \bigcirc$Description


This function returns a Curves structure if the input curves = NULL. It is provided despite the mw_new_curves function for global coherence with other memory types.

The function mw_change_curves returns NULL if not enough memory is available to allocate the structure. Your code should check this return value to send an error message in the NULL case, and do appropriate statement.

Since the MegaWave2 compiler allocates structures for input and output objects (See Volume one: ``MegaWave2 User's Guide''), this function is normally used only for internal objects. Do not forget to deallocate the internal curves structures before the end of the module.




$ \bigcirc$Example

/* Define a curves set to be two pre-defined curves  */

Curves curves=NULL;   /* Internal use: no Input neither Output of module */
Curve curve1,curve2;  /* Pre-defined curves (e.g. inputs of module) */

curves = mw_change_curves(curves);
if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n");
...
(End of this example as for the mw_new_curves function).

$ \bigcirc$Name


mw_delete_curves - Deallocate a curves set




$ \bigcirc$Summary


void mw_delete_curves(curves)

Curves curves;




$ \bigcirc$Description


This function deallocates all the memory allocated by the curves variable that is, all the points belonging to all curves into this set, all Curvestructures and the Curvesstructure itself. You should set curves = NULL after this call since the address pointed by curves is no longer valid.




$ \bigcirc$Example

Curves curves=NULL;   /* Internal use: no Input neither Output of module */

curves = mw_new_curves();
if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n");
.
.
.
mw_delete_curves(curves);

$ \bigcirc$Name


mw_length_curves - Return the number of curves into a curves structure




$ \bigcirc$Summary


unsigned int mw_length_curves(cvs);

Curves cvs;




$ \bigcirc$Description


This function returns the number of curves contained in the given cvs. It returns 0 if the structure is empty.




$ \bigcirc$Example

/* Define a curves set to be two pre-defined curves  */

Curves curves=NULL;   /* Internal use: no Input neither Output of module */
Curve curve1,curve2;  /* Pre-defined curves (e.g. inputs of module) */

curves = mw_new_curves();
if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n");

curves->first=curve1;
curve1->previous = curve2->next = NULL;
curve1->next = curve2;
curve2->previous = curve1;

/* The length would be 2 */
printf("Length=%d\n",mw_length_curves(curves));
$ \bigcirc$Name


mw_new_curves - Create a new curves




$ \bigcirc$Summary


Curves mw_new_curves();




$ \bigcirc$Description


This function creates a new Curvesstructure. It returns NULL if not enough memory is available to create the structure. Your code should check this value to send an error message in the NULL case, and do appropriate statement.

Since the MegaWave2 compiler allocates structures for input and output objects (See Volume one: ``MegaWave2 User's Guide''), this function is normally used only for internal objects. Do not forget to deallocate the internal structures before the end of the module.




$ \bigcirc$Example

/* Define a curves set to be two pre-defined curves  */

Curves curves=NULL;   /* Internal use: no Input neither Output of module */
Curve curve1,curve2;  /* Pre-defined curves (e.g. inputs of module) */

curves = mw_new_curves();
if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n");

curves->first=curve1;
curve1->previous = curve2->next = NULL;
curve1->next = curve2;
curve2->previous = curve1;
$ \bigcirc$Name


mw_npoints_curves - Return the total number of points a curves structure contains




$ \bigcirc$Summary


unsigned int mw_npoints_curves(cvs);

Curves cvs;




$ \bigcirc$Description


This function returns the total number of points contained in the given cvs, that is the sum of mw_length_curve(cv) for all curves cv contained in cvs. The function returns 0 if the structure is empty.


next up previous contents index
Next: Polygon, a variant of Up: Set of planar curves Previous: Related file (external) types   Contents   Index
mw 2004-05-05