KiCad PCB EDA Suite
Loading...
Searching...
No Matches
altium_parser_pcb.cpp
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) 2020 Thomas Pointhuber <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <map>
26#include <unordered_map>
27
28#include <ki_exception.h>
29#include <math/util.h>
30
31#include <wx/log.h>
32
33#include "altium_parser_pcb.h"
36
37
45static const wxChar* traceAltiumImport = wxT( "KICAD_ALTIUM_IMPORT" );
46
47
48/*
49 * Returns an Altium layer id from V6 and V7 file format data, compatible with the rest of the parser.
50 */
52{
54 return aV7Layer;
55
56 return aV6Layer;
57}
58
59
60/*
61 * Returns V7 layer ids for Mechanical 17 and above. Otherwise, V6 layer ids.
62 */
63ALTIUM_LAYER altium_layer_from_name( const wxString& aName )
64{
65 if( aName.IsEmpty() )
67
68 static const std::unordered_map<std::string, ALTIUM_LAYER> hash_map = {
69 { "TOP", ALTIUM_LAYER::TOP_LAYER },
70 { "MID1", ALTIUM_LAYER::MID_LAYER_1 },
71 { "MID2", ALTIUM_LAYER::MID_LAYER_2 },
72 { "MID3", ALTIUM_LAYER::MID_LAYER_3 },
73 { "MID4", ALTIUM_LAYER::MID_LAYER_4 },
74 { "MID5", ALTIUM_LAYER::MID_LAYER_5 },
75 { "MID6", ALTIUM_LAYER::MID_LAYER_6 },
76 { "MID7", ALTIUM_LAYER::MID_LAYER_7 },
77 { "MID8", ALTIUM_LAYER::MID_LAYER_8 },
78 { "MID9", ALTIUM_LAYER::MID_LAYER_9 },
79 { "MID10", ALTIUM_LAYER::MID_LAYER_10 },
80 { "MID11", ALTIUM_LAYER::MID_LAYER_11 },
81 { "MID12", ALTIUM_LAYER::MID_LAYER_12 },
82 { "MID13", ALTIUM_LAYER::MID_LAYER_13 },
83 { "MID14", ALTIUM_LAYER::MID_LAYER_14 },
84 { "MID15", ALTIUM_LAYER::MID_LAYER_15 },
85 { "MID16", ALTIUM_LAYER::MID_LAYER_16 },
86 { "MID17", ALTIUM_LAYER::MID_LAYER_17 },
87 { "MID18", ALTIUM_LAYER::MID_LAYER_18 },
88 { "MID19", ALTIUM_LAYER::MID_LAYER_19 },
89 { "MID20", ALTIUM_LAYER::MID_LAYER_20 },
90 { "MID21", ALTIUM_LAYER::MID_LAYER_21 },
91 { "MID22", ALTIUM_LAYER::MID_LAYER_22 },
92 { "MID23", ALTIUM_LAYER::MID_LAYER_23 },
93 { "MID24", ALTIUM_LAYER::MID_LAYER_24 },
94 { "MID25", ALTIUM_LAYER::MID_LAYER_25 },
95 { "MID26", ALTIUM_LAYER::MID_LAYER_26 },
96 { "MID27", ALTIUM_LAYER::MID_LAYER_27 },
97 { "MID28", ALTIUM_LAYER::MID_LAYER_28 },
98 { "MID29", ALTIUM_LAYER::MID_LAYER_29 },
99 { "MID30", ALTIUM_LAYER::MID_LAYER_30 },
100 { "BOTTOM", ALTIUM_LAYER::BOTTOM_LAYER },
101
102 { "TOPOVERLAY", ALTIUM_LAYER::TOP_OVERLAY },
103 { "BOTTOMOVERLAY", ALTIUM_LAYER::BOTTOM_OVERLAY },
104 { "TOPPASTE", ALTIUM_LAYER::TOP_PASTE },
105 { "BOTTOMPASTE", ALTIUM_LAYER::BOTTOM_PASTE },
106 { "TOPSOLDER", ALTIUM_LAYER::TOP_SOLDER },
107 { "BOTTOMSOLDER", ALTIUM_LAYER::BOTTOM_SOLDER },
108
109 { "PLANE1", ALTIUM_LAYER::INTERNAL_PLANE_1 },
110 { "PLANE2", ALTIUM_LAYER::INTERNAL_PLANE_2 },
111 { "PLANE3", ALTIUM_LAYER::INTERNAL_PLANE_3 },
112 { "PLANE4", ALTIUM_LAYER::INTERNAL_PLANE_4 },
113 { "PLANE5", ALTIUM_LAYER::INTERNAL_PLANE_5 },
114 { "PLANE6", ALTIUM_LAYER::INTERNAL_PLANE_6 },
115 { "PLANE7", ALTIUM_LAYER::INTERNAL_PLANE_7 },
116 { "PLANE8", ALTIUM_LAYER::INTERNAL_PLANE_8 },
117 { "PLANE9", ALTIUM_LAYER::INTERNAL_PLANE_9 },
118 { "PLANE10", ALTIUM_LAYER::INTERNAL_PLANE_10 },
119 { "PLANE11", ALTIUM_LAYER::INTERNAL_PLANE_11 },
120 { "PLANE12", ALTIUM_LAYER::INTERNAL_PLANE_12 },
121 { "PLANE13", ALTIUM_LAYER::INTERNAL_PLANE_13 },
122 { "PLANE14", ALTIUM_LAYER::INTERNAL_PLANE_14 },
123 { "PLANE15", ALTIUM_LAYER::INTERNAL_PLANE_15 },
124 { "PLANE16", ALTIUM_LAYER::INTERNAL_PLANE_16 },
125
126 { "DRILLGUIDE", ALTIUM_LAYER::DRILL_GUIDE },
127 { "KEEPOUT", ALTIUM_LAYER::KEEP_OUT_LAYER },
128
129 { "MECHANICAL1", ALTIUM_LAYER::MECHANICAL_1 },
130 { "MECHANICAL2", ALTIUM_LAYER::MECHANICAL_2 },
131 { "MECHANICAL3", ALTIUM_LAYER::MECHANICAL_3 },
132 { "MECHANICAL4", ALTIUM_LAYER::MECHANICAL_4 },
133 { "MECHANICAL5", ALTIUM_LAYER::MECHANICAL_5 },
134 { "MECHANICAL6", ALTIUM_LAYER::MECHANICAL_6 },
135 { "MECHANICAL7", ALTIUM_LAYER::MECHANICAL_7 },
136 { "MECHANICAL8", ALTIUM_LAYER::MECHANICAL_8 },
137 { "MECHANICAL9", ALTIUM_LAYER::MECHANICAL_9 },
138 { "MECHANICAL10", ALTIUM_LAYER::MECHANICAL_10 },
139 { "MECHANICAL11", ALTIUM_LAYER::MECHANICAL_11 },
140 { "MECHANICAL12", ALTIUM_LAYER::MECHANICAL_12 },
141 { "MECHANICAL13", ALTIUM_LAYER::MECHANICAL_13 },
142 { "MECHANICAL14", ALTIUM_LAYER::MECHANICAL_14 },
143 { "MECHANICAL15", ALTIUM_LAYER::MECHANICAL_15 },
144 { "MECHANICAL16", ALTIUM_LAYER::MECHANICAL_16 },
145
146 { "DRILLDRAWING", ALTIUM_LAYER::DRILL_DRAWING },
147 { "MULTILAYER", ALTIUM_LAYER::MULTI_LAYER },
148
149 // FIXME: the following mapping is just a guess
150 { "CONNECTIONS", ALTIUM_LAYER::CONNECTIONS },
151 { "BACKGROUND", ALTIUM_LAYER::BACKGROUND },
152 { "DRCERRORMARKERS", ALTIUM_LAYER::DRC_ERROR_MARKERS },
153 { "SELECTIONS", ALTIUM_LAYER::SELECTIONS },
154 { "VISIBLEGRID1", ALTIUM_LAYER::VISIBLE_GRID_1 },
155 { "VISIBLEGRID2", ALTIUM_LAYER::VISIBLE_GRID_2 },
156 { "PADHOLES", ALTIUM_LAYER::PAD_HOLES },
157 { "VIAHOLES", ALTIUM_LAYER::VIA_HOLES },
158 };
159
160 auto it = hash_map.find( std::string( aName.c_str() ) );
161
162 if( it != hash_map.end() )
163 return it->second;
164
165 // Try V7 format mechanical layers
166 const wxString mechanicalStr( "MECHANICAL" );
167
168 if( aName.StartsWith( mechanicalStr ) )
169 {
170 unsigned long val = 0;
171
172 if( aName.Mid( mechanicalStr.length() ).ToULong( &val ) )
173 return static_cast<ALTIUM_LAYER>( static_cast<int>( ALTIUM_LAYER::V7_MECHANICAL_BASE ) + val );
174 }
175
176 wxLogError( _( "Unknown mapping of the Altium layer '%s'." ), aName );
178}
179
180
182{
183 static const std::unordered_map<std::string, ALTIUM_MECHKIND> hash_map = {
184 { "AssemblyTop", ALTIUM_MECHKIND::ASSEMBLY_TOP },
185 { "AssemblyBottom", ALTIUM_MECHKIND::ASSEMBLY_BOT },
186
187 { "AssemblyNotes", ALTIUM_MECHKIND::ASSEMBLY_NOTES },
188 { "Board", ALTIUM_MECHKIND::BOARD },
189
190 { "CoatingTop", ALTIUM_MECHKIND::COATING_TOP },
191 { "CoatingBottom", ALTIUM_MECHKIND::COATING_BOT },
192
193 { "ComponentCenterTop", ALTIUM_MECHKIND::COMPONENT_CENTER_TOP },
194 { "ComponentCenterBottom", ALTIUM_MECHKIND::COMPONENT_CENTER_BOT },
195
196 { "ComponentOutlineTop", ALTIUM_MECHKIND::COMPONENT_OUTLINE_TOP },
197 { "ComponentOutlineBottom", ALTIUM_MECHKIND::COMPONENT_OUTLINE_BOT },
198
199 { "CourtyardTop", ALTIUM_MECHKIND::COURTYARD_TOP },
200 { "CourtyardBottom", ALTIUM_MECHKIND::COURTYARD_BOT },
201
202 { "DesignatorTop", ALTIUM_MECHKIND::DESIGNATOR_TOP },
203 { "DesignatorBottom", ALTIUM_MECHKIND::DESIGNATOR_BOT },
204
205 { "Dimensions", ALTIUM_MECHKIND::DIMENSIONS },
206 { "DimensionsTop", ALTIUM_MECHKIND::DIMENSIONS_TOP },
207 { "DimensionsBottom", ALTIUM_MECHKIND::DIMENSIONS_BOT },
208
209 { "FabNotes", ALTIUM_MECHKIND::FAB_NOTES },
210
211 { "GluePointsTop", ALTIUM_MECHKIND::GLUE_POINTS_TOP },
212 { "GluePointsBottom", ALTIUM_MECHKIND::GLUE_POINTS_BOT },
213
214 { "GoldPlatingTop", ALTIUM_MECHKIND::GOLD_PLATING_TOP },
215 { "GoldPlatingBottom", ALTIUM_MECHKIND::GOLD_PLATING_BOT },
216
217 { "ValueTop", ALTIUM_MECHKIND::VALUE_TOP },
218 { "ValueBottom", ALTIUM_MECHKIND::VALUE_BOT },
219
220 { "VCut", ALTIUM_MECHKIND::V_CUT },
221
222 { "3DBodyTop", ALTIUM_MECHKIND::BODY_3D_TOP },
223 { "3DBodyBottom", ALTIUM_MECHKIND::BODY_3D_BOT },
224
225 { "RouteToolPath", ALTIUM_MECHKIND::ROUTE_TOOL_PATH },
226 { "Sheet", ALTIUM_MECHKIND::SHEET },
227 { "BoardShape", ALTIUM_MECHKIND::BOARD_SHAPE },
228 };
229
230 auto it = hash_map.find( std::string( aName.c_str() ) );
231
232 if( it != hash_map.end() )
233 {
234 return it->second;
235 }
236 else
237 {
238 wxLogError( _( "Unknown mapping of the Altium layer kind '%s'." ), aName );
240 }
241}
242
243
244void altium_parse_polygons( std::map<wxString, wxString>& aProps,
245 std::vector<ALTIUM_VERTICE>& aVertices )
246{
247 for( size_t i = 0; i < std::numeric_limits<size_t>::max(); i++ )
248 {
249 const wxString si = std::to_string( i );
250
251 const wxString vxi = wxT( "VX" ) + si;
252 const wxString vyi = wxT( "VY" ) + si;
253
254 if( aProps.find( vxi ) == aProps.end() || aProps.find( vyi ) == aProps.end() )
255 break; // it doesn't seem like we know beforehand how many vertices are inside a polygon
256
257 const bool isRound = ALTIUM_PROPS_UTILS::ReadInt( aProps, wxT( "KIND" ) + si, 0 ) != 0;
258 const int32_t radius = ALTIUM_PROPS_UTILS::ReadKicadUnit( aProps, wxT( "R" ) + si, wxT( "0mil" ) );
259 const double sa = ALTIUM_PROPS_UTILS::ReadDouble( aProps, wxT( "SA" ) + si, 0. );
260 const double ea = ALTIUM_PROPS_UTILS::ReadDouble( aProps, wxT( "EA" ) + si, 0. );
261 const VECTOR2I vp = VECTOR2I( ALTIUM_PROPS_UTILS::ReadKicadUnit( aProps, vxi, wxT( "0mil" ) ),
262 -ALTIUM_PROPS_UTILS::ReadKicadUnit( aProps, vyi, wxT( "0mil" ) ) );
263 const VECTOR2I cp = VECTOR2I( ALTIUM_PROPS_UTILS::ReadKicadUnit( aProps, wxT( "CX" ) + si, wxT( "0mil" ) ),
264 -ALTIUM_PROPS_UTILS::ReadKicadUnit( aProps, wxT( "CY" ) + si, wxT( "0mil" ) ) );
265
266 aVertices.emplace_back( isRound, radius, sa, ea, vp, cp );
267 }
268}
269
270
271static ALTIUM_MODE ReadAltiumModeFromProperties( const std::map<wxString, wxString>& aProps,
272 wxString aKey )
273{
274 wxString mode = ALTIUM_PROPS_UTILS::ReadString( aProps, aKey, wxT( "" ) );
275
276 if( mode == wxT( "None" ) )
277 return ALTIUM_MODE::NONE;
278 else if( mode == wxT( "Rule" ) )
279 return ALTIUM_MODE::RULE;
280 else if( mode == wxT( "Manual" ) )
281 return ALTIUM_MODE::MANUAL;
282
283 wxLogError( _( "Unknown Mode string: '%s'." ), mode );
285}
286
287
288static ALTIUM_RECORD ReadAltiumRecordFromProperties( const std::map<wxString, wxString>& aProps,
289 wxString aKey )
290{
291 wxString record = ALTIUM_PROPS_UTILS::ReadString( aProps, aKey, wxT( "" ) );
292
293 if( record == wxT( "Arc" ) )
294 return ALTIUM_RECORD::ARC;
295 else if( record == wxT( "Pad" ) )
296 return ALTIUM_RECORD::PAD;
297 else if( record == wxT( "Via" ) )
298 return ALTIUM_RECORD::VIA;
299 else if( record == wxT( "Track" ) )
301 else if( record == wxT( "Text" ) )
302 return ALTIUM_RECORD::TEXT;
303 else if( record == wxT( "Fill" ) )
304 return ALTIUM_RECORD::FILL;
305 else if( record == wxT( "Region" ) ) // correct?
307 else if( record == wxT( "Model" ) )
309
310 wxLogError( _( "Unknown Record name string: '%s'." ), record );
312}
313
314
317 const std::map<wxString, wxString>& aProps, wxString aKey )
318{
319 wxString parsedType = ALTIUM_PROPS_UTILS::ReadString( aProps, aKey, wxT( "" ) );
320
321 if( parsedType == wxT( "Mask" ) )
323
324 wxLogError( _( "Unknown Extended Primitive Information type: '%s'." ), parsedType );
326}
327
328
337static void ExpectSubrecordLengthAtLeast( const std::string& aStreamType,
338 const std::string& aSubrecordName, size_t aExpectedLength,
339 size_t aActualLength )
340{
341 if( aActualLength < aExpectedLength )
342 {
343 THROW_IO_ERROR( wxString::Format( "%s stream %s has length %d, "
344 "which is unexpected (expected at least %d)",
345 aStreamType, aSubrecordName, aActualLength,
346 aExpectedLength ) );
347 }
348}
349
350
352{
353 const std::map<wxString, wxString> props = aReader.ReadProperties();
354
355 if( props.empty() )
356 THROW_IO_ERROR( wxT( "ExtendedPrimitiveInformation stream has no properties!" ) );
357
358 primitiveIndex = ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "PRIMITIVEINDEX" ), -1 );
359 primitiveObjectId = ReadAltiumRecordFromProperties( props, wxT( "PRIMITIVEOBJECTID" ) );
361
362 pastemaskexpansionmode = ReadAltiumModeFromProperties( props, wxT( "PASTEMASKEXPANSIONMODE" ) );
364 props, wxT( "PASTEMASKEXPANSION_MANUAL" ), wxT( "0mil" ) );
366 ReadAltiumModeFromProperties( props, wxT( "SOLDERMASKEXPANSIONMODE" ) );
368 props, wxT( "SOLDERMASKEXPANSION_MANUAL" ), wxT( "0mil" ) );
369}
370
371
372ABOARD6_LAYER_STACKUP::ABOARD6_LAYER_STACKUP( const std::map<wxString, wxString>& aProps, const wxString& aPrefix,
373 uint32_t aLayerIdFallback )
374{
375 // LAYERID is specific to V7 format
376 layerId = ALTIUM_PROPS_UTILS::ReadInt( aProps, aPrefix + wxT( "LAYERID" ), aLayerIdFallback );
377
378 name = ALTIUM_PROPS_UTILS::ReadString( aProps, aPrefix + wxT( "NAME" ), wxT( "" ) );
379 nextId = ALTIUM_PROPS_UTILS::ReadInt( aProps, aPrefix + wxT( "NEXT" ), 0 );
380 prevId = ALTIUM_PROPS_UTILS::ReadInt( aProps, aPrefix + wxT( "PREV" ), 0 );
381 copperthick = ALTIUM_PROPS_UTILS::ReadKicadUnit( aProps, aPrefix + wxT( "COPTHICK" ), wxT( "1.4mil" ) );
382
383 dielectricconst = ALTIUM_PROPS_UTILS::ReadDouble( aProps, aPrefix + wxT( "DIELCONST" ), 0. );
384 dielectricthick = ALTIUM_PROPS_UTILS::ReadKicadUnit( aProps, aPrefix + wxT( "DIELHEIGHT" ), wxT( "60mil" ) );
385 dielectricmaterial = ALTIUM_PROPS_UTILS::ReadString( aProps, aPrefix + wxT( "DIELMATERIAL" ), wxT( "FR-4" ) );
386
387 // TODO: In some component libraries MECHENABLED may be FALSE but the layers show up as used.
388 // (we should check if any objects exists on these layers?)
389 wxString mechEnabled = ALTIUM_PROPS_UTILS::ReadString( aProps, aPrefix + wxT( "MECHENABLED" ), wxT( "" ) );
390
391 mechenabled = !mechEnabled.Contains( wxS( "FALSE" ) );
392
393 if( mechenabled )
394 {
395 wxString mechKind = ALTIUM_PROPS_UTILS::ReadString( aProps, aPrefix + wxT( "MECHKIND" ), wxT( "" ) );
396
397 if( !mechKind.IsEmpty() )
399 }
400}
401
402
403static std::vector<ABOARD6_LAYER_STACKUP> ReadAltiumStackupFromProperties( const std::map<wxString, wxString>& aProps )
404{
405 std::vector<ABOARD6_LAYER_STACKUP> stackup;
406
407 for( size_t i = 1; i < std::numeric_limits<size_t>::max(); i++ )
408 {
409 const wxString layeri = wxString( wxT( "LAYER" ) ) << std::to_string( i );
410 const wxString layername = layeri + wxT( "NAME" );
411
412 auto layernameit = aProps.find( layername );
413
414 if( layernameit == aProps.end() )
415 break;
416
417 ABOARD6_LAYER_STACKUP l( aProps, layeri, i );
418 stackup.push_back( l );
419 }
420
421 // V7 format layers
422 for( size_t i = 0; i < std::numeric_limits<size_t>::max(); i++ )
423 {
424 const wxString layeri = wxString( wxT( "LAYERV7_" ) ) << std::to_string( i );
425 const wxString layername = layeri + wxT( "NAME" );
426
427 auto layernameit = aProps.find( layername );
428
429 if( layernameit == aProps.end() )
430 break;
431
432 ABOARD6_LAYER_STACKUP l( aProps, layeri, 0 );
433 stackup.push_back( l );
434 }
435
436 return stackup;
437}
438
439
441{
442 std::map<wxString, wxString> props = aReader.ReadProperties();
443
444 if( props.empty() )
445 THROW_IO_ERROR( wxT( "Library stream has no properties!" ) );
446
447 layercount = ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "LAYERSETSCOUNT" ), 1 ) + 1;
448
450
452 {
453 wxString originalName = l.name;
454
455 // Ensure that layer names are unique in KiCad
456 for( int ii = 2; !layerNames.insert( l.name ).second; ii++ )
457 l.name = wxString::Format( wxT( "%s %d" ), originalName, ii );
458 }
459
460 if( aReader.HasParsingError() )
461 THROW_IO_ERROR( wxT( "Library stream was not parsed correctly!" ) );
462}
463
464
466{
467 std::map<wxString, wxString> props = aReader.ReadProperties();
468
469 if( props.empty() )
470 THROW_IO_ERROR( wxT( "Board6 stream has no properties!" ) );
471
472 sheetpos = VECTOR2I( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "SHEETX" ), wxT( "0mil" ) ),
473 -ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "SHEETY" ), wxT( "0mil" ) ) );
474 sheetsize = wxSize( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "SHEETWIDTH" ), wxT( "0mil" ) ),
475 ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "SHEETHEIGHT" ), wxT( "0mil" ) ) );
476
477 layercount = ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "LAYERSETSCOUNT" ), 1 ) + 1;
478
480
482 {
483 wxString originalName = l.name;
484
485 // Ensure that layer names are unique in KiCad
486 for( int ii = 2; !layerNames.insert( l.name ).second; ii++ )
487 l.name = wxString::Format( wxT( "%s %d" ), originalName, ii );
488 }
489
491
492 if( aReader.HasParsingError() )
493 THROW_IO_ERROR( wxT( "Board6 stream was not parsed correctly!" ) );
494}
495
497{
498 std::map<wxString, wxString> properties = aReader.ReadProperties();
499
500 if( properties.empty() )
501 THROW_IO_ERROR( wxT( "Classes6 stream has no properties!" ) );
502
503 name = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "NAME" ), wxT( "" ) );
504 uniqueid = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "UNIQUEID" ), wxT( "" ) );
505 kind = static_cast<ALTIUM_CLASS_KIND>( ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "KIND" ), -1 ) );
506
507 for( size_t i = 0; i < std::numeric_limits<size_t>::max(); i++ )
508 {
509 auto mit = properties.find( wxT( "M" ) + wxString( std::to_string( i ) ) );
510
511 if( mit == properties.end() )
512 break; // it doesn't seem like we know beforehand how many components are in the netclass
513
514 names.push_back( mit->second );
515 }
516
517 if( aReader.HasParsingError() )
518 THROW_IO_ERROR( wxT( "Classes6 stream was not parsed correctly" ) );
519}
520
522{
523 std::map<wxString, wxString> props = aReader.ReadProperties();
524
525 if( props.empty() )
526 THROW_IO_ERROR( wxT( "Components6 stream has no props" ) );
527
528 layer = altium_layer_from_name( ALTIUM_PROPS_UTILS::ReadString( props, wxT( "LAYER" ), wxT( "" ) ) );
529 position = VECTOR2I( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "X" ), wxT( "0mil" ) ),
530 -ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "Y" ), wxT( "0mil" ) ) );
531 rotation = ALTIUM_PROPS_UTILS::ReadDouble( props, wxT( "ROTATION" ), 0. );
532 locked = ALTIUM_PROPS_UTILS::ReadBool( props, wxT( "LOCKED" ), false );
533 nameon = ALTIUM_PROPS_UTILS::ReadBool( props, wxT( "NAMEON" ), true );
534 commenton = ALTIUM_PROPS_UTILS::ReadBool( props, wxT( "COMMENTON" ), false );
535 sourcedesignator = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "SOURCEDESIGNATOR" ), wxT( "" ) );
536
537 sourceUniqueID = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "SOURCEUNIQUEID" ), wxT( "" ) );
538
539 // Remove leading backslash from sourceUniqueID to match schematic component unique IDs
540 if( sourceUniqueID.starts_with( wxT( "\\" ) ) )
542
543 sourceHierachicalPath = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "SOURCEHIERARCHICALPATH" ), wxT( "" ) );
545 ALTIUM_PROPS_UTILS::ReadUnicodeString( props, wxT( "SOURCEFOOTPRINTLIBRARY" ), wxT( "" ) );
546 pattern = ALTIUM_PROPS_UTILS::ReadUnicodeString( props, wxT( "PATTERN" ), wxT( "" ) );
547
548 sourcecomponentlibrary = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "SOURCECOMPONENTLIBRARY" ), wxT( "" ) );
549 sourcelibreference = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "SOURCELIBREFERENCE" ), wxT( "" ) );
550
552 ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "NAMEAUTOPOSITION" ), 0 ) );
554 ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "COMMENTAUTOPOSITION" ), 0 ) );
555
556 if( aReader.HasParsingError() )
557 THROW_IO_ERROR( wxT( "Components6 stream was not parsed correctly" ) );
558}
559
561{
562 aReader.Skip( 2 );
563
564 std::map<wxString, wxString> props = aReader.ReadProperties();
565
566 if( props.empty() )
567 THROW_IO_ERROR( wxT( "Dimensions6 stream has no props" ) );
568
569 layer_v6 = altium_layer_from_name( ALTIUM_PROPS_UTILS::ReadString( props, wxT( "LAYER" ), wxT( "" ) ) );
570 layer_v7 = altium_layer_from_name( ALTIUM_PROPS_UTILS::ReadString( props, wxT( "LAYER_V7" ), wxT( "" ) ) );
571 kind = static_cast<ALTIUM_DIMENSION_KIND>( ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "DIMENSIONKIND" ), 0 ) );
572
573 textformat = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "TEXTFORMAT" ), wxT( "" ) );
574 textprefix = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "TEXTPREFIX" ), wxT( "" ) );
575 textsuffix = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "TEXTSUFFIX" ), wxT( "" ) );
576
577 height = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "HEIGHT" ), wxT( "0mil" ) );
578 angle = ALTIUM_PROPS_UTILS::ReadDouble( props, wxT( "ANGLE" ), 0. );
579
580 linewidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "LINEWIDTH" ), wxT( "10mil" ) );
581 textheight = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "TEXTHEIGHT" ), wxT( "10mil" ) );
582 textlinewidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "TEXTLINEWIDTH" ), wxT( "6mil" ) );
583 textprecision = ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "TEXTPRECISION" ), 2 );
584 textbold = ALTIUM_PROPS_UTILS::ReadBool( props, wxT( "TEXTLINEWIDTH" ), false );
585 textitalic = ALTIUM_PROPS_UTILS::ReadBool( props, wxT( "ITALIC" ), false );
586 textgap = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "TEXTGAP" ), wxT( "10mil" ) );
587
588 arrowsize = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "ARROWSIZE" ), wxT( "60mil" ) );
589
590 wxString text_position_raw = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "TEXTPOSITION" ), wxT( "" ) );
591
592 xy1 = VECTOR2I( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "X1" ), wxT( "0mil" ) ),
593 -ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "Y1" ), wxT( "0mil" ) ) );
594
595 int refcount = ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "REFERENCES_COUNT" ), 0 );
596
597 for( int i = 0; i < refcount; i++ )
598 {
599 const std::string refi = "REFERENCE" + std::to_string( i ) + "POINT";
600 const wxString ref( refi );
601 referencePoint.emplace_back( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, ref + wxT( "X" ), wxT( "0mil" ) ),
602 -ALTIUM_PROPS_UTILS::ReadKicadUnit( props, ref + wxT( "Y" ), wxT( "0mil" ) ) );
603 }
604
605 for( size_t i = 1; i < std::numeric_limits<size_t>::max(); i++ )
606 {
607 const std::string texti = "TEXT" + std::to_string( i );
608 const std::string textix = texti + "X";
609 const std::string textiy = texti + "Y";
610
611 if( props.find( textix ) == props.end() || props.find( textiy ) == props.end() )
612 break; // it doesn't seem like we know beforehand how many vertices are inside a polygon
613
614 textPoint.emplace_back( ALTIUM_PROPS_UTILS::ReadKicadUnit( props, textix, wxT( "0mil" ) ),
615 -ALTIUM_PROPS_UTILS::ReadKicadUnit( props, textiy, wxT( "0mil" ) ) );
616 }
617
618 wxString dimensionunit = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "TEXTDIMENSIONUNIT" ), wxT( "Millimeters" ) );
619
620 if( dimensionunit == wxT( "Inches" ) ) textunit = ALTIUM_UNIT::INCH;
621 else if( dimensionunit == wxT( "Mils" ) ) textunit = ALTIUM_UNIT::MILS;
622 else if( dimensionunit == wxT( "Millimeters" ) ) textunit = ALTIUM_UNIT::MM;
623 else if( dimensionunit == wxT( "Centimeters" ) ) textunit = ALTIUM_UNIT::CM;
625
627
628 if( aReader.HasParsingError() )
629 THROW_IO_ERROR( wxT( "Dimensions6 stream was not parsed correctly" ) );
630}
631
633{
634 std::map<wxString, wxString> properties = aReader.ReadProperties();
635
636 if( properties.empty() )
637 THROW_IO_ERROR( wxT( "Model stream has no properties!" ) );
638
639 name = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "NAME" ), wxT( "" ) );
640 id = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "ID" ), wxT( "" ) );
641 isEmbedded = ALTIUM_PROPS_UTILS::ReadBool( properties, wxT( "EMBED" ), false );
642
643 rotation.x = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "ROTX" ), 0. );
644 rotation.y = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "ROTY" ), 0. );
645 rotation.z = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "ROTZ" ), 0. );
646
647 z_offset = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "DZ" ), 0. );
648 checksum = ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "CHECKSUM" ), 0 );
649
650 if( aReader.HasParsingError() )
651 THROW_IO_ERROR( wxT( "Model stream was not parsed correctly" ) );
652}
653
655{
656 std::map<wxString, wxString> properties = aReader.ReadProperties();
657
658 if( properties.empty() )
659 THROW_IO_ERROR( wxT( "Nets6 stream has no properties" ) );
660
661 name = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "NAME" ), wxT( "" ) );
662
663 if( aReader.HasParsingError() )
664 THROW_IO_ERROR( wxT( "Nets6 stream was not parsed correctly" ) );
665}
666
668{
669 std::map<wxString, wxString> properties = aReader.ReadProperties();
670
671 if( properties.empty() )
672 THROW_IO_ERROR( wxT( "Polygons6 stream has no properties" ) );
673
674 layer_v6 = altium_layer_from_name( ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "LAYER" ), wxT( "" ) ) );
675 layer_v7 = altium_layer_from_name( ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "LAYER_V7" ), wxT( "" ) ) );
676 net = ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "NET" ), ALTIUM_NET_UNCONNECTED );
677 locked = ALTIUM_PROPS_UTILS::ReadBool( properties, wxT( "LOCKED" ), false );
678
679 // TODO: kind
680
681 gridsize = ALTIUM_PROPS_UTILS::ReadKicadUnit( properties, wxT( "GRIDSIZE" ), wxT( "0mil" ) );
682 trackwidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( properties, wxT( "TRACKWIDTH" ), wxT( "0mil" ) );
683 minprimlength = ALTIUM_PROPS_UTILS::ReadKicadUnit( properties, wxT( "MINPRIMLENGTH" ), wxT( "0mil" ) );
684 useoctagons = ALTIUM_PROPS_UTILS::ReadBool( properties, wxT( "USEOCTAGONS" ), false );
685
686 pourindex = ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "POURINDEX" ), 0 );
687
688 wxString hatchstyleraw = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "HATCHSTYLE" ), wxT( "" ) );
689
690 if( hatchstyleraw == wxT( "Solid" ) ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::SOLID;
691 else if( hatchstyleraw == wxT( "45Degree" ) ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::DEGREE_45;
692 else if( hatchstyleraw == wxT( "90Degree" ) ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::DEGREE_90;
693 else if( hatchstyleraw == wxT( "Horizontal" ) ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::HORIZONTAL;
694 else if( hatchstyleraw == wxT( "Vertical" ) ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::VERTICAL;
695 else if( hatchstyleraw == wxT( "None" ) ) hatchstyle = ALTIUM_POLYGON_HATCHSTYLE::NONE;
697
698 altium_parse_polygons( properties, vertices );
699
701
702 if( aReader.HasParsingError() )
703 THROW_IO_ERROR( wxT( "Polygons6 stream was not parsed correctly" ) );
704}
705
707{
708 aReader.Skip( 2 );
709
710 std::map<wxString, wxString> props = aReader.ReadProperties();
711
712 if( props.empty() )
713 THROW_IO_ERROR( wxT( "Rules6 stream has no props" ) );
714
715 name = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "NAME" ), wxT( "" ) );
716 priority = ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "PRIORITY" ), 1 );
717
718 scope1expr = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "SCOPE1EXPRESSION" ), wxT( "" ) );
719 scope2expr = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "SCOPE2EXPRESSION" ), wxT( "" ) );
720
721 wxString rulekind = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "RULEKIND" ), wxT( "" ) );
722 if( rulekind == wxT( "Clearance" ) )
723 {
725 clearanceGap = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "GAP" ), wxT( "10mil" ) );
726 }
727 else if( rulekind == wxT( "DiffPairsRouting" ) )
728 {
730 }
731 else if( rulekind == wxT( "Height" ) )
732 {
734 }
735 else if( rulekind == wxT( "HoleSize" ) )
736 {
738 minLimit = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MINLIMIT" ), wxT( "1mil" ) );
739 maxLimit = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MAXLIMIT" ), wxT( "150mil" ) );
740 }
741 else if( rulekind == wxT( "HoleToHoleClearance" ) )
742 {
744 clearanceGap = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "GAP" ), wxT( "10mil" ) );
745 }
746 else if( rulekind == wxT( "RoutingVias" ) )
747 {
749 width = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "WIDTH" ), wxT( "20mil" ) );
750 minWidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MINWIDTH" ), wxT( "20mil" ) );
751 maxWidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MAXWIDTH" ), wxT( "50mil" ) );
752 holeWidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "HOLEWIDTH" ), wxT( "10mil" ) );
753 minHoleWidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MINHOLEWIDTH" ), wxT( "10mil" ) );
754 maxHoleWidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MAXHOLEWIDTH" ), wxT( "28mil" ) );
755 }
756 else if( rulekind == wxT( "Width" ) )
757 {
759 minLimit = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MINLIMIT" ), wxT( "6mil" ) );
760 maxLimit = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "MAXLIMIT" ), wxT( "40mil" ) );
761 preferredWidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "PREFERREDWIDTH" ), wxT( "6mil" ) );
762}
763 else if( rulekind == wxT( "PasteMaskExpansion" ) )
764 {
766 pastemaskExpansion = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "EXPANSION" ), wxT( "0" ) );
767 }
768 else if( rulekind == wxT( "SolderMaskExpansion" ) )
769 {
771 soldermaskExpansion = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "EXPANSION" ), wxT( "4mil" ) );
772 }
773 else if( rulekind == wxT( "PlaneClearance" ) )
774 {
776 planeclearanceClearance = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "CLEARANCE" ), wxT( "10mil" ) );
777 }
778 else if( rulekind == wxT( "PolygonConnect" ) )
779 {
781 polygonconnectAirgapwidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "AIRGAPWIDTH" ), wxT( "10mil" ) );
782 polygonconnectReliefconductorwidth = ALTIUM_PROPS_UTILS::ReadKicadUnit( props, wxT( "RELIEFCONDUCTORWIDTH" ), wxT( "10mil" ) );
783 polygonconnectReliefentries = ALTIUM_PROPS_UTILS::ReadInt( props, wxT( "RELIEFENTRIES" ), 4 );
784
785 wxString style = ALTIUM_PROPS_UTILS::ReadString( props, wxT( "CONNECTSTYLE" ), wxT( "" ) );
786
787 if( style == wxT( "Direct" ) ) polygonconnectStyle = ALTIUM_CONNECT_STYLE::DIRECT;
788 else if( style == wxT( "Relief" ) ) polygonconnectStyle = ALTIUM_CONNECT_STYLE::RELIEF;
789 else if( style == wxT( "NoConnect" ) ) polygonconnectStyle = ALTIUM_CONNECT_STYLE::NONE;
791 }
792 else
793 {
795 }
796
797 if( aReader.HasParsingError() )
798 THROW_IO_ERROR( wxT( "Rules6 stream was not parsed correctly" ) );
799}
800
802{
803 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
804 if( recordtype != ALTIUM_RECORD::ARC )
805 {
806 THROW_IO_ERROR( wxT( "Arcs6 stream has invalid recordtype" ) );
807 }
808
809 // Subrecord 1
811
812 layer_v6 = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
813
814 uint8_t flags1 = aReader.Read<uint8_t>();
815 is_locked = ( flags1 & 0x04 ) == 0;
816 is_polygonoutline = ( flags1 & 0x02 ) != 0;
817
818 uint8_t flags2 = aReader.Read<uint8_t>();
819 is_keepout = flags2 == 2;
820
821 net = aReader.Read<uint16_t>();
822 polygon = aReader.Read<uint16_t>();
823 component = aReader.Read<uint16_t>();
824 aReader.Skip( 4 );
825 center = aReader.ReadVector2IPos();
826 radius = aReader.ReadKicadUnit();
827 startangle = aReader.Read<double>();
828 endangle = aReader.Read<double>();
829 width = aReader.ReadKicadUnit();
830 subpolyindex = aReader.Read<uint16_t>();
831
832 int remaining = aReader.GetRemainingSubrecordBytes();
833
834 if( remaining >= 9 )
835 {
836 aReader.Skip( 5 );
837 layer_v7 = static_cast<ALTIUM_LAYER>( aReader.Read<uint32_t>() );
838 }
839
840 if( remaining >= 10 )
841 keepoutrestrictions = aReader.Read<uint8_t>();
842 else
843 keepoutrestrictions = is_keepout ? 0x1F : 0;
844
846
847 aReader.SkipSubrecord();
848
849 if( aReader.HasParsingError() )
850 {
851 THROW_IO_ERROR( wxT( "Arcs6 stream was not parsed correctly" ) );
852 }
853}
854
856{
857 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
858
859 if( recordtype != ALTIUM_RECORD::MODEL )
860 THROW_IO_ERROR( wxT( "ComponentsBodies6 stream has invalid recordtype" ) );
861
863
864 aReader.Skip( 7 );
865 component = aReader.Read<uint16_t>();
866 aReader.Skip( 9 );
867
868 std::map<wxString, wxString> properties = aReader.ReadProperties();
869
870 if( properties.empty() )
871 THROW_IO_ERROR( wxT( "ComponentsBodies6 stream has no properties" ) );
872
873 modelName = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "MODEL.NAME" ), wxT( "" ) );
874 modelId = ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "MODELID" ), wxT( "" ) );
875 modelIsEmbedded = ALTIUM_PROPS_UTILS::ReadBool( properties, wxT( "MODEL.EMBED" ), false );
876
877 modelPosition.x = ALTIUM_PROPS_UTILS::ReadKicadUnit( properties, wxT( "MODEL.2D.X" ), wxT( "0mil" ) );
878 modelPosition.y = -ALTIUM_PROPS_UTILS::ReadKicadUnit( properties, wxT( "MODEL.2D.Y" ), wxT( "0mil" ) );
879 modelPosition.z = ALTIUM_PROPS_UTILS::ReadKicadUnit( properties, wxT( "MODEL.3D.DZ" ), wxT( "0mil" ) );
880
881 modelRotation.x = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "MODEL.3D.ROTX" ), 0. );
882 modelRotation.y = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "MODEL.3D.ROTY" ), 0. );
883 modelRotation.z = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "MODEL.3D.ROTZ" ), 0. );
884
885 rotation = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "MODEL.2D.ROTATION" ), 0. );
886
887 body_opacity_3d = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "BODYOPACITY3D" ), 1. );
888 body_projection = ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "BODYPROJECTION" ), 0 );
889
890 aReader.SkipSubrecord();
891
892 if( aReader.HasParsingError() )
893 THROW_IO_ERROR( wxT( "Components6 stream was not parsed correctly" ) );
894}
895
897{
898 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
899
900 if( recordtype != ALTIUM_RECORD::PAD )
901 THROW_IO_ERROR( wxT( "Pads6 stream has invalid recordtype" ) );
902
903 // Subrecord 1
904 size_t subrecord1 = aReader.ReadAndSetSubrecordLength();
905
906 if( subrecord1 == 0 )
907 THROW_IO_ERROR( wxT( "Pads6 stream has no subrecord1 data" ) );
908
909 name = aReader.ReadWxString();
910
911 if( aReader.GetRemainingSubrecordBytes() != 0 )
912 THROW_IO_ERROR( wxT( "Pads6 stream has invalid subrecord1 length" ) );
913
914 aReader.SkipSubrecord();
915
916 // Subrecord 2
918 aReader.SkipSubrecord();
919
920 // Subrecord 3
922 aReader.SkipSubrecord();
923
924 // Subrecord 4
926 aReader.SkipSubrecord();
927
928 // Subrecord 5
929 size_t subrecord5 = aReader.ReadAndSetSubrecordLength();
930
931 ExpectSubrecordLengthAtLeast( "Pads6", "subrecord5", 110, subrecord5 );
932
933 layer_v6 = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
936
937 uint8_t flags1 = aReader.Read<uint8_t>();
938 is_test_fab_top = ( flags1 & 0x80 ) != 0;
939 is_tent_bottom = ( flags1 & 0x40 ) != 0;
940 is_tent_top = ( flags1 & 0x20 ) != 0;
941 is_locked = ( flags1 & 0x04 ) == 0;
942
943 uint8_t flags2 = aReader.Read<uint8_t>();
944 is_test_fab_bottom = ( flags2 & 0x01 ) != 0;
945
946 net = aReader.Read<uint16_t>();
947 aReader.Skip( 2 );
948 component = aReader.Read<uint16_t>();
949 aReader.Skip( 4 ); // to 13
950
951 position = aReader.ReadVector2IPos();
952 topsize = aReader.ReadVector2ISize();
953 midsize = aReader.ReadVector2ISize();
954 botsize = aReader.ReadVector2ISize();
955 holesize = aReader.ReadKicadUnit(); // to 49
956
957 topshape = static_cast<ALTIUM_PAD_SHAPE>( aReader.Read<uint8_t>() );
958 midshape = static_cast<ALTIUM_PAD_SHAPE>( aReader.Read<uint8_t>() );
959 botshape = static_cast<ALTIUM_PAD_SHAPE>( aReader.Read<uint8_t>() );
960
961 direction = aReader.Read<double>();
962 plated = aReader.Read<uint8_t>() != 0;
963 aReader.Skip( 1 );
964 padmode = static_cast<ALTIUM_PAD_MODE>( aReader.Read<uint8_t>() );
965 aReader.Skip( 23 );
968 aReader.Skip( 7 );
969 pastemaskexpansionmode = static_cast<ALTIUM_MODE>( aReader.Read<uint8_t>() );
970 soldermaskexpansionmode = static_cast<ALTIUM_MODE>( aReader.Read<uint8_t>() );
971 aReader.Skip( 3 ); // to 106
972
975
976 if( subrecord5 == 110 )
977 {
978 // Don't know exactly what this is, but it's always been 0 in the files with 110-byte subrecord5.
979 // e.g. https://gitlab.com/kicad/code/kicad/-/issues/16514
980 const uint32_t unknown = aReader.ReadKicadUnit(); // to 110
981
982 if( unknown != 0 )
983 {
984 THROW_IO_ERROR( wxString::Format( "Pads6 stream subrecord5 + 106 has value %d, which is unexpected",
985 unknown ) );
986 }
987 holerotation = 0;
988 }
989 else
990 {
991 // More than 110, need at least 114
992 ExpectSubrecordLengthAtLeast( "Pads6", "subrecord5", 114, subrecord5 );
993 holerotation = aReader.Read<double>(); // to 114
994 }
995
996 if( subrecord5 >= 120 )
997 {
998 tolayer = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
999 aReader.Skip( 2 );
1000 fromlayer = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
1001 //aReader.skip( 2 );
1002 }
1003 else if( subrecord5 == 171 )
1004 {
1005 }
1006
1007 if( subrecord5 >= 202 )
1008 {
1009 aReader.Skip( 40 );
1010 pad_to_die_length = aReader.ReadKicadUnit();
1011 aReader.Skip( 32 );
1012 pad_to_die_delay = KiROUND( aReader.Read<double>() * 1e18 );
1013 }
1014
1015 aReader.SkipSubrecord();
1016
1017 // Subrecord 6
1018 size_t subrecord6 = aReader.ReadAndSetSubrecordLength();
1019 // Known lengths: 596, 628, 651
1020 // 596 is the number of bytes read in this code-block
1021 if( subrecord6 >= 596 )
1022 {
1023 sizeAndShape = std::make_unique<APAD6_SIZE_AND_SHAPE>();
1024
1025 for( wxSize& size : sizeAndShape->inner_size )
1026 size.x = aReader.ReadKicadUnitX();
1027
1028 for( wxSize& size : sizeAndShape->inner_size )
1029 size.y = aReader.ReadKicadUnitY();
1030
1031 for( ALTIUM_PAD_SHAPE& shape : sizeAndShape->inner_shape )
1032 shape = static_cast<ALTIUM_PAD_SHAPE>( aReader.Read<uint8_t>() );
1033
1034 aReader.Skip( 1 );
1035
1036 sizeAndShape->holeshape = static_cast<ALTIUM_PAD_HOLE_SHAPE>( aReader.Read<uint8_t>() );
1037 sizeAndShape->slotsize = aReader.ReadKicadUnit();
1038 sizeAndShape->slotrotation = aReader.Read<double>();
1039
1040 for( VECTOR2I& pt : sizeAndShape->holeoffset )
1041 pt.x = aReader.ReadKicadUnitX();
1042
1043 for( VECTOR2I& pt : sizeAndShape->holeoffset )
1044 pt.y = aReader.ReadKicadUnitY();
1045
1046 aReader.Skip( 1 );
1047
1048 for( ALTIUM_PAD_SHAPE_ALT& shape : sizeAndShape->alt_shape )
1049 shape = static_cast<ALTIUM_PAD_SHAPE_ALT>( aReader.Read<uint8_t>() );
1050
1051 for( uint8_t& radius : sizeAndShape->cornerradius )
1052 radius = aReader.Read<uint8_t>();
1053 }
1054 else if( subrecord6 != 0 )
1055 {
1056 wxLogError( _( "Pads6 stream has unexpected length for subrecord 6: %d." ), subrecord6 );
1057 }
1058
1060
1061 aReader.SkipSubrecord();
1062
1063 if( aReader.HasParsingError() )
1064 THROW_IO_ERROR( wxT( "Pads6 stream was not parsed correctly" ) );
1065}
1066
1068{
1069 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
1070
1071 if( recordtype != ALTIUM_RECORD::VIA )
1072 THROW_IO_ERROR( wxT( "Vias6 stream has invalid recordtype" ) );
1073
1074 // Subrecord 1
1075 size_t subrecord1 = aReader.ReadAndSetSubrecordLength();
1076
1077 aReader.Skip( 1 );
1078 uint8_t flags1 = aReader.Read<uint8_t>();
1079 is_test_fab_top = ( flags1 & 0x80 ) != 0;
1080 is_tent_bottom = ( flags1 & 0x40 ) != 0;
1081 is_tent_top = ( flags1 & 0x20 ) != 0;
1082 is_locked = ( flags1 & 0x04 ) == 0;
1083
1084 uint8_t flags2 = aReader.Read<uint8_t>();
1085 is_test_fab_bottom = ( flags2 & 0x01 ) != 0;
1086
1087 net = aReader.Read<uint16_t>();
1088 aReader.Skip( 8 );
1089 position = aReader.ReadVector2IPos();
1090 diameter = aReader.ReadKicadUnit();
1091 holesize = aReader.ReadKicadUnit();
1092
1093 layer_start = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
1094 layer_end = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
1095
1096 if( subrecord1 <= 74 )
1097 {
1099 }
1100 else
1101 {
1102 uint8_t temp_byte = aReader.Read<uint8_t>(); // Unknown.
1103
1105 thermal_relief_conductorcount = aReader.Read<uint8_t>();
1106 aReader.Skip( 1 ); // Unknown.
1107
1109
1110 aReader.ReadKicadUnit(); // Unknown. 20mil?
1111 aReader.ReadKicadUnit(); // Unknown. 20mil?
1112
1113 aReader.Skip( 4 );
1115 aReader.Skip( 8 );
1116
1117 temp_byte = aReader.Read<uint8_t>();
1118 soldermask_expansion_manual = temp_byte & 0x02;
1119
1120 aReader.Skip( 7 );
1121
1122 viamode = static_cast<ALTIUM_PAD_MODE>( aReader.Read<uint8_t>() );
1123
1124 for( int ii = 0; ii < 32; ++ii )
1125 {
1126 diameter_by_layer[ii] = aReader.ReadKicadUnit();
1127 }
1128 }
1129
1130 if( subrecord1 >= 246 )
1131 {
1132 aReader.Skip( 38 );
1133 soldermask_expansion_linked = aReader.Read<uint8_t>() & 0x01;
1135 }
1136
1137 if( subrecord1 >= 307 )
1138 {
1139 aReader.Skip( 45 );
1140
1141 pos_tolerance = aReader.ReadKicadUnit();
1142 neg_tolerance = aReader.ReadKicadUnit();
1143 }
1144
1145 aReader.SkipSubrecord();
1146
1147 if( aReader.HasParsingError() )
1148 THROW_IO_ERROR( wxT( "Vias6 stream was not parsed correctly" ) );
1149}
1150
1152{
1153 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
1154
1155 if( recordtype != ALTIUM_RECORD::TRACK )
1156 THROW_IO_ERROR( wxT( "Tracks6 stream has invalid recordtype" ) );
1157
1158 // Subrecord 1
1159 aReader.ReadAndSetSubrecordLength();
1160
1161 layer_v6 = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
1162
1163 uint8_t flags1 = aReader.Read<uint8_t>();
1164 is_locked = ( flags1 & 0x04 ) == 0;
1165 is_polygonoutline = ( flags1 & 0x02 ) != 0;
1166
1167 uint8_t flags2 = aReader.Read<uint8_t>();
1168 is_keepout = flags2 == 2;
1169
1170 net = aReader.Read<uint16_t>();
1171 polygon = aReader.Read<uint16_t>();
1172 component = aReader.Read<uint16_t>();
1173 aReader.Skip( 4 );
1174 start = aReader.ReadVector2IPos();
1175 end = aReader.ReadVector2IPos();
1176 width = aReader.ReadKicadUnit();
1177 subpolyindex = aReader.Read<uint16_t>();
1178 aReader.Skip( 1 );
1179
1180 int remaining = aReader.GetRemainingSubrecordBytes();
1181
1182 if( remaining >= 9 )
1183 {
1184 aReader.Skip( 5 );
1185 layer_v7 = static_cast<ALTIUM_LAYER>( aReader.Read<uint32_t>() );
1186 }
1187
1188 if( remaining >= 10 )
1189 keepoutrestrictions = aReader.Read<uint8_t>();
1190 else
1191 keepoutrestrictions = is_keepout ? 0x1F : 0;
1192
1194
1195 aReader.SkipSubrecord();
1196
1197 if( aReader.HasParsingError() )
1198 THROW_IO_ERROR( wxT( "Tracks6 stream was not parsed correctly" ) );
1199}
1200
1201ATEXT6::ATEXT6( ALTIUM_BINARY_PARSER& aReader, std::map<uint32_t, wxString>& aStringTable )
1202{
1203 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
1204
1205 if( recordtype != ALTIUM_RECORD::TEXT )
1206 THROW_IO_ERROR( wxT( "Texts6 stream has invalid recordtype" ) );
1207
1208 // Subrecord 1 - Properties
1209 size_t subrecord1 = aReader.ReadAndSetSubrecordLength();
1210
1211 layer_v6 = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
1212 aReader.Skip( 6 );
1213 component = aReader.Read<uint16_t>();
1214 aReader.Skip( 4 );
1215 position = aReader.ReadVector2IPos();
1216 height = aReader.ReadKicadUnit();
1217 strokefonttype = static_cast<STROKE_FONT_TYPE>( aReader.Read<uint16_t>() );
1218 // TODO: The Serif font type doesn't match well with KiCad, we should replace it with a better match
1219
1220 rotation = aReader.Read<double>();
1221 isMirrored = aReader.Read<uint8_t>() != 0;
1222 strokewidth = aReader.ReadKicadUnit();
1223
1224 if( subrecord1 < 123 )
1225 {
1227 aReader.SkipSubrecord();
1228 return;
1229 }
1230
1231 isComment = aReader.Read<uint8_t>() != 0;
1232 isDesignator = aReader.Read<uint8_t>() != 0;
1233 aReader.Skip( 1 );
1234 fonttype = static_cast<ALTIUM_TEXT_TYPE>( aReader.Read<uint8_t>() );
1235 isBold = aReader.Read<uint8_t>() != 0;
1236 isItalic = aReader.Read<uint8_t>() != 0;
1237
1238 char fontData[64] = { 0 };
1239 aReader.ReadBytes( fontData, sizeof( fontData ) );
1240 fontname = wxString( fontData, wxMBConvUTF16LE(), sizeof( fontData ) ).BeforeFirst( '\0' );
1241
1242 char tmpbyte = aReader.Read<uint8_t>();
1243 isInverted = !!tmpbyte;
1244 margin_border_width = aReader.ReadKicadUnit(); // "Margin Border"
1245 widestring_index = aReader.Read<uint32_t>();
1246 aReader.Skip( 4 );
1247
1248 // An inverted rect in Altium is like a text box with the text inverted.
1249 isInvertedRect = aReader.Read<uint8_t>() != 0;
1250
1253 textbox_rect_justification = static_cast<ALTIUM_TEXT_POSITION>( aReader.Read<uint8_t>() );
1254 text_offset_width = aReader.ReadKicadUnit(); // "Text Offset"
1255
1256 int remaining = aReader.GetRemainingSubrecordBytes();
1257
1258 if( remaining >= 93 )
1259 {
1260 VECTOR2I unk_vec = aReader.ReadVector2ISize();
1261 wxLogTrace( traceAltiumImport, " Unk vec: %d, %d\n", unk_vec.x, unk_vec.y );
1262
1263 barcode_margin = aReader.ReadVector2ISize();
1264
1265 int32_t unk32 = aReader.ReadKicadUnit();
1266 wxLogTrace( traceAltiumImport, " Unk32: %d\n", unk32 );
1267
1268 barcode_type = static_cast<ALTIUM_BARCODE_TYPE>( aReader.Read<uint8_t>() );
1269 uint8_t unk8 = aReader.Read<uint8_t>();
1270 wxLogTrace( traceAltiumImport, " Unk8: %u\n", unk8 );
1271
1272 barcode_inverted = aReader.Read<uint8_t>() != 0;
1273 fonttype = static_cast<ALTIUM_TEXT_TYPE>( aReader.Read<uint8_t>() );
1274
1275 aReader.ReadBytes( fontData, sizeof( fontData ) );
1276 barcode_fontname = wxString( fontData, wxMBConvUTF16LE(), sizeof( fontData ) ).BeforeFirst( '\0' );
1277
1278 uint8_t unk8_2 = aReader.Read<uint8_t>();
1279 wxLogTrace( traceAltiumImport, " Unk8_2: %u\n", unk8 );
1280
1281 layer_v7 = static_cast<ALTIUM_LAYER>( aReader.Read<uint32_t>() );
1282 }
1283
1284 if( remaining >= 103 )
1285 {
1286 // "Frame" text type flag
1287 isFrame = aReader.Read<uint8_t>() != 0;
1288
1289 // Use "Offset" border value instead of "Margin"
1290 isOffsetBorder = aReader.Read<uint8_t>() != 0;
1291
1292 for( size_t ii = 0; ii < 8; ++ii )
1293 {
1294 uint8_t temp = aReader.Peek<uint8_t>();
1295 uint32_t temp32 = ii < 3 ? ALTIUM_PROPS_UTILS::ConvertToKicadUnit( aReader.Peek<uint32_t>() ) : 0;
1296 wxLogTrace( traceAltiumImport, "3ATEXT6 %zu:\t Byte:%u, Kicad:%u\n", ii, temp, temp32 );
1297 aReader.Skip( 1 );
1298 }
1299 }
1300 else
1301 {
1303 isOffsetBorder = false;
1304 }
1305
1306 if( remaining >= 115 )
1307 {
1308 // textbox_rect_justification will be wrong (5) when this flag is unset,
1309 // in that case, we should always use the left bottom justification.
1310 isJustificationValid = aReader.Read<uint8_t>() != 0;
1311 }
1312 else
1313 {
1314 isJustificationValid = false;
1315 }
1316
1317 aReader.SkipSubrecord();
1318
1319 // Subrecord 2 - Legacy 8bit string, max 255 chars, unknown codepage
1320 aReader.ReadAndSetSubrecordLength();
1321
1322 auto entry = aStringTable.find( widestring_index );
1323
1324 if( entry != aStringTable.end() )
1325 text = entry->second;
1326 else
1327 text = aReader.ReadWxString();
1328
1329 // Normalize Windows line endings
1330 text.Replace( wxT( "\r\n" ), wxT( "\n" ) );
1331
1332 aReader.SkipSubrecord();
1333
1334 // Altium only supports inverting truetype fonts
1336 {
1337 isInverted = false;
1338 isInvertedRect = false;
1339 }
1340
1342
1343 if( aReader.HasParsingError() )
1344 THROW_IO_ERROR( wxT( "Texts6 stream was not parsed correctly" ) );
1345}
1346
1348{
1349 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
1350
1351 if( recordtype != ALTIUM_RECORD::FILL )
1352 THROW_IO_ERROR( wxT( "Fills6 stream has invalid recordtype" ) );
1353
1354 // Subrecord 1
1355 aReader.ReadAndSetSubrecordLength();
1356
1357 layer_v6 = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
1358
1359 uint8_t flags1 = aReader.Read<uint8_t>();
1360 is_locked = ( flags1 & 0x04 ) == 0;
1361
1362 uint8_t flags2 = aReader.Read<uint8_t>();
1363 is_keepout = flags2 == 2;
1364
1365 net = aReader.Read<uint16_t>();
1366 aReader.Skip( 2 );
1367 component = aReader.Read<uint16_t>();
1368 aReader.Skip( 4 );
1369 pos1 = aReader.ReadVector2IPos();
1370 pos2 = aReader.ReadVector2IPos();
1371 rotation = aReader.Read<double>();
1372
1373 int remaining = aReader.GetRemainingSubrecordBytes();
1374
1375 if( remaining >= 9 )
1376 {
1377 aReader.Skip( 5 );
1378 layer_v7 = static_cast<ALTIUM_LAYER>( aReader.Read<uint32_t>() );
1379 }
1380
1381 if( remaining >= 10 )
1382 keepoutrestrictions = aReader.Read<uint8_t>();
1383 else
1384 keepoutrestrictions = is_keepout ? 0x1F : 0;
1385
1387
1388 aReader.SkipSubrecord();
1389
1390 if( aReader.HasParsingError() )
1391 THROW_IO_ERROR( wxT( "Fills6 stream was not parsed correctly" ) );
1392}
1393
1394AREGION6::AREGION6( ALTIUM_BINARY_PARSER& aReader, bool aExtendedVertices )
1395{
1396 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
1397
1398 if( recordtype != ALTIUM_RECORD::REGION )
1399 THROW_IO_ERROR( wxT( "Regions6 stream has invalid recordtype" ) );
1400
1401 // Subrecord 1
1402 aReader.ReadAndSetSubrecordLength();
1403
1404 layer_v6 = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
1405
1406 uint8_t flags1 = aReader.Read<uint8_t>();
1407 is_locked = ( flags1 & 0x04 ) == 0;
1408 is_teardrop = ( flags1 & 0x10 ) != 0;
1409
1410 uint8_t flags2 = aReader.Read<uint8_t>();
1411 is_keepout = flags2 == 2;
1412
1413 net = aReader.Read<uint16_t>();
1414 polygon = aReader.Read<uint16_t>();
1415 component = aReader.Read<uint16_t>();
1416 aReader.Skip( 5 );
1417 holecount = aReader.Read<uint16_t>();
1418 aReader.Skip( 2 );
1419
1420 std::map<wxString, wxString> properties = aReader.ReadProperties();
1421
1422 if( properties.empty() )
1423 THROW_IO_ERROR( wxT( "Regions6 stream has empty properties" ) );
1424
1425 layer_v7 = altium_layer_from_name( ALTIUM_PROPS_UTILS::ReadString( properties, wxT( "V7_LAYER" ), "" ) );
1426
1427 int pkind = ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "KIND" ), 0 );
1428 bool is_cutout = ALTIUM_PROPS_UTILS::ReadBool( properties, wxT( "ISBOARDCUTOUT" ), false );
1429
1430 is_shapebased = ALTIUM_PROPS_UTILS::ReadBool( properties, wxT( "ISSHAPEBASED" ), false );
1431 keepoutrestrictions = static_cast<uint8_t>(
1432 ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "KEEPOUTRESTRIC" ), 0x1F ) );
1433
1434 // TODO: this can differ from the other subpolyindex?!
1435 // Note: "the other subpolyindex" is "polygon"
1436 subpolyindex = static_cast<uint16_t>(
1437 ALTIUM_PROPS_UTILS::ReadInt( properties, "SUBPOLYINDEX", ALTIUM_POLYGON_NONE ) );
1438
1439 switch( pkind )
1440 {
1441 case 0:
1442 if( is_cutout )
1443 {
1445 }
1446 else
1447 {
1449 }
1450
1451 break;
1452
1453 case 1:
1455 break;
1456
1457 case 2:
1459 break;
1460
1461 case 3:
1462 kind = ALTIUM_REGION_KIND::UNKNOWN_3; // TODO: what kind is this?
1463 break;
1464
1465 case 4:
1467 break;
1468
1469 default:
1471 break;
1472 }
1473
1474 uint32_t num_outline_vertices = aReader.Read<uint32_t>();
1475
1476 if( aExtendedVertices )
1477 num_outline_vertices++; // Has a closing vertex
1478
1479 for( uint32_t i = 0; i < num_outline_vertices; i++ )
1480 {
1481 if( aExtendedVertices )
1482 {
1483 bool isRound = aReader.Read<uint8_t>() != 0;
1484 VECTOR2I position = aReader.ReadVector2IPos();
1485 VECTOR2I center = aReader.ReadVector2IPos();
1486 int32_t radius = aReader.ReadKicadUnit();
1487 double angle1 = aReader.Read<double>();
1488 double angle2 = aReader.Read<double>();
1489 outline.emplace_back( isRound, radius, angle1, angle2, position, center );
1490 }
1491 else
1492 {
1493 // For some regions the coordinates are stored as double and not as int32_t
1494 int32_t x = ALTIUM_PROPS_UTILS::ConvertToKicadUnit( aReader.Read<double>() );
1495 int32_t y = ALTIUM_PROPS_UTILS::ConvertToKicadUnit( -aReader.Read<double>() );
1496 outline.emplace_back( VECTOR2I( x, y ) );
1497 }
1498 }
1499
1500 holes.resize( holecount );
1501 for( uint16_t k = 0; k < holecount; k++ )
1502 {
1503 uint32_t num_hole_vertices = aReader.Read<uint32_t>();
1504 holes.at( k ).reserve( num_hole_vertices );
1505
1506 for( uint32_t i = 0; i < num_hole_vertices; i++ )
1507 {
1508 int32_t x = ALTIUM_PROPS_UTILS::ConvertToKicadUnit( aReader.Read<double>() );
1509 int32_t y = ALTIUM_PROPS_UTILS::ConvertToKicadUnit( -aReader.Read<double>() );
1510 holes.at( k ).emplace_back( VECTOR2I( x, y ) );
1511 }
1512 }
1513
1515
1516 aReader.SkipSubrecord();
1517
1518 if( aReader.HasParsingError() )
1519 THROW_IO_ERROR( wxT( "Regions6 stream was not parsed correctly" ) );
1520}
void altium_parse_polygons(std::map< wxString, wxString > &aProps, std::vector< ALTIUM_VERTICE > &aVertices)
ALTIUM_MECHKIND altium_mechkind_from_name(const wxString &aName)
static void ExpectSubrecordLengthAtLeast(const std::string &aStreamType, const std::string &aSubrecordName, size_t aExpectedLength, size_t aActualLength)
Throw an IO_ERROR if the actual length is less than the expected length.
ALTIUM_LAYER altium_layer_from_name(const wxString &aName)
static AEXTENDED_PRIMITIVE_INFORMATION_TYPE ReadAltiumExtendedPrimitiveInformationTypeFromProperties(const std::map< wxString, wxString > &aProps, wxString aKey)
ALTIUM_LAYER altium_versioned_layer(ALTIUM_LAYER aV6Layer, ALTIUM_LAYER aV7Layer)
static ALTIUM_MODE ReadAltiumModeFromProperties(const std::map< wxString, wxString > &aProps, wxString aKey)
static std::vector< ABOARD6_LAYER_STACKUP > ReadAltiumStackupFromProperties(const std::map< wxString, wxString > &aProps)
static ALTIUM_RECORD ReadAltiumRecordFromProperties(const std::map< wxString, wxString > &aProps, wxString aKey)
ALTIUM_PAD_SHAPE_ALT
ALTIUM_TEXT_POSITION
ALTIUM_MECHKIND
ALTIUM_PAD_MODE
ALTIUM_TEXT_TYPE
ALTIUM_PAD_SHAPE
ALTIUM_BARCODE_TYPE
ALTIUM_DIMENSION_KIND
ALTIUM_PAD_HOLE_SHAPE
const uint16_t ALTIUM_NET_UNCONNECTED
ALTIUM_CLASS_KIND
const uint16_t ALTIUM_POLYGON_NONE
AEXTENDED_PRIMITIVE_INFORMATION_TYPE
ALTIUM_RECORD
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
void Skip(size_t aLength)
size_t GetRemainingSubrecordBytes() const
std::map< wxString, wxString > ReadProperties(std::function< std::map< wxString, wxString >(const std::string &)> handleBinaryData=[](const std::string &) { return std::map< wxString, wxString >();})
int ReadBytes(char *aOut, size_t aSize)
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
static int32_t ReadKicadUnit(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static bool ReadBool(const std::map< wxString, wxString > &aProps, const wxString &aKey, bool aDefault)
static wxString ReadUnicodeString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static wxString ReadString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static double ReadDouble(const std::map< wxString, wxString > &aProps, const wxString &aKey, double aDefault)
static int32_t ConvertToKicadUnit(const double aValue)
#define _(s)
static const wxChar * traceAltiumImport
Flag to enable Altium importer logging.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
double startangle
uint16_t component
uint32_t width
ALTIUM_LAYER layer
AARC6(ALTIUM_BINARY_PARSER &aReader)
uint8_t keepoutrestrictions
uint16_t polygon
VECTOR2I center
uint32_t radius
uint16_t net
ALTIUM_LAYER layer_v6
ALTIUM_LAYER layer_v7
bool is_polygonoutline
double endangle
uint16_t subpolyindex
ABOARD6_LAYER_STACKUP(const std::map< wxString, wxString > &aProps, const wxString &aPrefix, uint32_t aLayerIdFallback)
VECTOR2I sheetpos
std::set< wxString > layerNames
ABOARD6(ALTIUM_BINARY_PARSER &aReader)
std::vector< ABOARD6_LAYER_STACKUP > stackup
std::vector< ALTIUM_VERTICE > board_vertices
wxString uniqueid
std::vector< wxString > names
ALTIUM_CLASS_KIND kind
wxString name
ACLASS6(ALTIUM_BINARY_PARSER &aReader)
wxString sourceHierachicalPath
ALTIUM_TEXT_POSITION commentautoposition
ALTIUM_TEXT_POSITION nameautoposition
ACOMPONENT6(ALTIUM_BINARY_PARSER &aReader)
wxString sourcefootprintlibrary
ALTIUM_LAYER layer
wxString sourcelibreference
wxString sourcedesignator
wxString sourceUniqueID
wxString sourcecomponentlibrary
ACOMPONENTBODY6(ALTIUM_BINARY_PARSER &aReader)
ALTIUM_UNIT textunit
uint32_t textlinewidth
ALTIUM_LAYER layer
ALTIUM_LAYER layer_v6
std::vector< VECTOR2I > textPoint
ALTIUM_DIMENSION_KIND kind
ALTIUM_LAYER layer_v7
ADIMENSION6(ALTIUM_BINARY_PARSER &aReader)
std::vector< VECTOR2I > referencePoint
AEXTENDED_PRIMITIVE_INFORMATION_TYPE type
AEXTENDED_PRIMITIVE_INFORMATION(ALTIUM_BINARY_PARSER &aReader)
VECTOR2I pos2
ALTIUM_LAYER layer
uint16_t net
VECTOR2I pos1
double rotation
uint8_t keepoutrestrictions
AFILL6(ALTIUM_BINARY_PARSER &aReader)
ALTIUM_LAYER layer_v6
uint16_t component
ALTIUM_LAYER layer_v7
std::set< wxString > layerNames
std::vector< ABOARD6_LAYER_STACKUP > stackup
ALIBRARY(ALTIUM_BINARY_PARSER &aReader)
double z_offset
int32_t checksum
wxString name
VECTOR3D rotation
AMODEL(ALTIUM_BINARY_PARSER &aReader)
ANET6(ALTIUM_BINARY_PARSER &aReader)
wxString name
double holerotation
int32_t soldermaskexpansionmanual
uint16_t net
ALTIUM_LAYER layer
APAD6(ALTIUM_BINARY_PARSER &aReader)
std::unique_ptr< APAD6_SIZE_AND_SHAPE > sizeAndShape
ALTIUM_LAYER layer_v7
ALTIUM_LAYER tolayer
ALTIUM_PAD_SHAPE topshape
ALTIUM_LAYER layer_v6
ALTIUM_PAD_MODE padmode
ALTIUM_MODE pastemaskexpansionmode
uint32_t holesize
double direction
ALTIUM_MODE soldermaskexpansionmode
wxString name
bool is_test_fab_bottom
int32_t pad_to_die_delay
bool is_tent_bottom
VECTOR2I botsize
ALTIUM_PAD_SHAPE botshape
uint16_t component
VECTOR2I midsize
ALTIUM_PAD_SHAPE midshape
int32_t pastemaskexpansionmanual
ALTIUM_LAYER fromlayer
VECTOR2I position
VECTOR2I topsize
bool is_test_fab_top
int32_t pad_to_die_length
ALTIUM_LAYER layer_v6
int32_t minprimlength
std::vector< ALTIUM_VERTICE > vertices
APOLYGON6(ALTIUM_BINARY_PARSER &aReader)
ALTIUM_LAYER layer_v7
ALTIUM_POLYGON_HATCHSTYLE hatchstyle
ALTIUM_LAYER layer
uint8_t keepoutrestrictions
ALTIUM_LAYER layer
AREGION6(ALTIUM_BINARY_PARSER &aReader, bool aExtendedVertices)
ALTIUM_LAYER layer_v7
uint16_t holecount
ALTIUM_LAYER layer_v6
std::vector< ALTIUM_VERTICE > outline
uint16_t subpolyindex
std::vector< std::vector< ALTIUM_VERTICE > > holes
uint16_t component
uint16_t polygon
ALTIUM_REGION_KIND kind
ALTIUM_RULE_KIND kind
ALTIUM_CONNECT_STYLE polygonconnectStyle
wxString scope1expr
wxString name
int planeclearanceClearance
int32_t polygonconnectReliefconductorwidth
int pastemaskExpansion
wxString scope2expr
int soldermaskExpansion
ARULE6(ALTIUM_BINARY_PARSER &aReader)
int32_t polygonconnectAirgapwidth
int polygonconnectReliefentries
uint32_t text_offset_width
VECTOR2I barcode_margin
uint32_t textbox_rect_height
uint16_t component
ALTIUM_LAYER layer_v6
ALTIUM_TEXT_POSITION textbox_rect_justification
bool isInvertedRect
wxString text
uint32_t widestring_index
uint32_t textbox_rect_width
double rotation
uint32_t margin_border_width
uint32_t height
wxString fontname
bool isJustificationValid
ALTIUM_BARCODE_TYPE barcode_type
ALTIUM_LAYER layer
VECTOR2I position
ALTIUM_LAYER layer_v7
ALTIUM_TEXT_TYPE fonttype
STROKE_FONT_TYPE strokefonttype
wxString barcode_fontname
bool isOffsetBorder
ATEXT6(ALTIUM_BINARY_PARSER &aReader, std::map< uint32_t, wxString > &aStringTable)
bool barcode_inverted
uint32_t strokewidth
ALTIUM_LAYER layer_v6
ATRACK6(ALTIUM_BINARY_PARSER &aReader)
uint32_t width
bool is_polygonoutline
ALTIUM_LAYER layer_v7
uint16_t polygon
uint16_t subpolyindex
uint8_t keepoutrestrictions
VECTOR2I start
ALTIUM_LAYER layer
uint16_t component
bool soldermask_expansion_linked
uint32_t thermal_relief_conductorcount
uint32_t diameter
uint32_t neg_tolerance
uint16_t net
VECTOR2I position
int32_t thermal_relief_airgap
bool is_test_fab_top
int32_t soldermask_expansion_front
uint32_t pos_tolerance
bool is_tent_bottom
bool is_test_fab_bottom
bool soldermask_expansion_manual
ALTIUM_PAD_MODE viamode
AVIA6(ALTIUM_BINARY_PARSER &aReader)
uint32_t thermal_relief_conductorwidth
int32_t soldermask_expansion_back
uint32_t diameter_by_layer[32]
ALTIUM_LAYER layer_start
ALTIUM_LAYER layer_end
uint32_t holesize
VECTOR2I center
int radius
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695