According to comments the solution is quite easy
1.prepare data
- represent your mesh as table of points and remove redundant points (point = x,y,z... + int cnt=0; )
- and table of lines (line = 2 * index of point from point table + bool deleted=false)
- while creating table of lines for each used point increment its cnt counter
2.remove redundant lines (join border between thick lines)
- find all lines that are overlapping and lie on the same line
- they have the same or opposite direction
- remove the shorter one and dissect the bigger one and update all tables accordingly (also point cnt !!!)
- after this find all lines between points used booth more than twice
- delete them ...
3.find all closed loops
something like this:
1.create list of polygons
- polygon is list of point indexes
2.take any undeleted line
- if found add new polygon to list and
- copy its points to polygon
- flag line as deleted
- if not found stop
3.find line with point matching last polygon point
- add the other point to polygon
- flag line as deleted
- repeat bullet 2 until there is no such line found
4.goto 1
4.now found polygon with the biggest bounding box
- this polygon is the outer perimeter
- so delete it
- also you can draw it by different color for debugging purposes
5.now sum the rest
- all remaining polygons are the holes
- so triangulate them
- and sum all triangle areas by basic math formula ...
- also you can draw them by other different color for debugging purposes