KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerber_diff.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2025 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef GERBER_DIFF_H
21#define GERBER_DIFF_H
22
24#include <math/vector2d.h>
25#include <gal/color4d.h>
26#include <nlohmann/json_fwd.hpp>
27#include <wx/string.h>
28
29
62
63
73VECTOR2I CalculateAlignment( const SHAPE_POLY_SET& aReference, const SHAPE_POLY_SET& aComparison );
74
75
86GERBER_DIFF_RESULT CalculateGerberDiff( const SHAPE_POLY_SET& aReference, const SHAPE_POLY_SET& aComparison );
87
88
92enum class DIFF_UNITS
93{
97};
98
99
109wxString FormatDiffResultText( const GERBER_DIFF_RESULT& aResult, const wxString& aFile1, const wxString& aFile2,
110 DIFF_UNITS aUnits = DIFF_UNITS::MM );
111
112
123nlohmann::json FormatDiffResultJson( const GERBER_DIFF_RESULT& aResult, const wxString& aFile1, const wxString& aFile2,
124 DIFF_UNITS aUnits = DIFF_UNITS::MM, double aMaxDiffPercent = 0.0 );
125
126
131{
132 int dpi = 300;
133 int width = 0;
134 int height = 0;
135 bool antialias = true;
136
141};
142
143
154bool RenderDiffToPng( const GERBER_DIFF_RESULT& aResult, const wxString& aOutputPath,
155 const DIFF_RENDER_OPTIONS& aOptions );
156
157
158#endif // GERBER_DIFF_H
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
Represent a set of closed polygons.
DIFF_UNITS
Units for diff result formatting.
Definition gerber_diff.h:93
GERBER_DIFF_RESULT CalculateGerberDiff(const SHAPE_POLY_SET &aReference, const SHAPE_POLY_SET &aComparison)
Calculate the geometric differences between two poly sets.
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.
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.
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.
bool RenderDiffToPng(const GERBER_DIFF_RESULT &aResult, const wxString &aOutputPath, const DIFF_RENDER_OPTIONS &aOptions)
Render a diff result to PNG with colored regions.
@ INCH
Definition rs274x.cpp:62
Options for diff PNG rendering.
KIGFX::COLOR4D colorRemovals
Red.
KIGFX::COLOR4D colorAdditions
Green.
int height
0 = calculate from DPI
KIGFX::COLOR4D colorOverlap
Gray.
KIGFX::COLOR4D colorBackground
White.
int width
0 = calculate from DPI
Result of a Gerber diff calculation containing the geometric differences and area statistics.
Definition gerber_diff.h:35
SHAPE_POLY_SET removals
Areas in file1 but not file2 (file1 AND NOT file2)
Definition gerber_diff.h:38
double removalsPercent
Removals as percent of reference area.
Definition gerber_diff.h:47
double additionsArea
Area of additions in mm^2.
Definition gerber_diff.h:43
SHAPE_POLY_SET overlap
Areas present in both files (file1 AND file2)
Definition gerber_diff.h:36
double referenceArea
Total area of file1 in mm^2.
Definition gerber_diff.h:40
double overlapArea
Area of overlap in mm^2.
Definition gerber_diff.h:42
double comparisonArea
Total area of file2 in mm^2.
Definition gerber_diff.h:41
double netChangePercent
Net change as percent of reference area.
Definition gerber_diff.h:48
double removalsArea
Area of removals in mm^2.
Definition gerber_diff.h:44
double additionsPercent
Additions as percent of reference area.
Definition gerber_diff.h:46
SHAPE_POLY_SET additions
Areas in file2 but not file1 (file2 AND NOT file1)
Definition gerber_diff.h:37
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687