next up previous contents index
Next: Horizontal segment Up: Point with a type Previous: Related file (external) types   Contents   Index


Functions Summary

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

$ \bigcirc$Name


mw_change_point_type - Define the point_type structure, if not defined




$ \bigcirc$Summary


Point_type mw_change_point_type(pt)

Point_type pt;




$ \bigcirc$Description


This function returns a Point_type structure if the input pt = NULL. It is provided despite the
mw_new_point_type() function for global coherence with other memory types.

The function mw_change_point_type 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_type pt=NULL; /* Internal use: no Input neither Output of module */

/* Define a point type as image border */

pt = mw_change_point_type(pt);
if (pt == NULL) mwerror(FATAL,1,"Not enough memory.\n");
pt->type = 1; /* image border */

$ \bigcirc$Name


mw_copy_point_type - Copy all point types starting from the given one




$ \bigcirc$Summary


Point_type mw_copy_point_type(in,out)

Point_type in, out;




$ \bigcirc$Description


This function copies the current point type and the next point types contained in the chain defined at the starting point type 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_type 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_type in; /* Predefined point */
Point_type out=NULL; 

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

$ \bigcirc$Name


mw_delete_point_type - Deallocate the point_type structure




$ \bigcirc$Summary


void mw_delete_point_type(pt)

Point_type pt;




$ \bigcirc$Description


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




$ \bigcirc$Example

/* Remove the first point_type of an existing morpho_line */

Morpho_line ll; /* Existing morpho_line (e.g. Input of module) */
Point_type pt;  /* Internal use */

pt = ll->first_type;
ll->first_type=pt->next;
pt->next->previous = NULL;
free(pt);
pt = NULL;

/* Remove all point_type of an existing morpho_line */

mw_delete_point_type(ll->first_type);

$ \bigcirc$Name


mw_new_point_type - Create a new point_type structure




$ \bigcirc$Summary


Point_type mw_new_point_type();




$ \bigcirc$Description


This function creates a new Point_type 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) with type 1 at the end of an existing morpho_line */

Morpho_line ll;  /* Existing morpho_line (e.g. Input of module) */
Point_curve point,p;  /* Internal use: no Input neither Output of module */
Point_type pt,t;

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

/* Find the last point of the morpho_line */
p = ll->first_point; t = ll->first_type; 
while (p->next) {p=p->next; t=t->next;}

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

/* Do not deallocate point_curve and point_type or morpho_line will become inconsistent */


next up previous contents index
Next: Horizontal segment Up: Point with a type Previous: Related file (external) types   Contents   Index
mw 2004-05-05