static void write_layers( MODEL_VRML& aModel, std::ofstream& output_file, BOARD* aPcb )
{
    // VRML_LAYER board;
    aModel.board.Tesselate( &aModel.holes );
    double brdz = aModel.board_thickness / 2.0
                  - ( Millimeter2iu( ART_OFFSET / 2.0 ) ) * aModel.scale;
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_PCB ),
            &aModel.board, false, false, brdz, -brdz, aModel.precision );

    // VRML_LAYER top_copper;
    aModel.top_copper.Tesselate( &aModel.holes );
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ),
            &aModel.top_copper, true, true,
            aModel.GetLayerZ( F_Cu ), 0, aModel.precision );

    // VRML_LAYER top_tin;
    aModel.top_tin.Tesselate( &aModel.holes );
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ),
            &aModel.top_tin, true, true,
            aModel.GetLayerZ( F_Cu )
            + Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
            0, aModel.precision );

    // VRML_LAYER bot_copper;
    aModel.bot_copper.Tesselate( &aModel.holes );
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TRACK ),
            &aModel.bot_copper, true, false,
            aModel.GetLayerZ( B_Cu ), 0, aModel.precision );

    // VRML_LAYER bot_tin;
    aModel.bot_tin.Tesselate( &aModel.holes );
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ),
                        &aModel.bot_tin, true, false,
                        aModel.GetLayerZ( B_Cu )
                        - Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
                        0, aModel.precision );

    // VRML_LAYER PTH;
    aModel.plated_holes.Tesselate( NULL, true );
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_TIN ),
                        &aModel.plated_holes, false, false,
                        aModel.GetLayerZ( F_Cu )
                        + Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
                        aModel.GetLayerZ( B_Cu )
                        - Millimeter2iu( ART_OFFSET / 2.0 ) * aModel.scale,
                        aModel.precision );

    // VRML_LAYER top_silk;
    aModel.top_silk.Tesselate( &aModel.holes );
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ),
            &aModel.top_silk, true, true,
            aModel.GetLayerZ( F_SilkS ), 0, aModel.precision );

    // VRML_LAYER bot_silk;
    aModel.bot_silk.Tesselate( &aModel.holes );
    write_triangle_bag( output_file, aModel.GetColor( VRML_COLOR_SILK ),
            &aModel.bot_silk, true, false,
            aModel.GetLayerZ( B_SilkS ), 0, aModel.precision );
}
Esempio n. 2
0
static void write_and_empty_triangle_bag( FILE* output_file, TRIANGLEBAG& triangles,
                                          int color, double boardIU2WRML )
{
    if( !triangles.empty() )
    {
        write_triangle_bag( output_file, color, triangles, boardIU2WRML );
        triangles.clear( );
    }
}