KiCad PCB EDA Suite
AREGION6 Struct Reference

#include <altium_parser_pcb.h>

Public Member Functions

 AREGION6 (ALTIUM_PARSER &aReader, bool aExtendedVertices)
 

Public Attributes

bool is_locked
 
bool is_keepout
 
bool is_shapebased
 
ALTIUM_LAYER layer
 
uint16_t net
 
uint16_t component
 
uint16_t subpolyindex
 
uint16_t holecount
 
ALTIUM_REGION_KIND kind
 
std::vector< ALTIUM_VERTICEoutline
 
std::vector< std::vector< ALTIUM_VERTICE > > holes
 

Detailed Description

Definition at line 490 of file altium_parser_pcb.h.

Constructor & Destructor Documentation

◆ AREGION6()

AREGION6::AREGION6 ( ALTIUM_PARSER aReader,
bool  aExtendedVertices 
)
explicit

Definition at line 876 of file altium_parser_pcb.cpp.

877 {
878  ALTIUM_RECORD recordtype = static_cast<ALTIUM_RECORD>( aReader.Read<uint8_t>() );
879 
880  if( recordtype != ALTIUM_RECORD::REGION )
881  THROW_IO_ERROR( "Regions6 stream has invalid recordtype" );
882 
883  // Subrecord 1
884  aReader.ReadAndSetSubrecordLength();
885 
886  layer = static_cast<ALTIUM_LAYER>( aReader.Read<uint8_t>() );
887 
888  uint8_t flags1 = aReader.Read<uint8_t>();
889  is_locked = ( flags1 & 0x04 ) == 0;
890 
891  uint8_t flags2 = aReader.Read<uint8_t>();
892  is_keepout = flags2 == 2;
893 
894  net = aReader.Read<uint16_t>();
895  subpolyindex = aReader.Read<uint16_t>();
896  component = aReader.Read<uint16_t>();
897  aReader.Skip( 5 );
898  holecount = aReader.Read<uint16_t>();
899  aReader.Skip( 2 );
900 
901  std::map<wxString, wxString> properties = aReader.ReadProperties();
902 
903  if( properties.empty() )
904  THROW_IO_ERROR( "Regions6 stream has empty properties" );
905 
906  int pkind = ALTIUM_PARSER::ReadInt( properties, "KIND", 0 );
907  bool is_cutout = ALTIUM_PARSER::ReadBool( properties, "ISBOARDCUTOUT", false );
908 
909  is_shapebased = ALTIUM_PARSER::ReadBool( properties, "ISSHAPEBASED", false );
910 
911  // TODO: this can differ from the other subpolyindex?!
912  //subpolyindex = static_cast<uint16_t>(
913  // ALTIUM_PARSER::ReadInt( properties, "SUBPOLYINDEX", ALTIUM_POLYGON_NONE ) );
914 
915  switch( pkind )
916  {
917  case 0:
918  if( is_cutout )
919  {
921  }
922  else
923  {
925  }
926  break;
927  case 1:
929  break;
930  case 2:
931  kind = ALTIUM_REGION_KIND::UNKNOWN_2; // TODO: what kind is this?
932  break;
933  case 3:
934  kind = ALTIUM_REGION_KIND::UNKNOWN_3; // TODO: what kind is this?
935  break;
936  case 4:
938  break;
939  default:
941  break;
942  }
943 
944  uint32_t num_outline_vertices = aReader.Read<uint32_t>();
945 
946  for( uint32_t i = 0; i < num_outline_vertices; i++ )
947  {
948  if( aExtendedVertices )
949  {
950  bool isRound = aReader.Read<uint8_t>() != 0;
951  wxPoint position = aReader.ReadWxPoint();
952  wxPoint center = aReader.ReadWxPoint();
953  int32_t radius = aReader.ReadKicadUnit();
954  double angle1 = aReader.Read<double>();
955  double angle2 = aReader.Read<double>();
956  outline.emplace_back( isRound, radius, angle1, angle2, position, center );
957  }
958  else
959  {
960  // For some regions the coordinates are stored as double and not as int32_t
961  int32_t x = ALTIUM_PARSER::ConvertToKicadUnit( aReader.Read<double>() );
962  int32_t y = ALTIUM_PARSER::ConvertToKicadUnit( -aReader.Read<double>() );
963  outline.emplace_back( wxPoint( x, y ) );
964  }
965  }
966 
967  // TODO: for now we only support holes in regions where there are stored as double
968  if( !aExtendedVertices )
969  {
970  holes.resize( holecount );
971  for( uint16_t k = 0; k < holecount; k++ )
972  {
973  uint32_t num_hole_vertices = aReader.Read<uint32_t>();
974  holes.at( k ).reserve( num_hole_vertices );
975 
976  for( uint32_t i = 0; i < num_hole_vertices; i++ )
977  {
978  int32_t x = ALTIUM_PARSER::ConvertToKicadUnit( aReader.Read<double>() );
979  int32_t y = ALTIUM_PARSER::ConvertToKicadUnit( -aReader.Read<double>() );
980  holes.at( k ).emplace_back( wxPoint( x, y ) );
981  }
982  }
983  }
984 
985  aReader.SkipSubrecord();
986 
987  if( aReader.HasParsingError() )
988  THROW_IO_ERROR( "Regions6 stream was not parsed correctly" );
989 }
ALTIUM_REGION_KIND kind
ALTIUM_LAYER layer
std::vector< std::vector< ALTIUM_VERTICE > > holes
ALTIUM_RECORD
uint16_t holecount
void Skip(size_t aLength)
uint16_t subpolyindex
uint16_t net
size_t ReadAndSetSubrecordLength()
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
std::map< wxString, wxString > ReadProperties()
wxPoint ReadWxPoint()
static bool ReadBool(const std::map< wxString, wxString > &aProps, const wxString &aKey, bool aDefault)
int32_t ReadKicadUnit()
std::vector< ALTIUM_VERTICE > outline
uint16_t component
void SkipSubrecord()
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
bool HasParsingError()
static int32_t ConvertToKicadUnit(const double aValue)

References BOARD_CUTOUT, CAVITY_DEFINITION, component, ALTIUM_PARSER::ConvertToKicadUnit(), COPPER, ALTIUM_PARSER::HasParsingError(), holecount, holes, is_keepout, is_locked, is_shapebased, kind, layer, net, outline, POLYGON_CUTOUT, ALTIUM_PARSER::Read(), ALTIUM_PARSER::ReadAndSetSubrecordLength(), ALTIUM_PARSER::ReadBool(), ALTIUM_PARSER::ReadInt(), ALTIUM_PARSER::ReadKicadUnit(), ALTIUM_PARSER::ReadProperties(), ALTIUM_PARSER::ReadWxPoint(), REGION, ALTIUM_PARSER::Skip(), ALTIUM_PARSER::SkipSubrecord(), subpolyindex, THROW_IO_ERROR, UNKNOWN, UNKNOWN_2, and UNKNOWN_3.

Member Data Documentation

◆ component

uint16_t AREGION6::component

Definition at line 499 of file altium_parser_pcb.h.

Referenced by AREGION6().

◆ holecount

uint16_t AREGION6::holecount

Definition at line 501 of file altium_parser_pcb.h.

Referenced by AREGION6().

◆ holes

std::vector<std::vector<ALTIUM_VERTICE> > AREGION6::holes

Definition at line 506 of file altium_parser_pcb.h.

Referenced by AREGION6(), and ALTIUM_PCB::ParseRegions6Data().

◆ is_keepout

bool AREGION6::is_keepout

Definition at line 493 of file altium_parser_pcb.h.

Referenced by AREGION6(), and ALTIUM_PCB::ParseShapeBasedRegions6Data().

◆ is_locked

bool AREGION6::is_locked

Definition at line 492 of file altium_parser_pcb.h.

Referenced by AREGION6().

◆ is_shapebased

bool AREGION6::is_shapebased

Definition at line 495 of file altium_parser_pcb.h.

Referenced by AREGION6().

◆ kind

ALTIUM_REGION_KIND AREGION6::kind

Definition at line 503 of file altium_parser_pcb.h.

Referenced by AREGION6(), and ALTIUM_PCB::ParseShapeBasedRegions6Data().

◆ layer

◆ net

uint16_t AREGION6::net

Definition at line 498 of file altium_parser_pcb.h.

Referenced by AREGION6().

◆ outline

std::vector<ALTIUM_VERTICE> AREGION6::outline

◆ subpolyindex

uint16_t AREGION6::subpolyindex

The documentation for this struct was generated from the following files: