From d5064b98a4a9c7faadcddcfdbab50b959891172c Mon Sep 17 00:00:00 2001 From: Cirilo Bernardo Date: Sat, 15 Feb 2014 08:39:06 +0100 Subject: [PATCH] Export VRML and IDF maintenance. Fix minor bug in eeschema (opening a relative path does not work) (patch from HennerZeller). --- eeschema/eeschema.cpp | 2 +- pcbnew/exporters/export_vrml.cpp | 46 +++++++++++++++++++++++++++++--- utils/idftools/idf_cylinder.cpp | 2 +- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 5efa3e62c8..7b1d86cd90 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -205,7 +205,7 @@ bool EDA_APP::OnInit() // wxSetWorkingDirectory does not like empty paths wxSetWorkingDirectory( filename.GetPath() ); - if( frame->LoadOneEEProject( filename.GetFullPath(), false ) ) + if( frame->LoadOneEEProject( filename.GetFullName(), false ) ) frame->GetCanvas()->Refresh( true ); } else diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 83965bfbf5..ba45f83988 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -44,6 +44,7 @@ * * 3. Export Graphics to Layer objects (see 3d_draw.cpp for clues) to ensure that custom * tracks/fills/logos are rendered. + * module->TransformGraphicShapesWithClearanceToPolygonSet * * For mechanical correctness, we should use the following settings with arcs: * 1. max. deviation: the number of edges should be determined by the max. @@ -925,7 +926,8 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) } -static void export_vrml_edge_module( MODEL_VRML& aModel, EDGE_MODULE* aOutline ) +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 + aModel.tx; @@ -936,6 +938,10 @@ static void export_vrml_edge_module( MODEL_VRML& aModel, EDGE_MODULE* aOutline ) 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; @@ -944,8 +950,41 @@ static void export_vrml_edge_module( MODEL_VRML& aModel, EDGE_MODULE* aOutline ) export_vrml_circle( aModel, layer, x, y, xf, yf, w ); break; + case S_POLYGON: + { + VRML_LAYER* vl; + + if( !VRMLEXPORT::GetLayer( aModel, layer, &vl ) ) + break; + + int nvert = aOutline->GetPolyPoints().size(); + 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 + aModel.tx; + y = - ( corner.y * aModel.scale + aModel.ty ); + vl->AddVertex( seg, x, y ); + + ++i; + } + vl->EnsureWinding( seg, false ); + } + break; + default: - export_vrml_line( aModel, layer, x, y, xf, yf, w ); break; } } @@ -1134,7 +1173,8 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule break; case PCB_MODULE_EDGE_T: - export_vrml_edge_module( aModel, dynamic_cast( item ) ); + export_vrml_edge_module( aModel, dynamic_cast( item ), + aModule->GetOrientation() ); break; default: diff --git a/utils/idftools/idf_cylinder.cpp b/utils/idftools/idf_cylinder.cpp index e289a0f2d6..f64a9b3d5c 100644 --- a/utils/idftools/idf_cylinder.cpp +++ b/utils/idftools/idf_cylinder.cpp @@ -177,7 +177,7 @@ int main( int argc, char **argv ) tstr.clear(); tstr.str( line ); - if( (tstr >> extraZ) && extraZ > 0.0 ) + if( (tstr >> extraZ) && extraZ >= 0.0 ) ok = true; }