Пример #1
0
void Render::renderizaArestas()
{
    QPainter buff(frontBuffer);
    QPoint p;
    HalfEdge *partida;
    HalfEdge::iterator it;

    buff.setPen(vizinhoScreen);

    if(vsel != NULL)
        partida = vsel->getEdge();
    if(hsel != NULL)
        partida = hsel;
    if(fsel != NULL)
        partida = fsel->getHalfEdge();

    if(vsel != NULL || hsel != NULL)
    {
        for(it = partida->v_begin(); it != partida->v_end(); ++it)
        {
            buff.drawLine(transforma(it->getOrigem()->getPoint()), transforma(it->getDestino()->getPoint()));
        }
        if(hsel != NULL)
        {
            partida = partida->getTwin();
            for(it = partida->v_begin(); it != partida->v_end(); ++it)
            {
                buff.drawLine(transforma(it->getOrigem()->getPoint()), transforma(it->getDestino()->getPoint()));
            }
        }else
            buff.drawLine(transforma(partida->getOrigem()->getPoint()), transforma(partida->getDestino()->getPoint()));
    }
    QVector<HalfEdge *> *v;
    if(fsel != NULL)
    {
        if(interface.isExterna(fsel))
            v = &(interface.componentesFaceExterna);
        else
        {
            v = new QVector<HalfEdge *>();
            v->push_back(partida->getTwin());
        }
        for(int i = 0; i < v->size(); ++i)
        {
            partida = v->at(i)->getTwin();

            for(it = partida->f_begin(); it != partida->f_end(); ++it)
            {
                buff.drawLine(transforma(it->getOrigem()->getPoint()), transforma(it->getDestino()->getPoint()));
            }
            buff.drawLine(transforma(partida->getOrigem()->getPoint()), transforma(partida->getDestino()->getPoint()));
        }
        if(!interface.isExterna(fsel))
            delete v;
    }

}
Пример #2
0
void Render::renderizaFaceExterna(QPen *pen)
{
    bool passa;
    QVector<HalfEdge*> *list = &(interface.componentesFaceExterna);
    QVector<HalfEdge*> temp;
    HalfEdge *val;
    HalfEdge::iterator it, jt;
    QImage buffExt(buffer->width(), buffer->height(), QImage::Format_ARGB32_Premultiplied);
    QPainter p;
    p.begin(&buffExt);
    p.setCompositionMode(QPainter::CompositionMode_Source);
    p.fillRect(buffExt.rect(), pen->color());
    p.end();

    for(int i = 0; i < list->size(); ++i)
    {
        val = list->at(i);
        passa = false;

          for(it = val->v_begin(); it != val->v_end() ; ++it)
            {
               if(dentroFace(val->getTwin(),it->getDestino()->getPoint()))
                {
                    passa = true;
                    break;
                }
            }

        if( passa || componenteFaceUnica(&it))
            renderizaComponente(val->getTwin(),&buffExt,QPen(Qt::transparent));
        else
            temp.push_back(val->getTwin());
    }
    for(int i = 0; i < temp.size(); ++i)
        renderizaFace(temp[i],&buffExt,*pen);

    p.begin(frontBuffer);
    p.setCompositionMode(QPainter::CompositionMode_SourceOver);
    p.drawImage(0,0, buffExt);
    p.end();
}
Пример #3
0
void Render::renderizaFaces()
{
    HalfEdge *partida;
    HalfEdge::iterator it;
    bool renderizaExterna = false;

    if(vsel != NULL)
        partida = vsel->getEdge();
    if(hsel != NULL)
        partida = hsel;
    if(fsel != NULL)
        partida = fsel->getHalfEdge();

    if(vsel != NULL)
    {
        if(interface.isExterna(partida->getFace()))
            renderizaExterna = true;
        else
            renderizaFace(partida, frontBuffer,vizinhoScreen);
        for(it = partida->v_begin(); it != partida->v_end(); ++it)
        {
            if(interface.isExterna(it->getFace()))
                renderizaExterna = true;
            else
                renderizaFace(&it, frontBuffer,vizinhoScreen);
        }
    }

    if(hsel != NULL)
    {
        if(interface.isExterna(partida->getFace()))
            renderizaExterna = true;
        else
            renderizaFace(partida, frontBuffer,vizinhoScreen);

        if(interface.isExterna(partida->getTwin()->getFace()))
            renderizaExterna = true;
        else
            renderizaFace(partida->getTwin(), frontBuffer,vizinhoScreen);
    }

    QVector<HalfEdge *> *v;
    QSet<Face*> f;
    if(fsel != NULL)
    {
        if(interface.isExterna(fsel))
            v = &(interface.componentesFaceExterna);
        else
        {
            v = new QVector<HalfEdge *>();
            v->push_back(partida->getTwin());
        }
        for(int i = 0; i < v->size(); ++i)
        {
            partida = v->at(i)->getTwin();

            if(interface.isExterna(partida->getTwin()->getFace()))
                renderizaExterna = true;
            else
                renderizaFace(partida->getTwin(), frontBuffer,vizinhoScreen);
            for(it = partida->f_begin(); it != partida->f_end(); ++it)
            {
                if(interface.isExterna(it->getTwin()->getFace()))
                    renderizaExterna = true;
                else
                    f.insert(it->getTwin()->getFace());
            }
        }
        if(!interface.isExterna(fsel))
            delete v;
        QSet<Face*>::iterator jt;
        for(jt = f.begin(); jt != f.end(); ++jt)
            renderizaFace((*jt)->getHalfEdge(), frontBuffer,vizinhoScreen);
    }


    if(renderizaExterna)
        renderizaFaceExterna(&vizinhoScreen);
}