static void export_vrml_drawsegment( MODEL_VRML& aModel, DRAWSEGMENT* drawseg )
{
    LAYER_NUM layer = drawseg->GetLayer();
    double  w   = drawseg->GetWidth() * aModel.scale;
    double  x   = drawseg->GetStart().x * aModel.scale;
    double  y   = drawseg->GetStart().y * aModel.scale;
    double  xf  = drawseg->GetEnd().x * aModel.scale;
    double  yf  = drawseg->GetEnd().y * aModel.scale;

    // Items on the edge layer are handled elsewhere; just return
    if( layer == Edge_Cuts )
        return;

    switch( drawseg->GetShape() )
    {
    case S_ARC:
        export_vrml_arc( aModel, layer,
                (double) drawseg->GetCenter().x,
                (double) drawseg->GetCenter().y,
                (double) drawseg->GetArcStart().x,
                (double) drawseg->GetArcStart().y,
                w, drawseg->GetAngle() / 10 );
        break;

    case S_CIRCLE:
        export_vrml_circle( aModel, layer, x, y, xf, yf, w );
        break;

    default:
        export_vrml_line( aModel, layer, x, y, xf, yf, w );
        break;
    }
}
예제 #2
0
static void export_vrml_edge_module( EDGE_MODULE* aOutline ) //{{{
{
    int    layer = aOutline->GetLayer();
    double x     = aOutline->GetStart().x;
    double y     = aOutline->GetStart().y;
    double xf    = aOutline->GetEnd().x;
    double yf    = aOutline->GetEnd().y;
    double w     = aOutline->GetWidth();

    switch( aOutline->GetShape() )
    {
    case S_ARC:
        export_vrml_arc( layer, x, y, xf, yf, w, aOutline->GetAngle()/10 );
        break;

    case S_CIRCLE:
        export_vrml_circle( layer, x, y, xf, yf, w );
        break;

    default:
        export_vrml_line( layer, x, y, xf, yf, w, 1 );
        break;
    }
}
static void export_vrml_edge_module( MODEL_VRML& aModel, EDGE_MODULE* aOutline,
                                     double aOrientation )
{
    LAYER_NUM layer = aOutline->GetLayer();
    double  x   = aOutline->GetStart().x * aModel.scale;
    double  y   = aOutline->GetStart().y * aModel.scale;
    double  xf  = aOutline->GetEnd().x * aModel.scale;
    double  yf  = aOutline->GetEnd().y * aModel.scale;
    double  w   = aOutline->GetWidth() * aModel.scale;

    switch( aOutline->GetShape() )
    {
    case S_SEGMENT:
        export_vrml_line( aModel, layer, x, y, xf, yf, w );
        break;

    case S_ARC:
        export_vrml_arc( aModel, layer, x, y, xf, yf, w, aOutline->GetAngle() / 10 );
        break;

    case S_CIRCLE:
        export_vrml_circle( aModel, layer, x, y, xf, yf, w );
        break;

    case S_POLYGON:
        {
            VRML_LAYER* vl;

            if( !GetLayer( aModel, layer, &vl ) )
                break;

            int nvert = aOutline->GetPolyPoints().size() - 1;
            int i = 0;

            if( nvert < 3 ) break;

            int seg = vl->NewContour();

            if( seg < 0 )
                break;

            while( i < nvert )
            {
                CPolyPt corner( aOutline->GetPolyPoints()[i] );
                RotatePoint( &corner.x, &corner.y, aOrientation );
                corner.x += aOutline->GetPosition().x;
                corner.y += aOutline->GetPosition().y;

                x = corner.x * aModel.scale;
                y = - ( corner.y * aModel.scale );

                if( !vl->AddVertex( seg, x, y ) )
                    throw( std::runtime_error( vl->GetError() ) );

                ++i;
            }
            vl->EnsureWinding( seg, false );
        }
        break;

    default:
        break;
    }
}
예제 #4
0
static void export_vrml_drawsegment( DRAWSEGMENT* drawseg ) //{{{
{
    int    layer = drawseg->GetLayer();
    double w     = drawseg->GetWidth();
    double x     = drawseg->GetStart().x;
    double y     = drawseg->GetStart().y;
    double xf    = drawseg->GetEnd().x;
    double yf    = drawseg->GetEnd().y;

    // Items on the edge layer are high, not thick
    if( layer == EDGE_N )
    {
        switch( drawseg->GetShape() )
        {
        // There is a special 'varc' primitive for this
        case S_ARC:
            export_vrml_varc( layer_triangles[layer],
                              FIRST_COPPER_LAYER, LAST_COPPER_LAYER,
                              x, y, xf, yf, drawseg->GetAngle()/10 );
            break;

        // Circles on edge are usually important holes
        case S_CIRCLE:
            export_vrml_hole( layer_triangles[layer],
                              FIRST_COPPER_LAYER, LAST_COPPER_LAYER, x, y,
                              hypot( xf - x, yf - y ) / 2 );
            break;

        default:
        {
            // Simply a quad
            double z_top    = layer_z[FIRST_COPPER_LAYER];
            double z_bottom = layer_z[LAST_COPPER_LAYER];
            bag_vquad( layer_triangles[layer], x, y, xf, yf, z_top, z_bottom );
            break;
        }
        }
    }
    else
    {
        switch( drawseg->GetShape() )
        {
        case S_ARC:
            export_vrml_arc( layer,
                             (double) drawseg->GetCenter().x,
                             (double) drawseg->GetCenter().y,
                             (double) drawseg->GetArcStart().x,
                             (double) drawseg->GetArcStart().y,
                             w, drawseg->GetAngle()/10 );
            break;

        case S_CIRCLE:
            export_vrml_circle( layer, x, y, xf, yf, w );
            break;

        default:
            export_vrml_line( layer, x, y, xf, yf, w, 1 );
            break;
        }
    }
}