Functions Summary

The following is a description of all the functions related to
the `Polygons`

type. The list is in alphabetical order.

**mw_change_polygons** - Define the polygons structure, if not defined

**Summary**

Polygons mw_change_polygons(polygons)

Polygons polygons;

**Description**

This function returns a Polygons structure if the input `polygons = NULL`

.
It is provided despite the `mw_new_polygons`

function for
global coherence with other memory types.

The function `mw_change_polygons`

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 polygons structures before the end of the module.

**Example**

/* Define a polygons set to be two pre-defined polygons */ Polygons polygons=NULL; /* Internal use: no Input neither Output of module */ Polygon polygon1,polygon2; /* Pre-defined polygons (e.g. inputs of module) */ polygons = mw_change_polygons(polygons); if (polygons == NULL) mwerror(FATAL,1,"Not enough memory.\n"); ...(End of this example as for the

`mw_new_polygons`

function).

**mw_delete_polygons** - Deallocate a polygons set

**Summary**

void mw_delete_polygons(polygons)

Polygons polygons;

**Description**

This function deallocates all the memory allocated by the polygons variable
that is, all the points belonging to all polygons into this set, all channels arrays (if any), all `Polygon`structures and the `Polygons`structure itself.
You should set `polygons = NULL`

after this call since the address pointed
by `polygons`

is no longer valid.

**Example**

Polygons polygons=NULL; /* Internal use: no Input neither Output of module */ polygons = mw_new_polygons(); if (polygons == NULL) mwerror(FATAL,1,"Not enough memory.\n"); . . . mw_delete_polygons(polygons);

**mw_length_polygons** - Return the number of polygons into a polygons structure

**Summary**

unsigned int mw_length_polygons(polys);

Polygons polys;

**Description**

This function returns the number of polygons contained in the given
`polys`

. It returns 0 if the structure is empty.

**Example**

/* Define a polygons set to be two pre-defined polygons */ Polygons polygons=NULL; /* Internal use: no Input neither Output of module */ Polygon polygon1,polygon2; /* Pre-defined polygons (e.g. inputs of module) */ polygons = mw_new_polygons(); if (polygons == NULL) mwerror(FATAL,1,"Not enough memory.\n"); polygons->first=polygon1; polygon1->previous = polygon2->next = NULL; polygon1->next = polygon2; polygon2->previous = polygon1; /* The length would be 2 */ printf("Length=%d\n",mw_length_polygons(polygons));

**mw_new_polygons** - Create a new polygons

**Summary**

Polygons mw_new_polygons();

**Description**

This function creates a new `Polygons`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 structures before the end of the module.

**Example**

/* Define a polygons set to be two pre-defined polygons */ Polygons polygons=NULL; /* Internal use: no Input neither Output of module */ Polygon polygon1,polygon2; /* Pre-defined polygons (e.g. inputs of module) */ polygons = mw_new_polygons(); if (polygons == NULL) mwerror(FATAL,1,"Not enough memory.\n"); polygons->first=polygon1; polygon1->previous = polygon2->next = NULL; polygon1->next = polygon2; polygon2->previous = polygon1;