svn ps svn:eol-style native
This commit is contained in:
parent
a3ea4268df
commit
c425aeb350
File diff suppressed because it is too large
Load Diff
|
@ -1,138 +1,138 @@
|
|||
/*************************************************************************/
|
||||
/* Functions to create drill data used to create files and report files */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "common.h"
|
||||
#include "plot_common.h"
|
||||
#include "pcbnew.h"
|
||||
#include "pcbplot.h"
|
||||
#include "macros.h"
|
||||
#include "gendrill.h"
|
||||
|
||||
|
||||
/* Local Functions */
|
||||
/* Compare function used for sorting holes by increasing diameter value
|
||||
* and X value
|
||||
*/
|
||||
static bool CmpHoleDiameterValue( const HOLE_INFO& a, const HOLE_INFO& b )
|
||||
{
|
||||
if ( a.m_Hole_Diameter != b.m_Hole_Diameter )
|
||||
return a.m_Hole_Diameter < b.m_Hole_Diameter;
|
||||
if ( a.m_Hole_Pos_X != b.m_Hole_Pos_X )
|
||||
return a.m_Hole_Pos_X < b.m_Hole_Pos_X;
|
||||
return a.m_Hole_Pos_Y < b.m_Hole_Pos_Y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function BuildHolesList
|
||||
* Create the list of holes and tools for a given board
|
||||
* The list is sorted by incraesin drill values
|
||||
* Only holes from aFirstLayer to aLastLayer copper layers are listed (for vias, because pad holes are always through holes)
|
||||
* @param Pcb : the given board
|
||||
* @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb holes info
|
||||
* @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use
|
||||
* @param aFirstLayer = first layer to consider
|
||||
* @param aLastLayer = last layer to consider
|
||||
*/
|
||||
void Build_Holes_List( BOARD* aPcb,
|
||||
std::vector<HOLE_INFO>& aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer,
|
||||
int aFirstLayer, int aLastLayer )
|
||||
{
|
||||
HOLE_INFO new_hole;
|
||||
int hole_value;
|
||||
|
||||
aHoleListBuffer.clear();
|
||||
aToolListBuffer.clear();
|
||||
|
||||
if( aFirstLayer > aLastLayer )
|
||||
EXCHG( aFirstLayer, aLastLayer );
|
||||
|
||||
/* build hole list for vias */
|
||||
TRACK* track = aPcb->m_Track;
|
||||
for( ; track != NULL; track = track->Next() )
|
||||
{
|
||||
if( track->Type() != TYPEVIA )
|
||||
continue;
|
||||
SEGVIA* via = (SEGVIA*) track;
|
||||
hole_value = via->GetDrillValue();
|
||||
if( hole_value == 0 )
|
||||
continue;
|
||||
new_hole.m_Tool_Reference = -1; // Flag value for Not initialized
|
||||
new_hole.m_Hole_Orient = 0;
|
||||
new_hole.m_Hole_Diameter = hole_value;
|
||||
new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter;
|
||||
new_hole.m_Hole_Shape = 0; // hole shape: round
|
||||
new_hole.m_Hole_Pos_X = via->m_Start.x;
|
||||
new_hole.m_Hole_Pos_Y = via->m_Start.y; // hole position
|
||||
via->ReturnLayerPair( &new_hole.m_Hole_Top_Layer, &new_hole.m_Hole_Bottom_Layer );
|
||||
// ReturnLayerPair return params with m_Hole_Bottom_Layer < m_Hole_Top_Layer
|
||||
if( new_hole.m_Hole_Bottom_Layer > aFirstLayer )
|
||||
continue;
|
||||
if( new_hole.m_Hole_Top_Layer < aLastLayer )
|
||||
continue;
|
||||
aHoleListBuffer.push_back( new_hole );
|
||||
}
|
||||
|
||||
/* build hole list for pads */
|
||||
MODULE* Module = aPcb->m_Modules;
|
||||
for( ; Module != NULL; Module = Module->Next() )
|
||||
{
|
||||
/* Read and analyse pads */
|
||||
D_PAD* pad = Module->m_Pads;
|
||||
for( ; pad != NULL; pad = pad->Next() )
|
||||
{
|
||||
if( pad->m_Drill.x == 0 )
|
||||
continue;
|
||||
new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
|
||||
new_hole.m_Hole_Orient = pad->m_Orient;
|
||||
new_hole.m_Hole_Shape = 0; // hole shape: round
|
||||
new_hole.m_Hole_Diameter = min( pad->m_Drill.x, pad->m_Drill.x );
|
||||
new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter;
|
||||
if( pad->m_DrillShape != PAD_CIRCLE )
|
||||
new_hole.m_Hole_Shape = 1; // oval flag set
|
||||
new_hole.m_Hole_SizeX = pad->m_Drill.x;
|
||||
new_hole.m_Hole_SizeY = pad->m_Drill.y;
|
||||
new_hole.m_Hole_Pos_X = pad->m_Pos.x;
|
||||
new_hole.m_Hole_Pos_Y = pad->m_Pos.y; // hole position
|
||||
new_hole.m_Hole_Bottom_Layer = COPPER_LAYER_N;
|
||||
new_hole.m_Hole_Top_Layer = LAYER_CMP_N; // pad holes are through holes
|
||||
aHoleListBuffer.push_back( new_hole );
|
||||
}
|
||||
}
|
||||
|
||||
// Sort holes per increasing diameter value
|
||||
sort( aHoleListBuffer.begin(), aHoleListBuffer.end(), CmpHoleDiameterValue );
|
||||
|
||||
// build the tool list
|
||||
int LastHole = -1; /* Set to not initialised
|
||||
* (this is a value not used for aHoleListBuffer[ii].m_Hole_Diameter) */
|
||||
DRILL_TOOL new_tool( 0 );
|
||||
unsigned jj;
|
||||
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
|
||||
{
|
||||
if( aHoleListBuffer[ii].m_Hole_Diameter != LastHole )
|
||||
{
|
||||
new_tool.m_Diameter = ( aHoleListBuffer[ii].m_Hole_Diameter );
|
||||
aToolListBuffer.push_back( new_tool );
|
||||
LastHole = new_tool.m_Diameter;
|
||||
}
|
||||
|
||||
jj = aToolListBuffer.size();
|
||||
if( jj == 0 )
|
||||
continue; // Should not occurs
|
||||
|
||||
aHoleListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1)
|
||||
|
||||
aToolListBuffer.back().m_TotalCount++;
|
||||
if( aHoleListBuffer[ii].m_Hole_Shape )
|
||||
aToolListBuffer.back().m_OvalCount++;
|
||||
}
|
||||
}
|
||||
/*************************************************************************/
|
||||
/* Functions to create drill data used to create files and report files */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "fctsys.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "common.h"
|
||||
#include "plot_common.h"
|
||||
#include "pcbnew.h"
|
||||
#include "pcbplot.h"
|
||||
#include "macros.h"
|
||||
#include "gendrill.h"
|
||||
|
||||
|
||||
/* Local Functions */
|
||||
/* Compare function used for sorting holes by increasing diameter value
|
||||
* and X value
|
||||
*/
|
||||
static bool CmpHoleDiameterValue( const HOLE_INFO& a, const HOLE_INFO& b )
|
||||
{
|
||||
if ( a.m_Hole_Diameter != b.m_Hole_Diameter )
|
||||
return a.m_Hole_Diameter < b.m_Hole_Diameter;
|
||||
if ( a.m_Hole_Pos_X != b.m_Hole_Pos_X )
|
||||
return a.m_Hole_Pos_X < b.m_Hole_Pos_X;
|
||||
return a.m_Hole_Pos_Y < b.m_Hole_Pos_Y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function BuildHolesList
|
||||
* Create the list of holes and tools for a given board
|
||||
* The list is sorted by incraesin drill values
|
||||
* Only holes from aFirstLayer to aLastLayer copper layers are listed (for vias, because pad holes are always through holes)
|
||||
* @param Pcb : the given board
|
||||
* @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb holes info
|
||||
* @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use
|
||||
* @param aFirstLayer = first layer to consider
|
||||
* @param aLastLayer = last layer to consider
|
||||
*/
|
||||
void Build_Holes_List( BOARD* aPcb,
|
||||
std::vector<HOLE_INFO>& aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer,
|
||||
int aFirstLayer, int aLastLayer )
|
||||
{
|
||||
HOLE_INFO new_hole;
|
||||
int hole_value;
|
||||
|
||||
aHoleListBuffer.clear();
|
||||
aToolListBuffer.clear();
|
||||
|
||||
if( aFirstLayer > aLastLayer )
|
||||
EXCHG( aFirstLayer, aLastLayer );
|
||||
|
||||
/* build hole list for vias */
|
||||
TRACK* track = aPcb->m_Track;
|
||||
for( ; track != NULL; track = track->Next() )
|
||||
{
|
||||
if( track->Type() != TYPEVIA )
|
||||
continue;
|
||||
SEGVIA* via = (SEGVIA*) track;
|
||||
hole_value = via->GetDrillValue();
|
||||
if( hole_value == 0 )
|
||||
continue;
|
||||
new_hole.m_Tool_Reference = -1; // Flag value for Not initialized
|
||||
new_hole.m_Hole_Orient = 0;
|
||||
new_hole.m_Hole_Diameter = hole_value;
|
||||
new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter;
|
||||
new_hole.m_Hole_Shape = 0; // hole shape: round
|
||||
new_hole.m_Hole_Pos_X = via->m_Start.x;
|
||||
new_hole.m_Hole_Pos_Y = via->m_Start.y; // hole position
|
||||
via->ReturnLayerPair( &new_hole.m_Hole_Top_Layer, &new_hole.m_Hole_Bottom_Layer );
|
||||
// ReturnLayerPair return params with m_Hole_Bottom_Layer < m_Hole_Top_Layer
|
||||
if( new_hole.m_Hole_Bottom_Layer > aFirstLayer )
|
||||
continue;
|
||||
if( new_hole.m_Hole_Top_Layer < aLastLayer )
|
||||
continue;
|
||||
aHoleListBuffer.push_back( new_hole );
|
||||
}
|
||||
|
||||
/* build hole list for pads */
|
||||
MODULE* Module = aPcb->m_Modules;
|
||||
for( ; Module != NULL; Module = Module->Next() )
|
||||
{
|
||||
/* Read and analyse pads */
|
||||
D_PAD* pad = Module->m_Pads;
|
||||
for( ; pad != NULL; pad = pad->Next() )
|
||||
{
|
||||
if( pad->m_Drill.x == 0 )
|
||||
continue;
|
||||
new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
|
||||
new_hole.m_Hole_Orient = pad->m_Orient;
|
||||
new_hole.m_Hole_Shape = 0; // hole shape: round
|
||||
new_hole.m_Hole_Diameter = min( pad->m_Drill.x, pad->m_Drill.x );
|
||||
new_hole.m_Hole_SizeX = new_hole.m_Hole_SizeY = new_hole.m_Hole_Diameter;
|
||||
if( pad->m_DrillShape != PAD_CIRCLE )
|
||||
new_hole.m_Hole_Shape = 1; // oval flag set
|
||||
new_hole.m_Hole_SizeX = pad->m_Drill.x;
|
||||
new_hole.m_Hole_SizeY = pad->m_Drill.y;
|
||||
new_hole.m_Hole_Pos_X = pad->m_Pos.x;
|
||||
new_hole.m_Hole_Pos_Y = pad->m_Pos.y; // hole position
|
||||
new_hole.m_Hole_Bottom_Layer = COPPER_LAYER_N;
|
||||
new_hole.m_Hole_Top_Layer = LAYER_CMP_N; // pad holes are through holes
|
||||
aHoleListBuffer.push_back( new_hole );
|
||||
}
|
||||
}
|
||||
|
||||
// Sort holes per increasing diameter value
|
||||
sort( aHoleListBuffer.begin(), aHoleListBuffer.end(), CmpHoleDiameterValue );
|
||||
|
||||
// build the tool list
|
||||
int LastHole = -1; /* Set to not initialised
|
||||
* (this is a value not used for aHoleListBuffer[ii].m_Hole_Diameter) */
|
||||
DRILL_TOOL new_tool( 0 );
|
||||
unsigned jj;
|
||||
for( unsigned ii = 0; ii < aHoleListBuffer.size(); ii++ )
|
||||
{
|
||||
if( aHoleListBuffer[ii].m_Hole_Diameter != LastHole )
|
||||
{
|
||||
new_tool.m_Diameter = ( aHoleListBuffer[ii].m_Hole_Diameter );
|
||||
aToolListBuffer.push_back( new_tool );
|
||||
LastHole = new_tool.m_Diameter;
|
||||
}
|
||||
|
||||
jj = aToolListBuffer.size();
|
||||
if( jj == 0 )
|
||||
continue; // Should not occurs
|
||||
|
||||
aHoleListBuffer[ii].m_Tool_Reference = jj; // Tool value Initialized (value >= 1)
|
||||
|
||||
aToolListBuffer.back().m_TotalCount++;
|
||||
if( aHoleListBuffer[ii].m_Hole_Shape )
|
||||
aToolListBuffer.back().m_OvalCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
/*******************************************************************************/
|
||||
/* classes and functions declaration unsed in drill file and report generation */
|
||||
/*******************************************************************************/
|
||||
|
||||
#ifndef GENDRILL_H
|
||||
#define GENDRILL_H
|
||||
|
||||
/* the DRILL_TOOL class handle tools used in the excellon drill file */
|
||||
class DRILL_TOOL
|
||||
{
|
||||
public:
|
||||
int m_Diameter; // the diameter of the used tool (for oblong, the smaller size)
|
||||
int m_TotalCount; // how many times it is used (round and oblong)
|
||||
int m_OvalCount; // oblong count
|
||||
public:
|
||||
DRILL_TOOL( int diametre )
|
||||
{
|
||||
m_TotalCount = 0;
|
||||
m_OvalCount = 0;
|
||||
m_Diameter = diametre;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* the HOLE_INFO class handle hole which must be drilled (diameter, position and layers) */
|
||||
class HOLE_INFO
|
||||
{
|
||||
public:
|
||||
int m_Hole_Diameter; // hole value, and for oblong min(hole size x, hole size y)
|
||||
int m_Tool_Reference; // Tool reference for this hole = 1 ... n (values <=0 must not be used)
|
||||
int m_Hole_SizeX; // hole size x for oblong holes
|
||||
int m_Hole_SizeY; // hole size y for oblong holes
|
||||
int m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes
|
||||
int m_Hole_Shape; // hole shape: round (0) or oval (1)
|
||||
int m_Hole_Pos_X; // hole position X
|
||||
int m_Hole_Pos_Y; // hole position Y
|
||||
int m_Hole_Bottom_Layer; // hole starting layer (usually copper)
|
||||
int m_Hole_Top_Layer; // hole ending layer (usually component): m_Hole_First_Layer < m_Hole_Last_Layer
|
||||
};
|
||||
|
||||
|
||||
/* the DrillPrecision class to handle drill precision format in excellon files*/
|
||||
class DrillPrecision
|
||||
{
|
||||
public:
|
||||
int m_lhs;
|
||||
int m_rhs;
|
||||
|
||||
public:
|
||||
DrillPrecision( int l, int r ) { m_lhs = l; m_rhs = r; }
|
||||
};
|
||||
|
||||
/* zeros format */
|
||||
enum zeros_fmt {
|
||||
DECIMAL_FORMAT,
|
||||
SUPPRESS_LEADING,
|
||||
SUPPRESS_TRAILING,
|
||||
KEEP_ZEROS
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function BuildHolesList
|
||||
* Create the list of holes and tools for a given board
|
||||
* @param Pcb : the given board
|
||||
* @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb info
|
||||
* @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use
|
||||
*/
|
||||
void Build_Holes_List( BOARD* Pcb, std::vector<HOLE_INFO>& aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer,
|
||||
int aFirstLayer, int aLastLayer );
|
||||
|
||||
|
||||
void GenDrillMapFile( BOARD* aPcb,
|
||||
FILE* aFile,
|
||||
const wxString& aFullFileName,
|
||||
wxSize aSheetSize,
|
||||
std::vector<HOLE_INFO> aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL> aToolListBuffer,
|
||||
bool aUnit_Drill_is_Inch,
|
||||
int format );
|
||||
|
||||
void Gen_Drill_PcbMap( BOARD* aPcb, FILE* aFile,
|
||||
std::vector<HOLE_INFO>& aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer,
|
||||
int format );
|
||||
|
||||
/*
|
||||
* Create a list of drill values and drill count
|
||||
*/
|
||||
void GenDrillReportFile( FILE* aFile, const wxString& aBoardFilename,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer, bool aUnit_Drill_is_Inch );
|
||||
|
||||
#endif // #ifndef GENDRILL_H
|
||||
/*******************************************************************************/
|
||||
/* classes and functions declaration unsed in drill file and report generation */
|
||||
/*******************************************************************************/
|
||||
|
||||
#ifndef GENDRILL_H
|
||||
#define GENDRILL_H
|
||||
|
||||
/* the DRILL_TOOL class handle tools used in the excellon drill file */
|
||||
class DRILL_TOOL
|
||||
{
|
||||
public:
|
||||
int m_Diameter; // the diameter of the used tool (for oblong, the smaller size)
|
||||
int m_TotalCount; // how many times it is used (round and oblong)
|
||||
int m_OvalCount; // oblong count
|
||||
public:
|
||||
DRILL_TOOL( int diametre )
|
||||
{
|
||||
m_TotalCount = 0;
|
||||
m_OvalCount = 0;
|
||||
m_Diameter = diametre;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* the HOLE_INFO class handle hole which must be drilled (diameter, position and layers) */
|
||||
class HOLE_INFO
|
||||
{
|
||||
public:
|
||||
int m_Hole_Diameter; // hole value, and for oblong min(hole size x, hole size y)
|
||||
int m_Tool_Reference; // Tool reference for this hole = 1 ... n (values <=0 must not be used)
|
||||
int m_Hole_SizeX; // hole size x for oblong holes
|
||||
int m_Hole_SizeY; // hole size y for oblong holes
|
||||
int m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes
|
||||
int m_Hole_Shape; // hole shape: round (0) or oval (1)
|
||||
int m_Hole_Pos_X; // hole position X
|
||||
int m_Hole_Pos_Y; // hole position Y
|
||||
int m_Hole_Bottom_Layer; // hole starting layer (usually copper)
|
||||
int m_Hole_Top_Layer; // hole ending layer (usually component): m_Hole_First_Layer < m_Hole_Last_Layer
|
||||
};
|
||||
|
||||
|
||||
/* the DrillPrecision class to handle drill precision format in excellon files*/
|
||||
class DrillPrecision
|
||||
{
|
||||
public:
|
||||
int m_lhs;
|
||||
int m_rhs;
|
||||
|
||||
public:
|
||||
DrillPrecision( int l, int r ) { m_lhs = l; m_rhs = r; }
|
||||
};
|
||||
|
||||
/* zeros format */
|
||||
enum zeros_fmt {
|
||||
DECIMAL_FORMAT,
|
||||
SUPPRESS_LEADING,
|
||||
SUPPRESS_TRAILING,
|
||||
KEEP_ZEROS
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function BuildHolesList
|
||||
* Create the list of holes and tools for a given board
|
||||
* @param Pcb : the given board
|
||||
* @param aHoleListBuffer : the std::vector<HOLE_INFO> to fill with pcb info
|
||||
* @param aToolListBuffer : the std::vector<DRILL_TOOL> to fill with tools to use
|
||||
*/
|
||||
void Build_Holes_List( BOARD* Pcb, std::vector<HOLE_INFO>& aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer,
|
||||
int aFirstLayer, int aLastLayer );
|
||||
|
||||
|
||||
void GenDrillMapFile( BOARD* aPcb,
|
||||
FILE* aFile,
|
||||
const wxString& aFullFileName,
|
||||
wxSize aSheetSize,
|
||||
std::vector<HOLE_INFO> aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL> aToolListBuffer,
|
||||
bool aUnit_Drill_is_Inch,
|
||||
int format );
|
||||
|
||||
void Gen_Drill_PcbMap( BOARD* aPcb, FILE* aFile,
|
||||
std::vector<HOLE_INFO>& aHoleListBuffer,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer,
|
||||
int format );
|
||||
|
||||
/*
|
||||
* Create a list of drill values and drill count
|
||||
*/
|
||||
void GenDrillReportFile( FILE* aFile, const wxString& aBoardFilename,
|
||||
std::vector<DRILL_TOOL>& aToolListBuffer, bool aUnit_Drill_is_Inch );
|
||||
|
||||
#endif // #ifndef GENDRILL_H
|
||||
|
|
Loading…
Reference in New Issue