KiCad PCB EDA Suite
Loading...
Searching...
No Matches
diptrace_pcb_parser.cpp File Reference

Parser for DipTrace binary .dip board files. More...

#include <diptrace/diptrace_pcb_parser.h>
#include <board.h>
#include <board_design_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <netclass.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_shape.h>
#include <pcb_text.h>
#include <pcb_track.h>
#include <zone.h>
#include <netinfo.h>
#include <ki_exception.h>
#include <layer_ids.h>
#include <base_units.h>
#include <string_utils.h>
#include <project/net_settings.h>
#include <stroke_params.h>
#include <wx/log.h>
#include <trace_helpers.h>
#include <array>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <tuple>
#include <unordered_set>

Go to the source code of this file.

Functions

static uint32_t ReadColorPacked (BINARY_READER &aReader)
 Read a 3-byte RGB color from the reader and return it packed as 0x00RRGGBB.
 
static int ReadInt3At (const uint8_t *aData, size_t aPos)
 Decode a 3-byte big-endian biased integer from raw data at a given offset.
 
static int ReadInt4At (const uint8_t *aData, size_t aPos)
 Decode a 4-byte big-endian biased integer from raw data at a given offset.
 
static bool FindComponentRotation (const uint8_t *aData, size_t aDataSize, size_t aBoundaryOffset, int &aQuarterTurns)
 Recover a placed component's rotation, expressed in 90-degree quarter turns.
 
static bool EnvFlagEnabled (const char *aVarName)
 
static bool ShouldDumpPadPostBlock (const wxString &aRefdes)
 
static bool ShouldDumpPadGap (const wxString &aRefdes)
 
static bool ShouldDumpComponentHeader (const wxString &aRefdes)
 
static bool ShouldDumpFootprintOrientation (const wxString &aRefdes)
 
static bool ShouldDumpNets ()
 
static bool ShouldDumpZones ()
 
static void DumpComponentHeader (const DT_COMPONENT &aComp, int aFieldA, int aFieldB, int aFieldC, int aFieldD, int aFieldE, int aFieldF, uint8_t aSep1, uint8_t aSep2, uint8_t aSep3)
 
static int32_t ReadRawLE32 (const uint8_t *aData, size_t aPos)
 
static float ReadRawLEFloat32 (const uint8_t *aData, size_t aPos)
 
static wxString BytesToHex (const uint8_t *aData, size_t aLen)
 
static void DumpComponentRawFields (const DT_COMPONENT &aComp, const uint8_t *aData, size_t aPosXPos, size_t aPosYPos, size_t aRotPos, size_t aFieldCPos, size_t aFieldDPos)
 
static bool IsAngleLikeCode (int aValue)
 
static void DumpComponentBinaryScan (const DT_COMPONENT &aComp, const uint8_t *aData, size_t aDataSize)
 
static void DumpPadPostBlock (const DT_COMPONENT &aComp, const DT_PAD &aPad, const uint8_t *aData, size_t aPostDimPos, size_t aPostDimSize)
 
static void DumpPadGap (const DT_COMPONENT &aComp, const uint8_t *aData, size_t aGapStart, size_t aGapEnd)
 
static void DumpComponentTail (const DT_COMPONENT &aComp, const uint8_t *aData, size_t aTailStart, int aVisibility, uint8_t aSideFlag1, uint8_t aSideFlag2, int aOrderIdx, int aRefdesYOffset, int aValueYOffset, uint8_t aHasOffset, uint8_t aTailTerm)
 
static void DumpRulesetBlock (int aRuleSetIndex, const wxString &aRuleSetName, int aBlockIndex, const std::array< int, 26 > &aValues)
 
static void DumpZoneHeader (int aZoneIndex, size_t aHeaderPos, const uint8_t *aData, int aFieldA, int aFlags1, int aFlags2, int aFlags3, int aMinWidth, int aClearance, int aMinimumArea, int aSeparator, int aLayer, int aFieldB, int aVtxCount, const wxString &aNetName)
 
static void DumpZoneGap (int aZoneIndex, size_t aGapStart, size_t aGapEnd, const uint8_t *aData)
 
static void DumpZoneTail (int aZoneIndex, size_t aTailStart, size_t aSearchEnd, const uint8_t *aData)
 
static size_t StringFieldSize (const uint8_t *aData, size_t aDataSize, size_t aPos, int aVersion)
 Compute the total byte length of a DipTrace string field at a given offset without allocating a wxString.
 
static bool decodeMountHoleBlockAt (const uint8_t *aData, size_t aBlockStart, size_t aSearchEnd, std::vector< DT_MOUNT_HOLE > &aHoles)
 

Variables

static const uint8_t BOUNDARY_STD []
 Component boundary pattern: int3(0) int3(-1) int3(-1) int4(0)
 
static const uint8_t BOUNDARY_ALT []
 Alternate boundary pattern: int3(0) int3(0) int3(0) int4(0) – v41 nameplate files.
 
static constexpr size_t BOUNDARY_CORE_LEN = 13
 
static const uint8_t BOARD_SETTINGS_FONT_MARKER []
 Board settings font marker: int3(4), int3(4), int3(0)
 
static const uint8_t TEXT_SECTION_ZEROS []
 Text section zeros: 3x int3(0)
 
static const uint8_t NET_SENTINEL []
 Net record sentinel: int3(0) int3(-1) int3(-1) This 9-byte pattern appears immediately before each net record's index field.
 
static constexpr size_t NET_SENTINEL_LEN = 9
 
static const uint8_t CHAIN_HEADER []
 Track chain header pattern: 3 zero bytes + int3(-1)
 
static constexpr size_t CHAIN_HEADER_LEN = 6
 
static constexpr size_t TRACK_NODE_SIZE = 41
 Track node record size in bytes.
 
static constexpr int ZONE_FONT_PREAMBLE_TAIL = -20000
 Zone section preamble constant: int4(-20000), the last field of the font block.
 
static constexpr size_t NOT_FOUND = std::string::npos
 Sentinel for "not found" in pattern searches.
 
static constexpr int FONT_BLOCK_SHAPE_VERSION = 46
 First version that stores per-component shape data in font (Tahoma) blocks rather than contiguous fixed-size shape records.
 
static const uint8_t TAHOMA_FONT_PATTERN []
 UTF-16BE pattern for the string "Tahoma" as stored in v46+ component font blocks.
 
static constexpr size_t TAHOMA_FONT_PATTERN_LEN = 14
 
static constexpr size_t FONT_BLOCK_HEADER_SIZE = 25
 Size of the fixed metadata header following the font string in each font block.
 
static constexpr size_t FONT_PREAMBLE_LABEL_OFFSET = 163
 v46+ font-shape preamble (between the pad region end and the first font block).
 
static constexpr size_t FONT_PREAMBLE_FIXED_SIZE = 165
 
static constexpr size_t FONT_BLOCK_FIXED_SIZE = 72
 Fixed framing of each v46+ font-shape block, excluding its variable parts: Tahoma(14) + meta(25) + int3 shapeType(3) + trailer(28) + uint16 label count(2) = 72 bytes; the variable parts are 8 bytes per coordinate point and 2 bytes per trailing label char.
 
static constexpr size_t FONT_BLOCK_TRAILER_SIZE = 28
 
static constexpr size_t COMPONENT_TAIL_SIZE = 37
 Size of the fixed-layout component tail found at the end of every component region.
 
static const uint8_t COMPONENT_TAIL_PATTERN []
 The component tail starts with int3(0) + int4(0) + int4(0) = 11 constant bytes.
 
static constexpr size_t COMPONENT_TAIL_PATTERN_LEN = 11
 
static constexpr size_t PAD_PRE_HEADER_SIZE = 14
 Pad record layout constants.
 
static constexpr size_t PAD_DIMENSIONS_SIZE = 16
 
static constexpr size_t PAD_HEADER_PREAMBLE_UTF16 = 74
 Fixed byte preamble between the component header strings and the first pad record.
 
static constexpr size_t PAD_HEADER_PREAMBLE_ASCII = 76
 
static constexpr size_t PAD_POST_DIM_FIXED_SIZE = 36
 
static constexpr size_t PAD_POST_DIM_HEADER = 11
 
static constexpr size_t PAD_POST_DIM_TAIL = 25
 
static constexpr size_t PAD_POLYGON_VERTEX_SIZE = 8
 
static constexpr int PAD_MAX_NET_INDEX = 10000
 Upper bound for a plausible pad net index, used as a chain-walk desync guard.
 
static constexpr int FP_SHAPE_COUNT_OFFSET = 71
 Shape count (int3) is at this offset past the end of the pad region.
 
static constexpr int FP_SHAPE_DATA_OFFSET = 74
 Shape record data starts at this offset past the end of the pad region.
 
static constexpr int FP_SHAPE_RECORD_SIZE_V37 = 62
 Record size for v37 (legacy) format.
 
static constexpr int FP_SHAPE_RECORD_SIZE_V45 = 60
 Record size for v45+ format.
 
static constexpr int FP_CHAIN_SHAPE_COUNT_OFFSET = 69
 v46+ chained-shape block layout used by some footprints (e.g. TO-92 in PCB_6).
 
static constexpr int FP_CHAIN_SHAPE_DATA_OFFSET = 72
 
static constexpr int FP_CHAIN_SHAPE_RECORD_SIZE = 76
 
static constexpr int FP_CHAIN_SHAPE_WIDTH_OFFSET = 37
 
static constexpr int FP_CHAIN_SHAPE_TYPE_OFFSET = 41
 
static constexpr int FP_CHAIN_SHAPE_X1_OFFSET = 44
 
static constexpr int FP_CHAIN_SHAPE_Y1_OFFSET = 48
 
static constexpr int FP_CHAIN_SHAPE_X2_OFFSET = 52
 
static constexpr int FP_CHAIN_SHAPE_Y2_OFFSET = 56
 
static constexpr int FP_CHAIN_SHAPE_X3_OFFSET = 60
 
static constexpr int FP_CHAIN_SHAPE_Y3_OFFSET = 64
 
static constexpr int FP_CHAIN_TYPE_LINE = 2
 
static constexpr int FP_CHAIN_TYPE_ARC = 3
 
static constexpr int FP_CHAIN_MOUNT_HOLE_OFFSET = 44
 
static constexpr int FP_SHAPE_NORM_RANGE = 10000
 Normalized coordinate range used by DipTrace shape records.
 
static constexpr int FP_SHAPE_DEFAULT_WIDTH = -10000
 Sentinel value for "use default line width" in shape width field.
 
static constexpr int DT_FP_LAYER_TOP_SILK = 0
 DipTrace footprint-graphic layer enum (int3 stored 5 bytes ahead of each shape's font block).
 
static constexpr int DT_FP_LAYER_TOP_ASSY = 1
 
static constexpr int DT_FP_LAYER_TOP_MASK = 2
 
static constexpr int DT_FP_LAYER_TOP_PASTE = 3
 
static constexpr int DT_FP_LAYER_TOP_KEEPOUT = 9
 
static constexpr int DT_FP_LAYER_TOP_COURTYARD = 16
 
static constexpr int DT_FP_LAYER_TOP_OUTLINE = 18
 
static constexpr size_t MOUNT_HOLE_HEADER_SIZE = 20
 Hole block header: int3(hole_count + 2) + byte(flag) + 4 * int4(0)
 
static constexpr size_t MOUNT_HOLE_RECORD_SIZE = 18
 Per-hole record: byte + byte + int4(x) + int4(y) + int4(outer_diam) + int4(drill_diam)
 
static constexpr size_t MOUNT_HOLE_TERM_SIZE = 2
 Hole block terminator bytes: 0x00 0x00.
 
static constexpr size_t MOUNT_HOLE_TRAILER_SIZE = 16
 Zero trailer following the hole block in observed v54 files.
 

Detailed Description

Parser for DipTrace binary .dip board files.

Translates the DipTrace binary format into KiCad BOARD objects. Based on reverse-engineered format specification. Tested against DipTrace format versions 37, 39, 41, 45, 46, 49, 54, 58, and 60.

Definition in file diptrace_pcb_parser.cpp.

Function Documentation

◆ BytesToHex()

static wxString BytesToHex ( const uint8_t * aData,
size_t aLen )
static

◆ decodeMountHoleBlockAt()

◆ DumpComponentBinaryScan()

◆ DumpComponentHeader()

◆ DumpComponentRawFields()

static void DumpComponentRawFields ( const DT_COMPONENT & aComp,
const uint8_t * aData,
size_t aPosXPos,
size_t aPosYPos,
size_t aRotPos,
size_t aFieldCPos,
size_t aFieldDPos )
static

◆ DumpComponentTail()

static void DumpComponentTail ( const DT_COMPONENT & aComp,
const uint8_t * aData,
size_t aTailStart,
int aVisibility,
uint8_t aSideFlag1,
uint8_t aSideFlag2,
int aOrderIdx,
int aRefdesYOffset,
int aValueYOffset,
uint8_t aHasOffset,
uint8_t aTailTerm )
static

◆ DumpPadGap()

static void DumpPadGap ( const DT_COMPONENT & aComp,
const uint8_t * aData,
size_t aGapStart,
size_t aGapEnd )
static

◆ DumpPadPostBlock()

◆ DumpRulesetBlock()

static void DumpRulesetBlock ( int aRuleSetIndex,
const wxString & aRuleSetName,
int aBlockIndex,
const std::array< int, 26 > & aValues )
static

Definition at line 657 of file diptrace_pcb_parser.cpp.

References EnvFlagEnabled(), and traceDiptraceIo.

Referenced by DIPTRACE::PCB_PARSER::ParseDesignRules().

◆ DumpZoneGap()

static void DumpZoneGap ( int aZoneIndex,
size_t aGapStart,
size_t aGapEnd,
const uint8_t * aData )
static

◆ DumpZoneHeader()

static void DumpZoneHeader ( int aZoneIndex,
size_t aHeaderPos,
const uint8_t * aData,
int aFieldA,
int aFlags1,
int aFlags2,
int aFlags3,
int aMinWidth,
int aClearance,
int aMinimumArea,
int aSeparator,
int aLayer,
int aFieldB,
int aVtxCount,
const wxString & aNetName )
static

◆ DumpZoneTail()

static void DumpZoneTail ( int aZoneIndex,
size_t aTailStart,
size_t aSearchEnd,
const uint8_t * aData )
static

◆ EnvFlagEnabled()

◆ FindComponentRotation()

static bool FindComponentRotation ( const uint8_t * aData,
size_t aDataSize,
size_t aBoundaryOffset,
int & aQuarterTurns )
static

Recover a placed component's rotation, expressed in 90-degree quarter turns.

DipTrace does not store the rotation inside the component geometry record; pads and footprint shapes are serialized in their canonical (unrotated) frame. The placement angle lives in a small per-component metadata block that precedes the boundary core by a variable distance. The block is anchored by the component Id (a biased int3), recognised here by its structural neighbourhood: a 28-byte zero run (int3(0) x4 followed by int4(0) x4) sits 7 bytes after the Id, and an int3(-1) sentinel sits 3 bytes before it. The rotation quarter-turn count is the biased int3 stored 6 bytes before the Id. The count is cumulative and may exceed three full turns; callers reduce it modulo four.

Returns
true and sets aQuarterTurns when the metadata anchor is found, false otherwise.

Definition at line 247 of file diptrace_pcb_parser.cpp.

References ReadInt3At().

Referenced by DIPTRACE::PCB_PARSER::ParseSingleComponent().

◆ IsAngleLikeCode()

static bool IsAngleLikeCode ( int aValue)
static

Definition at line 489 of file diptrace_pcb_parser.cpp.

References std::abs().

Referenced by DumpComponentBinaryScan().

◆ ReadColorPacked()

static uint32_t ReadColorPacked ( BINARY_READER & aReader)
static

Read a 3-byte RGB color from the reader and return it packed as 0x00RRGGBB.

Definition at line 198 of file diptrace_pcb_parser.cpp.

References DIPTRACE::BINARY_READER::ReadColor().

Referenced by DIPTRACE::PCB_PARSER::FindAndParseTextObjects(), DIPTRACE::PCB_PARSER::ParseLayers(), and DIPTRACE::PCB_PARSER::ParseTextRecords().

◆ ReadInt3At()

◆ ReadInt4At()

◆ ReadRawLE32()

static int32_t ReadRawLE32 ( const uint8_t * aData,
size_t aPos )
static

Definition at line 421 of file diptrace_pcb_parser.cpp.

Referenced by DumpComponentBinaryScan(), and DumpComponentRawFields().

◆ ReadRawLEFloat32()

static float ReadRawLEFloat32 ( const uint8_t * aData,
size_t aPos )
static

Definition at line 431 of file diptrace_pcb_parser.cpp.

Referenced by DumpComponentRawFields().

◆ ShouldDumpComponentHeader()

static bool ShouldDumpComponentHeader ( const wxString & aRefdes)
static

◆ ShouldDumpFootprintOrientation()

static bool ShouldDumpFootprintOrientation ( const wxString & aRefdes)
static

Definition at line 362 of file diptrace_pcb_parser.cpp.

References EnvFlagEnabled(), and filter.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ ShouldDumpNets()

static bool ShouldDumpNets ( )
static

Definition at line 383 of file diptrace_pcb_parser.cpp.

References EnvFlagEnabled().

Referenced by DIPTRACE::PCB_PARSER::FindAndParseNets().

◆ ShouldDumpPadGap()

static bool ShouldDumpPadGap ( const wxString & aRefdes)
static

Definition at line 318 of file diptrace_pcb_parser.cpp.

References EnvFlagEnabled(), and filter.

Referenced by DumpPadGap().

◆ ShouldDumpPadPostBlock()

static bool ShouldDumpPadPostBlock ( const wxString & aRefdes)
static

Definition at line 296 of file diptrace_pcb_parser.cpp.

References EnvFlagEnabled(), and filter.

Referenced by DumpPadPostBlock().

◆ ShouldDumpZones()

static bool ShouldDumpZones ( )
static

◆ StringFieldSize()

static size_t StringFieldSize ( const uint8_t * aData,
size_t aDataSize,
size_t aPos,
int aVersion )
static

Compute the total byte length of a DipTrace string field at a given offset without allocating a wxString.

Returns 0 if the field cannot be read.

Definition at line 781 of file diptrace_pcb_parser.cpp.

References DIPTRACE::LEGACY_STRING_VERSION, DIPTRACE::MAX_STRING_CHARS, and ReadInt3At().

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

Variable Documentation

◆ BOARD_SETTINGS_FONT_MARKER

const uint8_t BOARD_SETTINGS_FONT_MARKER[]
static
Initial value:
= {
0x0F, 0x42, 0x44,
0x0F, 0x42, 0x44,
0x0F, 0x42, 0x40,
}

Board settings font marker: int3(4), int3(4), int3(0)

Definition at line 91 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindAndParseComponents().

◆ BOUNDARY_ALT

const uint8_t BOUNDARY_ALT[]
static
Initial value:
= {
0x0F, 0x42, 0x40,
0x0F, 0x42, 0x40,
0x0F, 0x42, 0x40,
0x3B, 0x9A, 0xCA, 0x00,
}

Alternate boundary pattern: int3(0) int3(0) int3(0) int4(0) – v41 nameplate files.

Definition at line 81 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FieldWalkComponentBoundaries(), and DIPTRACE::PCB_PARSER::FindAndParseComponents().

◆ BOUNDARY_CORE_LEN

size_t BOUNDARY_CORE_LEN = 13
staticconstexpr

◆ BOUNDARY_STD

const uint8_t BOUNDARY_STD[]
static
Initial value:
= {
0x0F, 0x42, 0x40,
0x0F, 0x42, 0x3F,
0x0F, 0x42, 0x3F,
0x3B, 0x9A, 0xCA, 0x00,
}

Component boundary pattern: int3(0) int3(-1) int3(-1) int4(0)

Definition at line 73 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FieldWalkComponentBoundaries(), and DIPTRACE::PCB_PARSER::FindAndParseComponents().

◆ CHAIN_HEADER

const uint8_t CHAIN_HEADER[]
static
Initial value:
= {
0x00, 0x00, 0x00,
0x0F, 0x42, 0x3F,
}

Track chain header pattern: 3 zero bytes + int3(-1)

Definition at line 115 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::ParseNetRouting().

◆ CHAIN_HEADER_LEN

size_t CHAIN_HEADER_LEN = 6
staticconstexpr

Definition at line 120 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::ParseNetRouting().

◆ COMPONENT_TAIL_PATTERN

const uint8_t COMPONENT_TAIL_PATTERN[]
static
Initial value:
= {
0x0F, 0x42, 0x40,
0x3B, 0x9A, 0xCA, 0x00,
0x3B, 0x9A, 0xCA, 0x00,
}

The component tail starts with int3(0) + int4(0) + int4(0) = 11 constant bytes.

Definition at line 167 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::ParseComponentTail().

◆ COMPONENT_TAIL_PATTERN_LEN

size_t COMPONENT_TAIL_PATTERN_LEN = 11
staticconstexpr

Definition at line 173 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::ParseComponentTail().

◆ COMPONENT_TAIL_SIZE

size_t COMPONENT_TAIL_SIZE = 37
staticconstexpr

Size of the fixed-layout component tail found at the end of every component region.

Contains text positioning data (refdes/value Y offsets and visibility flags).

Definition at line 164 of file diptrace_pcb_parser.cpp.

Referenced by DumpComponentTail(), DIPTRACE::PCB_PARSER::FindMountHolesInRegion(), and DIPTRACE::PCB_PARSER::ParseComponentTail().

◆ DT_FP_LAYER_TOP_ASSY

int DT_FP_LAYER_TOP_ASSY = 1
staticconstexpr

Definition at line 2456 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ DT_FP_LAYER_TOP_COURTYARD

int DT_FP_LAYER_TOP_COURTYARD = 16
staticconstexpr

Definition at line 2460 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ DT_FP_LAYER_TOP_KEEPOUT

int DT_FP_LAYER_TOP_KEEPOUT = 9
staticconstexpr

Definition at line 2459 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ DT_FP_LAYER_TOP_MASK

int DT_FP_LAYER_TOP_MASK = 2
staticconstexpr

Definition at line 2457 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ DT_FP_LAYER_TOP_OUTLINE

int DT_FP_LAYER_TOP_OUTLINE = 18
staticconstexpr

Definition at line 2461 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ DT_FP_LAYER_TOP_PASTE

int DT_FP_LAYER_TOP_PASTE = 3
staticconstexpr

Definition at line 2458 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ DT_FP_LAYER_TOP_SILK

int DT_FP_LAYER_TOP_SILK = 0
staticconstexpr

DipTrace footprint-graphic layer enum (int3 stored 5 bytes ahead of each shape's font block).

Definition at line 2455 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ FONT_BLOCK_FIXED_SIZE

size_t FONT_BLOCK_FIXED_SIZE = 72
staticconstexpr

Fixed framing of each v46+ font-shape block, excluding its variable parts: Tahoma(14) + meta(25) + int3 shapeType(3) + trailer(28) + uint16 label count(2) = 72 bytes; the variable parts are 8 bytes per coordinate point and 2 bytes per trailing label char.

Definition at line 159 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindShapesInFontBlocks().

◆ FONT_BLOCK_HEADER_SIZE

size_t FONT_BLOCK_HEADER_SIZE = 25
staticconstexpr

Size of the fixed metadata header following the font string in each font block.

Layout: flag(1) + fontSize(int3) + fontH(int4) + fontW(int4)

  • field_b(int3) + field_c(int3) + lineWidth(int4) + layerIdx(int3) = 25 bytes.

Definition at line 148 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindShapesInFontBlocks().

◆ FONT_BLOCK_SHAPE_VERSION

int FONT_BLOCK_SHAPE_VERSION = 46
staticconstexpr

First version that stores per-component shape data in font (Tahoma) blocks rather than contiguous fixed-size shape records.

Definition at line 133 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindMountHolesInRegion(), and DIPTRACE::PCB_PARSER::FindShapesInRegion().

◆ FONT_BLOCK_TRAILER_SIZE

size_t FONT_BLOCK_TRAILER_SIZE = 28
staticconstexpr

◆ FONT_PREAMBLE_FIXED_SIZE

size_t FONT_PREAMBLE_FIXED_SIZE = 165
staticconstexpr

◆ FONT_PREAMBLE_LABEL_OFFSET

size_t FONT_PREAMBLE_LABEL_OFFSET = 163
staticconstexpr

v46+ font-shape preamble (between the pad region end and the first font block).

The first 163 bytes are fixed; a trailing uint16-counted UTF-16 group label follows, so the first block sits at padRegionEnd + 165 + 2 * (label char count read at padRegionEnd + 163).

Definition at line 153 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindShapesInFontBlocks().

◆ FP_CHAIN_MOUNT_HOLE_OFFSET

int FP_CHAIN_MOUNT_HOLE_OFFSET = 44
staticconstexpr

◆ FP_CHAIN_SHAPE_COUNT_OFFSET

int FP_CHAIN_SHAPE_COUNT_OFFSET = 69
staticconstexpr

v46+ chained-shape block layout used by some footprints (e.g. TO-92 in PCB_6).

Definition at line 2433 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindMountHolesInRegion(), and DIPTRACE::PCB_PARSER::FindShapesInChainedBlocks().

◆ FP_CHAIN_SHAPE_DATA_OFFSET

int FP_CHAIN_SHAPE_DATA_OFFSET = 72
staticconstexpr

◆ FP_CHAIN_SHAPE_RECORD_SIZE

int FP_CHAIN_SHAPE_RECORD_SIZE = 76
staticconstexpr

◆ FP_CHAIN_SHAPE_TYPE_OFFSET

int FP_CHAIN_SHAPE_TYPE_OFFSET = 41
staticconstexpr

◆ FP_CHAIN_SHAPE_WIDTH_OFFSET

int FP_CHAIN_SHAPE_WIDTH_OFFSET = 37
staticconstexpr

◆ FP_CHAIN_SHAPE_X1_OFFSET

int FP_CHAIN_SHAPE_X1_OFFSET = 44
staticconstexpr

◆ FP_CHAIN_SHAPE_X2_OFFSET

int FP_CHAIN_SHAPE_X2_OFFSET = 52
staticconstexpr

◆ FP_CHAIN_SHAPE_X3_OFFSET

int FP_CHAIN_SHAPE_X3_OFFSET = 60
staticconstexpr

◆ FP_CHAIN_SHAPE_Y1_OFFSET

int FP_CHAIN_SHAPE_Y1_OFFSET = 48
staticconstexpr

◆ FP_CHAIN_SHAPE_Y2_OFFSET

int FP_CHAIN_SHAPE_Y2_OFFSET = 56
staticconstexpr

◆ FP_CHAIN_SHAPE_Y3_OFFSET

int FP_CHAIN_SHAPE_Y3_OFFSET = 64
staticconstexpr

◆ FP_CHAIN_TYPE_ARC

int FP_CHAIN_TYPE_ARC = 3
staticconstexpr

◆ FP_CHAIN_TYPE_LINE

int FP_CHAIN_TYPE_LINE = 2
staticconstexpr

◆ FP_SHAPE_COUNT_OFFSET

int FP_SHAPE_COUNT_OFFSET = 71
staticconstexpr

Shape count (int3) is at this offset past the end of the pad region.

Definition at line 2421 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindMountHolesInRegion(), and DIPTRACE::PCB_PARSER::FindShapesInRegion().

◆ FP_SHAPE_DATA_OFFSET

int FP_SHAPE_DATA_OFFSET = 74
staticconstexpr

Shape record data starts at this offset past the end of the pad region.

Definition at line 2424 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindMountHolesInRegion(), and DIPTRACE::PCB_PARSER::FindShapesInRegion().

◆ FP_SHAPE_DEFAULT_WIDTH

int FP_SHAPE_DEFAULT_WIDTH = -10000
staticconstexpr

Sentinel value for "use default line width" in shape width field.

Definition at line 2452 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint().

◆ FP_SHAPE_NORM_RANGE

int FP_SHAPE_NORM_RANGE = 10000
staticconstexpr

Normalized coordinate range used by DipTrace shape records.

Definition at line 2449 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::CreateFootprint(), DIPTRACE::PCB_PARSER::FindShapesInChainedBlocks(), and DIPTRACE::PCB_PARSER::FindShapesInFontBlocks().

◆ FP_SHAPE_RECORD_SIZE_V37

int FP_SHAPE_RECORD_SIZE_V37 = 62
staticconstexpr

Record size for v37 (legacy) format.

Definition at line 2427 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindMountHolesInRegion(), and DIPTRACE::PCB_PARSER::FindShapesInRegion().

◆ FP_SHAPE_RECORD_SIZE_V45

int FP_SHAPE_RECORD_SIZE_V45 = 60
staticconstexpr

Record size for v45+ format.

Definition at line 2430 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindMountHolesInRegion(), and DIPTRACE::PCB_PARSER::FindShapesInRegion().

◆ MOUNT_HOLE_HEADER_SIZE

size_t MOUNT_HOLE_HEADER_SIZE = 20
staticconstexpr

Hole block header: int3(hole_count + 2) + byte(flag) + 4 * int4(0)

Definition at line 2469 of file diptrace_pcb_parser.cpp.

Referenced by decodeMountHoleBlockAt().

◆ MOUNT_HOLE_RECORD_SIZE

size_t MOUNT_HOLE_RECORD_SIZE = 18
staticconstexpr

Per-hole record: byte + byte + int4(x) + int4(y) + int4(outer_diam) + int4(drill_diam)

Definition at line 2472 of file diptrace_pcb_parser.cpp.

Referenced by decodeMountHoleBlockAt().

◆ MOUNT_HOLE_TERM_SIZE

size_t MOUNT_HOLE_TERM_SIZE = 2
staticconstexpr

Hole block terminator bytes: 0x00 0x00.

Definition at line 2475 of file diptrace_pcb_parser.cpp.

Referenced by decodeMountHoleBlockAt().

◆ MOUNT_HOLE_TRAILER_SIZE

size_t MOUNT_HOLE_TRAILER_SIZE = 16
staticconstexpr

Zero trailer following the hole block in observed v54 files.

Definition at line 2478 of file diptrace_pcb_parser.cpp.

Referenced by decodeMountHoleBlockAt().

◆ NET_SENTINEL

const uint8_t NET_SENTINEL[]
static
Initial value:
= {
0x0F, 0x42, 0x40,
0x0F, 0x42, 0x3F,
0x0F, 0x42, 0x3F,
}

Net record sentinel: int3(0) int3(-1) int3(-1) This 9-byte pattern appears immediately before each net record's index field.

Definition at line 106 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindAndParseNets(), and DIPTRACE::PCB_PARSER::ParseNetRouting().

◆ NET_SENTINEL_LEN

size_t NET_SENTINEL_LEN = 9
staticconstexpr

◆ NOT_FOUND

size_t NOT_FOUND = std::string::npos
staticconstexpr

◆ PAD_DIMENSIONS_SIZE

size_t PAD_DIMENSIONS_SIZE = 16
staticconstexpr

Definition at line 177 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_HEADER_PREAMBLE_ASCII

size_t PAD_HEADER_PREAMBLE_ASCII = 76
staticconstexpr

Definition at line 182 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_HEADER_PREAMBLE_UTF16

size_t PAD_HEADER_PREAMBLE_UTF16 = 74
staticconstexpr

Fixed byte preamble between the component header strings and the first pad record.

Verified constant across the corpus per string-format family.

Definition at line 181 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_MAX_NET_INDEX

int PAD_MAX_NET_INDEX = 10000
staticconstexpr

Upper bound for a plausible pad net index, used as a chain-walk desync guard.

DipTrace net indices run 0..netCount-1 (or -1 for unconnected); nets are parsed after components, so this must comfortably exceed the largest board's net count (the reference board has 568) without admitting the multi-million garbage a desynced read would produce.

Definition at line 192 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_POLYGON_VERTEX_SIZE

size_t PAD_POLYGON_VERTEX_SIZE = 8
staticconstexpr

Definition at line 186 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_POST_DIM_FIXED_SIZE

size_t PAD_POST_DIM_FIXED_SIZE = 36
staticconstexpr

Definition at line 183 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_POST_DIM_HEADER

size_t PAD_POST_DIM_HEADER = 11
staticconstexpr

Definition at line 184 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_POST_DIM_TAIL

size_t PAD_POST_DIM_TAIL = 25
staticconstexpr

Definition at line 185 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ PAD_PRE_HEADER_SIZE

size_t PAD_PRE_HEADER_SIZE = 14
staticconstexpr

Pad record layout constants.

Definition at line 176 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindPadsInRegion().

◆ TAHOMA_FONT_PATTERN

const uint8_t TAHOMA_FONT_PATTERN[]
static
Initial value:
= {
0x00, 0x06,
0x00, 0x54, 0x00, 0x61, 0x00, 0x68,
0x00, 0x6F, 0x00, 0x6D, 0x00, 0x61,
}

UTF-16BE pattern for the string "Tahoma" as stored in v46+ component font blocks.

Format: uint16(6) + 6 UTF-16BE code units = 14 bytes total.

Definition at line 137 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindShapesInFontBlocks(), and DIPTRACE::SCH_PARSER::isFontBearingShapeStart().

◆ TAHOMA_FONT_PATTERN_LEN

size_t TAHOMA_FONT_PATTERN_LEN = 14
staticconstexpr

◆ TEXT_SECTION_ZEROS

const uint8_t TEXT_SECTION_ZEROS[]
static
Initial value:
= {
0x0F, 0x42, 0x40,
0x0F, 0x42, 0x40,
0x0F, 0x42, 0x40,
}

Text section zeros: 3x int3(0)

Definition at line 98 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindAndParseTextObjects().

◆ TRACK_NODE_SIZE

size_t TRACK_NODE_SIZE = 41
staticconstexpr

Track node record size in bytes.

Definition at line 123 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::ParseNetRouting().

◆ ZONE_FONT_PREAMBLE_TAIL

int ZONE_FONT_PREAMBLE_TAIL = -20000
staticconstexpr

Zone section preamble constant: int4(-20000), the last field of the font block.

Definition at line 126 of file diptrace_pcb_parser.cpp.

Referenced by DIPTRACE::PCB_PARSER::FindAndParseZones().