Beruflich Dokumente
Kultur Dokumente
3. IMPLEMENTATION
3.1 Choice of Array Size and FEV Type Number
I defined the size of all arrays (i.e. constant SIZE) to 50 so that the program can
handle 50 or less edges, faces and vertices each. The size of the array will not
result in null access error because all for loops will stop looping once the array[i] !
= NULL.
Also, size of the array (of pointers) does not determine how much space is
actually taken because memory is allocated to the pointer elements only when the
FEV structure exists. So an array with size 1000 will not result in 1000 memory
units taken up.
I defined the constants FACE, EDGE, VERTEX and MATRIX with numbers (i.e.
1111, 2222, 3333, 4444 respectively) larger than array size 50 so that the program
will not mistake serial numbers with the numbers that define the type (i.e.
fev_type).
I have p_structures (printable structures) that contain integer and double fields
and non-printable structures that contain pointers to make it easier to convert
between printable and non-printable structures.
3.2 Structure to File
I get the FEV structure from new_tetrahedron(), which are FEV p_structures
that contain integer or double fields instead of pointers. Then I converted all the
information into FEV structures that contain pointers.
I use a depth-first search method to fill up all the structure. The head face will
trigger the traversal.
Then I go through each array to find out how many FEV there are. Using these
counts, I use for loops to print the FEV into pgp.data.
3.3 File to Structure
I parsed the file and stored the information in printable structures. Then I
convert the structures to non-printable structure so that the structures are linked
together through pointers.
4. BONUS