From 77945c4eb888d113c984a47d8005ef098d04fbf3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 19 Feb 2013 10:21:55 +0100 Subject: [PATCH] Pcbnew: Export vrml: fix an issue for 3D shapes having a local offset defined: the local offset was not correctly scaled. --- pcbnew/class_zone.cpp | 5 ++++- pcbnew/export_vrml.cpp | 13 +++++++------ polygon/PolyLine.cpp | 3 ++- polygon/PolyLine.h | 1 - 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index a2d4322675..36f1b489b5 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -300,7 +300,10 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, * with outlines thickness = 0 is a faster than * just draw filled polygons but with outlines thickness = m_ZoneMinThickness * So DO NOT use draw filled polygons with outlines having a thickness > 0 - * Note: Extra segments ( added by kbool to joint holes with external outline) are not drawn + * Note: Extra segments ( added to joint holes with external outline) flagged by + * m_utility != 0 are not drawn + * Note not all polygon libraries provide a flag for these extra-segments, therefore + * the m_utility member can be always 0 */ { // Draw outlines: diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index 5c656d7f5a..6b8954b77b 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -1111,10 +1111,11 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, fprintf( aOutputFile, " rotation %g %g %g %g\n", rot[0], rot[1], rot[2], rot[3] ); } - // adjust 3D shape offset position - int offsetx = vrmlm->m_MatPosition.x; - int offsety = vrmlm->m_MatPosition.y; - double offsetz = vrmlm->m_MatPosition.z; + // adjust 3D shape local offset position + // they are given in inch, so they are converted in board IU. + double offsetx = vrmlm->m_MatPosition.x * IU_PER_MILS * 1000.0; + double offsety = vrmlm->m_MatPosition.y * IU_PER_MILS * 1000.0; + double offsetz = vrmlm->m_MatPosition.z * IU_PER_MILS * 1000.0; if ( isFlipped ) NEGATE(offsetz); @@ -1124,8 +1125,8 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule, RotatePoint(&offsetx, &offsety, aModule->GetOrientation()); fprintf( aOutputFile, " translation %g %g %g\n", - (double) (offsetx + aModule->m_Pos.x) * boardIU2WRML, - - (double)(offsety + aModule->m_Pos.y) * boardIU2WRML, // Y axis is reversed in Pcbnew + (offsetx + aModule->m_Pos.x) * boardIU2WRML, + - (offsety + aModule->m_Pos.y) * boardIU2WRML, // Y axis is reversed in Pcbnew offsetz + layer_z[aModule->GetLayer()] * boardIU2WRML); fprintf( aOutputFile, " scale %g %g %g\n", diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 5eacc6e031..1475f4c755 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -1,7 +1,8 @@ // PolyLine.cpp ... implementation of CPolyLine class from FreePCB. // -// implementation for kicad and kbool polygon clipping library +// implementation for kicad, using clipper polygon clipping library +// for transformations not handled (at least for Kicad) by boost::polygon // #include #include diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index e234cbf0a8..98273d3769 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -17,7 +17,6 @@ #include -//#include #include #include // for wxPoint definition