Pcbnew, zone filler: Ensure hatch pattern thickness bigger than zone minimal width (one micron bigger).
This margin is mandatory to avoid incorrect polygons in Gerber files: due to the fact Gerber units can be 10 nm (and Gerbview internal unit is also 10nm), valid polygons can be converted to non valid (self intersecting for instance) by coordinates truncation. This is a known problem in Gerber files (not specific to Gerber format) Fixes: lp:1847737 https://bugs.launchpad.net/kicad/+bug/1847737
This commit is contained in:
parent
4b2d801fec
commit
a18d3cca6e
|
@ -48,6 +48,7 @@
|
||||||
#include <geometry/convex_hull.h>
|
#include <geometry/convex_hull.h>
|
||||||
#include <geometry/geometry_utils.h>
|
#include <geometry/geometry_utils.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
#include <convert_to_biu.h>
|
||||||
|
|
||||||
#include "zone_filler.h"
|
#include "zone_filler.h"
|
||||||
|
|
||||||
|
@ -995,10 +996,15 @@ void ZONE_FILLER::addHatchFillTypeOnZone( const ZONE_CONTAINER* aZone, SHAPE_POL
|
||||||
{
|
{
|
||||||
// Build grid:
|
// Build grid:
|
||||||
|
|
||||||
// obvously line thickness must be > zone min thickness. However, it should be
|
// obviously line thickness must be > zone min thickness.
|
||||||
// the case because the zone dialog setup ensure that. However, it can happens
|
// It can happens if a board file was edited by hand by a python script
|
||||||
// if a board file was edited by hand by a python script
|
// Use 1 micron margin to be *sure* there is no issue in Gerber files
|
||||||
int thickness = std::max( aZone->GetHatchFillTypeThickness(), aZone->GetMinThickness()+2 );
|
// (Gbr file unit = 1 or 10 nm) due to some truncation in coordinates or calculations
|
||||||
|
// This margin also avoid problems due to rounding coordinates in next calculations
|
||||||
|
// that can create incorrect polygons
|
||||||
|
int thickness = std::max( aZone->GetHatchFillTypeThickness(),
|
||||||
|
aZone->GetMinThickness()+Millimeter2iu( 0.001 ) );
|
||||||
|
|
||||||
int linethickness = thickness - aZone->GetMinThickness();
|
int linethickness = thickness - aZone->GetMinThickness();
|
||||||
int gridsize = thickness + aZone->GetHatchFillTypeGap();
|
int gridsize = thickness + aZone->GetHatchFillTypeGap();
|
||||||
double orientation = aZone->GetHatchFillTypeOrientation();
|
double orientation = aZone->GetHatchFillTypeOrientation();
|
||||||
|
|
Loading…
Reference in New Issue