how to do surface triangulation?

I want to calculate the surface area of an irregular object, the object has been grided and now I know the coordination of grids right on the boundary, the next step is that I have to try to use surface triangulation to creat traingles on boundary, then calculate the surface area(or other better ways you can think?).

please look at this link:

http://www2.imm.dtu.dk/~jab/gallery/polygonization.html

but I do not know how to write C code for this transformation, anyone can help me? reply here or email <<snipped>>? thanks