SVG_IMPORT_PLUGIN: enable postprocessing of polygons with degeneracy and holes

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6739
This commit is contained in:
Tomasz Wlostowski 2021-12-31 15:27:41 +01:00
parent 3fce15f442
commit 01d1f8723c
2 changed files with 10 additions and 3 deletions

View File

@ -85,13 +85,17 @@ bool SVG_IMPORT_PLUGIN::Import()
default: break;
}
m_importer->NewShape( rule );
m_internalImporter.NewShape( rule );
for( NSVGpath* path = shape->paths; path != nullptr; path = path->next )
DrawPath( path->pts, path->npts, path->closed, shape->fill.type == NSVG_PAINT_COLOR,
lineWidth );
}
m_internalImporter.PostprocessNestedPolygons();
wxCHECK( m_importer, false );
m_internalImporter.ImportTo( *m_importer );
return true;
}
@ -168,7 +172,7 @@ void SVG_IMPORT_PLUGIN::DrawCubicBezierCurve( const float* aPoints,
void SVG_IMPORT_PLUGIN::DrawPolygon( const std::vector< VECTOR2D >& aPoints, double aWidth )
{
m_importer->AddPolygon( aPoints, aWidth );
m_internalImporter.AddPolygon( aPoints, aWidth );
}
@ -177,7 +181,7 @@ void SVG_IMPORT_PLUGIN::DrawLineSegments( const std::vector< VECTOR2D >& aPoints
unsigned int numLineStartPoints = aPoints.size() - 1;
for( unsigned int pointIndex = 0; pointIndex < numLineStartPoints; ++pointIndex )
m_importer->AddLine( aPoints[ pointIndex ], aPoints[ pointIndex + 1 ], aWidth );
m_internalImporter.AddLine( aPoints[ pointIndex ], aPoints[ pointIndex + 1 ], aWidth );
}

View File

@ -29,6 +29,7 @@
#include "nanosvg.h"
#include "graphics_import_plugin.h"
#include "graphics_importer_buffer.h"
#include <math/vector2d.h>
#include <wildcards_and_files_ext.h>
@ -85,6 +86,8 @@ private:
wxString m_messages; // messages generated during svg file parsing.
// Each message ends by '\n'
GRAPHICS_IMPORTER_BUFFER m_internalImporter;
};
#endif /* SVG_IMPORT_PLUGIN_H */