コード例 #1
0
ファイル: Interface.cpp プロジェクト: Mendelev/cg-ufrj-2011
void Interface::adicionaface(HalfEdge* e, Face* f)
{
    HalfEdge *ori = e;
    HalfEdge *ant = NULL;
    HalfEdge *nova = NULL;
    HalfEdge *first;
    bool sai = false;

    nova = new HalfEdge();

    nova->setFace(f);
    nova->setTwin(ori);
    ori->setTwin(nova);
    nova->setOrigem(ori->getDestino());
    f->setOuterComp(nova);
    ant = nova;
    first = nova;

    ori = ori->getProx();
    while(true)
    {
        while(ori->getTwin() != NULL)
        {
            if(ori == e)
            {
                sai = true;
                break;
            }
            ori = ori->getTwin()->getProx();
        }

        if(sai)
            break;

        nova = new HalfEdge();

        nova->setFace(f);
        nova->setTwin(ori);
        ori->setTwin(nova);
        nova->setProx(ant);
        ant->setAnt(nova);
        nova->setOrigem(ori->getDestino());

        ori = ori->getProx();

        ant = nova;
    }

    ori->getTwin()->setProx(ant);
    ant->setAnt(ori->getTwin());
}
コード例 #2
0
ファイル: Interface.cpp プロジェクト: Mendelev/cg-ufrj-2011
void Interface::addFace(QVector<QPointF> in)
{
    Face *f = new Face();
    HalfEdge *ant = NULL;
    HalfEdge *first, *twin, *temp;

    for(int i = 0; i < in.size(); i++)
    {
        HalfEdge *e = new HalfEdge();
        if (i == 0)     first = e;

        temp = findTwin(in[i],in[(i+1)%in.size()]);
        if (temp != NULL)
            e = temp;
        else
            map[qMakePair(in[i], in[(i+1)%in.size()])] = e;

        twin = e->getTwin();
        if (twin == NULL)
            twin = findTwin(in[(i+1)%in.size()],in[i]);


        minX = MIN(minX, in[i].x());
        maxX = MAX(maxX, in[i].x());
        minY = MIN(minY, in[i].y());
        maxY = MAX(maxY, in[i].y());

        Vertex *v = addVertex(in[i]);
        v->setEdge(e);
        e->setOrigem(v);

        e->setFace(f);

        e->setAnt(ant);
        if (ant!= NULL)
        {
            ant->setProx(e);
        }

        e->setTwin(twin);
        if (twin!= NULL)
        {
            twin->setTwin(e);
        }

        ant = e;
    }

    first->setAnt(ant);
    ant->setProx(first);

    f->setOuterComp(first);

    faces.push_back(f);
}