tudelft3d / prepair

Automatic repair of single polygons (according to the OGC Simple Features / ISO19107 rules) using a constrained triangulation.
GNU General Public License v3.0
115 stars 24 forks source link

Extracting just the triangulation result #1

Closed preet closed 11 years ago

preet commented 11 years ago

Hi! I'd been using prepair before to fix land polygons so that I could subsequently triangulate and then render them in 3d. However, since prepair uses triangulation as a basis to fix degenerate polygons, I've been trying to extract the relevant triangulation directly.

I do this by looking at the value of the additional 'info()' param that's attached to each triangulation face and compare the value to the 'interior' and 'exterior' addresses defined in the repair() function. I opt to keep triangles that have an info() == NULL because it seems like the repair() function sets all interior faces to NULL after processing them whereas exterior faces will have a non null address.

The result seems to work, but I'm not sure if what I'm doing is correct. Will interior triangles always correspond to NULL? Am I collecting the right set of triangles by doing the following?:

    Triangulation opTriangulation;
    OGRMultiPolygon * opPolygons = repair(ipGeometry,
                                          opTriangulation);
    Triangulation::Finite_faces_iterator fIt;
    for(fIt  = opTriangulation.finite_faces_begin();
        fIt != opTriangulation.finite_faces_end(); ++fIt)
    {
        // assumption: if face->info() == NULL, we
        // have the correct interior triangle
        if(fIt->info() == NULL)   {
            // get triangle
            Triangulation::Triangle cdtTri =
                    opTriangulation.triangle(fIt);

            // ... copy triangle coords ... //
        }
    }

Regards,

Preet

kenohori commented 11 years ago

Hi Preet,

This should work without problems. As you write, the repair() function sets interior triangles to NULL after reconstruction.

However, if speed is an issue, you might consider extracting the triangulation in the repair() function itself, after tagging and before reconstruction. In that case, you should use the triangles marked with the interior tag.

Cheers, Ken