25 #include <unordered_map> 36 static const std::unordered_map<std::string, ALTIUM_LAYER> hash_map = {
128 auto it = hash_map.find( std::string( aName.c_str() ) );
129 if( it == hash_map.end() )
132 "Unknown mapping of the Altium layer '%s'. Please report as issue.", aName ) );
142 std::map<wxString, wxString>& aProperties, std::vector<ALTIUM_VERTICE>& aVertices )
144 for(
size_t i = 0; i < std::numeric_limits<size_t>::max(); i++ )
146 const wxString si = std::to_string( i );
148 const wxString vxi =
"VX" + si;
149 const wxString vyi =
"VY" + si;
151 if( aProperties.find( vxi ) == aProperties.end()
152 || aProperties.find( vyi ) == aProperties.end() )
158 const int32_t radius =
169 aVertices.emplace_back( isRound, radius, sa, ea, vp, cp );
175 std::map<wxString, wxString> properties = aReader.
ReadProperties();
176 if( properties.empty() )
192 for(
size_t i = 1; i < std::numeric_limits<size_t>::max(); i++ )
194 const wxString layeri =
"LAYER" + std::to_string( i );
195 const wxString layername = layeri +
"NAME";
197 auto layernameit = properties.find( layername );
198 if( layernameit == properties.end() )
214 properties, layeri +
"DIELHEIGHT",
"60mil" );
231 std::map<wxString, wxString> properties = aReader.
ReadProperties();
232 if( properties.empty() )
239 kind = static_cast<ALTIUM_CLASS_KIND>(
242 for(
size_t i = 0; i < std::numeric_limits<size_t>::max(); i++ )
244 auto mit = properties.find(
"M" + std::to_string( i ) );
245 if( mit == properties.end() )
249 names.push_back( mit->second );
260 std::map<wxString, wxString> properties = aReader.
ReadProperties();
261 if( properties.empty() )
299 std::map<wxString, wxString> properties = aReader.
ReadProperties();
300 if( properties.empty() )
307 kind = static_cast<ALTIUM_DIMENSION_KIND>(
328 for(
int i = 0; i < refcount; i++ )
330 const std::string refi =
"REFERENCE" + std::to_string( i );
336 for(
size_t i = 1; i < std::numeric_limits<size_t>::max(); i++ )
338 const std::string texti =
"TEXT" + std::to_string( i );
339 const std::string textix = texti +
"X";
340 const std::string textiy = texti +
"Y";
342 if( properties.find( textix ) == properties.end()
343 || properties.find( textiy ) == properties.end() )
353 wxString dimensionunit =
355 if( dimensionunit ==
"Inches" )
359 else if( dimensionunit ==
"Mils" )
363 else if( dimensionunit ==
"Millimeters" )
367 else if( dimensionunit ==
"Centimeters" )
384 std::map<wxString, wxString> properties = aReader.
ReadProperties();
385 if( properties.empty() )
406 std::map<wxString, wxString> properties = aReader.
ReadProperties();
407 if( properties.empty() )
422 std::map<wxString, wxString> properties = aReader.
ReadProperties();
423 if( properties.empty() )
444 if( hatchstyleraw ==
"Solid" )
448 else if( hatchstyleraw ==
"45Degree" )
452 else if( hatchstyleraw ==
"90Degree" )
456 else if( hatchstyleraw ==
"Horizontal" )
460 else if( hatchstyleraw ==
"Vertical" )
464 else if( hatchstyleraw ==
"None" )
493 std::map<wxString, wxString> properties = aReader.
ReadProperties();
494 if( properties.empty() )
506 if( rulekind ==
"Clearance" )
511 else if( rulekind ==
"DiffPairsRouting" )
515 else if( rulekind ==
"Height" )
519 else if( rulekind ==
"HoleSize" )
523 else if( rulekind ==
"HoleToHoleClearance" )
527 else if( rulekind ==
"Width" )
531 else if( rulekind ==
"PasteMaskExpansion" )
535 else if( rulekind ==
"PlaneClearance" )
541 else if( rulekind ==
"PolygonConnect" )
547 properties,
"RELIEFCONDUCTORWIDTH",
"10mil" );
553 if( style ==
"Direct" )
555 else if( style ==
"Relief" )
557 else if( style ==
"NoConnect" )
575 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
584 layer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
586 uint8_t flags1 = aReader.
Read<uint8_t>();
590 uint8_t flags2 = aReader.
Read<uint8_t>();
593 net = aReader.
Read<uint16_t>();
613 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
616 THROW_IO_ERROR(
"ComponentsBodies6 stream has invalid recordtype" );
625 std::map<wxString, wxString> properties = aReader.
ReadProperties();
626 if( properties.empty() )
657 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
665 if( subrecord1 == 0 )
690 if( subrecord5 < 114 )
691 THROW_IO_ERROR(
"Pads6 stream subrecord has length < 114, which is unexpected" );
693 layer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
697 uint8_t flags1 = aReader.
Read<uint8_t>();
703 uint8_t flags2 = aReader.
Read<uint8_t>();
706 net = aReader.
Read<uint16_t>();
717 topshape = static_cast<ALTIUM_PAD_SHAPE>( aReader.
Read<uint8_t>() );
718 midshape = static_cast<ALTIUM_PAD_SHAPE>( aReader.
Read<uint8_t>() );
719 botshape = static_cast<ALTIUM_PAD_SHAPE>( aReader.
Read<uint8_t>() );
724 padmode = static_cast<ALTIUM_PAD_MODE>( aReader.
Read<uint8_t>() );
734 if( subrecord5 >= 120 )
736 tolayer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
738 fromlayer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
741 else if( subrecord5 == 171 )
751 if( subrecord6 >= 596 )
753 sizeAndShape = std::make_unique<APAD6_SIZE_AND_SHAPE>();
762 shape = static_cast<ALTIUM_PAD_SHAPE>( aReader.
Read<uint8_t>() );
766 sizeAndShape->holeshape = static_cast<ALTIUM_PAD_HOLE_SHAPE>( aReader.
Read<uint8_t>() );
779 shape = static_cast<ALTIUM_PAD_SHAPE_ALT>( aReader.
Read<uint8_t>() );
782 radius = aReader.
Read<uint8_t>();
784 else if( subrecord6 != 0 )
787 "Pads6 stream has unexpected length for subrecord 6: %d", subrecord6 ) );
798 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
809 uint8_t flags1 = aReader.
Read<uint8_t>();
815 uint8_t flags2 = aReader.
Read<uint8_t>();
818 net = aReader.
Read<uint16_t>();
825 layer_end = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
827 if( subrecord1 <= 74 )
834 viamode = static_cast<ALTIUM_PAD_MODE>( aReader.
Read<uint8_t>() );
847 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
856 layer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
858 uint8_t flags1 = aReader.
Read<uint8_t>();
862 uint8_t flags2 = aReader.
Read<uint8_t>();
865 net = aReader.
Read<uint16_t>();
883 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
892 layer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
910 textposition = static_cast<ALTIUM_TEXT_POSITION>( aReader.
Read<uint8_t>() );
915 if( subrecord1 <= 230 )
920 fonttype = static_cast<ALTIUM_TEXT_TYPE>( aReader.
Read<uint8_t>() );
930 text.Replace(
"\r\n",
"\n" );
942 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
951 layer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
953 uint8_t flags1 = aReader.
Read<uint8_t>();
956 uint8_t flags2 = aReader.
Read<uint8_t>();
959 net = aReader.
Read<uint16_t>();
977 ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.
Read<uint8_t>() );
986 layer = static_cast<ALTIUM_LAYER>( aReader.
Read<uint8_t>() );
988 uint8_t flags1 = aReader.
Read<uint8_t>();
991 uint8_t flags2 = aReader.
Read<uint8_t>();
994 net = aReader.
Read<uint16_t>();
1001 std::map<wxString, wxString> properties = aReader.
ReadProperties();
1002 if( properties.empty() )
1045 uint32_t num_outline_vertices = aReader.
Read<uint32_t>();
1047 for( uint32_t i = 0; i < num_outline_vertices; i++ )
1049 if( aExtendedVertices )
1051 bool isRound = aReader.
Read<uint8_t>() != 0;
1055 double angle1 = aReader.
Read<
double>();
1056 double angle2 = aReader.
Read<
double>();
1057 outline.emplace_back( isRound, radius, angle1, angle2, position, center );
1064 outline.emplace_back( wxPoint( x, y ) );
1069 if( !aExtendedVertices )
1072 for( uint16_t k = 0; k <
holecount; k++ )
1074 uint32_t num_hole_vertices = aReader.
Read<uint32_t>();
1075 holes.at( k ).reserve( num_hole_vertices );
1077 for( uint32_t i = 0; i < num_hole_vertices; i++ )
1081 holes.at( k ).emplace_back( wxPoint( x, y ) );
AREGION6(ALTIUM_PARSER &aReader, bool aExtendedVertices)
ADIMENSION6(ALTIUM_PARSER &aReader)
FP_3DMODEL::VECTOR3D modelPosition
int32_t soldermaskexpansionmanual
static int PropertiesReadInt(const std::map< wxString, wxString > &aProperties, const wxString &aKey, int aDefault)
int planeclearanceClearance
ALTIUM_TEXT_POSITION nameautoposition
ALTIUM_PAD_SHAPE topshape
AMODEL(ALTIUM_PARSER &aReader)
ALTIUM_DIMENSION_KIND kind
ARULE6(ALTIUM_PARSER &aReader)
static bool PropertiesReadBool(const std::map< wxString, wxString > &aProperties, const wxString &aKey, bool aDefault)
int32_t polygonconnectAirgapwidth
static int32_t PropertiesReadKicadUnit(const std::map< wxString, wxString > &aProperties, const wxString &aKey, const wxString &aDefault)
std::vector< std::vector< ALTIUM_VERTICE > > holes
static int32_t ConvertToKicadUnit(const double aValue)
wxString sourcedesignator
ALTIUM_PAD_RULE soldermaskexpansionmode
wxString sourcefootprintlibrary
AVIA6(ALTIUM_PARSER &aReader)
FP_3DMODEL::VECTOR3D rotation
wxString sourcelibreference
ATEXT6(ALTIUM_PARSER &aReader)
void Skip(size_t aLength)
ALTIUM_CONNECT_STYLE polygonconnectStyle
wxString dielectricmaterial
std::vector< wxString > names
std::vector< wxPoint > textPoint
size_t GetRemainingSubrecordBytes() const
wxString sourcecomponentlibrary
APAD6(ALTIUM_PARSER &aReader)
size_t ReadAndSetSubrecordLength()
std::map< wxString, wxString > ReadProperties()
ALTIUM_PAD_RULE pastemaskexpansionmode
const uint16_t ALTIUM_NET_UNCONNECTED
static double PropertiesReadDouble(const std::map< wxString, wxString > &aProperties, const wxString &aKey, double aDefault)
ACOMPONENTBODY6(ALTIUM_PARSER &aReader)
ABOARD6(ALTIUM_PARSER &aReader)
FP_3DMODEL::VECTOR3D modelRotation
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
AFILL6(ALTIUM_PARSER &aReader)
ACLASS6(ALTIUM_PARSER &aReader)
ALTIUM_PAD_SHAPE botshape
std::vector< ALTIUM_VERTICE > vertices
ANET6(ALTIUM_PARSER &aReader)
ALTIUM_TEXT_POSITION textposition
ATRACK6(ALTIUM_PARSER &aReader)
std::vector< ALTIUM_VERTICE > outline
int32_t pastemaskexpansionmanual
APOLYGON6(ALTIUM_PARSER &aReader)
std::unique_ptr< APAD6_SIZE_AND_SHAPE > sizeAndShape
std::vector< ALTIUM_VERTICE > board_vertices
ALTIUM_TEXT_POSITION commentautoposition
ALTIUM_PAD_SHAPE midshape
std::vector< wxPoint > referencePoint
std::vector< ABOARD6_LAYER_STACKUP > stackup
ALTIUM_LAYER altium_layer_from_name(const wxString &aName)
ACOMPONENT6(ALTIUM_PARSER &aReader)
static wxString PropertiesReadString(const std::map< wxString, wxString > &aProperties, const wxString &aKey, const wxString &aDefault)
ALTIUM_POLYGON_HATCHSTYLE hatchstyle
#define THROW_IO_ERROR(msg)
ALTIUM_TEXT_TYPE fonttype
AARC6(ALTIUM_PARSER &aReader)
void altium_parse_polygons(std::map< wxString, wxString > &aProperties, std::vector< ALTIUM_VERTICE > &aVertices)
int32_t polygonconnectReliefconductorwidth
int polygonconnectReliefentries