761 NET* current_net =
nullptr;
764 auto parsePinToken = [](
const std::string& token,
NET_PIN&
pin ) ->
bool
766 size_t dot_pos = token.find(
'.' );
768 if( dot_pos == std::string::npos )
771 pin.ref_des = token.substr( 0, dot_pos );
772 pin.pin_name = token.substr( dot_pos + 1 );
778 auto expandShortcutPin = [](
const std::string& token ) -> std::vector<std::string>
780 std::vector<std::string> results;
783 if( token.find(
'{' ) == std::string::npos )
785 results.push_back( token );
796 bool is_range =
false;
799 std::vector<RangePart> parts;
801 std::string current_prefix;
803 while( pos < token.size() )
805 if( token[pos] ==
'{' )
807 size_t close_pos = token.find(
'}', pos );
809 if( close_pos == std::string::npos )
812 results.push_back( token );
816 std::string range_str = token.substr( pos + 1, close_pos - pos - 1 );
817 size_t dash_pos = range_str.find(
'-' );
819 if( dash_pos != std::string::npos )
822 part.prefix = current_prefix;
823 part.is_range =
true;
826 INT_MIN,
"net range" );
828 INT_MIN,
"net range" );
830 if( part.start == INT_MIN || part.end == INT_MIN )
832 results.push_back( token );
836 parts.push_back( part );
837 current_prefix.clear();
842 current_prefix += range_str;
849 current_prefix += token[pos];
855 if( !current_prefix.empty() || parts.empty() )
857 RangePart final_part;
858 final_part.prefix = current_prefix;
859 final_part.is_range =
false;
860 final_part.start = 0;
862 parts.push_back( final_part );
867 results.push_back(
"" );
869 for(
const auto& part : parts )
871 std::vector<std::string> new_results;
875 for(
const auto& base : results )
877 int step = ( part.start <= part.end ) ? 1 : -1;
879 for(
int i = part.start; step > 0 ? i <= part.end : i >= part.end; i += step )
881 new_results.push_back( base + part.prefix + std::to_string( i ) );
887 for(
const auto& base : results )
889 new_results.push_back( base + part.prefix );
893 results = std::move( new_results );
907 std::istringstream iss( line );
911 if( token ==
"SIGNAL" )
916 current_net = &
m_nets.back();
919 std::string pin_token;
921 while( iss >> pin_token )
924 if( pin_token ==
".REUSE." )
927 std::string instance, rsignal;
929 if( ( iss >> instance >> rsignal ) && !current_net->
pins.empty() )
931 current_net->
pins.back().reuse_instance = instance;
932 current_net->
pins.back().reuse_signal = rsignal;
939 for(
const auto& expanded : expandShortcutPin( pin_token ) )
943 if( parsePinToken( expanded,
pin ) )
944 current_net->
pins.push_back(
pin );
956 if( token ==
".REUSE." )
958 std::string instance, rsignal;
960 if( ( iss >> instance >> rsignal ) && !current_net->
pins.empty() )
962 current_net->
pins.back().reuse_instance = instance;
963 current_net->
pins.back().reuse_signal = rsignal;
970 for(
const auto& expanded : expandShortcutPin( token ) )
974 if( parsePinToken( expanded,
pin ) )
975 current_net->
pins.push_back(
pin );
978 }
while( iss >> token );
1229 if( line[0] ==
'*' )
1237 std::stringstream iss( line );
1238 std::string
name, type;
1239 double x = 0.0, y = 0.0;
1240 int pieces = 0, flags = 0;
1242 if( !( iss >>
name >> type >> x >> y >> pieces >> flags ) )
1245 std::string owner, signame;
1246 double hatchgrid = 0.0, hatchrad = 0.0;
1249 if( iss >> owner >> signame )
1251 iss >> hatchgrid >> hatchrad >> priority;
1254 for(
int i = 0; i < pieces; ++i )
1261 std::stringstream iss2( line );
1262 std::string poly_type;
1263 int corners = 0, arcs = 0;
1267 if( !( iss2 >> poly_type >> corners >> arcs >> width >> level ) )
1276 pour.
is_cutout = ( poly_type ==
"POCUT" || poly_type ==
"CUTOUT"
1277 || poly_type ==
"CIRCUT" );
1285 if( type ==
"HATOUT" )
1289 else if( type ==
"VOIDOUT" )
1294 else if( type ==
"PADTHERM" )
1298 else if( type ==
"VIATHERM" )
1304 if( poly_type ==
"CIRCLE" || poly_type ==
"CIRCUT" )
1308 std::vector<std::pair<double, double>> endpoints;
1310 for(
int j = 0; j < corners; ++j )
1315 std::stringstream iss3( line );
1316 double px = 0.0, py = 0.0;
1318 if( iss3 >> px >> py )
1319 endpoints.emplace_back( px, py );
1322 if( endpoints.size() == 2 )
1324 double cx = ( endpoints[0].first + endpoints[1].first ) / 2.0;
1325 double cy = ( endpoints[0].second + endpoints[1].second ) / 2.0;
1326 double radius = std::hypot( endpoints[1].first - endpoints[0].first,
1327 endpoints[1].second - endpoints[0].second ) / 2.0;
1334 arc.start_angle = 0.0;
1335 arc.delta_angle = 360.0;
1336 pour.
points.emplace_back( x + cx +
radius, y + cy, arc );
1339 else if( poly_type ==
"SEG" )
1342 for(
int j = 0; j < corners; ++j )
1347 std::stringstream iss3( line );
1348 double px = 0.0, py = 0.0;
1350 if( iss3 >> px >> py )
1352 pour.
points.emplace_back( x + px, y + py );
1364 int totalLines = corners + arcs;
1365 bool nextIsArcEndpoint =
false;
1368 for(
int j = 0; j < totalLines; ++j )
1373 std::stringstream iss3( line );
1374 double px = 0.0, py = 0.0;
1376 if( !( iss3 >> px >> py ) )
1379 int angle1 = 0, angle2 = 0;
1381 if( iss3 >> angle1 >> angle2 )
1387 pendingArc.
cx = x + px;
1388 pendingArc.cy = y + py;
1389 pendingArc.start_angle = angle1 / 10.0;
1390 pendingArc.delta_angle = angle2 / 10.0;
1392 if( !pour.
points.empty() )
1394 double dx = pour.
points.back().x - pendingArc.cx;
1395 double dy = pour.
points.back().y - pendingArc.cy;
1396 pendingArc.radius = std::sqrt( dx * dx + dy * dy );
1399 nextIsArcEndpoint =
true;
1401 else if( nextIsArcEndpoint )
1403 if( pendingArc.radius == 0.0 )
1405 double dx = ( x + px ) - pendingArc.cx;
1406 double dy = ( y + py ) - pendingArc.cy;
1407 pendingArc.radius = std::sqrt( dx * dx + dy * dy );
1410 pour.
points.emplace_back( x + px, y + py, pendingArc );
1411 nextIsArcEndpoint =
false;
1415 pour.
points.emplace_back( x + px, y + py );
1430 if( line[0] ==
'*' )
1437 std::stringstream iss( line );
1438 std::string
name, units;
1439 double orix = 0.0, oriy = 0.0;
1440 int pieces = 0, terminals = 0, stacks = 0, text_cnt = 0, labels = 0;
1442 if( !( iss >>
name >> units >> orix >> oriy >> pieces >> terminals >> stacks >> text_cnt >> labels ) )
1447 decal.
units = units;
1450 for(
int i = 0; i < pieces; ++i )
1452 if( !
readLine( aStream, line ) )
break;
1455 std::stringstream iss2( line );
1461 if( !( iss2 >> type >> corners >> width ) )
1494 decal.
items.push_back( item );
1500 if( type.find(
"COP" ) == 0 )
1502 std::string remaining;
1503 std::getline( iss2, remaining );
1506 std::istringstream rem_ss( remaining );
1507 int pinnum_val = -1;
1509 if( rem_ss >> pinnum_val )
1510 item.
pinnum = pinnum_val;
1514 if( type.find(
"KPT" ) == 0 )
1516 std::string restrictions;
1518 if( iss2 >> restrictions )
1522 for(
int j = 0; j < corners; ++j )
1527 std::stringstream iss3( line );
1528 double px = 0.0, py = 0.0;
1530 if( !( iss3 >> px >> py ) )
1536 int startAngleTenths = 0, deltaAngleTenths = 0;
1537 double bboxMinX = 0.0, bboxMinY = 0.0, bboxMaxX = 0.0, bboxMaxY = 0.0;
1539 if( iss3 >> startAngleTenths >> deltaAngleTenths
1540 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY )
1542 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
1543 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
1544 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
1545 double startAngle = startAngleTenths / 10.0;
1546 double deltaAngle = deltaAngleTenths / 10.0;
1549 double startAngleRad = startAngle *
M_PI / 180.0;
1550 double startX = cx +
radius * std::cos( startAngleRad );
1551 double startY = cy +
radius * std::sin( startAngleRad );
1554 double endAngleRad = ( startAngle + deltaAngle ) *
M_PI / 180.0;
1555 double endX = cx +
radius * std::cos( endAngleRad );
1556 double endY = cy +
radius * std::sin( endAngleRad );
1559 item.
points.emplace_back( startX, startY );
1565 arc.start_angle = startAngle;
1566 arc.delta_angle = deltaAngle;
1569 item.
points.emplace_back( endX, endY, arc );
1573 item.
points.emplace_back( px, py );
1577 decal.
items.push_back( item );
1584 for(
int i = 0; i < text_cnt + labels; ++i )
1586 std::string attrLine, fontLine, nameLine;
1588 if( !
readLine( aStream, attrLine ) )
1593 if( !
readLine( aStream, fontLine ) )
1597 if( !
readLine( aStream, nameLine ) )
1601 std::stringstream ss( attrLine );
1602 std::string type_token;
1605 std::string mirrored_str, right_reading_str;
1610 attr.
visible = ( type_token ==
"VALUE" || type_token ==
"FULL_NAME"
1611 || type_token ==
"NAME" || type_token ==
"FULL_BOTH"
1612 || type_token ==
"BOTH" );
1613 attr.
mirrored = ( mirrored_str ==
"M" );
1614 ss >> right_reading_str;
1615 attr.
right_reading = ( right_reading_str ==
"Y" || right_reading_str ==
"ORTHO" );
1619 attr.
name = nameLine;
1630 for(
int i = 0; i < terminals; ++i )
1632 if( !
readLine( aStream, line ) )
break;
1634 size_t t_pos = line.find(
'T' );
1636 if( t_pos != std::string::npos )
1639 std::stringstream iss_t( line );
1641 double nmx = 0.0, nmy = 0.0;
1643 if( iss_t >> term.
x >> term.
y >> nmx >> nmy )
1647 if( term.
name.empty() )
1648 term.
name = std::to_string( i + 1 );
1658 for(
int i = 0; i < stacks; ++i )
1663 std::stringstream iss_pad( line );
1666 int stack_lines = 0;
1667 iss_pad >> token >> pin_idx >> stack_lines;
1669 if( token !=
"PAD" )
1673 std::string plated_token;
1674 bool default_plated =
true;
1675 double header_drill = 0.0;
1677 if( iss_pad >> plated_token )
1679 if( plated_token ==
"P" )
1680 default_plated =
true;
1681 else if( plated_token ==
"N" )
1682 default_plated =
false;
1690 double header_slot_ori = 0.0;
1691 double header_slot_len = 0.0;
1692 double header_slot_off = 0.0;
1694 if( iss_pad >> header_slot_ori >> header_slot_len >> header_slot_off )
1699 std::vector<PAD_STACK_LAYER> stack;
1701 for(
int j = 0; j < stack_lines; ++j )
1706 std::stringstream line_ss( line );
1712 if( !( line_ss >> layer >> size >> shape ) )
1716 layer_data.
layer = layer;
1717 layer_data.
sizeA = size;
1718 layer_data.
sizeB = size;
1719 layer_data.
shape = shape;
1720 layer_data.
plated = default_plated;
1721 layer_data.
drill = header_drill;
1732 else if( shape ==
"S" )
1736 double corner = 0.0;
1738 if( line_ss >> corner )
1751 else if( shape ==
"RA" || shape ==
"SA" )
1756 else if( shape ==
"A" )
1761 if( line_ss >> intd )
1764 else if( shape ==
"OF" )
1767 double ori = 0.0, length = 0.0, offset = 0.0;
1769 if( line_ss >> ori >> length >> offset )
1772 layer_data.
sizeB = length;
1776 else if( shape ==
"RF" )
1780 double ori = 0.0, length = 0.0, offset = 0.0;
1782 if( line_ss >> ori >> length >> offset )
1785 layer_data.
sizeB = length;
1788 double corner = 0.0;
1790 if( line_ss >> corner )
1804 else if( shape ==
"RT" || shape ==
"ST" )
1807 double ori = 0.0, outsize = 0.0, spkwid = 0.0;
1810 if( line_ss >> ori >> outsize >> spkwid >> spknum )
1818 else if( shape ==
"O" || shape ==
"OC" )
1824 else if( shape ==
"RC" )
1828 double ori = 0.0, length = 0.0, offset = 0.0, corner = 0.0;
1830 if( line_ss >> ori >> length >> offset )
1833 layer_data.
sizeB = length;
1836 if( line_ss >> corner )
1853 std::vector<std::string> remaining;
1854 std::string token_rem;
1856 while( line_ss >> token_rem )
1857 remaining.push_back( token_rem );
1860 if( !remaining.empty() )
1866 -1.0,
"pad layer drill" );
1868 if( drill_val >= 0.0 )
1870 layer_data.
drill = drill_val;
1875 if( idx < remaining.size() )
1877 if( remaining[idx] ==
"P" || remaining[idx] ==
"Y" )
1879 layer_data.
plated =
true;
1882 else if( remaining[idx] ==
"N" )
1884 layer_data.
plated =
false;
1890 if( idx + 2 < remaining.size() )
1901 stack.push_back( layer_data );
1914 ROUTE* current_route =
nullptr;
1915 TRACK current_track;
1916 bool in_track =
false;
1917 bool prev_is_plane_connection =
false;
1919 int last_plane_connection_layer = 0;
1920 double last_plane_connection_width = 0;
1921 bool last_plane_on_copper =
false;
1922 std::string default_via_name;
1923 bool has_pending_arc_center =
false;
1925 std::string pending_arc_dir;
1929 if( line[0] ==
'*' )
1931 if( line.rfind(
"*SIGNAL*", 0 ) == 0 )
1933 if( in_track && current_route )
1935 current_route->
tracks.push_back( current_track );
1936 current_track.
points.clear();
1940 prev_is_plane_connection =
false;
1941 has_pending_arc_center =
false;
1943 std::istringstream iss( line );
1947 std::string net_name;
1951 default_via_name.clear();
1953 while( iss >> token )
1955 if( !token.empty() && token.back() ==
';' )
1959 default_via_name = token;
1964 current_route->
net_name = net_name;
1975 if( !isdigit( line[0] ) && line[0] !=
'-' && line[0] !=
'+' )
1977 if( in_track && current_route )
1979 current_route->
tracks.push_back( current_track );
1980 current_track.
points.clear();
1984 prev_is_plane_connection =
false;
1989 std::istringstream pin_iss( line );
1990 std::string pin_token;
1992 while( pin_iss >> pin_token )
1994 size_t dot_pos = pin_token.find(
'.' );
1996 if( dot_pos != std::string::npos )
1999 pin.ref_des = pin_token.substr( 0, dot_pos );
2000 pin.pin_name = pin_token.substr( dot_pos + 1 );
2005 for(
const auto& existing : current_route->
pins )
2007 if( existing.ref_des ==
pin.ref_des &&
2008 existing.pin_name ==
pin.pin_name )
2016 current_route->
pins.push_back(
pin );
2024 std::istringstream iss( line );
2029 iss >> pt.
x >> pt.
y >> layer >> width >> flags;
2041 std::string via_name;
2042 std::string arc_dir;
2048 bool is_unrouted = ( layer == 0 );
2049 bool is_plane_connection = is_unrouted;
2052 bool has_teardrop =
false;
2053 bool has_jumper =
false;
2054 bool has_power =
false;
2056 while( iss >> token )
2059 if( token ==
"CW" || token ==
"CCW" )
2068 if( token ==
"POWER" )
2078 if( token ==
"THERMAL" )
2089 if( token ==
"TEARDROP" )
2091 has_teardrop =
true;
2092 std::string td_token;
2094 while( iss >> td_token )
2096 if( td_token ==
"P" )
2102 std::streampos pos = iss.tellg();
2105 if( iss >> td_flags )
2115 else if( td_token ==
"N" )
2120 std::streampos pos = iss.tellg();
2123 if( iss >> td_flags )
2137 if( td_token ==
"CW" || td_token ==
"CCW" )
2139 else if( td_token ==
"POWER" )
2144 via_name = td_token;
2146 else if( td_token ==
"THERMAL" )
2149 via_name = td_token;
2160 std::streampos pos = iss.tellg();
2161 std::string jumper_flag;
2163 if( iss >> jumper_flag )
2165 if( jumper_flag ==
"S" || jumper_flag ==
"E" )
2168 jumper.
name = token;
2169 jumper.
is_start = ( jumper_flag ==
"S" );
2188 if( token ==
"REUSE" || token ==
".REUSE." )
2191 std::string instance;
2201 if( !arc_dir.empty() )
2203 pending_arc_center = pt;
2204 pending_arc_dir = arc_dir;
2205 has_pending_arc_center =
true;
2209 if( has_pending_arc_center )
2211 has_pending_arc_center =
false;
2213 if( in_track && !current_track.
points.empty() )
2216 double dx0 = arc_start.
x - pending_arc_center.
x;
2217 double dy0 = arc_start.
y - pending_arc_center.
y;
2218 double start_angle = std::atan2( dy0, dx0 );
2220 std::atan2( pt.
y - pending_arc_center.
y, pt.
x - pending_arc_center.
x );
2221 double sweep = end_angle - start_angle;
2225 if( pending_arc_dir ==
"CCW" )
2227 while(
sweep <= 0.0 )
2232 while(
sweep >= 0.0 )
2237 pt.
arc.
cx = pending_arc_center.
x;
2238 pt.
arc.
cy = pending_arc_center.
y;
2239 pt.
arc.
radius = std::sqrt( dx0 * dx0 + dy0 * dy0 );
2249 int effective_layer = layer;
2250 bool is_pad_connection = ( layer == 65 );
2254 if( is_unrouted && in_track )
2255 effective_layer = current_track.
layer;
2260 if( !via_name.empty() && current_route )
2263 via.name = via_name;
2264 via.location = { pt.
x, pt.
y };
2265 current_route->
vias.push_back(
via );
2273 if( has_power && via_name.empty() && !is_unrouted && !is_pad_connection && current_route )
2277 if( !default_via_name.empty() )
2278 implicit_via.
name = default_via_name;
2283 current_route->
vias.push_back( implicit_via );
2287 if( has_teardrop && current_route )
2289 current_route->
teardrops.push_back( teardrop );
2293 if( has_jumper && current_route )
2295 current_route->
jumpers.push_back( jumper );
2301 if( is_plane_connection && prev_is_plane_connection )
2310 last_plane_connection_pt = pt;
2311 last_plane_connection_layer = effective_layer;
2312 last_plane_connection_width = width;
2313 last_plane_on_copper =
true;
2316 prev_is_plane_connection =
true;
2320 if( is_plane_connection && !prev_is_plane_connection )
2326 current_track.
points.push_back( pt );
2328 if( current_route && current_track.
points.size() > 1 )
2329 current_route->
tracks.push_back( current_track );
2331 current_track.
points.clear();
2338 last_plane_on_copper = !is_unrouted;
2340 if( last_plane_on_copper )
2342 last_plane_connection_pt = pt;
2343 last_plane_connection_layer = effective_layer;
2344 last_plane_connection_width = width;
2347 prev_is_plane_connection =
true;
2351 if( !is_plane_connection && prev_is_plane_connection )
2355 if( in_track && current_route && current_track.
points.size() > 1 )
2356 current_route->
tracks.push_back( current_track );
2358 prev_is_plane_connection =
false;
2360 if( is_pad_connection )
2366 current_track.
points.clear();
2368 if( last_plane_on_copper && last_plane_connection_layer == effective_layer )
2370 current_track.
layer = effective_layer;
2371 current_track.
width = std::max( width, last_plane_connection_width );
2372 current_track.
points.push_back( last_plane_connection_pt );
2373 current_track.
points.push_back( pt );
2379 if( !has_power && via_name.empty() && current_route && last_plane_on_copper &&
2380 std::abs( pt.
x - last_plane_connection_pt.
x ) < 0.001 &&
2381 std::abs( pt.
y - last_plane_connection_pt.
y ) < 0.001 )
2385 if( !default_via_name.empty() )
2386 implicit_via.
name = default_via_name;
2391 current_route->
vias.push_back( implicit_via );
2394 current_track.
layer = effective_layer;
2395 current_track.
width = width;
2396 current_track.
points.push_back( pt );
2399 last_plane_on_copper =
false;
2406 if( is_pad_connection )
2408 if( in_track && !current_track.
points.empty() )
2410 current_track.
points.push_back( pt );
2412 if( current_route && current_track.
points.size() > 1 )
2413 current_route->
tracks.push_back( current_track );
2415 current_track.
points.clear();
2423 prev_is_plane_connection =
false;
2427 current_track.
layer = effective_layer;
2428 current_track.
width = width;
2429 current_track.
points.clear();
2430 current_track.
points.push_back( pt );
2435 bool layer_changed = ( effective_layer != current_track.
layer );
2436 bool width_changed = (
std::abs( width - current_track.
width ) > 0.001 );
2438 if( layer_changed || width_changed )
2441 bool connect =
true;
2443 if( layer_changed && via_name.empty() )
2445 bool same_location =
2446 ( pt.
x == current_track.
points.back().x &&
2447 pt.
y == current_track.
points.back().y );
2453 if( !has_power && current_route )
2457 default_via_name.empty() ?
"STANDARDVIA" : default_via_name;
2459 current_route->
vias.push_back( implicit_via );
2462 else if( !has_power )
2472 current_track.
points.push_back( pt );
2476 current_route->
tracks.push_back( current_track );
2481 current_track.
layer = effective_layer;
2482 current_track.
width = width;
2483 current_track.
points.clear();
2484 current_track.
points.push_back( prev_pt );
2488 current_track.
points.push_back( pt );
2493 if( in_track && current_route )
2495 current_route->
tracks.push_back( current_track );
2639 if( line[0] ==
'*' )
2645 std::istringstream iss( line );
2646 std::string
name, type;
2647 double xloc = 0.0, yloc = 0.0;
2649 iss >>
name >> type >> xloc >> yloc >> pieces;
2652 for(
int i = 0; i < pieces; ++i )
2657 if( line[0] ==
'*' )
2663 std::istringstream piss( line );
2664 std::string shape_type;
2667 int linestyle = 0, level = 0;
2668 piss >> shape_type >> corners >> width >> linestyle >> level;
2671 if( shape_type ==
"CLOSED" || shape_type ==
"OPEN" || shape_type ==
"BRDCLS" )
2675 polyline.
width = width;
2676 polyline.
closed = ( shape_type ==
"CLOSED" || shape_type ==
"BRDCLS" );
2678 for(
int j = 0; j < corners; ++j )
2683 if( line[0] ==
'*' )
2689 std::istringstream ciss( line );
2690 double dx = 0.0, dy = 0.0;
2695 int startAngleTenths = 0, deltaAngleTenths = 0;
2696 double bboxMinX = 0.0, bboxMinY = 0.0, bboxMaxX = 0.0, bboxMaxY = 0.0;
2698 if( ciss >> startAngleTenths >> deltaAngleTenths
2699 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY )
2701 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
2702 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
2703 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
2704 double startAngle = startAngleTenths / 10.0;
2705 double deltaAngle = deltaAngleTenths / 10.0;
2707 double startAngleRad = startAngle *
M_PI / 180.0;
2708 double startX = cx +
radius * std::cos( startAngleRad );
2709 double startY = cy +
radius * std::sin( startAngleRad );
2711 double endAngleRad = ( startAngle + deltaAngle ) *
M_PI / 180.0;
2712 double endX = cx +
radius * std::cos( endAngleRad );
2713 double endY = cy +
radius * std::sin( endAngleRad );
2715 polyline.
points.emplace_back( xloc + startX, yloc + startY );
2721 arc.start_angle = startAngle;
2722 arc.delta_angle = deltaAngle;
2724 polyline.
points.emplace_back( xloc + endX, yloc + endY, arc );
2728 polyline.
points.emplace_back( xloc + dx, yloc + dy );
2732 if( !polyline.
points.empty() )
2735 else if( shape_type ==
"CIRCLE" || shape_type ==
"BRDCIR" )
2740 polyline.
width = width;
2743 double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
2747 std::istringstream c1( line );
2751 if( corners >= 2 &&
readLine( aStream, line ) )
2753 std::istringstream c2( line );
2758 double cx = xloc + ( x1 + x2 ) / 2.0;
2759 double cy = yloc + ( y1 + y2 ) / 2.0;
2760 double radius = std::sqrt( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) / 2.0;
2767 arc.start_angle = 0.0;
2768 arc.delta_angle = 360.0;
2772 if( !polyline.
points.empty() )
2778 for(
int j = 0; j < corners; ++j )
2783 if( line[0] ==
'*' )
2800 if( line[0] ==
'*' )
2810 std::istringstream iss( line );
2811 std::string
name, type;
2812 double xloc = 0.0, yloc = 0.0;
2813 int pieces = 0, flags = 0, textCount = 0;
2814 std::string seventhToken, eighthToken;
2815 std::string signame;
2817 iss >>
name >> type >> xloc >> yloc >> pieces >> flags >> seventhToken >> eighthToken;
2819 if( !eighthToken.empty() )
2823 signame = eighthToken;
2825 std::istringstream tiss( seventhToken );
2828 else if( !seventhToken.empty() )
2836 if( std::all_of( seventhToken.begin(), seventhToken.end(),
2839 return std::isdigit( c );
2842 std::istringstream tiss( seventhToken );
2847 signame = seventhToken;
2852 std::string reuse_instance, reuse_signal;
2856 if( line.find(
".REUSE." ) != std::string::npos )
2858 std::istringstream riss( line );
2859 std::string reuse_keyword;
2860 riss >> reuse_keyword >> reuse_instance >> reuse_signal;
2868 if( type ==
"BOARD" )
2870 for(
int i=0; i<pieces; ++i )
2872 if( !
readLine( aStream, line ) )
break;
2875 std::istringstream piss( line );
2876 std::string shape_type;
2879 int piece_flags = 0;
2881 piss >> shape_type >> corners >> width >> piece_flags >> level;
2883 if( shape_type ==
"CLOSED" || shape_type ==
"OPEN" || shape_type ==
"BRDCLS" )
2887 polyline.
width = width;
2888 polyline.
closed = ( shape_type ==
"CLOSED" || shape_type ==
"BRDCLS" );
2890 for(
int j = 0; j < corners; ++j )
2895 if( line[0] ==
'*' )
2901 std::istringstream ciss( line );
2902 double dx = 0.0, dy = 0.0;
2907 int startAngleTenths = 0, deltaAngleTenths = 0;
2908 double bboxMinX = 0.0, bboxMinY = 0.0, bboxMaxX = 0.0, bboxMaxY = 0.0;
2910 if( ciss >> startAngleTenths >> deltaAngleTenths
2911 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY )
2913 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
2914 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
2915 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
2916 double startAngle = startAngleTenths / 10.0;
2917 double deltaAngle = deltaAngleTenths / 10.0;
2919 double startAngleRad = startAngle *
M_PI / 180.0;
2920 double startX = cx +
radius * std::cos( startAngleRad );
2921 double startY = cy +
radius * std::sin( startAngleRad );
2923 double endAngleRad = ( startAngle + deltaAngle ) *
M_PI / 180.0;
2924 double endX = cx +
radius * std::cos( endAngleRad );
2925 double endY = cy +
radius * std::sin( endAngleRad );
2927 polyline.
points.emplace_back( xloc + startX, yloc + startY );
2933 arc.start_angle = startAngle;
2934 arc.delta_angle = deltaAngle;
2936 polyline.
points.emplace_back( xloc + endX, yloc + endY, arc );
2940 polyline.
points.emplace_back( xloc + dx, yloc + dy );
2944 if( !polyline.
points.empty() )
2947 else if( shape_type ==
"CIRCLE" || shape_type ==
"BRDCIR" )
2950 double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
2954 std::istringstream c1( line );
2958 if( corners >= 2 &&
readLine( aStream, line ) )
2960 std::istringstream c2( line );
2964 double cx = xloc + ( x1 + x2 ) / 2.0;
2965 double cy = yloc + ( y1 + y2 ) / 2.0;
2966 double radius = std::sqrt( ( x2 - x1 ) * ( x2 - x1 ) +
2967 ( y2 - y1 ) * ( y2 - y1 ) ) / 2.0;
2971 polyline.
width = width;
2978 arc.start_angle = 0.0;
2979 arc.delta_angle = 360.0;
2983 if( !polyline.
points.empty() )
2988 for(
int j=0; j<corners; ++j )
2990 if( !
readLine( aStream, line ) )
break;
2996 else if(
name.rfind(
"DIM", 0 ) == 0 && type ==
"LINES" )
3016 double baspnt1_x = 0, baspnt1_y = 0;
3017 double baspnt2_x = 0, baspnt2_y = 0;
3018 double arwln_x = 0, arwln_y = 0;
3019 int baspnt_count = 0;
3020 bool hasArwln =
false;
3022 for(
int i = 0; i < pieces; ++i )
3027 if( line[0] ==
'*' )
3033 std::istringstream piss( line );
3034 std::string shape_type;
3037 int piece_flags = 0;
3039 piss >> shape_type >> corners >> width >> piece_flags >> level;
3043 for(
int j = 0; j < corners; ++j )
3048 if( line[0] ==
'*' )
3054 std::istringstream ciss( line );
3055 double dx = 0.0, dy = 0.0;
3060 if( shape_type ==
"BASPNT" && j == 0 )
3062 if( baspnt_count == 0 )
3064 baspnt1_x = xloc + dx;
3065 baspnt1_y = yloc + dy;
3067 else if( baspnt_count == 1 )
3069 baspnt2_x = xloc + dx;
3070 baspnt2_y = yloc + dy;
3077 if( shape_type ==
"ARWLN1" && j == 0 )
3079 arwln_x = xloc + dx;
3080 arwln_y = yloc + dy;
3087 if( baspnt_count >= 2 )
3091 double dx =
std::abs( baspnt2_x - baspnt1_x );
3092 double dy =
std::abs( baspnt2_y - baspnt1_y );
3093 bool isHorizontal = dx > dy;
3112 dim.
points.push_back( pt1 );
3113 dim.
points.push_back( pt2 );
3118 for(
int t = 0; t < textCount; ++t )
3123 if( line[0] ==
'*' )
3129 std::istringstream tiss( line );
3130 double tx = 0.0, ty = 0.0;
3137 for(
int s = 0; s < skipLines; ++s )
3145 double theight = 0.0, twidth = 0.0;
3146 tiss >> trot >> tlayer >> theight >> twidth;
3169 if( !dim.
points.empty() )
3172 else if( type ==
"KEEPOUT" || type ==
"RESTRICTVIA" || type ==
"RESTRICTROUTE"
3173 || type ==
"RESTRICTAREA" || type ==
"PLACEMENT_KEEPOUT" )
3179 if( type ==
"KEEPOUT" || type ==
"RESTRICTAREA" )
3186 else if( type ==
"RESTRICTVIA" )
3193 else if( type ==
"RESTRICTROUTE" )
3200 else if( type ==
"PLACEMENT_KEEPOUT" )
3209 for(
int i = 0; i < pieces; ++i )
3214 if( line[0] ==
'*' )
3222 std::istringstream piss( line );
3223 std::string shape_type;
3226 int piece_flags = 0;
3228 std::string restrictions;
3229 piss >> shape_type >> corners >> width >> piece_flags >> level >> restrictions;
3232 keepout.
layers.push_back( level );
3238 if( !restrictions.empty() )
3241 bool has_restriction_codes =
false;
3243 for(
char c : restrictions )
3245 if( std::isalpha( c ) )
3247 has_restriction_codes =
true;
3252 if( has_restriction_codes )
3263 for(
char c : restrictions )
3304 if( shape_type ==
"KPTCIR" )
3307 double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
3311 std::istringstream c1( line );
3315 if( corners >= 2 &&
readLine( aStream, line ) )
3317 std::istringstream c2( line );
3322 double cx = xloc + ( x1 + x2 ) / 2.0;
3323 double cy = yloc + ( y1 + y2 ) / 2.0;
3324 double radius = std::sqrt( ( x2 - x1 ) * ( x2 - x1 ) +
3325 ( y2 - y1 ) * ( y2 - y1 ) ) / 2.0;
3332 arc.start_angle = 0.0;
3333 arc.delta_angle = 360.0;
3340 for(
int j = 0; j < corners; ++j )
3345 if( line[0] ==
'*' )
3351 std::istringstream ciss( line );
3352 double dx = 0.0, dy = 0.0;
3357 int startAngleTenths = 0, deltaAngleTenths = 0;
3358 double bboxMinX = 0.0, bboxMinY = 0.0, bboxMaxX = 0.0, bboxMaxY = 0.0;
3360 if( ciss >> startAngleTenths >> deltaAngleTenths
3361 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY )
3363 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
3364 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
3365 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
3366 double startAngle = startAngleTenths / 10.0;
3367 double deltaAngle = deltaAngleTenths / 10.0;
3369 double startAngleRad = startAngle *
M_PI / 180.0;
3370 double startX = cx +
radius * std::cos( startAngleRad );
3371 double startY = cy +
radius * std::sin( startAngleRad );
3373 double endAngleRad = ( startAngle + deltaAngle ) *
M_PI / 180.0;
3374 double endX = cx +
radius * std::cos( endAngleRad );
3375 double endY = cy +
radius * std::sin( endAngleRad );
3377 keepout.
outline.emplace_back( xloc + startX, yloc + startY );
3383 arc.start_angle = startAngle;
3384 arc.delta_angle = deltaAngle;
3386 keepout.
outline.emplace_back( xloc + endX, yloc + endY, arc );
3390 keepout.
outline.emplace_back( xloc + dx, yloc + dy );
3396 if( !keepout.
outline.empty() )
3399 else if( type ==
"COPPER" || type ==
"COPCUT" )
3405 for(
int i = 0; i < pieces; ++i )
3410 if( line[0] ==
'*' )
3419 std::istringstream piss( line );
3420 std::string shape_type;
3423 int piece_flags = 0;
3425 piss >> shape_type >> corners >> width >> piece_flags >> level;
3429 copper.
layer = level;
3430 copper.
width = width;
3433 copper.
filled = ( shape_type ==
"COPCLS" || shape_type ==
"COPCIR" );
3434 copper.
is_cutout = ( shape_type ==
"COPCUT" || shape_type ==
"COPCCO" ||
3435 shape_type ==
"CIRCUR" || type ==
"COPCUT" );
3438 if( shape_type ==
"COPCIR" || shape_type ==
"COPCCO" || shape_type ==
"CIRCUR" )
3441 double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
3445 std::istringstream c1( line );
3449 if( corners >= 2 &&
readLine( aStream, line ) )
3451 std::istringstream c2( line );
3455 double cx = xloc + ( x1 + x2 ) / 2.0;
3456 double cy = yloc + ( y1 + y2 ) / 2.0;
3457 double radius = std::sqrt( ( x2 - x1 ) * ( x2 - x1 ) +
3458 ( y2 - y1 ) * ( y2 - y1 ) ) / 2.0;
3464 arc.start_angle = 0.0;
3465 arc.delta_angle = 360.0;
3472 for(
int j = 0; j < corners; ++j )
3477 if( line[0] ==
'*' )
3483 std::istringstream ciss( line );
3484 double dx = 0.0, dy = 0.0;
3489 int startAngleTenths = 0, deltaAngleTenths = 0;
3490 double bboxMinX = 0.0, bboxMinY = 0.0, bboxMaxX = 0.0, bboxMaxY = 0.0;
3492 if( ciss >> startAngleTenths >> deltaAngleTenths
3493 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY )
3495 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
3496 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
3497 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
3498 double startAngle = startAngleTenths / 10.0;
3499 double deltaAngle = deltaAngleTenths / 10.0;
3501 double startAngleRad = startAngle *
M_PI / 180.0;
3502 double startX = cx +
radius * std::cos( startAngleRad );
3503 double startY = cy +
radius * std::sin( startAngleRad );
3505 double endAngleRad = ( startAngle + deltaAngle ) *
M_PI / 180.0;
3506 double endX = cx +
radius * std::cos( endAngleRad );
3507 double endY = cy +
radius * std::sin( endAngleRad );
3509 copper.
outline.emplace_back( xloc + startX, yloc + startY );
3515 arc.start_angle = startAngle;
3516 arc.delta_angle = deltaAngle;
3518 copper.
outline.emplace_back( xloc + endX, yloc + endY, arc );
3522 copper.
outline.emplace_back( xloc + dx, yloc + dy );
3531 else if( type ==
"LINES" )
3534 for(
int i = 0; i < pieces; ++i )
3539 if( line[0] ==
'*' )
3546 std::istringstream piss( line );
3547 std::string shape_type;
3550 int piece_flags = 0;
3552 piss >> shape_type >> corners >> width >> piece_flags >> level;
3556 graphic.
layer = level;
3557 graphic.
width = width;
3561 graphic.
closed = ( shape_type ==
"CLOSED" || shape_type ==
"CIRCLE" );
3563 if( shape_type ==
"CIRCLE" )
3566 double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
3570 std::istringstream c1( line );
3574 if( corners >= 2 &&
readLine( aStream, line ) )
3576 std::istringstream c2( line );
3580 double cx = xloc + ( x1 + x2 ) / 2.0;
3581 double cy = yloc + ( y1 + y2 ) / 2.0;
3582 double radius = std::sqrt( ( x2 - x1 ) * ( x2 - x1 ) +
3583 ( y2 - y1 ) * ( y2 - y1 ) ) / 2.0;
3589 arc.start_angle = 0.0;
3590 arc.delta_angle = 360.0;
3597 for(
int j = 0; j < corners; ++j )
3602 if( line[0] ==
'*' )
3608 std::istringstream ciss( line );
3609 double dx = 0.0, dy = 0.0;
3613 int startAngleTenths = 0, deltaAngleTenths = 0;
3614 double bboxMinX = 0.0, bboxMinY = 0.0, bboxMaxX = 0.0, bboxMaxY = 0.0;
3616 if( ciss >> startAngleTenths >> deltaAngleTenths
3617 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY )
3619 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
3620 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
3621 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
3622 double startAngle = startAngleTenths / 10.0;
3623 double deltaAngle = deltaAngleTenths / 10.0;
3625 double startAngleRad = startAngle *
M_PI / 180.0;
3626 double startX = cx +
radius * std::cos( startAngleRad );
3627 double startY = cy +
radius * std::sin( startAngleRad );
3629 double endAngleRad = ( startAngle + deltaAngle ) *
M_PI / 180.0;
3630 double endX = cx +
radius * std::cos( endAngleRad );
3631 double endY = cy +
radius * std::sin( endAngleRad );
3633 graphic.
points.emplace_back( xloc + startX, yloc + startY );
3639 arc.start_angle = startAngle;
3640 arc.delta_angle = deltaAngle;
3642 graphic.
points.emplace_back( xloc + endX, yloc + endY, arc );
3646 graphic.
points.emplace_back( xloc + dx, yloc + dy );
3651 if( !graphic.
points.empty() )
3658 for(
int i = 0; i < pieces; ++i )
3663 if( line[0] ==
'*' )
3669 std::istringstream piss( line );
3670 std::string shape_type;
3672 piss >> shape_type >> corners;
3674 for(
int j = 0; j < corners; ++j )
3679 if( line[0] ==
'*' )
3691 for(
int t = 0; t < textCount; ++t )
3696 if( line[0] ==
'*' )
3702 std::istringstream tiss( line );
3712 for(
int s = 0; s < skipLines; ++s )
3718 text.location.x += xloc;
3719 text.location.y += yloc;
3721 std::string mirrored;
3723 text.mirrored = ( mirrored ==
"M" );
3731 if( line[0] ==
'*' )
3737 size_t bracket_start = line.find(
'<' );
3738 size_t bracket_end = line.find(
'>' );
3740 if( bracket_start != std::string::npos && bracket_end != std::string::npos )
3743 line.substr( bracket_start + 1, bracket_end - bracket_start - 1 );
3746 std::istringstream fiss( line );
3747 std::string font_style_part;
3748 fiss >> font_style_part;
3750 size_t colon_pos = font_style_part.find(
':' );
3752 if( colon_pos != std::string::npos )
3753 text.font_style = font_style_part.substr( 0, colon_pos );
3755 text.font_style = font_style_part;
3762 if( line[0] ==
'*' )
3768 text.content = line;
3782 int pendingGates = 0;
3783 int pendingGatePins = 0;
3784 int pendingSigPins = 0;
3785 int pendingUnusedPins = 0;
3803 auto isInteger = [](
const std::string& aToken ) ->
bool
3805 return !aToken.empty() && aToken.find_first_not_of(
"0123456789" ) == std::string::npos;
3808 auto tokenize = [](
const std::string& aLine ) -> std::vector<std::string>
3810 std::istringstream lss( aLine );
3811 std::vector<std::string> tokens;
3814 while( lss >> token )
3815 tokens.push_back( token );
3822 if( line[0] ==
'*' )
3829 if( line[0] ==
'{' && currentPartType )
3833 if( line[0] ==
'}' )
3836 if( line[0] ==
'*' )
3842 std::string attrName, attrValue;
3844 if( line[0] ==
'"' )
3846 size_t endQuote = line.find(
'"', 1 );
3848 if( endQuote != std::string::npos )
3850 attrName = line.substr( 1, endQuote - 1 );
3851 attrValue = line.substr( endQuote + 1 );
3856 std::istringstream attrSS( line );
3858 std::getline( attrSS >> std::ws, attrValue );
3861 if( !attrValue.empty() && attrValue[0] ==
' ' )
3862 attrValue = attrValue.substr( 1 );
3864 if( !attrName.empty() && !attrValue.empty() )
3865 currentPartType->
attributes[attrName] = attrValue;
3871 if( line[0] ==
'{' || line[0] ==
'}' )
3874 std::vector<std::string> tokens = tokenize( line );
3876 if( tokens.empty() )
3880 if( pendingGatePins > 0 )
3882 for(
const std::string& token : tokens )
3884 if( pendingGatePins == 0 )
3890 std::vector<std::string> parts;
3894 while( ( pos = token.find(
'.', start ) ) != std::string::npos )
3896 parts.push_back( token.substr( start, pos - start ) );
3900 parts.push_back( token.substr( start ) );
3902 if( parts.size() < 3 )
3908 bool isNumericSecond = isInteger( parts[1] );
3910 if( currentGate && parts[2].size() == 1 && !isNumericSecond )
3916 if( !parts[2].
empty() )
3917 gpin.
elec_type = parsePinElecType( parts[2][0] );
3919 if( parts.size() >= 4 )
3922 currentGate->
pins.push_back( gpin );
3924 else if( isNumericSecond )
3938 if( pendingGates == 0 && pendingSigPins == 0 && pendingUnusedPins > 0 )
3940 pendingUnusedPins -= std::min<int>( pendingUnusedPins, tokens.size() );
3945 if( currentPartType && tokens.size() >= 3 && tokens[0] ==
"G" && isInteger( tokens[1] )
3946 && isInteger( tokens[2] ) )
3950 currentPartType->
gates.push_back( gate );
3951 currentGate = ¤tPartType->
gates.back();
3955 if( pendingGates > 0 )
3962 if( currentPartType && tokens[0] ==
"SIGPIN" )
3964 std::istringstream sss( line );
3965 std::string keyword;
3973 if( pendingSigPins > 0 )
3982 pt.
name = tokens[0];
3984 if( tokens.size() > 1 )
3989 currentGate =
nullptr;
3992 pendingGatePins = 0;
3994 pendingUnusedPins = 0;
3996 for(
size_t ii = 2; ii < tokens.size(); ++ii )
3998 if( !isInteger( tokens[ii] ) )
4003 if( ii + 1 < tokens.size() && isInteger( tokens[ii + 1] ) )
4006 if( ii + 2 < tokens.size() && isInteger( tokens[ii + 2] ) )
4655 bool inDifPair =
false;
4656 bool inNetClassData =
false;
4657 bool inNetClass =
false;
4658 bool inRuleSet =
false;
4659 bool inRuleSetFor =
false;
4660 bool inClearanceRule =
false;
4661 int netClassDataDepth = -1;
4662 int netClassDepth = -1;
4663 int ruleSetDepth = -1;
4664 int clearanceRuleDepth = -1;
4665 bool foundDefaultRules =
false;
4666 bool isDefaultRuleSet =
false;
4667 std::string ruleSetNetClass;
4677 if( line[0] ==
'*' && braceDepth == 0 )
4684 for(
char c : line )
4692 if( braceDepth == 0 && inDifPair )
4695 if( !currentDiffPair.
name.empty() )
4702 if( inNetClass && braceDepth <= netClassDepth )
4704 if( !currentNetClass.
name.empty() )
4711 if( inNetClassData && braceDepth <= netClassDataDepth )
4713 inNetClassData =
false;
4716 if( inClearanceRule && braceDepth < clearanceRuleDepth )
4718 inClearanceRule =
false;
4720 if( isDefaultRuleSet )
4722 if(
m_design_rules.default_clearance != std::numeric_limits<double>::max() )
4728 if(
m_design_rules.copper_edge_clearance != std::numeric_limits<double>::max() )
4732 == std::numeric_limits<double>::max() )
4741 == std::numeric_limits<double>::max() )
4747 foundDefaultRules =
true;
4751 if( inRuleSetFor && braceDepth < ruleSetDepth + 1 )
4752 inRuleSetFor =
false;
4754 if( inRuleSet && braceDepth < ruleSetDepth )
4757 isDefaultRuleSet =
false;
4758 ruleSetNetClass.clear();
4763 std::istringstream iss( line );
4769 if( token ==
"LAYER" )
4771 std::string secondToken;
4774 if( secondToken ==
"DATA" )
4781 if( token ==
"NET_CLASS" )
4783 std::string secondToken;
4786 if( secondToken ==
"DATA" )
4788 inNetClassData =
true;
4789 netClassDataDepth = braceDepth;
4791 else if( inNetClassData && !secondToken.empty() )
4793 if( inNetClass && !currentNetClass.
name.empty() )
4797 currentNetClass.
name = secondToken;
4799 netClassDepth = braceDepth;
4801 else if( inRuleSetFor && !secondToken.empty() )
4803 ruleSetNetClass = secondToken;
4806 else if( inNetClass && token ==
"NET" )
4808 std::string netName;
4811 if( !netName.empty() )
4812 currentNetClass.
net_names.push_back( netName );
4814 else if( token ==
"RULE_SET" )
4816 std::string ruleNum;
4820 ruleSetDepth = braceDepth;
4821 ruleSetNetClass.clear();
4822 isDefaultRuleSet = ( ruleNum ==
"(1)" && !foundDefaultRules );
4824 else if( inRuleSet && !inClearanceRule && token ==
"FOR" )
4826 inRuleSetFor =
true;
4828 else if( inRuleSet && token ==
"CLEARANCE_RULE" )
4830 inClearanceRule =
true;
4831 clearanceRuleDepth = braceDepth;
4833 if( isDefaultRuleSet )
4835 m_design_rules.default_clearance = std::numeric_limits<double>::max();
4836 m_design_rules.copper_edge_clearance = std::numeric_limits<double>::max();
4839 else if( inClearanceRule )
4844 if( !iss.fail() && val > 0.0 )
4846 if( isDefaultRuleSet )
4848 if( token ==
"MIN_TRACK_WIDTH" )
4853 else if( token ==
"REC_TRACK_WIDTH" )
4858 else if( token ==
"DRILL_TO_DRILL" )
4863 else if( token ==
"OUTLINE_TO_TRACK" || token ==
"OUTLINE_TO_VIA"
4864 || token ==
"OUTLINE_TO_PAD" || token ==
"OUTLINE_TO_COPPER"
4865 || token ==
"OUTLINE_TO_SMD" )
4870 else if( token.rfind(
"SAME_NET_", 0 ) == 0 || token ==
"BODY_TO_BODY"
4871 || token ==
"MAX_TRACK_WIDTH"
4872 || token.rfind(
"TEXT_TO_", 0 ) == 0
4873 || token.rfind(
"COPPER_TO_", 0 ) == 0 )
4879 else if( token ==
"TRACK_TO_TRACK" || token.rfind(
"VIA_TO_", 0 ) == 0
4880 || token.rfind(
"PAD_TO_", 0 ) == 0
4881 || token.rfind(
"SMD_TO_", 0 ) == 0
4882 || token.rfind(
"DRILL_TO_", 0 ) == 0 )
4888 else if( !ruleSetNetClass.empty() )
4892 if( nc.name == ruleSetNetClass )
4894 if( token ==
"REC_TRACK_WIDTH" )
4895 nc.track_width = val;
4896 else if( token ==
"TRACK_TO_TRACK" )
4905 else if( token ==
"DIF_PAIR" )
4908 if( inDifPair && !currentDiffPair.
name.empty() )
4912 iss >> currentDiffPair.
name;
4915 else if( inDifPair )
4917 if( token ==
"NET" )
4919 std::string netName;
4928 else if( token ==
"GAP" )
4930 iss >> currentDiffPair.
gap;
4932 else if( token ==
"WIDTH" )
4934 iss >> currentDiffPair.
width;
4936 else if( token ==
"CONNECTION" )
4942 else if( token ==
"ASSOCIATED" )
4945 std::string keyword, netName;
4946 iss >> keyword >> netName;
4948 if( keyword ==
"NET" )
4960 if( token ==
"PART" && !inDifPair && !inNetClass )
4962 std::string partName;
4965 if( !partName.empty() )
4968 int savedDepth = braceDepth;
4976 if( line[0] ==
'}' )
4979 if( line[0] ==
'{' )
4982 if( line[0] ==
'*' )
4989 std::string attrName, attrValue;
4991 if( line[0] ==
'"' )
4993 size_t endQuote = line.find(
'"', 1 );
4995 if( endQuote != std::string::npos )
4997 attrName = line.substr( 1, endQuote - 1 );
4998 attrValue = line.substr( endQuote + 1 );
5003 std::istringstream attrSS( line );
5005 std::getline( attrSS >> std::ws, attrValue );
5008 if( !attrValue.empty() && attrValue[0] ==
' ' )
5009 attrValue = attrValue.substr( 1 );
5011 if( !attrName.empty() && !attrValue.empty() )
5012 attrs[attrName] = attrValue;
5016 braceDepth = savedDepth;