KiCad PCB EDA Suite
Loading...
Searching...
No Matches
identity_reconciler.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 */
20
21#ifndef KICAD_DIFF_IDENTITY_RECONCILER_H
22#define KICAD_DIFF_IDENTITY_RECONCILER_H
23
24#include <kicommon.h>
25#include <kiid.h>
26#include <math/vector2d.h>
27#include <math/box2.h>
28
29#include <wx/string.h>
30
31#include <map>
32#include <set>
33#include <string>
34#include <vector>
35
36
37namespace KICAD_DIFF
38{
39
52{
54 wxString type;
57 std::vector<std::pair<wxString, std::string>> keyProps;
58};
59
60
69{
70 std::map<KIID_PATH, KIID_PATH> aToB; // id-in-A -> id-in-B for matched items
71 std::map<KIID_PATH, KIID_PATH> bToA; // inverse for quick lookup
72 std::set<KIID_PATH> aOnly; // items in A with no B match
73 std::set<KIID_PATH> bOnly; // items in B with no A match
74 std::vector<KIID_PATH> duplicatesA; // KIID_PATH appearing 2+ times in A
75 std::vector<KIID_PATH> duplicatesB;
76 std::size_t similarityMatches = 0; // count of matches made via fallback
77};
78
79
97{
98public:
99 struct CONFIG
100 {
101 double similarityThreshold = 0.85;
102 bool enableSimilarity = true;
103 bool detectDuplicates = true;
104 unsigned int positionTolerance = 0; // nm; 0 = strict equality
105 };
106
108 explicit IDENTITY_RECONCILER( const CONFIG& aConfig ) : m_config( aConfig ) {}
109
110 const CONFIG& GetConfig() const { return m_config; }
111 void SetConfig( const CONFIG& aConfig ) { m_config = aConfig; }
112
113 RECONCILIATION Reconcile( const std::vector<ITEM_DESCRIPTOR>& aA,
114 const std::vector<ITEM_DESCRIPTOR>& aB ) const;
115
122 double ScoreSimilarity( const ITEM_DESCRIPTOR& aA, const ITEM_DESCRIPTOR& aB ) const;
123
124private:
126};
127
128} // namespace KICAD_DIFF
129
130#endif // KICAD_DIFF_IDENTITY_RECONCILER_H
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
IDENTITY_RECONCILER(const CONFIG &aConfig)
void SetConfig(const CONFIG &aConfig)
#define KICOMMON_API
Definition kicommon.h:27
Descriptor used by the identity reconciler to compare items across two documents.
std::vector< std::pair< wxString, std::string > > keyProps
Maps every item in document A to either a peer in document B or to "only-in-A", and vice versa.
std::set< KIID_PATH > aOnly
std::vector< KIID_PATH > duplicatesA
std::map< KIID_PATH, KIID_PATH > aToB
std::vector< KIID_PATH > duplicatesB
std::set< KIID_PATH > bOnly
std::map< KIID_PATH, KIID_PATH > bToA
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683