next up previous contents index
Next: Points, Curves and Polygons Up: Set of polygons Previous: Related file (external) types   Contents   Index


Functions Summary

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

$ \bigcirc$Name


mw_change_polygons - Define the polygons structure, if not defined




$ \bigcirc$Summary


Polygons mw_change_polygons(polygons)

Polygons polygons;




$ \bigcirc$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.




$ \bigcirc$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).

$ \bigcirc$Name


mw_delete_polygons - Deallocate a polygons set




$ \bigcirc$Summary


void mw_delete_polygons(polygons)

Polygons polygons;




$ \bigcirc$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 Polygonstructures and the Polygonsstructure itself. You should set polygons = NULL after this call since the address pointed by polygons is no longer valid.




$ \bigcirc$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);

$ \bigcirc$Name


mw_length_polygons - Return the number of polygons into a polygons structure




$ \bigcirc$Summary


unsigned int mw_length_polygons(polys);

Polygons polys;




$ \bigcirc$Description


This function returns the number of polygons contained in the given polys. It returns 0 if the structure is empty.




$ \bigcirc$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));
$ \bigcirc$Name


mw_new_polygons - Create a new polygons




$ \bigcirc$Summary


Polygons mw_new_polygons();




$ \bigcirc$Description


This function creates a new Polygonsstructure. 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.




$ \bigcirc$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;


next up previous contents index
Next: Points, Curves and Polygons Up: Set of polygons Previous: Related file (external) types   Contents   Index
mw 2004-05-05