next up previous contents index
Next: Planar curve Up: Point of a planar Previous: Related file (external) types   Contents   Index


Functions Summary

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

$ \bigcirc$Name


mw_change_point_curve - Define the point_curve structure, if not defined




$ \bigcirc$Summary


Point_curve mw_change_point_curve(point)

Point_curve point;




$ \bigcirc$Description


This function returns a Point_curve structure if the input point = NULL. It is provided despite the mw_new_point_curve function for global coherence with other memory types.

The function mw_change_point_curve 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 structures before the end of the module, except if they are part of an input or output chain.




$ \bigcirc$Example

Point_curve point=NULL; /* Internal use: no Input neither Output of module */

/* Define the point (5,1) of the plane */

point = mw_change_point_curve(point);
if (point == NULL) mwerror(FATAL,1,"Not enough memory.\n");
point->x = 5;
point->y = 1;

$ \bigcirc$Name


mw_copy_point_curve - Copy all points starting from the given one




$ \bigcirc$Summary


Point_curve mw_copy_point_curve(in,out)

Point_curve in, out;




$ \bigcirc$Description


This function copies the current point and the next points contained in the chain defined at the starting point in. The result is put in out, which may not be a predefined structure : in case of out=NULL, the out structure is allocated.

The function mw_copy_point_curve returns NULL if not enough memory is available to perform the copy, or out elsewhere. Your code should check this return value to send an error message in the NULL case, and do appropriate statement.




$ \bigcirc$Example

Point_curve in; /* Predefined point */
Point_curve out=NULL; 

out=mw_copy_point_curve(in,out);
if (!out) mwerror(FATAL,1,"Not enough memory.\n");

$ \bigcirc$Name


mw_delete_point_curve - Deallocate the point_curve structure




$ \bigcirc$Summary


void mw_delete_point_curve(point)

Point_curve point;




$ \bigcirc$Description


This function deallocates the Point_curve structures starting from the given point, including this point itself. You should set point = NULL after this call since the address pointed by point is no longer valid. Warning : to deallocate only a point and not all the next points of a chain, just use free(point).




$ \bigcirc$Example

/* Remove the first point of an existing curve */

Curve curve;  /* Existing curve (e.g. Input of module) */
Point_curve point;  /* Internal use */

point = curve->first;
curve->first=point->next;
point->next->previous = NULL;
free(point);
point = NULL;

/* Remove all points of an existing curve */

mw_delete_point_curve(curve->first);

$ \bigcirc$Name


mw_new_point_curve - Create a new point_curve structure




$ \bigcirc$Summary


Point_curve mw_new_point_curve();




$ \bigcirc$Description


This function creates a new Point_curve structure. 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 point structures before the end of the module, except if they are part of an input or output curve.




$ \bigcirc$Example

/* Insert the point (0,0) at the end of an existing curve */

Curve curve;  /* Existing curve (e.g. Input of module) */
Point_curve point,p;  /* Internal use: no Input neither Output of module */

/* Define the point (0,0) */
point = mw_new_point_curve();
if (point == NULL) mwerror(FATAL,1,"Not enough memory.\n");
point->x = point->y = 0;
point->next = NULL;

/* Find the last point of the curve */
p = curve->first; while (p->next) p=p->next;

/* Insert the point */
p->next = point;
point->previous = p;

/* Do not deallocate point or curve will become inconsistent */


next up previous contents index
Next: Planar curve Up: Point of a planar Previous: Related file (external) types   Contents   Index
mw 2004-05-05