KiCad PCB EDA Suite
altium_pcb.cpp File Reference
#include "altium_pcb.h"
#include "altium_parser_pcb.h"
#include "plugins/altium/altium_parser.h"
#include <class_board.h>
#include <class_dimension.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_track.h>
#include <class_edge_mod.h>
#include <class_text_mod.h>
#include <board_stackup_manager/stackup_predefined_prms.h>
#include <compoundfilereader.h>
#include <convert_basic_shapes_to_polygon.h>
#include <project.h>
#include <trigo.h>
#include <utf.h>
#include <wx/docview.h>
#include <wx/mstream.h>
#include <wx/wfstream.h>
#include <wx/zstream.h>

Go to the source code of this file.

Functions

void ParseAltiumPcb (BOARD *aBoard, const wxString &aFileName, const std::map< ALTIUM_PCB_DIR, std::string > &aFileMapping)
 Helper method which opens a Altium Board File and parses it. More...
 
bool IsAltiumLayerCopper (ALTIUM_LAYER aLayer)
 
bool IsAltiumLayerAPlane (ALTIUM_LAYER aLayer)
 

Function Documentation

◆ IsAltiumLayerAPlane()

◆ IsAltiumLayerCopper()

bool IsAltiumLayerCopper ( ALTIUM_LAYER  aLayer)

Definition at line 94 of file altium_pcb.cpp.

References BOTTOM_LAYER, and TOP_LAYER.

Referenced by ALTIUM_PCB::ParsePads6Data().

◆ ParseAltiumPcb()

void ParseAltiumPcb ( BOARD aBoard,
const wxString &  aFileName,
const std::map< ALTIUM_PCB_DIR, std::string > &  aFileMapping 
)

Helper method which opens a Altium Board File and parses it.

Parameters
aBoardboard the pcb should be appended to
aFileNamefile name of board file
aFileMappingmapping how altium stream names are mapped

Definition at line 50 of file altium_pcb.cpp.

52 {
53  // Open file
54  FILE* fp = wxFopen( aFileName, "rb" );
55  if( fp == nullptr )
56  {
57  wxLogError( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
58  return;
59  }
60 
61  fseek( fp, 0, SEEK_END );
62  long len = ftell( fp );
63  if( len < 0 )
64  {
65  fclose( fp );
66  THROW_IO_ERROR( "Reading error, cannot determine length of file" );
67  }
68 
69  std::unique_ptr<unsigned char[]> buffer( new unsigned char[len] );
70  fseek( fp, 0, SEEK_SET );
71 
72  size_t bytesRead = fread( buffer.get(), sizeof( unsigned char ), len, fp );
73  fclose( fp );
74  if( static_cast<size_t>( len ) != bytesRead )
75  {
76  THROW_IO_ERROR( "Reading error" );
77  }
78 
79  try
80  {
81  CFB::CompoundFileReader reader( buffer.get(), bytesRead );
82 
83  // Parse File
84  ALTIUM_PCB pcb( aBoard );
85  pcb.Parse( reader, aFileMapping );
86  }
87  catch( CFB::CFBException& exception )
88  {
89  THROW_IO_ERROR( exception.what() );
90  }
91 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
#define _(s)
Definition: 3d_actions.cpp:33
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), and THROW_IO_ERROR.

Referenced by ALTIUM_CIRCUIT_MAKER_PLUGIN::Load(), ALTIUM_DESIGNER_PLUGIN::Load(), and ALTIUM_CIRCUIT_STUDIO_PLUGIN::Load().