next up previous contents index
Next: Chain of morpho sets Up: Morpho set Previous: Related file (external) types   Contents   Index


Functions Summary

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

$ \bigcirc$Name


mw_change_morpho_set - Define a morpho set, if not already defined




$ \bigcirc$Summary


Morpho_set mw_change_morpho_set(ms)

Morpho_set ms;




$ \bigcirc$Description


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

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

Morpho_set ms=NULL; /* Internal use: no Input neither Output of module */
Hsegment seg=NULL;

/* Define a morpho set containing one segment only */

if (!(seg=mw_change_hsegment(seg)) ||
    !(ms=mw_change_morpho_set(ms))) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;

ms->first_segment=seg;
ms->minvalue=0.0;
ms->maxvalue = 1.0;
ms->area=201;

$ \bigcirc$Name


mw_copy_morpho_set - Copy a morpho set into another one




$ \bigcirc$Summary


Morpho_set mw_copy_morpho_set(in,out)

Morpho_set in, out;




$ \bigcirc$Description


This function copies the Morpho_set in into out. The chain of segments are also duplicated. 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_set 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_set in; /* Predefined morpho_set */
Morpho_set out=NULL; 

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

$ \bigcirc$Name


mw_delete_morpho_set - Deallocate a morpho set




$ \bigcirc$Summary


void mw_delete_morpho_set(ms)

Morpho_set ms;




$ \bigcirc$Description


This function deallocates the Morpho_set ms, including the chain of horizontal segments. You should set ms = NULL after this call since the address pointed by ms is no longer valid.




$ \bigcirc$Example

Morpho_set ms; /* Internal use: no Input neither Output of module */
Hsegment seg;

/* Define a morpho set containing one segment only */

if (!(seg=mw_new_hsegment()) ||
    !(ms=mw_new_morpho_set())) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;

ms->first_segment=seg;
ms->minvalue=0.0;
ms->maxvalue = 1.0;
ms->area=201;

/* .
   .
   (statement)
   .
   .
*/

/* Deallocate the morpho_set */
mw_delete_morpho_set(ms);

$ \bigcirc$Name


mw_length_morpho_set - Return the number of segments a morpho set contains




$ \bigcirc$Summary


unsigned int mw_length_morpho_set(ms)

Morpho_set ms;




$ \bigcirc$Description


This function returns the number of segments contained in the input ms. It returns 0 if the structure is empty or undefined.




$ \bigcirc$Example

Morpho_set ms=NULL; /* Internal use: no Input neither Output of module */
Hsegment seg=NULL;

/* Define a morpho set containing one segment only */

if (!(seg=mw_change_hsegment(seg)) ||
    !(ms=mw_change_morpho_set(ms))) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;

ms->first_segment=seg;
ms->minvalue=0.0;
ms->maxvalue = 1.0;
ms->area=201;

/* This will print 1 */
printf("%d",mw_length_morpho_set(ms));

$ \bigcirc$Name


mw_new_morpho_set - Create a new morpho set




$ \bigcirc$Summary


Morpho_set mw_new_morpho_set()




$ \bigcirc$Description


This function returns a new Morpho_set 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

Morpho_set ms; /* Internal use: no Input neither Output of module */
Hsegment seg;

/* Define a morpho set containing one segment only */

if (!(seg=mw_new_hsegment()) ||
    !(ms=mw_new_morpho_set())) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;

ms->first_segment=seg;
ms->minvalue=0.0;
ms->maxvalue = 1.0;
ms->area=201;


next up previous contents index
Next: Chain of morpho sets Up: Morpho set Previous: Related file (external) types   Contents   Index
mw 2004-05-05