Adding polygon types



next up previous
Next: Manual pages Up: A reference Guide Previous: Adding device drivers

Adding polygon types

The following section must be revised and completed, use it only as a guideline, but the best information in (as usual) on the code, in other words UTSL

A polygon type let the user manipulate some polygons using a better set of parameters, as device drivers, polygon types are implemnted using an structure, most of whose fields are pointer to functions, we describe now this structure and how to add the new polygon type to Unifpack kernel.

As with device drivers there is a shell script (pltempla) that creates the necessary files, to fix ideas, suposse we want to create a polygon type to handle ``Ngon's'', we first execute the script as in

    $ pltempla Ngon ngon

this would create two files (plngon.c and plngon.h) that will contain the code for the polygon type Ngon.

Edit the file plngon.c, if you must keep any special data for the polygon add the necessary fields into the _AuxPlData structure, next you must write or complete the code for the following functions, remember that polygon types handle the fundamental polygons , below we refer to the polygon only as ``the polygon''.

CanHandleGroup
Takes a group as parameter and decides if the polygon type can be used for this group, usually the number and order of the generators are checked.
ChangeParams
Checks if the parameters provided are valid, if so changes the parameters and deletes (free()'s) the old parameters, otherwise do nothing.
UpdateData
Recalculates the polygon, namely the vertices and the maps.
Draw
Draws the polygon, usually the code provided is enough, but sometimes a extra line requires some more code.
Init
Initialize internal data, should calculate initial values for the parameters.
Destroy
Deletes the data.
Write
Writes the internal data to the stream.
Read
Reads the parameters from the stream, and calculates the rest of the data.



next up previous
Next: Manual pages Up: A reference Guide Previous: Adding device drivers



coryan@mat.puc.cl