Commit 47c1edd7 authored by unknown's avatar unknown Committed by jean-pierre charras

Add patch about idf export (from cirilo_bernardo), with a fix for Windows.

parents b9246dd4 6652bcdc
include_directories( include_directories(
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/lib_dxf" "${CMAKE_SOURCE_DIR}/lib_dxf"
"${CMAKE_SOURCE_DIR}/pcbnew/exporters"
"${CMAKE_SOURCE_DIR}/utils/idftools" "${CMAKE_SOURCE_DIR}/utils/idftools"
) )
link_directories( link_directories(
"${CMAKE_BINARY_DIR}/lib_dxf" "${CMAKE_BINARY_DIR}/lib_dxf"
) )
add_executable( idfcyl idf_cylinder.cpp ) add_library( idf3 STATIC
idf_helpers.cpp idf_common.cpp idf_outlines.cpp
idf_parser.cpp vrml_layer.cpp )
add_executable( idfcyl idf_cylinder.cpp )
add_executable( idfrect idf_rect.cpp ) add_executable( idfrect idf_rect.cpp )
add_executable( dxf2idf dxf2idfmain.cpp dxf2idf.cpp )
add_executable( idf2vrml idf2vrml.cpp )
add_executable( dxf2idf dxf2idfmain.cpp dxf2idf.cpp target_link_libraries( dxf2idf lib_dxf idf3 ${wxWidgets_LIBRARIES} )
"${CMAKE_SOURCE_DIR}/pcbnew/exporters/idf_common.cpp"
"${CMAKE_SOURCE_DIR}/common/richio.cpp" if( WIN32 )
) set ( LIB_GLU glu32 )
else()
set ( LIB_GLU GLU )
endif()
add_dependencies( idfcyl lib-dependencies ) target_link_libraries( idf2vrml idf3 ${LIB_GLU} ${wxWidgets_LIBRARIES} )
add_dependencies( idfrect lib-dependencies )
add_dependencies( dxf2idf lib-dependencies )
target_link_libraries( dxf2idf lib_dxf ${wxWidgets_LIBRARIES} )
install( TARGETS idfcyl idfrect dxf2idf install( TARGETS idfcyl idfrect dxf2idf idf2vrml
DESTINATION ${KICAD_BIN} DESTINATION ${KICAD_BIN}
COMPONENT binary ) COMPONENT binary )
...@@ -123,7 +123,8 @@ int main( int argc, char **argv ) ...@@ -123,7 +123,8 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> height ) && height > 0.001 ) tstr >> height;
if( !tstr.fail() && height > 0.001 )
ok = true; ok = true;
} }
...@@ -186,4 +187,4 @@ int main( int argc, char **argv ) ...@@ -186,4 +187,4 @@ int main( int argc, char **argv )
fprintf( fp, ".END_ELECTRICAL\n" ); fprintf( fp, ".END_ELECTRICAL\n" );
return 0; return 0;
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -149,7 +149,9 @@ int main( int argc, char **argv ) ...@@ -149,7 +149,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> dia) && dia > 0.0 )
tstr >> dia;
if( !tstr.fail() && dia > 0.0 )
ok = true; ok = true;
} }
...@@ -163,7 +165,9 @@ int main( int argc, char **argv ) ...@@ -163,7 +165,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> length) && length > 0.0 )
tstr >> length;
if( !tstr.fail() && length > 0.0 )
ok = true; ok = true;
} }
...@@ -177,7 +181,9 @@ int main( int argc, char **argv ) ...@@ -177,7 +181,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> extraZ) && extraZ >= 0.0 )
tstr >> extraZ;
if( !tstr.fail() && extraZ >= 0.0 )
ok = true; ok = true;
} }
...@@ -191,7 +197,9 @@ int main( int argc, char **argv ) ...@@ -191,7 +197,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> wireDia) && wireDia > 0.0 )
tstr >> wireDia;
if( !tstr.fail() && wireDia > 0.0 )
{ {
if( wireDia < dia ) if( wireDia < dia )
ok = true; ok = true;
...@@ -236,7 +244,9 @@ void make_vcyl( bool inch, bool axial, double dia, double length, ...@@ -236,7 +244,9 @@ void make_vcyl( bool inch, bool axial, double dia, double length,
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> pitch) && pitch > 0.0 )
tstr >> pitch;
if( !tstr.fail() && pitch > 0.0 )
{ {
if( (pitch - wireDia) <= (dia / 2.0) ) if( (pitch - wireDia) <= (dia / 2.0) )
{ {
...@@ -436,7 +446,9 @@ void make_hcyl( bool inch, bool axial, double dia, double length, ...@@ -436,7 +446,9 @@ void make_hcyl( bool inch, bool axial, double dia, double length,
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> pitch) && pitch > 0.0 )
tstr >> pitch;
if( !tstr.fail() && pitch > 0.0 )
{ {
if( axial ) if( axial )
{ {
...@@ -477,7 +489,9 @@ void make_hcyl( bool inch, bool axial, double dia, double length, ...@@ -477,7 +489,9 @@ void make_hcyl( bool inch, bool axial, double dia, double length,
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> lead) && lead > 0.0 )
tstr >> lead;
if( !tstr.fail() && lead > 0.0 )
{ {
if( lead < wireDia ) if( lead < wireDia )
cout << "* WARNING: lead length must be >= wireDia\n"; cout << "* WARNING: lead length must be >= wireDia\n";
......
.HEADER
BOARD_FILE 3.0 "Created by KiCad (2014-01-21 BZR 4629)-product" 2014/01/23.09:19:46 1
"Arduino_MEGA_2560-Rev3.kicad_pcb" MM
.END_HEADER
.BOARD_OUTLINE ECAD
1.60000
0 246.20220 -25.67000 0
0 247.20220 -26.67000 0
0 344.26220 -26.67000 0
0 345.26220 -25.67000 0
0 345.26220 -25.40000 0
0 347.80220 -22.86000 0
0 347.80220 11.43000 0
0 345.26220 13.97000 0
0 345.26220 24.13000 0
0 342.72220 26.67000 0
0 247.20220 26.67000 0
0 246.20220 25.67000 0
0 246.20220 -25.67000 0
.END_BOARD_OUTLINE
.DRILLED_HOLES
3.200 342.72220 -24.13000 NPTH "@HOLE0" MTG ECAD
3.200 261.44220 24.13000 NPTH "@HOLE1" MTG ECAD
3.200 336.37220 24.13000 NPTH "@HOLE2" MTG ECAD
3.200 260.17220 -24.13000 NPTH "@HOLE3" MTG ECAD
3.200 312.24220 8.89000 NPTH "@HOLE4" MTG ECAD
3.200 312.24220 -19.05000 NPTH "@HOLE5" MTG ECAD
0.950 309.82920 3.81000 PTH "ICSP" PIN ECAD
0.950 312.36920 3.81000 PTH "ICSP" PIN ECAD
0.950 309.82920 1.27000 PTH "ICSP" PIN ECAD
0.950 312.36920 1.27000 PTH "ICSP" PIN ECAD
0.950 309.82920 -1.27000 PTH "ICSP" PIN ECAD
0.950 312.36920 -1.27000 PTH "ICSP" PIN ECAD
0.850 309.70220 24.13000 PTH "PWML" PIN ECAD
0.850 307.16220 24.13000 PTH "PWML" PIN ECAD
0.850 304.62220 24.13000 PTH "PWML" PIN ECAD
0.850 302.08220 24.13000 PTH "PWML" PIN ECAD
0.850 299.54220 24.13000 PTH "PWML" PIN ECAD
0.850 297.00220 24.13000 PTH "PWML" PIN ECAD
0.850 294.46220 24.13000 PTH "PWML" PIN ECAD
0.850 291.92220 24.13000 PTH "PWML" PIN ECAD
1.400 254.88900 -23.36800 PTH "X1" PIN ECAD
1.400 257.88620 -18.36420 PTH "X1" PIN ECAD
1.400 251.89180 -18.36420 PTH "X1" PIN ECAD
1.400 255.65100 -23.36800 PTH "X1" PIN ECAD
1.400 254.12700 -23.36800 PTH "X1" PIN ECAD
1.400 251.89180 -19.12620 PTH "X1" PIN ECAD
1.400 251.89180 -17.60220 PTH "X1" PIN ECAD
1.400 257.88620 -19.12620 PTH "X1" PIN ECAD
1.400 257.88620 -17.60220 PTH "X1" PIN ECAD
0.850 297.00220 -24.13000 PTH "ADCL" PIN ECAD
0.850 299.54220 -24.13000 PTH "ADCL" PIN ECAD
0.850 302.08220 -24.13000 PTH "ADCL" PIN ECAD
0.850 304.62220 -24.13000 PTH "ADCL" PIN ECAD
0.850 307.16220 -24.13000 PTH "ADCL" PIN ECAD
0.850 309.70220 -24.13000 PTH "ADCL" PIN ECAD
0.850 312.24220 -24.13000 PTH "ADCL" PIN ECAD
0.850 314.78220 -24.13000 PTH "ADCL" PIN ECAD
0.850 332.56220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 330.02220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 327.48220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 324.94220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 322.40220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 319.86220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 317.32220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 314.78220 24.13000 PTH "COMMUNICATION" PIN ECAD
0.850 319.86220 -24.13000 PTH "ADCH" PIN ECAD
0.850 322.40220 -24.13000 PTH "ADCH" PIN ECAD
0.850 324.94220 -24.13000 PTH "ADCH" PIN ECAD
0.850 327.48220 -24.13000 PTH "ADCH" PIN ECAD
0.850 330.02220 -24.13000 PTH "ADCH" PIN ECAD
0.850 332.56220 -24.13000 PTH "ADCH" PIN ECAD
0.850 335.10220 -24.13000 PTH "ADCH" PIN ECAD
0.850 337.64220 -24.13000 PTH "ADCH" PIN ECAD
0.950 254.72220 10.18000 PTH "X2" PIN ECAD
0.950 254.72220 12.68000 PTH "X2" PIN ECAD
0.950 252.72220 12.68000 PTH "X2" PIN ECAD
0.950 252.72220 10.18000 PTH "X2" PIN ECAD
2.200 250.01220 17.43000 PTH "X2" PIN ECAD
2.200 250.01220 5.43000 PTH "X2" PIN ECAD
0.950 267.03020 20.82800 PTH "ICSP1" PIN ECAD
0.950 267.03020 18.28800 PTH "ICSP1" PIN ECAD
0.950 264.49020 20.82800 PTH "ICSP1" PIN ECAD
0.950 264.49020 18.28800 PTH "ICSP1" PIN ECAD
0.950 261.95020 20.82800 PTH "ICSP1" PIN ECAD
0.950 261.95020 18.28800 PTH "ICSP1" PIN ECAD
0.850 267.15720 -0.63500 PTH "Y2" PIN ECAD
0.850 262.07720 -0.63500 PTH "Y2" PIN ECAD
0.950 267.03020 13.20800 PTH "JP5" PIN ECAD
0.950 264.49020 13.20800 PTH "JP5" PIN ECAD
0.950 267.03020 15.74800 PTH "JP5" PIN ECAD
0.950 264.49020 15.74800 PTH "JP5" PIN ECAD
0.950 340.18220 24.13000 PTH "XIO" PIN ECAD
0.950 342.72220 24.13000 PTH "XIO" PIN ECAD
0.950 340.18220 21.59000 PTH "XIO" PIN ECAD
0.950 342.72220 21.59000 PTH "XIO" PIN ECAD
0.950 340.18220 19.05000 PTH "XIO" PIN ECAD
0.950 342.72220 19.05000 PTH "XIO" PIN ECAD
0.950 340.18220 16.51000 PTH "XIO" PIN ECAD
0.950 342.72220 16.51000 PTH "XIO" PIN ECAD
0.950 340.18220 13.97000 PTH "XIO" PIN ECAD
0.950 342.72220 13.97000 PTH "XIO" PIN ECAD
0.950 340.18220 11.43000 PTH "XIO" PIN ECAD
0.950 342.72220 11.43000 PTH "XIO" PIN ECAD
0.950 340.18220 8.89000 PTH "XIO" PIN ECAD
0.950 342.72220 8.89000 PTH "XIO" PIN ECAD
0.950 340.18220 6.35000 PTH "XIO" PIN ECAD
0.950 342.72220 6.35000 PTH "XIO" PIN ECAD
0.950 340.18220 3.81000 PTH "XIO" PIN ECAD
0.950 342.72220 3.81000 PTH "XIO" PIN ECAD
0.950 340.18220 1.27000 PTH "XIO" PIN ECAD
0.950 342.72220 1.27000 PTH "XIO" PIN ECAD
0.950 340.18220 -1.27000 PTH "XIO" PIN ECAD
0.950 342.72220 -1.27000 PTH "XIO" PIN ECAD
0.950 340.18220 -3.81000 PTH "XIO" PIN ECAD
0.950 342.72220 -3.81000 PTH "XIO" PIN ECAD
0.950 340.18220 -6.35000 PTH "XIO" PIN ECAD
0.950 342.72220 -6.35000 PTH "XIO" PIN ECAD
0.950 340.18220 -8.89000 PTH "XIO" PIN ECAD
0.950 342.72220 -8.89000 PTH "XIO" PIN ECAD
0.950 340.18220 -11.43000 PTH "XIO" PIN ECAD
0.950 342.72220 -11.43000 PTH "XIO" PIN ECAD
0.950 340.18220 -13.97000 PTH "XIO" PIN ECAD
0.950 342.72220 -13.97000 PTH "XIO" PIN ECAD
0.950 340.18220 -16.51000 PTH "XIO" PIN ECAD
0.950 342.72220 -16.51000 PTH "XIO" PIN ECAD
0.950 340.18220 -19.05000 PTH "XIO" PIN ECAD
0.950 342.72220 -19.05000 PTH "XIO" PIN ECAD
0.850 264.99820 24.13000 PTH "JP6" PIN ECAD
0.850 267.53820 24.13000 PTH "JP6" PIN ECAD
0.850 270.07820 24.13000 PTH "JP6" PIN ECAD
0.850 272.61820 24.13000 PTH "JP6" PIN ECAD
0.850 275.15820 24.13000 PTH "JP6" PIN ECAD
0.850 277.69820 24.13000 PTH "JP6" PIN ECAD
0.850 280.23820 24.13000 PTH "JP6" PIN ECAD
0.850 282.77820 24.13000 PTH "JP6" PIN ECAD
0.850 285.31820 24.13000 PTH "JP6" PIN ECAD
0.850 287.85820 24.13000 PTH "JP6" PIN ECAD
0.850 274.14220 -24.13000 PTH "POWER" PIN ECAD
0.850 276.68220 -24.13000 PTH "POWER" PIN ECAD
0.850 279.22220 -24.13000 PTH "POWER" PIN ECAD
0.850 281.76220 -24.13000 PTH "POWER" PIN ECAD
0.850 284.30220 -24.13000 PTH "POWER" PIN ECAD
0.850 286.84220 -24.13000 PTH "POWER" PIN ECAD
0.850 289.38220 -24.13000 PTH "POWER" PIN ECAD
0.850 291.92220 -24.13000 PTH "POWER" PIN ECAD
.END_DRILLED_HOLES
.HEADER
LIBRARY_FILE 3.0 "Created by KiCad (2014-01-21 BZR 4629)-product" 2014/01/23.09:19:46 1
.END_HEADER
.HEADER
BOARD_FILE 3.0 "Sample File Generator" 10/22/96.16:02:44 1
sample_board THOU
.END_HEADER
# This is the first BOARD section
# SEC1-0
# SEC1-1
.BOARD_OUTLINE MCAD
62.0
0 5030.5 -120.0 0.0
0 5187.5 -120.0 0.0
0 5187.5 2130.0 0.0
0 5155.0 2130.0 0.0
0 5155.0 2550.0 -180.0
0 5187.5 2550.0 0.0
0 5187.5 4935.0 0.0
0 4945.0 5145.0 0.0
0 4945.0 5420.0 0.0
0 4865.0 5500.0 0.0
0 210.0 5500.0 0.0
0 130.0 5420.0 0.0
0 130.0 5145.0 0.0
0 -112.5 4935.0 0.0
0 -112.5 2550.0 0.0
0 -80.0 2550.0 0.0
0 -80.0 2130.0 -180.0
0 -112.5 2130.0 0.0
0 -112.5 -140.0 0.0
0 45.5 -140.0 0.0
0 45.5 -400.0 0.0
0 2442.5 -400.0 0.0
0 2442.5 -140.0 0.0
0 2631.5 -140.0 0.0
0 2631.5 -400.0 0.0
0 5030.5 -400.0 0.0
0 5030.5 -120.0 0.0
1 2650.0 2350.0 0.0
1 3000.0 2350.0 360.0
.END_BOARD_OUTLINE
# This is the second BOARD section
# SEC2-0
# SEC2-1
# NOT SEC1-1
.ROUTE_OUTLINE ECAD
ALL
0 5112.5 150.0 0.0
0 5112.5 2058.2 0.0
0 5112.5 2621.8 -162.9
0 5112.5 4863.2 0.0
0 4878.8 5075.0 0.0
0 226.4 5075.0 0.0
0 138.0 4910.3 0.0
0 138.0 4800.0 0.0
0 -37.5 4662.5 0.0
0 -37.5 2621.8 0.0
0 -37.5 2058.2 -162.9
0 -37.5 150.0 0.0
0 162.5 0.0 0.0
0 4912.5 0.0 0.0
0 5112.5 150.0 0.0
.END_ROUTE_OUTLINE
# This is the third BOARD section
# SEC3-0
# SEC3-1
.PLACE_OUTLINE MCAD
TOP 1000.0
0 5080.0 2034.9 0.0
0 5080.0 2645.1 -152.9
0 5080.0 4837.3 0.0
0 4855.3 5042.5 0.0
0 252.9 5042.5 0.0
0 170.5 4896.9 0.0
0 170.5 4798.4 0.0
0 -5.0 4659.0 0.0
0 -5.0 2645.1 0.0
0 -5.0 2034.9 -152.9
0 -5.0 182.5 0.0
0 192.0 32.5 0.0
0 4883.1 32.5 0.0
0 5080.0 182.5 0.0
0 5080.0 2034.9 0.0
.END_PLACE_OUTLINE
# This is the fourth BOARD section
# SEC4-0
# SEC4-1
.PLACE_OUTLINE UNOWNED
BOTTOM 200.0
0 300.0 200.0 0.0
0 4800.0 200.0 0.0
0 4800.0 4800.0 0.0
0 300.0 4800.0 0.0
0 300.0 200.0 0.0
.END_PLACE_OUTLINE
# This is the fifth BOARD section
# SEC5-0
# SEC5-1
.ROUTE_KEEPOUT ECAD
ALL
0 2650.0 2350.0 0.0
0 3100.0 2350.0 360.0
.END_ROUTE_KEEPOUT
# This is the sixth BOARD section
# SEC6-0
# SEC6-1
.PLACE_KEEPOUT MCAD
BOTH 0.0
0 2650.0 2350.0 0.0
0 3100.0 2350.0 360.0
.END_PLACE_KEEPOUT
# This is the seventh BOARD section
# SEC7-0
# SEC7-1
.PLACE_KEEPOUT MCAD
TOP 300.0
0 3700.0 5000.0 0.0
0 3700.0 4300.0 0.0
0 4000.0 4300.0 0.0
0 4000.0 3700.0 0.0
0 5000.0 3700.0 0.0
0 5000.0 4800.0 0.0
0 4800.0 5000.0 0.0
0 3700.0 5000.0 0.0
.END_PLACE_KEEPOUT
# This is the eighth BOARD section
# SEC8-0
# SEC8-1
.DRILLED_HOLES
30.0 1800.0 100.0 PTH J1 PIN ECAD
30.0 1700.0 100.0 PTH J1 PIN ECAD
30.0 1600.0 100.0 PTH J1 PIN ECAD
30.0 1500.0 100.0 PTH J1 PIN ECAD
30.0 1400.0 100.0 PTH J1 PIN ECAD
30.0 1300.0 100.0 PTH J1 PIN ECAD
30.0 1200.0 100.0 PTH J1 PIN ECAD
30.0 1100.0 100.0 PTH J1 PIN ECAD
30.0 1000.0 100.0 PTH J1 PIN ECAD
30.0 0900.0 100.0 PTH J1 PIN ECAD
30.0 0800.0 100.0 PTH J1 PIN ECAD
30.0 0700.0 100.0 PTH J1 PIN ECAD
30.0 0700.0 200.0 PTH J1 PIN ECAD
30.0 0800.0 200.0 PTH J1 PIN ECAD
30.0 0900.0 200.0 PTH J1 PIN ECAD
30.0 1000.0 200.0 PTH J1 PIN ECAD
30.0 1100.0 200.0 PTH J1 PIN ECAD
30.0 1200.0 200.0 PTH J1 PIN ECAD
30.0 1300.0 200.0 PTH J1 PIN ECAD
30.0 1400.0 200.0 PTH J1 PIN ECAD
30.0 1500.0 200.0 PTH J1 PIN ECAD
30 1600 200 PTH J1 PIN ECAD
30 1700 200 PTH J1 PIN ECAD
30 1800 200 PTH J1 PIN ECAD
30 4400 100 PTH J2 PIN ECAD
30 4300 100 PTH J2 PIN ECAD
30 4200 100 PTH J2 PIN ECAD
30 4100 100 PTH J2 PIN ECAD
30 4000 100 PTH J2 PIN ECAD
30 3900 100 PTH J2 PIN ECAD
30 3800 100 PTH J2 PIN ECAD
30 3700 100 PTH J2 PIN ECAD
30 3600 100 PTH J2 PIN ECAD
30 3500 100 PTH J2 PIN ECAD
30 3400 100 PTH J2 PIN ECAD
30 3300 100 PTH J2 PIN ECAD
30 3300 200 PTH J2 PIN ECAD
30 3400 200 PTH J2 PIN ECAD
30 3500 200 PTH J2 PIN ECAD
30 3600 200 PTH J2 PIN ECAD
30 3700 200 PTH J2 PIN ECAD
30 3800 200 PTH J2 PIN ECAD
30 3900 200 PTH J2 PIN ECAD
30 4000 200 PTH J2 PIN ECAD
30 4100 200 PTH J2 PIN ECAD
30 4200 200 PTH J2 PIN ECAD
30 4300 200 PTH J2 PIN ECAD
30 4400 200 PTH J2 PIN ECAD
30 3000 3300 PTH U3 PIN ECAD
30 3024.2 3203 PTH U3 PIN ECAD
30 3048.4 3105.9 PTH U3 PIN ECAD
30 3072.6 3008.9 PTH U3 PIN ECAD
30 3096.8 2911.9 PTH U3 PIN ECAD
30 3121 2814.9 PTH U3 PIN ECAD
30 3145.2 2717.8 PTH U3 PIN ECAD
30 3436.2 2790.4 PTH U3 PIN ECAD
30 3412.1 2887.4 PTH U3 PIN ECAD
30 3387.9 2984.5 PTH U3 PIN ECAD
30 3363.7 3081.5 PTH U3 PIN ECAD
30 3339.5 3178.5 PTH U3 PIN ECAD
30 3315.3 3275.6 PTH U3 PIN ECAD
30 3291.1 3372.6 PTH U3 PIN ECAD
30 2200 2500 PTH U4 PIN ECAD
30 2100 2500 PTH U4 PIN ECAD
30 2000 2500 PTH U4 PIN ECAD
30 1900 2500 PTH U4 PIN ECAD
30 1800 2500 PTH U4 PIN ECAD
30 1700 2500 PTH U4 PIN ECAD
30 1600 2500 PTH U4 PIN ECAD
30 1600 2200 PTH U4 PIN ECAD
30 1700 2200 PTH U4 PIN ECAD
30 1800 2200 PTH U4 PIN ECAD
30 1900 2200 PTH U4 PIN ECAD
30 2000 2200 PTH U4 PIN ECAD
30 2100 2200 PTH U4 PIN ECAD
30 2200 2200 PTH U4 PIN ECAD
20 2500 3100 PTH BOARD VIA ECAD
20 2500 3200 PTH BOARD VIA ECAD
20 2500 3300 PTH BOARD VIA ECAD
20 2000 1600 PTH BOARD VIA ECAD
20 1100 900 PTH BOARD VIA ECAD
20 1200 1600 PTH BOARD VIA ECAD
20 3900 3800 PTH BOARD VIA ECAD
20 3900 2300 PTH BOARD VIA ECAD
100.0 3100.0 -50.0 NPTH J2 MTG ECAD
100.0 4600.0 -50.0 NPTH J2 MTG ECAD
100.0 500.0 -50.0 NPTH J1 MTG ECAD
100.0 2000.0 -50.0 NPTH J1 MTG ECAD
93.0 5075.0 0.0 PTH BOARD MTG UNOWNED
93.0 0.0 4800.0 NPTH BOARD TOOL MCAD
93.0 0.0 0.0 PTH BOARD MTG UNOWNED
.END_DRILLED_HOLES
# This is the ninth BOARD section
# SEC9-0
# SEC9-1
.NOTES
3500.0 3300.0 75.0 2500.0 "This component rotated 14 degrees"
400.0 4400.0 75.0 3200.0 "Component height limited by enclosure latch"
1800.0 300.0 75.0 1700.0 "Do not move connectors!"
.END_NOTES
# This is the tenth and ALWAYS FINAL BOARD section
# SEC10-0
# SEC10-1
.PLACEMENT
cs13_a pn-cap C1
4000.0 1000.0 100.0 0.0 TOP PLACED
cc1210 pn-cc1210 C2
3000.0 3500.0 0.0 0.0 TOP PLACED
cc1210 pn-cc1210 C3
3200.0 1800.0 0.0 0.0 BOTTOM PLACED
cc1210 pn-cc1210 C4
1400.0 2300.0 0.0 270.0 TOP PLACED
cc1210 pn-cc1210 C5
1799.5 3518.1 0.0 0.0 BOTTOM PLACED
conn_din24 connector J1
1800.0 100.0 0.0 0.0 TOP MCAD
conn_din24 connector J2
4400.0 100.0 0.0 0.0 TOP MCAD
plcc_20 pn-pal16l8-plcc U1
1800.0 3200.0 0.0 0.0 BOTTOM ECAD
plcc_20 pn-pal16l8-plcc U2
3200.0 1800.0 0.0 0.0 TOP PLACED
dip_14w pn-hs346-dip U3
3000.0 3300.0 0.0 14.0 TOP PLACED
dip_14w pn-hs346-dip U4
2200.0 2500.0 0.0 270.0 TOP PLACED
.END_PLACEMENT
.HEADER
LIBRARY_file 3.0 "Sample File Generator" 10/22/96.16:41:37 1
.END_HEADER
# Component #1/5
.ELECTRICAL
cs13_a pn-cap THOU 150.0
0 -55.0 55.0 0.0
0 -55.0 -55.0 0.0
0 135.0 -55.0 0.0
0 135.0 -80.0 0.0
0 565.0 -80.0 0.0
0 565.0 -55.0 0.0
0 755.0 -55.0 0.0
0 755.0 55.0 0.0
0 565.0 55.0 0.0
0 565.0 80.0 0.0
0 135.0 80.0 0.0
0 135.0 55.0 0.0
0 -55.0 55.0 0.0
PROP CAPACITANCE 100.0
PROP TOLERANCE 5.0
.END_ELECTRICAL
# Component #2/5
.ELECTRICAL
cc1210 pn-cc1210 THOU 67.0
0 -40.0 56.0 0.0
0 -40.0 -56.0 0.0
0 182.0 -56.0 0.0
0 182.0 56.0 0.0
0 -40.0 56.0 0.0
PROP CAPACITANCE 0.1
PROP TOLERANCE 5.0
.END_ELECTRICAL
# Component #3/5
.ELECTRICAL
conn_din24 connector THOU 435.0
0 -1400.0 -500.0 0.0
0 300.0 -500.0 0.0
0 300.0 150.0 0.0
0 -1400.0 150.0 0.0
0 -1400.0 -500.0 0.0
.END_ELECTRICAL
# Component #4/5
.ELECTRICAL
dip_14w pn-hs346-dip THOU 200.0
0 350.0 50.0 0.0
0 -50.0 50.0 0.0
0 -50.0 -650.0 0.0
0 350.0 -650.0 0.0
0 350.0 50.0 0.0
.END_ELECTRICAL
# Component #5/5
.ELECTRICAL
plcc_20 pn-pal16l8-plcc THOU 14.0
0 -200.0 240.0 0.0
0 -240.0 200.0 0.0
0 -240.0 -240.0 0.0
0 240.0 -240.0 0.0
0 240.0 240.0 0.0
0 -200.0 240.0 0.0
.END_ELECTRICAL
.HEADER
BOARD_FILE 3.0 "Created by KiCad (2014-01-25 BZR 4633)-product" 2014/02/01.15:09:15 1
"test_idf2.kicad_pcb" MM
.END_HEADER
.BOARD_OUTLINE ECAD
1.60000
0 -86.00000 42.00000 0
0 -86.00000 -42.00000 0
0 86.00000 -42.00000 0
0 86.00000 42.00000 0
0 -86.00000 42.00000 0
.END_BOARD_OUTLINE
.DRILLED_HOLES
0.800 -74.00000 16.00000 PTH BOARD PIN ECAD
0.800 -74.00000 -28.00000 PTH BOARD PIN ECAD
0.850 -55.75000 16.00000 PTH BOARD PIN ECAD
0.850 -52.25000 16.00000 PTH BOARD PIN ECAD
0.850 -35.75000 16.00000 PTH BOARD PIN ECAD
0.850 -32.25000 16.00000 PTH BOARD PIN ECAD
1.575 -57.17500 -28.00000 PTH BOARD PIN ECAD
1.575 -50.82500 -28.00000 PTH BOARD PIN ECAD
1.575 -37.17500 -28.00000 PTH BOARD PIN ECAD
1.575 -30.82500 -28.00000 PTH BOARD PIN ECAD
0.800 -14.00000 16.00000 PTH BOARD PIN ECAD
0.800 -14.00000 -28.00000 PTH BOARD PIN ECAD
0.800 6.00000 16.00000 PTH BOARD PIN ECAD
0.800 6.00000 -28.00000 PTH BOARD PIN ECAD
0.800 26.00000 16.00000 PTH BOARD PIN ECAD
0.800 26.00000 -28.00000 PTH BOARD PIN ECAD
0.800 46.00000 16.00000 PTH BOARD PIN ECAD
0.800 46.00000 -28.00000 PTH BOARD PIN ECAD
0.800 66.00000 16.00000 PTH BOARD PIN ECAD
0.800 66.00000 -28.00000 PTH BOARD PIN ECAD
.END_DRILLED_HOLES
.PLACEMENT
"CYLV_MM" "D5.000_H8.000_Z3.000" "NOREFDES_0"
-74.000000 16.000000 0.000000 0.000 TOP ECAD
"CYLV_IN" "D0.250_H0.250_Z0.127" "NOREFDES_1"
-74.000000 -28.000000 0.000000 0.000 TOP ECAD
"CYLV_MM_L" "D5.000_H8.000_Z3.000_WD0.800_P3.500" "NOREFDES_2"
-54.000000 16.000000 0.000000 0.000 TOP ECAD
"CYLV_MM_R" "D5.000_H8.000_Z3.000_WD0.800_P3.500" "NOREFDES_3"
-34.000000 16.000000 0.000000 0.000 TOP ECAD
"CYLV_IN_L" "D0.250_H0.250_Z0.127_WD0.062_P0.250" "NOREFDES_4"
-54.000000 -28.000000 0.000000 0.000 TOP ECAD
"CYLV_IN_R" "D0.250_H0.250_Z0.127_WD0.062_P0.250" "NOREFDES_5"
-34.000000 -28.000000 0.000000 0.000 TOP ECAD
"CYLH_MM_AXI" "D2.500_H4.000_Z0.500_WD0.600_P8.000" "NOREFDES_6"
-14.000000 16.000000 0.000000 0.000 TOP ECAD
"CYLH_IN_AXI" "D0.098_H0.157_Z0.020_WD0.024_P0.315" "NOREFDES_7"
-14.000000 -28.000000 0.000000 0.000 TOP ECAD
"CYLH_MM_RAD" "D5.000_H6.000_Z0.200_WD0.600_P2.500_L3.000" "NOREFDES_8"
6.000000 16.000000 0.000000 0.000 TOP ECAD
"CYLH_IN_RAD" "D0.197_H0.236_Z0.008_WD0.024_P0.098_L0.118" "NOREFDES_9"
6.000000 -28.000000 0.000000 0.000 TOP ECAD
"RECTMM" "W10.000_L10.000_H6.000_C0.000" "NOREFDES_10"
26.000000 16.000000 0.000000 0.000 TOP ECAD
"RECTIN" "W393_L393_H236_C0" "NOREFDES_11"
26.000000 -28.000000 0.000000 0.000 TOP ECAD
"RECTMM" "W10.000_L10.000_H2.000_C0.500" "NOREFDES_12"
46.000000 16.000000 0.000000 0.000 TOP ECAD
"RECTIN" "W393_L393_H78_C19" "NOREFDES_13"
46.000000 -28.000000 0.000000 0.000 TOP ECAD
"RECTLMM" "W10.000_L10.000_H12.000_D0.800_P6.000" "NOREFDES_14"
66.000000 16.000000 0.000000 0.000 TOP ECAD
"RECTLIN" "W393_L393_H472_D31_P236" "NOREFDES_15"
66.000000 -28.000000 0.000000 0.000 TOP ECAD
.END_PLACEMENT
.HEADER
LIBRARY_FILE 3.0 "Created by KiCad (2014-01-25 BZR 4633)-product" 2014/02/01.15:09:15 1
.END_HEADER
# cylindrical outline, vertical, no pins
# file: "cylvmm_0_D5_L8_Z3.idf"
# dia: 5.000 mm
# length: 8.000 mm
# extra height: 3.000 mm
.ELECTRICAL
"CYLV_MM" "D5.000_H8.000_Z3.000" MM 11.000
0 0 0 0
0 5.000 0 360
.END_ELECTRICAL
# cylindrical outline, vertical, no pins
# file: "cylvin_0_D0.25_L0.25_Z0.127.idf"
# dia: 250 THOU
# length: 250 THOU
# extra height: 127 THOU
.ELECTRICAL
"CYLV_IN" "D0.250_H0.250_Z0.127" THOU 377
0 0 0 0
0 250 0 360
.END_ELECTRICAL
# cylindrical outline, vertical, 1 pin on left
# file: "cylvmm_1L_D5_L8_Z3_WD0.8_P3.5.idf"
# dia: 5.000 mm
# length: 8.000 mm
# extra height: 3.000 mm
# wire dia: 0.800 mm
# pitch: 3.500 mm
.ELECTRICAL
"CYLV_MM_L" "D5.000_H8.000_Z3.000_WD0.800_P3.500" MM 11.000
1 -0.718 0.400 0
1 -0.718 -0.400 -341.586
1 -1.750 -0.400 0
1 -1.750 0.400 -180
1 -0.718 0.400 0
.END_ELECTRICAL
# cylindrical outline, vertical, 1 pin on right
# file: "cylvmm_1R_D5_L8_Z3_WD0.8_P3.5.idf"
# dia: 5.000 mm
# length: 8.000 mm
# extra height: 3.000 mm
# wire dia: 0.800 mm
# pitch: 3.500 mm
.ELECTRICAL
"CYLV_MM_R" "D5.000_H8.000_Z3.000_WD0.800_P3.500" MM 11.000
0 0.718 0.400 0
0 0.718 -0.400 341.586
0 1.750 -0.400 0
0 1.750 0.400 180
0 0.718 0.400 0
.END_ELECTRICAL
# cylindrical outline, vertical, 1 pin on left
# file: "cylvin_1L_D0.25_L0.25_Z0.127_WD0.062_P0.25.idf"
# dia: 250 THOU
# length: 250 THOU
# extra height: 127 THOU
# wire dia: 62 THOU
# pitch: 250 THOU
.ELECTRICAL
"CYLV_IN_L" "D0.250_H0.250_Z0.127_WD0.062_P0.250" THOU 377
1 3 31 0
1 3 -31 -331.282
1 -125 -31 0
1 -125 31 -180
1 3 31 0
.END_ELECTRICAL
# cylindrical outline, vertical, 1 pin on right
# file: "cylvin_1R_D0.25_L0.25_Z0.127_WD0.062_P0.25.idf"
# dia: 250 THOU
# length: 250 THOU
# extra height: 127 THOU
# wire dia: 62 THOU
# pitch: 250 THOU
.ELECTRICAL
"CYLV_IN_R" "D0.250_H0.250_Z0.127_WD0.062_P0.250" THOU 377
0 -3 31 0
0 -3 -31 331.282
0 125 -31 0
0 125 31 180
0 -3 31 0
.END_ELECTRICAL
# cylindrical outline, horiz., axial pins
# file: "resistor.idf"
# dia: 2.500 mm
# length: 4.000 mm
# extra height: 0.500 mm
# wire dia: 0.600 mm
# pitch: 8.000 mm
.ELECTRICAL
"CYLH_MM_AXI" "D2.500_H4.000_Z0.500_WD0.600_P8.000" MM 3.000
0 -2.000 1.250 0
0 -2.000 0.300 0
0 -4.000 0.300 0
0 -4.000 -0.300 180
0 -2.000 -0.300 0
0 -2.000 -1.250 0
0 2.000 -1.250 0
0 2.000 -0.300 0
0 4.000 -0.300 0
0 4.000 0.300 180
0 2.000 0.300 0
0 2.000 1.250 0
0 -2.000 1.250 0
.END_ELECTRICAL
# cylindrical outline, horiz., axial pins
# file: "resistor_in.idf"
# dia: 98 THOU
# length: 157 THOU
# extra height: 20 THOU
# wire dia: 24 THOU
# pitch: 315 THOU
.ELECTRICAL
"CYLH_IN_AXI" "D0.098_H0.157_Z0.020_WD0.024_P0.315" THOU 118
0 -78 49 0
0 -78 12 0
0 -157 12 0
0 -157 -12 180
0 -78 -12 0
0 -78 -49 0
0 78 -49 0
0 78 -12 0
0 157 -12 0
0 157 12 180
0 78 12 0
0 78 49 0
0 -78 49 0
.END_ELECTRICAL
# cylindrical outline, horiz., radial pins
# file: "capacitor.idf"
# dia: 5.000 mm
# length: 6.000 mm
# extra height: 0.200 mm
# wire dia: 0.600 mm
# pitch: 2.500 mm
# lead: 3.000 mm
.ELECTRICAL
"CYLH_MM_RAD" "D5.000_H6.000_Z0.200_WD0.600_P2.500_L3.000" MM 5.200
0 -2.500 9.000 0
0 -2.500 3.000 0
0 -1.550 3.000 0
0 -1.550 0 0
0 -0.950 0 180
0 -0.950 3.000 0
0 0.950 3.000 0
0 0.950 0 0
0 1.550 0 180
0 1.550 3.000 0
0 2.500 3.000 0
0 2.500 9.000 0
0 -2.500 9.000 0
.END_ELECTRICAL
# cylindrical outline, horiz., radial pins
# file: "capacitor_in.idf"
# dia: 197 THOU
# length: 236 THOU
# extra height: 8 THOU
# wire dia: 24 THOU
# pitch: 98 THOU
# lead: 118 THOU
.ELECTRICAL
"CYLH_IN_RAD" "D0.197_H0.236_Z0.008_WD0.024_P0.098_L0.118" THOU 205
0 -98 354 0
0 -98 118 0
0 -61 118 0
0 -61 0 0
0 -37 0 180
0 -37 118 0
0 37 118 0
0 37 0 0
0 61 0 180
0 61 118 0
0 98 118 0
0 98 354 0
0 -98 354 0
.END_ELECTRICAL
# rectangular outline
# file: "rectMM_10x10x6_C0.idf"
# width: 10.000 mm
# length: 10.000 mm
# height: 6.000 mm
# chamfer: 0.000 mm
.ELECTRICAL
"RECTMM" "W10.000_L10.000_H6.000_C0.000" MM 6.000
0 5.000 5.000 0
0 -5.000 5.000 0
0 -5.000 -5.000 0
0 5.000 -5.000 0
0 5.000 5.000 0
.END_ELECTRICAL
# rectangular outline
# file: "rectIN_10x10x6mm_C0mm.idf"
# width: 393 THOU
# length: 393 THOU
# height: 236 THOU
# chamfer: 0 THOU
.ELECTRICAL
"RECTIN" "W393_L393_H236_C0" THOU 236
0 196 196 0
0 -196 196 0
0 -196 -196 0
0 196 -196 0
0 196 196 0
.END_ELECTRICAL
# rectangular outline
# file: "rectMM_10x10x2_C0.5.idf"
# width: 10.000 mm
# length: 10.000 mm
# height: 2.000 mm
# chamfer: 0.500 mm
.ELECTRICAL
"RECTMM" "W10.000_L10.000_H2.000_C0.500" MM 2.000
0 5.000 5.000 0
0 -4.500 5.000 0
0 -5.000 4.500 0
0 -5.000 -5.000 0
0 5.000 -5.000 0
0 5.000 5.000 0
.END_ELECTRICAL
# rectangular outline
# file: "rectIN_10x10x2mm_C0.5mm.idf"
# width: 393 THOU
# length: 393 THOU
# height: 78 THOU
# chamfer: 19 THOU
.ELECTRICAL
"RECTIN" "W393_L393_H78_C19" THOU 78
0 196 196 0
0 -176 196 0
0 -196 176 0
0 -196 -196 0
0 196 -196 0
0 196 196 0
.END_ELECTRICAL
# rectangular outline, leaded
# file: "rectLMM_10x10x12_D0.8_P6.0.idf"
# width: 10.000 mm
# length: 10.000 mm
# height: 12.000 mm
# wire dia: 0.800 mm
# pitch: 6.000 mm
.ELECTRICAL
"RECTLMM" "W10.000_L10.000_H12.000_D0.800_P6.000" MM 12.000
0 3.000 0.400 0
0 2.000 0.400 0
0 2.000 5.000 0
0 -8.000 5.000 0
0 -8.000 -5.000 0
0 2.000 -5.000 0
0 2.000 -0.400 0
0 3.000 -0.400 0
0 3.000 0.400 180
.END_ELECTRICAL
# rectangular outline, leaded
# file: "rectLIN_10x10x12mm_D0.8mm_P6.0mm.idf"
# width: 393 THOU
# length: 393 THOU
# height: 472 THOU
# wire dia: 31 THOU
# pitch: 236 THOU
.ELECTRICAL
"RECTLIN" "W393_L393_H472_D31_P236" THOU 472
0 118 15 0
0 78 15 0
0 78 196 0
0 -315 196 0
0 -315 -196 0
0 78 -196 0
0 78 -15 0
0 118 -15 0
0 118 15 180
.END_ELECTRICAL
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Cirilo Bernardo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cctype>
#include <iostream>
#include <sstream>
#include <idf_common.h>
#include <idf_helpers.h>
using namespace std;
using namespace IDF3;
// fetch a line from the given input file and trim the ends
bool IDF3::FetchIDFLine( std::ifstream& aModel, std::string& aLine, bool& isComment, std::streampos& aFilePos )
{
aLine = "";
aFilePos = aModel.tellg();
if( aFilePos == -1 )
return false;
std::getline( aModel, aLine );
isComment = false;
// A comment begins with a '#' and must be the first character on the line
if( aLine[0] == '#' )
{
// opening '#' is stripped
isComment = true;
aLine.erase( aLine.begin() );
}
// strip leading and trailing spaces
while( !aLine.empty() && isspace( *aLine.begin() ) )
aLine.erase( aLine.begin() );
while( !aLine.empty() && isspace( *aLine.rbegin() ) )
aLine.erase( --aLine.end() );
// a comment line may be empty to improve human readability
if( aLine.empty() && !isComment )
return false;
return true;
}
// extract an IDF string and move the index to point to the character after the substring
bool IDF3::GetIDFString( const std::string& aLine, std::string& aIDFString,
bool& hasQuotes, int& aIndex )
{
// 1. drop all leading spaces
// 2. if the first character is '"', read until the next '"',
// otherwise read until the next space or EOL.
std::ostringstream ostr;
int len = aLine.length();
int idx = aIndex;
if( idx < 0 || idx >= len )
return false;
while( isspace( aLine[idx] ) && idx < len ) ++idx;
if( idx == len )
{
aIndex = idx;
return false;
}
if( aLine[idx] == '"' )
{
hasQuotes = true;
++idx;
while( aLine[idx] != '"' && idx < len )
ostr << aLine[idx++];
if( idx == len )
{
ERROR_IDF << "unterminated quote mark in line:\n";
std::cerr << "LINE: " << aLine << "\n";
aIndex = idx;
return false;
}
++idx;
}
else
{
hasQuotes = false;
while( !isspace( aLine[idx] ) && idx < len )
ostr << aLine[idx++];
}
aIDFString = ostr.str();
aIndex = idx;
return true;
}
// perform a comparison between a fixed token string and an input string.
// the token is assumed to be an upper case IDF token and the input string
// is data from an IDF file. Since IDF tokens are case-insensitive, we cannot
// assume anything about the case of the input string.
bool IDF3::CompareToken( const char* aTokenString, const std::string& aInputString )
{
std::string::size_type i, j;
std::string bigToken = aInputString;
j = aInputString.length();
for( i = 0; i < j; ++i )
bigToken[i] = std::toupper( bigToken[i] );
if( !bigToken.compare( aTokenString ) )
return true;
return false;
}
// parse a string for an IDF3::KEY_OWNER
bool IDF3::ParseOwner( const std::string& aToken, IDF3::KEY_OWNER& aOwner )
{
if( CompareToken( "UNOWNED", aToken ) )
{
aOwner = UNOWNED;
return true;
}
else if( CompareToken( "ECAD", aToken ) )
{
aOwner = ECAD;
return true;
}
else if( CompareToken( "MCAD", aToken ) )
{
aOwner = MCAD;
return true;
}
ERROR_IDF << "unrecognized IDF OWNER: '" << aToken << "'\n";
return false;
}
bool IDF3::ParseIDFLayer( const std::string& aToken, IDF3::IDF_LAYER& aLayer )
{
if( CompareToken( "TOP", aToken ) )
{
aLayer = LYR_TOP;
return true;
}
else if( CompareToken( "BOTTOM", aToken ) )
{
aLayer = LYR_BOTTOM;
return true;
}
else if( CompareToken( "BOTH", aToken ) )
{
aLayer = LYR_BOTH;
return true;
}
else if( CompareToken( "INNER", aToken ) )
{
aLayer = LYR_INNER;
return true;
}
else if( CompareToken( "ALL", aToken ) )
{
aLayer = LYR_ALL;
return true;
}
ERROR_IDF << "unrecognized IDF LAYER: '" << aToken << "'\n";
aLayer = LYR_INVALID;
return false;
}
bool IDF3::WriteLayersText( std::ofstream& aBoardFile, IDF3::IDF_LAYER aLayer )
{
switch( aLayer )
{
case LYR_TOP:
aBoardFile << "TOP";
break;
case LYR_BOTTOM:
aBoardFile << "BOTTOM";
break;
case LYR_BOTH:
aBoardFile << "BOTH";
break;
case LYR_INNER:
aBoardFile << "INNER";
break;
case LYR_ALL:
aBoardFile << "ALL";
break;
default:
ERROR_IDF << "Invalid IDF layer" << aLayer << "\n";
return false;
break;
}
return !aBoardFile.fail();
}
std::string IDF3::GetPlacementString( IDF3::IDF_PLACEMENT aPlacement )
{
switch( aPlacement )
{
case PS_UNPLACED:
return "UNPLACED";
case PS_PLACED:
return "PLACED";
case PS_MCAD:
return "MCAD";
case PS_ECAD:
return "ECAD";
default:
break;
}
std::ostringstream ostr;
ostr << "[INVALID PLACEMENT VALUE]:" << aPlacement;
return ostr.str();
}
std::string IDF3::GetLayerString( IDF3::IDF_LAYER aLayer )
{
switch( aLayer )
{
case LYR_TOP:
return "TOP";
case LYR_BOTTOM:
return "BOTTOM";
case LYR_BOTH:
return "BOTH";
case LYR_INNER:
return "INNER";
case LYR_ALL:
return "ALL";
default:
break;
}
std::ostringstream ostr;
ostr << "[INVALID LAYER VALUE]:" << aLayer;
return ostr.str();
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Cirilo Bernardo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef IDF_HELPERS_H
#define IDF_HELPERS_H
#include <wx/wx.h>
#include <fstream>
#include <string>
#include <idf_common.h>
/**
* Macro TO_UTF8
* converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
* wxstring is a wxString, not a wxT() or _(). The scope of the return value
* is very limited and volatile, but can be used with printf() style functions well.
* NOTE: Taken from KiCad include/macros.h
*/
#define TO_UTF8( wxstring ) ( (const char*) (wxstring).utf8_str() )
/**
* function FROM_UTF8
* converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
* NOTE: Taken from KiCad include/macros.h
*/
static inline wxString FROM_UTF8( const char* cstring )
{
wxString line = wxString::FromUTF8( cstring );
if( line.IsEmpty() ) // happens when cstring is not a valid UTF8 sequence
line = wxConvCurrent->cMB2WC( cstring ); // try to use locale conversion
return line;
}
#define ERROR_IDF std::cerr << "* " << __FILE__ << ":" << __LINE__ << ":" << __FUNCTION__ << "(): "
// minimum drill diameters / slot widths to be represented in the IDF output
#define IDF_MIN_DIA_MM ( 0.001 )
#define IDF_MIN_DIA_THOU ( 0.00039 )
// conversion between mm and thou
#define IDF_MM_TO_THOU 0.0254
namespace IDF3
{
/**
* Function FetchIDFLine
* retrieves a single line from an IDF file and performs minimal processing. If a comment symbol
* is encountered then it is removed and a single leading space is removed if present; all trailing
* spaces are removed. If the line is not a comment then all leading and trailing spaces are stripped.
*
* @param aModel is an open IDFv3 file
* @param aLine (output) is the line retrieved from the file
* @param isComment (output) is set to true if the line is a comment
* @param aFilePos (output) is set to the beginning of the line in case the file needs to be rewound
*
* @return bool: true if a line was read and was not empty; otherwise false
*/
bool FetchIDFLine( std::ifstream& aModel, std::string& aLine, bool& isComment, std::streampos& aFilePos );
/**
* Function GetIDFString
* parses a line retrieved via FetchIDFLine() and returns the first IDF string found from the starting
* point aIndex
*
* @param aLine is the line to parse
* @param aIDFString (output) is the IDF string retrieved
* @param hasQuotes (output) is true if the string was in quotation marks
* @param aIndex (input/output) is the index into the input line
*
* @return bool: true if a string was retrieved, otherwise false
*/
bool GetIDFString( const std::string& aLine, std::string& aIDFString,
bool& hasQuotes, int& aIndex );
/**
* Function CompareToken
* performs a case-insensitive comparison of a token string and an input string
*
* @param aToken is an IDF token such as ".HEADER"
* @param aInputString is a string typically retrieved via GetIDFString
*
* @return bool: true if the token and input string match
*/
bool CompareToken( const char* aTokenString, const std::string& aInputString );
/**
* Function ParseOwner
* parses the input string for a valid IDF Owner type
*
* @param aToken is the string to be parsed
* @param aOwner (output) is the IDF Owner class
*
* @return bool: true if a valid OWNER was found, otherwise false
*/
bool ParseOwner( const std::string& aToken, IDF3::KEY_OWNER& aOwner );
/**
* Function ParseIDFLayer
* parses an input string for a valid IDF layer specification
*
* @param aToken is the string to be parsed
* @param aLayer (output) is the IDF Layer type or group
*
* @return bool: true if a valid IDF Layer type was found, otherwise false
*/
bool ParseIDFLayer( const std::string& aToken, IDF3::IDF_LAYER& aLayer );
/**
* Function WriteLayersText
* writes out text corresponding to the given IDF Layer type
*
* @param aBoardFile is an IDFv3 file open for output
* @param aLayer is the IDF Layer type
*
* @return bool: true if the data was successfully written, otherwise false
*/
bool WriteLayersText( std::ofstream& aBoardFile, IDF3::IDF_LAYER aLayer );
/**
* Function GetPlacementString
* returns a string representing the given IDF Placement type
*
* @param aPlacement is the IDF placement type to encode as a string
*
* @return string: the string representation of aPlacement
*/
std::string GetPlacementString( IDF3::IDF_PLACEMENT aPlacement );
/**
* Function GetLayerString
* returns a string representing the given IDF Layer type
*
* @param aLayer is the IDF layer type to encode as a string
*
* @return string: the string representation of aLayer
*/
std::string GetLayerString( IDF3::IDF_LAYER aLayer );
}
#endif // IDF_HELPERS_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -98,7 +98,9 @@ int main( int argc, char **argv ) ...@@ -98,7 +98,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> width) && width >= 0.001 )
tstr >> width;
if( !tstr.fail() && width >= 0.001 )
ok = true; ok = true;
} }
...@@ -112,7 +114,9 @@ int main( int argc, char **argv ) ...@@ -112,7 +114,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> length) && length > 0.0 )
tstr >> length;
if( !tstr.fail() && length > 0.0 )
ok = true; ok = true;
} }
...@@ -126,7 +130,9 @@ int main( int argc, char **argv ) ...@@ -126,7 +130,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> height) && height >= 0.001 )
tstr >> height;
if( !tstr.fail() && height >= 0.001 )
ok = true; ok = true;
} }
...@@ -140,7 +146,9 @@ int main( int argc, char **argv ) ...@@ -140,7 +146,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> chamfer) && chamfer >= 0.0 )
tstr >> chamfer;
if( !tstr.fail() && chamfer >= 0.0 )
{ {
if( chamfer > width / 3.0 || chamfer > length / 3.0 ) if( chamfer > width / 3.0 || chamfer > length / 3.0 )
cout << "* WARNING: chamfer must be <= MIN( width, length )/3\n"; cout << "* WARNING: chamfer must be <= MIN( width, length )/3\n";
...@@ -182,7 +190,9 @@ int main( int argc, char **argv ) ...@@ -182,7 +190,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> wireDia) && wireDia >= 0.001 )
tstr >> wireDia;
if( !tstr.fail() && wireDia >= 0.001 )
{ {
if( wireDia >= length ) if( wireDia >= length )
cout << "* WARNING: wire diameter must be < length\n"; cout << "* WARNING: wire diameter must be < length\n";
...@@ -201,7 +211,9 @@ int main( int argc, char **argv ) ...@@ -201,7 +211,9 @@ int main( int argc, char **argv )
tstr.clear(); tstr.clear();
tstr.str( line ); tstr.str( line );
if( (tstr >> pitch) && pitch >= 0.001 )
tstr >> pitch;
if( !tstr.fail() && pitch >= 0.001 )
{ {
if( pitch <= ( length + wireDia ) / 2.0 ) if( pitch <= ( length + wireDia ) / 2.0 )
cout << "* WARNING: pitch must be > (length + wireDia)/2\n"; cout << "* WARNING: pitch must be > (length + wireDia)/2\n";
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment