37 switch( aOutlineType )
40 return ".BOARD_OUTLINE";
43 return ".OTHER_OUTLINE";
46 return ".PLACEMENT_OUTLINE";
49 return ".ROUTE_OUTLINE";
52 return ".PLACE_KEEPOUT";
55 return ".ROUTE_KEEPOUT";
58 return ".VIA_KEEPOUT";
61 return ".PLACE_REGION";
64 return "COMPONENT OUTLINE";
70 std::ostringstream ostr;
71 ostr <<
"[INVALID OUTLINE TYPE VALUE]:" <<
static_cast<int>( aOutlineType );
77#ifndef DISABLE_IDF_OWNERSHIP
82 if( aParent ==
nullptr )
85 ostr <<
"* " << __FILE__ <<
":" << aSourceLine <<
":" << aSourceFunc <<
"():\n";
86 ostr <<
"* BUG: outline's parent not set; cannot enforce ownership rules\n";
88 aErrorString = ostr.str();
109 ostr << __FILE__ <<
":" << aSourceLine <<
":" << aSourceFunc <<
"():\n";
110 ostr <<
"* ownership violation; CAD type is ";
117 ostr <<
"while outline owner is " <<
GetOwnerString( aOwnerCAD ) <<
"\n";
119 aErrorString = ostr.str();
156 bool comment =
false;
165 std::stringstream tstr;
175 while( aBoardFile.good() )
187 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
189 ostr <<
" is quoted\n";
190 ostr <<
"* line: '" << iline <<
"'";
192 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
196 if( entry.size() >= 5 &&
CompareToken(
".END_", entry.substr( 0, 5 ) ) )
201 if( aBoardFile.eof() )
204 aBoardFile.seekg( pos );
208 if( npts > 0 && !closed )
211 ostr <<
"invalid outline (not closed)\n";
212 ostr <<
"* file position: " << pos;
214 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
222 ERROR_IDF <<
"invalid IDF3 file (BOARD_OUTLINE)\n";
223 cerr <<
"* WARNING: first outline is not in CCW order\n";
230 ERROR_IDF <<
"invalid IDF3 file (BOARD_OUTLINE)\n";
231 cerr <<
"* WARNING: final cutout does not have points in CW order\n";
232 cerr <<
"* file position: " << pos <<
"\n";
250 aBoardFile.seekg( pos );
258 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
260 ostr <<
" is not numeric\n";
261 ostr <<
"* line: '" << iline <<
"'\n";
262 ostr <<
"* file position: " << pos;
264 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
272 if( npts > 0 && !closed )
275 ostr <<
"invalid outline ( outline # " << loopidx <<
" not closed)\n";
276 ostr <<
"* file position: " << pos;
278 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
285 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
287 ostr <<
" is invalid\n";
288 ostr <<
"* line: '" << iline <<
"'\n";
289 ostr <<
"* file position: " << pos;
291 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
300 if( tmp == 0 || tmp == 1 )
306 catch( std::bad_alloc& )
309 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
310 "memory allocation failed" ) );
320 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
322 ostr <<
" is invalid (must be 0 or 1)\n";
323 ostr <<
"* line: '" << iline <<
"'\n";
324 ostr <<
"* file position: " << pos;
326 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
336 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
338 ostr <<
" is invalid (must be 0)\n";
339 ostr <<
"* line: '" << iline <<
"'\n";
340 ostr <<
"* file position: " << pos;
342 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
349 catch( std::bad_alloc& )
352 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
353 "memory allocation failed" ) );
368 ostr <<
" section may only have one outline\n";
369 ostr <<
"* line: '" << iline <<
"'\n";
370 ostr <<
"* file position: " << pos;
372 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
375 if( tmp - loopidx != 1 )
380 ostr <<
" section must have cutouts in numeric order from 1 onwards\n";
381 ostr <<
"* line: '" << iline <<
"'\n";
382 ostr <<
"* file position: " << pos;
384 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
388 if( ( loopidx == 0 && !op->
IsCCW() )
394 ostr <<
"* violation of loop point order rules by Loop Index " << loopidx <<
396 ostr <<
"* line: '" << iline <<
"'\n";
397 ostr <<
"* file position: " << pos;
399 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
406 catch( std::bad_alloc& )
409 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
410 "memory allocation failed" ) );
425 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
427 ostr <<
" is invalid\n";
428 ostr <<
"* line: '" << iline <<
"'\n";
429 ostr <<
"* file position: " << pos;
431 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
438 ostr <<
"\n* invalid outline: RECORD 3, FIELD 2 of ";
440 ostr <<
"* line: '" << iline <<
"'\n";
441 ostr <<
"* file position: " << pos;
443 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
450 ostr <<
"\n* invalid outline: RECORD 3, FIELD 2 of ";
452 ostr <<
"* line: '" << iline <<
"'\n";
453 ostr <<
"* file position: " << pos;
455 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
467 ostr <<
"\n* invalid outline: RECORD 3, FIELD 2 of ";
469 ostr <<
"* line: '" << iline <<
"'\n";
470 ostr <<
"* file position: " << pos;
472 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
479 ostr <<
"\n* invalid outline: RECORD 3, FIELD 3 of ";
481 ostr <<
"* line: '" << iline <<
"'\n";
482 ostr <<
"* file position: " << pos;
484 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
491 ostr <<
"\n* invalid outline: RECORD 3, FIELD 3 of ";
493 ostr <<
"* line: '" << iline <<
"'\n";
494 ostr <<
"* file position: " << pos;
496 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
508 ostr <<
"\n* invalid outline: RECORD 3, FIELD 3 of ";
510 ostr <<
"* line: '" << iline <<
"'\n";
511 ostr <<
"* file position: " << pos;
513 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
520 ostr <<
"\n* invalid outline: RECORD 3, FIELD 4 of ";
522 ostr <<
"* line: '" << iline <<
"'\n";
523 ostr <<
"* file position: " << pos;
525 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
532 ostr <<
"\n* invalid outline: RECORD 3, FIELD 4 of ";
534 ostr <<
"* line: '" << iline <<
"'\n";
535 ostr <<
"* file position: " << pos;
537 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
549 ostr <<
"\n* invalid outline: RECORD 3, FIELD 4 of ";
551 ostr <<
"* line: '" << iline <<
"'\n";
552 ostr <<
"* file position: " << pos;
554 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
571 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
573 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
583 if( ang < -MIN_ANG || ang >
MIN_ANG )
587 ostr <<
"\n* invalid outline: RECORD 3 of ";
589 ostr <<
"* violation: first point of an outline has a non-zero angle\n";
590 ostr <<
"* line: '" << iline <<
"'\n";
591 ostr <<
"* file position: " << pos;
593 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
603 ostr <<
"\n* invalid outline: RECORD 3 of ";
605 ostr <<
"* violation: adding a segment to a closed outline\n";
606 ostr <<
"* line: '" << iline <<
"'\n";
607 ostr <<
"* file position: " << pos;
609 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
626 catch( std::bad_alloc& )
629 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
630 "memory allocation failed" ) );
636 if( op->
size() != 0 )
642 ostr <<
"\n* invalid outline: RECORD 3 of ";
644 ostr <<
"* violation: adding a circle to a non-empty outline\n";
645 ostr <<
"* line: '" << iline <<
"'\n";
646 ostr <<
"* file position: " << pos;
648 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
653 else if( op->
size() != 0 )
668 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
669 "problems reading file (premature end of outline)" ) );
680 list< string >::const_iterator itS =
comments.begin();
681 list< string >::const_iterator itE =
comments.end();
685 aBoardFile <<
"# " << *itS <<
"\n";
689 return !aBoardFile.fail();
698 aBoardFile <<
"ECAD\n";
702 aBoardFile <<
"MCAD\n";
706 aBoardFile <<
"UNOWNED\n";
710 return !aBoardFile.fail();
716 std::list<IDF_SEGMENT*>::iterator bo;
717 std::list<IDF_SEGMENT*>::iterator eo;
720 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
721 "\n* BUG: nullptr outline pointer" ) );
723 if( aOutline->
size() == 1 )
726 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
727 "bad outline (single segment item, not circle)" ) );
736 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(5)
740 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(5)
746 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(1)
750 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(1)
762 if( aOutline->
IsCCW() )
770 if( ( aOutline->
IsCCW() && ( aIndex > 0 ) ) || ( ( !aOutline->
IsCCW() ) && ( aIndex == 0 ) ) )
772 eo = aOutline->
begin();
773 bo = aOutline->
end();
777 if( aOutline->
size() > 1 )
779 std::list<IDF_SEGMENT*>::iterator to = eo;
781 (*to)->startPoint = (*eo)->endPoint;
789 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
793 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
799 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
803 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
813 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
817 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
823 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
827 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
830 << setprecision( 3 ) << -aOutline->
front()->
angle <<
"\n";
841 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
842 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" 0\n";
846 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
847 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" "
848 << setprecision( 3 ) << -( *bo )->angle <<
"\n";
855 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
861 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
864 << setprecision( 3 ) << -( *bo )->angle <<
"\n";
874 if( aOutline->
size() > 1 )
877 bo = aOutline->
begin();
878 eo = aOutline->
end();
885 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
886 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" 0\n";
888 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
889 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" 0\n";
893 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
894 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" 0\n";
896 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
897 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" "
898 << setprecision( 3 ) << ( *bo )->angle <<
"\n";
905 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
909 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
915 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
919 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
921 << ( ( *bo )->endPoint.y /
IDF_THOU_TO_MM ) <<
" " << setprecision( 3 )
922 << ( *bo )->angle <<
"\n";
935 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
936 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" 0\n";
940 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
941 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" "
942 << setprecision( 3 ) << ( *bo )->angle <<
"\n";
949 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
955 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
958 << setprecision( 3 ) << ( *bo )->angle <<
"\n";
974 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
975 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
992 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
993 ostr <<
"* BUG: invalid IDF UNIT: " <<
static_cast<int>( aUnit ) <<
"\n";
1013 if( aThickness < 0.0 )
1016 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1017 ostr <<
"* BUG: aThickness < 0.0\n";
1031#ifndef DISABLE_IDF_OWNERSHIP
1055 bool quoted =
false;
1059 pos = aBoardFile.tellg();
1062 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
1063 "invalid invocation: blank header line" ) );
1070 ostr <<
"* violation: section names may not be in quotes\n";
1071 ostr <<
"* line: '" << aHeader <<
"'\n";
1072 ostr <<
"* file position: " << pos;
1074 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1082 ostr <<
"* violation: not a board outline\n";
1083 ostr <<
"* line: '" << aHeader <<
"'\n";
1084 ostr <<
"* file position: " << pos;
1086 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1092 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
1100 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
1107 bool comment =
false;
1108 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1110 if( ( !aBoardFile.good() && !aBoardFile.eof() ) || iline.empty() )
1115 ostr <<
"* violation: premature end\n";
1116 ostr <<
"* file position: " << pos;
1118 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1128 ostr <<
"* violation: comment within .BOARD_OUTLINE section\n";
1129 ostr <<
"* line: '" << iline <<
"'\n";
1130 ostr <<
"* file position: " << pos;
1132 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1140 ostr <<
"* violation: no thickness specified\n";
1141 ostr <<
"* file position: " << pos;
1143 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1146 std::stringstream teststr;
1151 if( teststr.fail() )
1156 ostr <<
"* violation: invalid RECORD 2 (thickness)\n";
1157 ostr <<
"* line: '" << iline <<
"'\n";
1158 ostr <<
"* file position: " << pos;
1160 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1174 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
1176 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1185 ERROR_IDF <<
"\n* WARNING: setting board thickness to default 1.6mm (";
1192 ERROR_IDF <<
"\n* WARNING: setting board thickness to positive number (";
1201 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1203 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
1208 ostr <<
"* violation: premature end\n";
1209 ostr <<
"* file position: " << pos;
1211 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1221 ostr <<
"* violation: comment within section\n";
1222 ostr <<
"* line: '" << iline <<
"'\n";
1223 ostr <<
"* file position: " << pos;
1225 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1233 ostr <<
"* violation: no .END_BOARD_OUTLINE found\n";
1234 ostr <<
"* file position: " << pos;
1236 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1246 aBoardFile <<
".BOARD_OUTLINE ";
1251 aBoardFile << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
"\n";
1253 aBoardFile << setiosflags( ios::fixed ) << setprecision( 1 )
1258 aBoardFile <<
".END_BOARD_OUTLINE\n\n";
1273#ifndef DISABLE_IDF_OWNERSHIP
1298 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1299 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
1305 if( *itS == aOutline )
1306 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
1307 "duplicate outline pointer" ) );
1315 catch(
const std::exception& e )
1328#ifndef DISABLE_IDF_OWNERSHIP
1339 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1340 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
1345 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1346 ostr <<
"* BUG: nullptr aOutline pointer\n";
1367 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1368 ostr <<
"* BUG: attempting to delete first outline in list\n";
1381 if( *itS == aOutline )
1397 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1408 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1409 ostr <<
"* BUG: index out of bounds (" << aIndex <<
" / " <<
outlines.size() <<
")\n";
1424 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1425 ostr <<
"* BUG: attempting to delete first outline in list\n";
1438 for( ; aIndex > 0; --aIndex )
1465 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1466 ostr <<
"* aIndex (" << aIndex <<
") is out of range (" <<
outlines.size() <<
")";
1472 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1474 for( ; aIndex > 0; --aIndex )
1489#ifndef DISABLE_IDF_OWNERSHIP
1507 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1508 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
1522 if( aComment.empty() )
1546 std::list< std::string >::iterator itS =
comments.begin();
1548 for( ; aIndex > 0; --aIndex )
1560 std::list< std::string >::iterator itS =
comments.begin();
1562 for( ; aIndex > 0; --aIndex )
1587#ifndef DISABLE_IDF_OWNERSHIP
1606#ifndef DISABLE_IDF_OWNERSHIP
1622 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1623 ostr <<
"* BUG: invalid side (" <<
static_cast<int>( aSide ) <<
"); must be one of TOP/BOTTOM\n";
1654 bool quoted =
false;
1656 std::streampos pos = aBoardFile.tellg();
1661 ostr <<
"\n* BUG: invalid invocation: blank header line\n";
1663 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1671 ostr <<
"* violation: section names must not be in quotes\n";
1672 ostr <<
"* line: '" << aHeader <<
"'\n";
1673 ostr <<
"* file position: " << pos;
1675 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1685 ostr <<
"* BUG: not an .OTHER outline\n";
1687 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1697 ostr <<
"* BUG: not a .VIA_KEEPOUT outline\n";
1699 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1706 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
1714 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
1720 bool comment =
false;
1726 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1728 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
1733 ostr <<
"* violation: premature end\n";
1734 ostr <<
"* file position: " << pos;
1736 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1745 ostr <<
"* violation: comment within .OTHER_OUTLINE section\n";
1746 ostr <<
"* line: '" << iline <<
"'\n";
1747 ostr <<
"* file position: " << pos;
1749 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1757 ostr <<
"* violation: no outline identifier\n";
1758 ostr <<
"* line: '" << iline <<
"'\n";
1759 ostr <<
"* file position: " << pos;
1761 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1771 ostr <<
"* violation: no thickness\n";
1772 ostr <<
"* line: '" << iline <<
"'\n";
1773 ostr <<
"* file position: " << pos;
1775 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1778 std::stringstream teststr;
1783 if( teststr.fail() )
1788 ostr <<
"* violation: invalid thickness\n";
1789 ostr <<
"* line: '" << iline <<
"'\n";
1790 ostr <<
"* file position: " << pos;
1792 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1806 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
1808 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1822 ostr <<
"* violation: no board side\n";
1823 ostr <<
"* line: '" << iline <<
"'\n";
1824 ostr <<
"* file position: " << pos;
1826 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1834 ostr <<
"* violation: invalid side (must be TOP or BOTTOM only)\n";
1835 ostr <<
"* line: '" << iline <<
"'\n";
1836 ostr <<
"* file position: " << pos;
1838 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1848 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1850 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
1855 ostr <<
"* violation: premature end\n";
1856 ostr <<
"* file position: " << pos;
1858 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1868 ostr <<
"* violation: comment within section\n";
1869 ostr <<
"* line: '" << iline <<
"'\n";
1870 ostr <<
"* file position: " << pos;
1872 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1882 ostr <<
"* violation: no .END_OTHER_OUTLINE found\n";
1883 ostr <<
"* file position: " << pos;
1885 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1895 ostr <<
"* violation: no .END_VIA_KEEPOUT found\n";
1896 ostr <<
"* file position: " << pos;
1898 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1914 aBoardFile <<
".OTHER_OUTLINE ";
1916 aBoardFile <<
".VIA_KEEPOUT ";
1923 aBoardFile <<
"\"" <<
uniqueID <<
"\" ";
1926 aBoardFile << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
" ";
1928 aBoardFile << setiosflags( ios::fixed ) << setprecision( 1 )
1942 ostr <<
"\n* invalid OTHER_OUTLINE side (neither top nor bottom): ";
1943 ostr << static_cast<int>(
side );
1944 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1956 aBoardFile <<
".END_OTHER_OUTLINE\n\n";
1958 aBoardFile <<
".END_VIA_KEEPOUT\n\n";
1964#ifndef DISABLE_IDF_OWNERSHIP
1988#ifndef DISABLE_IDF_OWNERSHIP
2015 bool quoted =
false;
2017 std::streampos pos = aBoardFile.tellg();
2021 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2022 "\n* BUG: invalid invocation; blank header line" ) );
2030 ostr <<
"* violation: section names must not be in quotes\n";
2031 ostr <<
"* line: '" << aHeader <<
"'\n";
2032 ostr <<
"* file position: " << pos;
2034 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2040 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2041 "\n* BUG: not a ROUTE outline" ) );
2046 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2047 "\n* BUG: not a ROUTE KEEPOUT outline" ) );
2053 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
2061 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
2069 bool comment =
false;
2073 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2075 if( !aBoardFile.good() )
2080 ostr <<
"* violation: premature end\n";
2081 ostr <<
"* file position: " << pos;
2083 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2093 ostr <<
"* violation: comment within a section\n";
2094 ostr <<
"* line: '" << iline <<
"'\n";
2095 ostr <<
"* file position: " << pos;
2097 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2105 ostr <<
"* violation: no layers specification\n";
2106 ostr <<
"* line: '" << iline <<
"'\n";
2107 ostr <<
"* file position: " << pos;
2109 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2117 ostr <<
"* violation: layers specification must not be in quotes\n";
2118 ostr <<
"* line: '" << iline <<
"'\n";
2119 ostr <<
"* file position: " << pos;
2121 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2129 ostr <<
"* violation: invalid layers specification\n";
2130 ostr <<
"* line: '" << iline <<
"'\n";
2131 ostr <<
"* file position: " << pos;
2133 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2143 ostr <<
"* violation: IDFv2 allows only TOP/BOTTOM/BOTH; layer was '";
2144 ostr << token <<
"'\n";
2145 ostr <<
"* line: '" << iline <<
"'\n";
2146 ostr <<
"* file position: " << pos;
2148 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2161 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2163 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
2168 ostr <<
"* violation: premature end\n";
2169 ostr <<
"* file position: " << pos;
2171 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2181 ostr <<
"* violation: comment within section\n";
2182 ostr <<
"* line: '" << iline <<
"'\n";
2183 ostr <<
"* file position: " << pos;
2185 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2195 ostr <<
"* violation: no .END_ROUTE_OUTLINE found\n";
2196 ostr <<
"* file position: " << pos;
2198 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2208 ostr <<
"* violation: no .END_ROUTE_KEEPOUT found\n";
2209 ostr <<
"* file position: " << pos;
2211 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2224 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2225 "layer not specified" ) );
2231 aBoardFile <<
".ROUTE_OUTLINE ";
2233 aBoardFile <<
".ROUTE_KEEPOUT ";
2246 aBoardFile <<
".END_ROUTE_OUTLINE\n\n";
2248 aBoardFile <<
".END_ROUTE_KEEPOUT\n\n";
2254#ifndef DISABLE_IDF_OWNERSHIP
2278#ifndef DISABLE_IDF_OWNERSHIP
2296 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
2297 ostr <<
"* BUG: invalid layer (" <<
static_cast<int>( aSide ) <<
"): must be one of TOP/BOTTOM/BOTH\n";
2319#ifndef DISABLE_IDF_OWNERSHIP
2331 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
2332 ostr <<
"* BUG: invalid height (" << aHeight <<
"): must be >= 0.0";
2361 bool quoted =
false;
2363 std::streampos pos = aBoardFile.tellg();
2366 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2367 "\n* BUG: invalid invocation: blank header line\n" ) );
2374 ostr <<
"* violation: section name must not be in quotes\n";
2375 ostr <<
"* line: '" << aHeader <<
"'\n";
2376 ostr <<
"* file position: " << pos;
2378 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2384 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2385 "\n* BUG: not a .PLACE_OUTLINE" ) );
2390 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2391 "\n* BUG: not a .PLACE_KEEPOUT" ) );
2397 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
2405 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
2413 bool comment =
false;
2417 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2419 if( !aBoardFile.good() )
2424 ostr <<
"* violation: premature end\n";
2425 ostr <<
"* file position: " << pos;
2427 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2437 ostr <<
"* violation: comment within the section\n";
2438 ostr <<
"* line: '" << iline <<
"'\n";
2439 ostr <<
"* file position: " << pos;
2441 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2449 ostr <<
"* violation: no board side information\n";
2450 ostr <<
"* line: '" << iline <<
"'\n";
2451 ostr <<
"* file position: " << pos;
2453 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2462 ostr <<
"* violation: invalid board side: must be one of TOP/BOTTOM/BOTH\n";
2463 ostr <<
"* line: '" << iline <<
"'\n";
2464 ostr <<
"* file position: " << pos;
2466 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2471 std::stringstream teststr;
2476 if( teststr.fail() )
2481 ostr <<
"* violation: invalid height\n";
2482 ostr <<
"* line: '" << iline <<
"'\n";
2483 ostr <<
"* file position: " << pos;
2485 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2493 ostr <<
"* violation: thickness < 0\n";
2494 ostr <<
"* line: '" << iline <<
"'\n";
2495 ostr <<
"* file position: " << pos;
2497 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2511 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
2513 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2527 ostr <<
"* violation: missing thickness\n";
2528 ostr <<
"* line: '" << iline <<
"'\n";
2529 ostr <<
"* file position: " << pos;
2531 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2547 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2549 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
2554 ostr <<
"* violation: premature end\n";
2555 ostr <<
"* file position: " << pos;
2557 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2567 ostr <<
"* violation: comment within section\n";
2568 ostr <<
"* line: '" << iline <<
"'\n";
2569 ostr <<
"* file position: " << pos;
2571 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2578 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2579 "invalid .PLACE_OUTLINE section: no .END_PLACE_OUTLINE found" ) );
2585 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2586 "invalid .PLACE_KEEPOUT section: no .END_PLACE_KEEPOUT found" ) );
2601 aBoardFile <<
".PLACE_OUTLINE ";
2603 aBoardFile <<
".PLACE_KEEPOUT ";
2620 ostr <<
"\n* invalid PLACE_OUTLINE/KEEPOUT side (";
2621 ostr << static_cast<int>(
side ) <<
"); must be one of TOP/BOTTOM/BOTH";
2622 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2638 aBoardFile << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
"\n";
2640 aBoardFile << setiosflags( ios::fixed ) << setprecision( 1 )
2649 aBoardFile <<
".END_PLACE_OUTLINE\n\n";
2651 aBoardFile <<
".END_PLACE_KEEPOUT\n\n";
2659#ifndef DISABLE_IDF_OWNERSHIP
2709#ifndef DISABLE_IDF_OWNERSHIP
2726 ostr <<
"invalid side (" <<
static_cast<int>( aSide ) <<
"); must be one of TOP/BOTTOM/BOTH\n";
2748#ifndef DISABLE_IDF_OWNERSHIP
2775 bool quoted =
false;
2777 std::streampos pos = aBoardFile.tellg();
2780 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2781 "\n* BUG: invalid invocation: blank header line" ) );
2788 ostr <<
"* violation: section name must not be in quotes\n";
2789 ostr <<
"* line: '" << aHeader <<
"'\n";
2790 ostr <<
"* file position: " << pos;
2792 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2796 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
"\n* BUG: not a .PLACE_REGION" ) );
2801 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
2809 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
2815 bool comment =
false;
2819 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2821 if( !aBoardFile.good() )
2826 ostr <<
"* violation: premature end\n";
2827 ostr <<
"* file position: " << pos;
2829 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2839 ostr <<
"* violation: comment within section\n";
2840 ostr <<
"* line: '" << iline <<
"'\n";
2841 ostr <<
"* file position: " << pos;
2843 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2851 ostr <<
"* violation: no board side specified\n";
2852 ostr <<
"* line: '" << iline <<
"'\n";
2853 ostr <<
"* file position: " << pos;
2855 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2864 ostr <<
"* violation: invalid board side, must be one of TOP/BOTTOM/BOTH\n";
2865 ostr <<
"* line: '" << iline <<
"'\n";
2866 ostr <<
"* file position: " << pos;
2868 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2876 ostr <<
"* violation: no outline identifier\n";
2877 ostr <<
"* line: '" << iline <<
"'\n";
2878 ostr <<
"* file position: " << pos;
2880 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2889 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2891 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
2896 ostr <<
"* violation: premature end\n";
2897 ostr <<
"* file position: " << pos;
2899 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2909 ostr <<
"* violation: comment within section\n";
2910 ostr <<
"* line: '" << iline <<
"'\n";
2911 ostr <<
"* file position: " << pos;
2913 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2918 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2919 "\n* invalid .PLACE_REGION section: no .END_PLACE_REGION found" ) );
2933 aBoardFile <<
".PLACE_REGION ";
2950 ostr <<
"\n* invalid PLACE_REGION side (must be TOP/BOTTOM/BOTH): ";
2951 ostr << static_cast<int>(
side );
2953 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2959 aBoardFile <<
" \"" <<
groupName <<
"\"\n";
2965 aBoardFile <<
".END_PLACE_REGION\n\n";
2971#ifndef DISABLE_IDF_OWNERSHIP
2998 bool quoted =
false;
2999 bool comment =
false;
3007 while( aLibFile.good() )
3019 ostr <<
"* violation: comment within section\n";
3020 ostr <<
"* line: '" << iline <<
"'\n";
3021 ostr <<
"* file position: " << pos;
3023 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3031 ostr <<
"* violation: bad property section (no PROP)\n";
3032 ostr <<
"* line: '" << iline <<
"'\n";
3033 ostr <<
"* file position: " << pos;
3035 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3043 ostr <<
"* violation: PROP or .END must not be quoted\n";
3044 ostr <<
"* line: '" << iline <<
"'\n";
3045 ostr <<
"* file position: " << pos;
3047 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3050 if( token.size() >= 5 &&
CompareToken(
".END_", token.substr( 0, 5 ) ) )
3055 aLibFile.seekg( pos );
3064 ostr <<
"* violation: expecting PROP or .END_ELECTRICAL\n";
3065 ostr <<
"* line: '" << iline <<
"'\n";
3066 ostr <<
"* file position: " << pos;
3068 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3076 ostr <<
"* violation: no PROP name\n";
3077 ostr <<
"* line: '" << iline <<
"'\n";
3078 ostr <<
"* file position: " << pos;
3080 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3090 ostr <<
"* violation: no PROP value\n";
3091 ostr <<
"* line: '" << iline <<
"'\n";
3092 ostr <<
"* file position: " << pos;
3094 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3099 if(
props.insert( pair< string, string >(pname, pval) ).second ==
false )
3104 ostr <<
"* violation: duplicate property name \"" << pname <<
"\"\n";
3105 ostr <<
"* line: '" << iline <<
"'\n";
3106 ostr <<
"* file position: " << pos;
3108 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3119 std::map< std::string, std::string >::const_iterator itS =
props.begin();
3120 std::map< std::string, std::string >::const_iterator itE =
props.end();
3124 aLibFile <<
"PROP " <<
"\"" << itS->first <<
"\" \""
3125 << itS->second <<
"\"\n";
3129 return !aLibFile.fail();
3142 bool quoted =
false;
3144 std::streampos pos = aLibFile.tellg();
3147 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
3148 "\n* BUG: invalid invocation: blank header line" ) );
3155 ostr <<
"* violation: section name must not be in quotes\n";
3156 ostr <<
"* line: '" << aHeader <<
"'\n";
3157 ostr <<
"* file position: " << pos;
3159 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3175 ostr <<
"* violation: expecting .ELECTRICAL or .MECHANICAL header\n";
3176 ostr <<
"* line: '" << aHeader <<
"'\n";
3177 ostr <<
"* file position: " << pos;
3179 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3185 bool comment =
false;
3187 while( aLibFile.good() && !
FetchIDFLine( aLibFile, iline, comment, pos ) );
3189 if( !aLibFile.good() )
3194 ostr <<
"* violation: premature end\n";
3195 ostr <<
"* file position: " << pos;
3197 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3207 ostr <<
"* violation: comment within section\n";
3208 ostr <<
"* line: '" << iline <<
"'\n";
3209 ostr <<
"* file position: " << pos;
3211 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3219 ostr <<
"* violation: no GEOMETRY NAME\n";
3220 ostr <<
"* line: '" << iline <<
"'\n";
3221 ostr <<
"* file position: " << pos;
3223 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3233 ostr <<
"* violation: no PART NAME\n";
3234 ostr <<
"* line: '" << iline <<
"'\n";
3235 ostr <<
"* file position: " << pos;
3237 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3247 ostr <<
"* violation: both GEOMETRY and PART names are empty\n";
3248 ostr <<
"* line: '" << iline <<
"'\n";
3249 ostr <<
"* file position: " << pos;
3251 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3259 ostr <<
"* violation: no UNIT type\n";
3260 ostr <<
"* line: '" << iline <<
"'\n";
3261 ostr <<
"* file position: " << pos;
3263 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3283 ostr <<
"* violation: invalid UNIT '" << token <<
"': must be one of MM or THOU\n";
3284 ostr <<
"* line: '" << iline <<
"'\n";
3285 ostr <<
"* file position: " << pos;
3287 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3295 ostr <<
"* violation: no height specified\n";
3296 ostr <<
"* line: '" << iline <<
"'\n";
3297 ostr <<
"* file position: " << pos;
3299 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3302 std::istringstream teststr;
3303 teststr.str( token );
3306 if( teststr.fail() )
3311 ostr <<
"* violation: invalid height '" << token <<
"'\n";
3312 ostr <<
"* line: '" << iline <<
"'\n";
3313 ostr <<
"* file position: " << pos;
3315 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3329 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
3331 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3341 while( aLibFile.good() && !
FetchIDFLine( aLibFile, iline, comment, pos ) );
3343 if( ( !aLibFile.good() && aLibFile.eof() ) && iline.empty() )
3348 ostr <<
"* violation: premature end\n";
3349 ostr <<
"* file position: " << pos;
3351 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3361 ostr <<
"* violation: comment within section\n";
3362 ostr <<
"* line: '" << iline <<
"'\n";
3363 ostr <<
"* file position: " << pos;
3365 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3375 ostr <<
"* violation: no .END_ELECTRICAL found\n";
3376 ostr <<
"* line: '" << iline <<
"'\n";
3377 ostr <<
"* file position: " << pos;
3379 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3389 ostr <<
"* violation: no .END_MECHANICAL found\n";
3390 ostr <<
"* line: '" << iline <<
"'\n";
3391 ostr <<
"* file position: " << pos;
3393 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3407 ostr <<
"\n* component type not set or invalid: " <<
static_cast<int>(
compType );
3409 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3416 aLibFile <<
".ELECTRICAL\n";
3418 aLibFile <<
".MECHANICAL\n";
3422 aLibFile <<
"\"" <<
geometry <<
"\" \"" <<
part <<
"\" ";
3425 aLibFile <<
"MM " << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
"\n";
3427 aLibFile <<
"THOU " << setiosflags( ios::fixed ) << setprecision( 1 )
3435 aLibFile <<
".END_ELECTRICAL\n\n";
3439 aLibFile <<
".END_MECHANICAL\n\n";
3446#ifndef DISABLE_IDF_OWNERSHIP
3465 switch( aCompClass )
3476 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
3477 ostr <<
"* BUG: invalid component class (must be ELECTRICAL or MECHANICAL): ";
3478 ostr << static_cast<int>( aCompClass ) <<
"\n";
3548 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
3549 ostr <<
"* BUG: decrementing refNum beyond 0";
3564 if( aGeom.empty() && aPart.empty() )
3568 uid =
"NOGEOM_NOPART";
3574 uid = aGeom +
"_" + aPart;
3590 p1.
x = 1.5 * cos( a );
3591 p1.
y = 1.5 * sin( a );
3597 catch( std::bad_alloc& )
3602 for(
int i = 0; i < 10; ++i )
3606 p2.
x = 2.5 * cos( a );
3607 p2.
y = 2.5 * sin( a );
3611 p2.
x = 1.5 * cos( a );
3612 p2.
y = 1.5 * sin( a );
3619 catch( std::bad_alloc& )
3631 p2.
x = 1.5 * cos( a );
3632 p2.
y = 1.5 * sin( a );
3638 catch( std::bad_alloc& )
void ClearComments(void)
Deletes all comments.
virtual bool Clear(void)
Free memory and reinitializes all internal data except for the parent pointer.
bool addOutline(IDF_OUTLINE *aOutline)
bool AddOutline(IDF_OUTLINE *aOutline)
Add the specified outline to this object.
virtual bool setThickness(double aThickness)
IDF3::KEY_OWNER GetOwner(void)
IDF_OUTLINE * GetOutline(size_t aIndex)
Return a pointer to the outline as specified by aIndex.
bool DeleteComment(size_t aIndex)
Deletes a comment based on the given index.
bool writeComments(std::ostream &aBoardFile)
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion)
Read data from a .BOARD_OUTLINE section.
const std::string * GetComment(size_t aIndex)
void writeOutlines(std::ostream &aBoardFile)
IDF3::OUTLINE_TYPE outlineType
std::list< std::string > * GetComments(void)
bool writeOwner(std::ostream &aBoardFile)
virtual bool SetThickness(double aThickness)
Set the thickness or height of the outline (mm).
virtual double GetThickness(void)
bool DelOutline(IDF_OUTLINE *aOutline)
Remove the given outline, subject to IDF ownership rules, if it is owned by this object.
const std::list< IDF_OUTLINE * > * GetOutlines(void)
Return outlines list.
virtual void writeData(std::ostream &aBoardFile)
Write the comments and .BOARD_OUTLINE section to an IDFv3 file.
void readOutlines(std::istream &aBoardFile, IDF3::IDF_VERSION aIdfVersion)
bool SetOwner(IDF3::KEY_OWNER aOwner)
Set the ownership status of the outline subject to IDF ownership rules.
std::list< std::string > comments
IDF3_BOARD * GetParent(void)
size_t OutlinesSize(void)
void writeOutline(std::ostream &aBoardFile, IDF_OUTLINE *aOutline, size_t aIndex)
size_t CommentsSize(void)
IDF3::OUTLINE_TYPE GetOutlineType(void)
void setParent(IDF3_BOARD *aParent)
Set the parent IDF_BOARD object.
virtual bool SetUnit(IDF3::IDF_UNIT aUnit)
Function SetUnit sets the native unit of the outline; except for component outlines this must be the ...
std::list< IDF_OUTLINE * > outlines
void AddComment(const std::string &aComment)
Add a comment to the outline data.
virtual IDF3::IDF_UNIT GetUnit(void)
Return the native unit type of the outline.
virtual bool SetGroupName(std::string aGroupName)
Set the name of the group, subject to IDF ownership rules.
virtual bool Clear(void) override
Delete internal data, subject to IDF ownership rules.
virtual void writeData(std::ostream &aBoardFile) override
Write the data to a .PLACE_REGION section of an IDFv3 file.
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read GROUP_OUTLINE data from an open IDFv3 file.
virtual IDF3::IDF_LAYER GetSide(void)
virtual const std::string & GetGroupName(void)
Return a reference to the (non-unique) group name.
GROUP_OUTLINE(IDF3_BOARD *aParent)
virtual bool SetSide(IDF3::IDF_LAYER aSide)
Set the side which this outline applies to (TOP, BOTTOM, BOTH).
IDF3::CAD_TYPE GetCadType(void)
void SetPartName(const std::string &aPartName)
Set the Part Name (Part Number, IDFv3 spec) of the component outline.
void readProperties(std::istream &aLibFile)
const std::string & GetUID(void)
virtual void writeData(std::ostream &aLibFile) override
Write comments and component outline data to an IDFv3 Library file.
virtual void readData(std::istream &aLibFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read a component outline from an open IDFv3 file.
IDF3::COMP_TYPE GetComponentClass(void)
std::map< std::string, std::string > props
IDF3_COMP_OUTLINE(IDF3_BOARD *aParent)
virtual bool Clear(void) override
Delete internal outline data.
bool CreateDefaultOutline(const std::string &aGeom, const std::string &aPart)
Create a default outline with the given Geometry and Part names.
int decrementRef(void)
Decrement the internal reference counter to keep track of the number of components referring to this ...
void SetGeomName(const std::string &aGeomName)
Set the Geometry Name (Package Name, IDFv3 spec) of the component outline.
bool SetComponentClass(IDF3::COMP_TYPE aCompClass)
Set the type of component outline (.ELECTRICAL or .MECHANICAL).
bool writeProperties(std::ostream &aLibFile)
const std::string & GetGeomName(void)
int incrementRef(void)
Increment the internal reference counter to keep track of the number of components referring to this ...
const std::string & GetPartName(void)
Return the Part Name (Part Number) of the component outline.
A segment and winding information for an IDF outline.
std::list< IDF_SEGMENT * >::iterator end()
std::list< IDF_SEGMENT * >::iterator begin()
bool push(IDF_SEGMENT *item)
Add a segment to the internal segment list.
A point as used by the various IDF related classes.
bool Matches(const IDF_POINT &aPoint, double aRadius=1e-5) const
Return true if the given coordinate point is within the given radius of the point.
A segment as used in IDFv3 outlines.
IDF_POINT endPoint
end point coordinates in mm
IDF_POINT startPoint
starting point coordinates in mm
double angle
included angle (degrees) according to IDFv3 specification
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read an OTHER_OUTLINE data from an IDFv3 file.
virtual bool Clear(void) override
Function Clear deletes internal data except for the parent object.
virtual bool SetOutlineIdentifier(const std::string &aUniqueID)
Function SetOutlineIdentifier sets the Outline Identifier string of this OTHER_OUTLINE object as per ...
virtual const std::string & GetOutlineIdentifier(void)
Function GetOutlineIdentifier returns the object's Outline Identifier.
virtual void writeData(std::ostream &aBoardFile) override
Write the OTHER_OUTLINE data to an open IDFv3 file.
virtual bool SetSide(IDF3::IDF_LAYER aSide)
Function SetSide sets the side which this outline is applicable to (TOP, BOTTOM).
OTHER_OUTLINE(IDF3_BOARD *aParent)
virtual IDF3::IDF_LAYER GetSide(void)
Function GetSide returns the side which this outline is applicable to.
PLACE_KO_OUTLINE(IDF3_BOARD *aParent)
virtual double GetMaxHeight(void)
Function GetMaxHeight returns the maximum allowable height for a component in this region.
virtual bool SetMaxHeight(double aHeight)
Function SetMaxHeight sets the maximum height of a component within this outline.
virtual bool SetSide(IDF3::IDF_LAYER aSide)
Function SetSide sets the side (TOP, BOTTOM, BOTH) which this outline applies to.
virtual IDF3::IDF_LAYER GetSide(void)
Function GetSide returns the side which this outline is applicable to.
virtual void writeData(std::ostream &aBoardFile) override
Write the PLACE_OUTLINE data to an open IDFv3 file.
virtual bool Clear(void) override
Function Clear deletes all internal data.
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read PLACE_OUTLINE data from an open IDFv3 file.
PLACE_OUTLINE(IDF3_BOARD *aParent)
ROUTE_KO_OUTLINE(IDF3_BOARD *aParent)
virtual void writeData(std::ostream &aBoardFile) override
Write the ROUTE_OUTLINE data to an open IDFv3 file.
virtual bool Clear(void) override
Function Clear deletes internal data except for the parent object.
virtual bool SetLayers(IDF3::IDF_LAYER aLayer)
Function SetLayers sets the layer or group of layers this outline is applicable to.
ROUTE_OUTLINE(IDF3_BOARD *aParent)
virtual void readData(std::istream &aBoardFile, const std::string &aHeader, IDF3::IDF_VERSION aIdfVersion) override
Read ROUTE_OUTLINE data from an IDFv3 file.
virtual IDF3::IDF_LAYER GetLayers(void)
Function GetLayers returns the layer or group of layers which this outline is applicable to.
VIA_KO_OUTLINE(IDF3_BOARD *aParent)
static bool CheckOwnership(int aSourceLine, const char *aSourceFunc, IDF3_BOARD *aParent, IDF3::KEY_OWNER aOwnerCAD, IDF3::OUTLINE_TYPE aOutlineType, std::string &aErrorString)
static std::string GetOutlineTypeString(IDF3::OUTLINE_TYPE aOutlineType)
bool ParseIDFLayer(const std::string &aToken, IDF3::IDF_LAYER &aLayer)
Parse an input string for a valid IDF layer specification.
bool GetIDFString(const std::string &aLine, std::string &aIDFString, bool &hasQuotes, int &aIndex)
Parse a line retrieved via FetchIDFLine() and returns the first IDF string found from the starting po...
CAD_TYPE
The class of CAD program which is opening or modifying a file.
std::string GetOwnerString(IDF3::KEY_OWNER aOwner)
bool FetchIDFLine(std::istream &aModel, std::string &aLine, bool &isComment, std::streampos &aFilePos)
Retrieve a single line from an IDF file and performs minimal processing.
OUTLINE_TYPE
The class of outline.
IDF_VERSION
The supported IDF versions (3.0 and 2.0 ONLY).
IDF_UNIT
The native unit of the board and of component outlines.
bool CompareToken(const char *aTokenString, const std::string &aInputString)
Perform a case-insensitive comparison of a token string and an input string.
IDF_LAYER
The various IDF layer classes and groupings.
KEY_OWNER
The type of CAD which has ownership an object.
bool WriteLayersText(std::ostream &aBoardFile, IDF3::IDF_LAYER aLayer)
Write out text corresponding to the given IDF Layer type.
COMP_TYPE
Whether a component is a mechanical or electrical part.
bool ParseOwner(const std::string &aToken, IDF3::KEY_OWNER &aOwner)
Parse the input string for a valid IDF Owner type.