Number of detected self intersection in vcglib does not coincide with the Meshlab number

178 Views Asked by At

When I execute my program

C:\Users\me\Documents\projectCGALII\build\Debug>test.exe pig.obj

I get 6 intersections and when it is checked in Meshlab it say 4 intersection. This is my program:

void  countSelfIntersection(const char* filename)
{
    OpenMesh(filename, pm);
    vcg::tri::UpdateTopology<PMesh>::FaceFace(pm);
    std::vector<PMesh::FaceType *> intersections;
    bool SelfIntersect = tri::Clean<PMesh>::SelfIntersections(pm, intersections);

    std::cout << "Count Intersection: " << intersections.size() << std::endl;

    for (std::vector<PMesh::FaceType *>::iterator it = intersections.begin(); it != intersections.end(); it++)
    {
        PMesh::FaceType *face = *it;
        for (int i = 0; i < 3; ++i)
        {
            std::cout << "Vertex(" <<i<<")"<< std::dec <<(int) face->cV0(i) << " " << std::dec << (int)face->cV1(i) << " " << std::dec << (int)face->cV2(i) << std::endl;
        }

        std::cout<<std::endl;


    }

}


int main(int argc, char* argv[])
{
    nonManinfoldEdge(argv[1]);
    return 0;
}

Attached pig.obj file here:

https://drive.google.com/open?id=1fEqZft_OhHxTsAvio58_TWOtvrYbGCOA

is the faces repeated in the result? How to get the right result as the meshlab does? Which is the better way to print the properties of every face or vertices in order to check that exist some repeated faces? How to remove the repeated faces if they exists?

1

There are 1 best solutions below

0
sergio campo On

Resolved!

int countSelfIntersections(PMesh &pm)
{
    vcg::tri::UpdateTopology<PMesh>::FaceFace(pm);
    std::vector<PFace *> intersections;
    bool SelfIntersect = tri::Clean<PMesh>::SelfIntersections(pm, intersections);
    tri::UpdateSelection<PMesh>::FaceClear(pm);

    for (std::vector<PFace*>::iterator it = intersections.begin(); it != intersections.end(); it++)
    {
        PFace *face = *it;
        face->SetS();
    }

    PMesh::FaceIterator f;
    f = pm.face.begin();
    std::vector<PFace*> sf;
    for (; f != pm.face.end(); ++f)
    {
        if (f->IsS())
        {
            sf.push_back(&(*f));
        }
    }

    return sf.size();
}