KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerber_diff.h File Reference
#include <geometry/shape_poly_set.h>
#include <math/vector2d.h>
#include <gal/color4d.h>
#include <nlohmann/json_fwd.hpp>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  GERBER_DIFF_RESULT
 Result of a Gerber diff calculation containing the geometric differences and area statistics. More...
 
struct  DIFF_RENDER_OPTIONS
 Options for diff PNG rendering. More...
 

Enumerations

enum class  DIFF_UNITS { MM , INCH , MILS }
 Units for diff result formatting. More...
 

Functions

VECTOR2I CalculateAlignment (const SHAPE_POLY_SET &aReference, const SHAPE_POLY_SET &aComparison)
 Calculate the alignment offset to make a comparison poly set align with a reference.
 
GERBER_DIFF_RESULT CalculateGerberDiff (const SHAPE_POLY_SET &aReference, const SHAPE_POLY_SET &aComparison)
 Calculate the geometric differences between two poly sets.
 
wxString FormatDiffResultText (const GERBER_DIFF_RESULT &aResult, const wxString &aFile1, const wxString &aFile2, DIFF_UNITS aUnits=DIFF_UNITS::MM)
 Format a diff result as human-readable text.
 
nlohmann::json FormatDiffResultJson (const GERBER_DIFF_RESULT &aResult, const wxString &aFile1, const wxString &aFile2, DIFF_UNITS aUnits=DIFF_UNITS::MM, double aMaxDiffPercent=0.0)
 Format a diff result as JSON.
 
bool RenderDiffToPng (const GERBER_DIFF_RESULT &aResult, const wxString &aOutputPath, const DIFF_RENDER_OPTIONS &aOptions)
 Render a diff result to PNG with colored regions.
 

Enumeration Type Documentation

◆ DIFF_UNITS

enum class DIFF_UNITS
strong

Units for diff result formatting.

Enumerator
MM 
INCH 
MILS 

Definition at line 92 of file gerber_diff.h.

Function Documentation

◆ CalculateAlignment()

VECTOR2I CalculateAlignment ( const SHAPE_POLY_SET & aReference,
const SHAPE_POLY_SET & aComparison )

Calculate the alignment offset to make a comparison poly set align with a reference.

Uses bounding box origin alignment.

Parameters
aReferenceThe reference poly set (will not be modified)
aComparisonThe comparison poly set (offset will translate this to align)
Returns
Translation vector to apply to aComparison to align with aReference

Definition at line 28 of file gerber_diff.cpp.

References SHAPE_POLY_SET::BBox(), BOX2< Vec >::GetOrigin(), and SHAPE_POLY_SET::OutlineCount().

Referenced by GERBVIEW_JOBS_HANDLER::JobGerberDiff().

◆ CalculateGerberDiff()

GERBER_DIFF_RESULT CalculateGerberDiff ( const SHAPE_POLY_SET & aReference,
const SHAPE_POLY_SET & aComparison )

Calculate the geometric differences between two poly sets.

Computes overlap, additions (in comparison but not reference), and removals (in reference but not comparison) using boolean operations.

Parameters
aReferenceThe reference poly set
aComparisonThe comparison poly set
Returns
GERBER_DIFF_RESULT with geometry and statistics

Definition at line 41 of file gerber_diff.cpp.

References result.

Referenced by GERBVIEW_JOBS_HANDLER::JobGerberDiff().

◆ FormatDiffResultJson()

nlohmann::json FormatDiffResultJson ( const GERBER_DIFF_RESULT & aResult,
const wxString & aFile1,
const wxString & aFile2,
DIFF_UNITS aUnits = DIFF_UNITS::MM,
double aMaxDiffPercent = 0.0 )

Format a diff result as JSON.

Parameters
aResultThe diff result to format
aFile1Name of the reference file
aFile2Name of the comparison file
aUnitsOutput units for area values
aMaxDiffPercentThreshold for within_threshold field (0 = any diff fails)
Returns
JSON object

Definition at line 149 of file gerber_diff.cpp.

References GERBER_DIFF_RESULT::additionsArea, GERBER_DIFF_RESULT::additionsPercent, GERBER_DIFF_RESULT::comparisonArea, GERBER_DIFF_RESULT::netChangePercent, GERBER_DIFF_RESULT::overlapArea, GERBER_DIFF_RESULT::referenceArea, GERBER_DIFF_RESULT::removalsArea, and GERBER_DIFF_RESULT::removalsPercent.

Referenced by GERBVIEW_JOBS_HANDLER::JobGerberDiff().

◆ FormatDiffResultText()

wxString FormatDiffResultText ( const GERBER_DIFF_RESULT & aResult,
const wxString & aFile1,
const wxString & aFile2,
DIFF_UNITS aUnits = DIFF_UNITS::MM )

Format a diff result as human-readable text.

Parameters
aResultThe diff result to format
aFile1Name of the reference file
aFile2Name of the comparison file
aUnitsOutput units for area values
Returns
Formatted text string

Definition at line 118 of file gerber_diff.cpp.

References GERBER_DIFF_RESULT::additionsArea, GERBER_DIFF_RESULT::additionsPercent, GERBER_DIFF_RESULT::comparisonArea, GERBER_DIFF_RESULT::netChangePercent, GERBER_DIFF_RESULT::overlapArea, GERBER_DIFF_RESULT::referenceArea, GERBER_DIFF_RESULT::removalsArea, and GERBER_DIFF_RESULT::removalsPercent.

Referenced by GERBVIEW_JOBS_HANDLER::JobGerberDiff().

◆ RenderDiffToPng()