KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerber_diff.cpp File Reference
#include "gerber_diff.h"
#include "gerber_to_png.h"
#include <plotters/plotter_png.h>
#include <base_units.h>
#include <cmath>
#include <json_common.h>

Go to the source code of this file.

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)
 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, double aMaxDiffPercent)
 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.
 

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()