Exemplo n.º 1
0
static void 
drawAllEdges(const Body& b, AcGiWorldDraw *pWorldDraw)
{
#ifndef NDEBUG
    Adesk::UInt16 currentColor = pWorldDraw->subEntityTraits().color();
    Adesk::UInt16 color = currentColor, lastColorSet = currentColor;
    const Adesk::UInt16 approxColor = 1;
    const Adesk::UInt16 bridgeColor = 2;
    const Adesk::UInt16 firstEdgeColor = 3;
    const Adesk::UInt16 secondEdgeColor = 4;
    int iEdge = 0, iFaces = b.faceCount();
#endif

    for (Face* f = b.faceList(); f != NULL; f = f->next())
    {
        if (f->edgeLoop() == NULL)
            continue;
        
        Edge* e = f->edgeLoop();
        do 
        {
            if (e->isEulerEdge()) 
            {
#ifndef NDEBUG
                if (e->isApprox())
                    color = approxColor;
                else if (iFaces == 1 && iEdge == 0)
                    color = firstEdgeColor;
                else if (iFaces == 1 && iEdge == 1)
                    color = secondEdgeColor;
                else if (e->isBridge())
                    color = bridgeColor;
                else
                    color = currentColor;

                if (color != lastColorSet)
                {
                    pWorldDraw->subEntityTraits().setColor(color);
                    lastColorSet = color;
                }
                iEdge++;
#else
                if (e->isBridge())
                    continue;
#endif
                Point3d p[2];
                p[0] = e->point();
                p[1] = e->next()->point();
                pWorldDraw->geometry().polyline(2, (AcGePoint3d*)p);
            }
        } while ((e = e->next()) != f->edgeLoop());
    }
}
void drawAllEdges(const Body& b, AcGiWorldDraw *pWorldDraw)
{
//#ifndef NDEBUG
//    Adesk::UInt16 currentColor = pWorldDraw->subEntityTraits().color();
//    Adesk::UInt16 color = currentColor, lastColorSet = currentColor;
//    const Adesk::UInt16 approxColor = 1;    // red
//    const Adesk::UInt16 bridgeColor = 2;    // yellow
//    const Adesk::UInt16 firstEdgeColor = 3; // green
//    const Adesk::UInt16 secondEdgeColor = 4;    // cyan
//    int iEdge = 0, iFaces = b.faceCount();
//#endif

    for (Face* f = b.faceList(); f != NULL; f = f->next())
    {
        if (f->edgeLoop() == NULL)
            continue;
        
        Edge* e = f->edgeLoop();
        do 
        {
            if (e->isEulerEdge()) 
            {
//#ifndef NDEBUG
//                if (e->isApprox())
//                    color = approxColor;
//                else if (iFaces == 1 && iEdge == 0)
//                    color = firstEdgeColor;
//                else if (iFaces == 1 && iEdge == 1)
//                    color = secondEdgeColor;
//                else if (e->isBridge())
//                    color = bridgeColor;
//                else
//                    color = currentColor;
//
//                if (color != lastColorSet)
//                {
//                    pWorldDraw->subEntityTraits().setColor(color);
//                    lastColorSet = color;
//                }
//                iEdge++;
//#else
                if (e->isBridge())
                    continue;
//#endif
                Point3d p[2];
                p[0] = e->point();
                p[1] = e->next()->point();
                pWorldDraw->geometry().polyline(2, (AcGePoint3d*)p);
            }
        } while ((e = e->next()) != f->edgeLoop());
    }
}