next up previous contents index
Next: Morpho line in the Up: Morpho line Previous: Related file (external) types   Contents   Index


Functions Summary

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

$ \bigcirc$Name


mw_change_morpho_line - Define a morpho line, if not already defined




$ \bigcirc$Summary


Morpho_line mw_change_morpho_line(ml)

Morpho_line ml;




$ \bigcirc$Description


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

The function mw_change_morpho_line 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

/* Copy the curve of a morpho line into another morpho line */
Morpho_line in,out=NULL;

out=mw_change_morpho_line(out);
if (!out) mwerror(FATAL,1,"Not enough memory !\n");
out->open = in->open;
if ( ((out->first_point = mw_new_point_curve()) == NULL) ||
     ((out->first_type = mw_new_point_type()) == NULL) )
   mwerror(FATAL, 1,"Not enough memory !\n");
mw_copy_point_curve(in->first_point,out->first_point);
mw_copy_point_type(in->first_type,out->first_type);

$ \bigcirc$Name


mw_copy_morpho_line - Copy a morpho line into another one




$ \bigcirc$Summary


Morpho_line mw_copy_morpho_line(in,out)

Morpho_line in, out;




$ \bigcirc$Description


This function copies the Morpho_line in into out. All fields are copied but the following : pdata, morphosets, num, previous and next. 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_morpho_line 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

Morpho_line in; /* Predefined morpho_line */
Morpho_line out=NULL; 

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

$ \bigcirc$Name


mw_delete_morpho_line - Deallocate a morpho line




$ \bigcirc$Summary


void mw_delete_morpho_line(ml)

Morpho_line ml;




$ \bigcirc$Description


This function deallocates the Morpho_line ml structure, including the curve (Point_curve) and the chain of types (Point_type). Other pointers are not deallicated. You should line ml = NULL after this call since the address pointed by ml is no longer valid.




$ \bigcirc$Example

Morpho_line ml; /* Internal use: no Input neither Output of module */
Point_curve pt;

/* Define a morpho line containing the point (0,0) only */

if (!(pt=mw_new_point_curve()) ||
    !(ml=mw_new_morpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
pt->x=pt->y=0;
ml->first_point=pt;

/* .
   .
   (statement)
   .
   .
*/

/* Deallocate the morpho_line */
mw_delete_morpho_line(ml);

$ \bigcirc$Name


mw_length_morpho_line - Return the number of points a morpho line contains




$ \bigcirc$Summary


unsigned int mw_length_morpho_line(ml)

Morpho_line ml;




$ \bigcirc$Description


This function returns the number of points contained in the input ml. It returns 0 if the structure is empty or undefined. If the field first_type is not NULL, the number of points defined by this field must equal the number of points in the curve.




$ \bigcirc$Example

Morpho_line ml; /* Internal use: no Input neither Output of module */
Point_curve pt;

/* Define a morpho line containing the point (0,0) only */

if (!(pt=mw_new_point_curve()) ||
    !(ml=mw_new_morpho_line())) mwerror(FATAL,1,"Not enough memory.\n");
pt->x=pt->y=0;
ml->first_point=pt;

/* This will print 1 */
printf("%d",mw_length_morpho_line(ml));

$ \bigcirc$Name


mw_new_morpho_line - Create a new morpho line




$ \bigcirc$Summary


Morpho_line mw_new_morpho_line()




$ \bigcirc$Description


This function returns a new Morpho_line structure, or 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.

The new structure is created with fields set to 0 or NULL.




$ \bigcirc$Example

/* Copy the curve of a morpho line into another morpho line */
Morpho_line in,out;

out=mw_new_morpho_line();
if (!out) mwerror(FATAL,1,"Not enough memory !\n");
out->open = in->open;
if ( ((out->first_point = mw_new_point_curve()) == NULL) ||
     ((out->first_type = mw_new_point_type()) == NULL) )
   mwerror(FATAL, 1,"Not enough memory !\n");
mw_copy_point_curve(in->first_point,out->first_point);
mw_copy_point_type(in->first_type,out->first_type);


next up previous contents index
Next: Morpho line in the Up: Morpho line Previous: Related file (external) types   Contents   Index
mw 2004-05-05