1

当我执行我的程序时

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

我得到 6 个交叉点,当它在 Meshlab 中检查时,它说 4 个交叉点。这是我的程序:

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;
}

在此处附加 pig.obj 文件:

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

结果中的面孔是否重复?如何像 meshlab 那样得到正确的结果?打印每个面或顶点的属性以检查是否存在一些重复面的更好方法是什么?如果存在重复的面孔,如何删除它们?

4

1 回答 1

0

解决!

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();
}
于 2018-06-12T07:04:51.447 回答