39 switch( aOutlineType )
42 return ".BOARD_OUTLINE";
45 return ".OTHER_OUTLINE";
48 return ".PLACEMENT_OUTLINE";
51 return ".ROUTE_OUTLINE";
54 return ".PLACE_KEEPOUT";
57 return ".ROUTE_KEEPOUT";
60 return ".VIA_KEEPOUT";
63 return ".PLACE_REGION";
66 return "COMPONENT OUTLINE";
72 std::ostringstream ostr;
73 ostr <<
"[INVALID OUTLINE TYPE VALUE]:" <<
static_cast<int>( aOutlineType );
79#ifndef DISABLE_IDF_OWNERSHIP
84 if( aParent ==
nullptr )
87 ostr <<
"* " << __FILE__ <<
":" << aSourceLine <<
":" << aSourceFunc <<
"():\n";
88 ostr <<
"* BUG: outline's parent not set; cannot enforce ownership rules\n";
90 aErrorString = ostr.str();
111 ostr << __FILE__ <<
":" << aSourceLine <<
":" << aSourceFunc <<
"():\n";
112 ostr <<
"* ownership violation; CAD type is ";
119 ostr <<
"while outline owner is " <<
GetOwnerString( aOwnerCAD ) <<
"\n";
121 aErrorString = ostr.str();
158 bool comment =
false;
167 std::stringstream tstr;
177 while( aBoardFile.good() )
189 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
191 ostr <<
" is quoted\n";
192 ostr <<
"* line: '" << iline <<
"'";
194 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
198 if( entry.size() >= 5 &&
CompareToken(
".END_", entry.substr( 0, 5 ) ) )
203 if( aBoardFile.eof() )
206 aBoardFile.seekg( pos );
210 if( npts > 0 && !closed )
213 ostr <<
"invalid outline (not closed)\n";
214 ostr <<
"* file position: " << pos;
216 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
224 ERROR_IDF <<
"invalid IDF3 file (BOARD_OUTLINE)\n";
225 cerr <<
"* WARNING: first outline is not in CCW order\n";
232 ERROR_IDF <<
"invalid IDF3 file (BOARD_OUTLINE)\n";
233 cerr <<
"* WARNING: final cutout does not have points in CW order\n";
234 cerr <<
"* file position: " << pos <<
"\n";
252 aBoardFile.seekg( pos );
260 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
262 ostr <<
" is not numeric\n";
263 ostr <<
"* line: '" << iline <<
"'\n";
264 ostr <<
"* file position: " << pos;
266 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
274 if( npts > 0 && !closed )
277 ostr <<
"invalid outline ( outline # " << loopidx <<
" not closed)\n";
278 ostr <<
"* file position: " << pos;
280 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
287 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
289 ostr <<
" is invalid\n";
290 ostr <<
"* line: '" << iline <<
"'\n";
291 ostr <<
"* file position: " << pos;
293 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
302 if( tmp == 0 || tmp == 1 )
308 catch( std::bad_alloc& )
311 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
312 "memory allocation failed" ) );
322 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
324 ostr <<
" is invalid (must be 0 or 1)\n";
325 ostr <<
"* line: '" << iline <<
"'\n";
326 ostr <<
"* file position: " << pos;
328 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
338 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
340 ostr <<
" is invalid (must be 0)\n";
341 ostr <<
"* line: '" << iline <<
"'\n";
342 ostr <<
"* file position: " << pos;
344 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
351 catch( std::bad_alloc& )
354 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
355 "memory allocation failed" ) );
370 ostr <<
" section may only have one outline\n";
371 ostr <<
"* line: '" << iline <<
"'\n";
372 ostr <<
"* file position: " << pos;
374 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
377 if( tmp - loopidx != 1 )
382 ostr <<
" section must have cutouts in numeric order from 1 onwards\n";
383 ostr <<
"* line: '" << iline <<
"'\n";
384 ostr <<
"* file position: " << pos;
386 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
390 if( ( loopidx == 0 && !op->
IsCCW() )
396 ostr <<
"* violation of loop point order rules by Loop Index " << loopidx <<
398 ostr <<
"* line: '" << iline <<
"'\n";
399 ostr <<
"* file position: " << pos;
401 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
408 catch( std::bad_alloc& )
411 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
412 "memory allocation failed" ) );
427 ostr <<
"\n* invalid outline: RECORD 3, FIELD 1 of " <<
429 ostr <<
" is invalid\n";
430 ostr <<
"* line: '" << iline <<
"'\n";
431 ostr <<
"* file position: " << pos;
433 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
440 ostr <<
"\n* invalid outline: RECORD 3, FIELD 2 of ";
442 ostr <<
"* line: '" << iline <<
"'\n";
443 ostr <<
"* file position: " << pos;
445 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
452 ostr <<
"\n* invalid outline: RECORD 3, FIELD 2 of ";
454 ostr <<
"* line: '" << iline <<
"'\n";
455 ostr <<
"* file position: " << pos;
457 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
469 ostr <<
"\n* invalid outline: RECORD 3, FIELD 2 of ";
471 ostr <<
"* line: '" << iline <<
"'\n";
472 ostr <<
"* file position: " << pos;
474 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
481 ostr <<
"\n* invalid outline: RECORD 3, FIELD 3 of ";
483 ostr <<
"* line: '" << iline <<
"'\n";
484 ostr <<
"* file position: " << pos;
486 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
493 ostr <<
"\n* invalid outline: RECORD 3, FIELD 3 of ";
495 ostr <<
"* line: '" << iline <<
"'\n";
496 ostr <<
"* file position: " << pos;
498 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
510 ostr <<
"\n* invalid outline: RECORD 3, FIELD 3 of ";
512 ostr <<
"* line: '" << iline <<
"'\n";
513 ostr <<
"* file position: " << pos;
515 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
522 ostr <<
"\n* invalid outline: RECORD 3, FIELD 4 of ";
524 ostr <<
"* line: '" << iline <<
"'\n";
525 ostr <<
"* file position: " << pos;
527 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
534 ostr <<
"\n* invalid outline: RECORD 3, FIELD 4 of ";
536 ostr <<
"* line: '" << iline <<
"'\n";
537 ostr <<
"* file position: " << pos;
539 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
551 ostr <<
"\n* invalid outline: RECORD 3, FIELD 4 of ";
553 ostr <<
"* line: '" << iline <<
"'\n";
554 ostr <<
"* file position: " << pos;
556 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
573 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
575 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
585 if( ang < -MIN_ANG || ang >
MIN_ANG )
589 ostr <<
"\n* invalid outline: RECORD 3 of ";
591 ostr <<
"* violation: first point of an outline has a non-zero angle\n";
592 ostr <<
"* line: '" << iline <<
"'\n";
593 ostr <<
"* file position: " << pos;
595 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
605 ostr <<
"\n* invalid outline: RECORD 3 of ";
607 ostr <<
"* violation: adding a segment to a closed outline\n";
608 ostr <<
"* line: '" << iline <<
"'\n";
609 ostr <<
"* file position: " << pos;
611 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
628 catch( std::bad_alloc& )
631 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
632 "memory allocation failed" ) );
638 if( op->
size() != 0 )
644 ostr <<
"\n* invalid outline: RECORD 3 of ";
646 ostr <<
"* violation: adding a circle to a non-empty outline\n";
647 ostr <<
"* line: '" << iline <<
"'\n";
648 ostr <<
"* file position: " << pos;
650 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
655 else if( op->
size() != 0 )
670 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
671 "problems reading file (premature end of outline)" ) );
682 list< string >::const_iterator itS =
comments.begin();
683 list< string >::const_iterator itE =
comments.end();
687 aBoardFile <<
"# " << *itS <<
"\n";
691 return !aBoardFile.fail();
700 aBoardFile <<
"ECAD\n";
704 aBoardFile <<
"MCAD\n";
708 aBoardFile <<
"UNOWNED\n";
712 return !aBoardFile.fail();
718 std::list<IDF_SEGMENT*>::iterator bo;
719 std::list<IDF_SEGMENT*>::iterator eo;
722 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
723 "\n* BUG: nullptr outline pointer" ) );
725 if( aOutline->
size() == 1 )
728 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
729 "bad outline (single segment item, not circle)" ) );
738 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(5)
742 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(5)
748 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(1)
752 aBoardFile << aIndex <<
" " << setiosflags(ios::fixed) << setprecision(1)
764 if( aOutline->
IsCCW() )
772 if( ( aOutline->
IsCCW() && ( aIndex > 0 ) ) || ( ( !aOutline->
IsCCW() ) && ( aIndex == 0 ) ) )
774 eo = aOutline->
begin();
775 bo = aOutline->
end();
779 if( aOutline->
size() > 1 )
781 std::list<IDF_SEGMENT*>::iterator to = eo;
783 (*to)->startPoint = (*eo)->endPoint;
791 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
795 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
801 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
805 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
815 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
819 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
825 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
829 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
832 << setprecision( 3 ) << -aOutline->
front()->
angle <<
"\n";
843 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
844 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" 0\n";
848 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
849 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" "
850 << setprecision( 3 ) << -( *bo )->angle <<
"\n";
857 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
863 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
866 << setprecision( 3 ) << -( *bo )->angle <<
"\n";
876 if( aOutline->
size() > 1 )
879 bo = aOutline->
begin();
880 eo = aOutline->
end();
887 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
888 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" 0\n";
890 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
891 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" 0\n";
895 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
896 << ( *bo )->startPoint.x <<
" " << ( *bo )->startPoint.y <<
" 0\n";
898 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
899 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" "
900 << setprecision( 3 ) << ( *bo )->angle <<
"\n";
907 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
911 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
917 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
921 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
923 << ( ( *bo )->endPoint.y /
IDF_THOU_TO_MM ) <<
" " << setprecision( 3 )
924 << ( *bo )->angle <<
"\n";
937 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
938 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" 0\n";
942 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 5 )
943 << ( *bo )->endPoint.x <<
" " << ( *bo )->endPoint.y <<
" "
944 << setprecision( 3 ) << ( *bo )->angle <<
"\n";
951 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
957 aBoardFile << aIndex <<
" " << setiosflags( ios::fixed ) << setprecision( 1 )
960 << setprecision( 3 ) << ( *bo )->angle <<
"\n";
976 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
977 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
994 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
995 ostr <<
"* BUG: invalid IDF UNIT: " <<
static_cast<int>( aUnit ) <<
"\n";
1015 if( aThickness < 0.0 )
1018 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1019 ostr <<
"* BUG: aThickness < 0.0\n";
1033#ifndef DISABLE_IDF_OWNERSHIP
1057 bool quoted =
false;
1061 pos = aBoardFile.tellg();
1064 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
1065 "invalid invocation: blank header line" ) );
1072 ostr <<
"* violation: section names may not be in quotes\n";
1073 ostr <<
"* line: '" << aHeader <<
"'\n";
1074 ostr <<
"* file position: " << pos;
1076 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1084 ostr <<
"* violation: not a board outline\n";
1085 ostr <<
"* line: '" << aHeader <<
"'\n";
1086 ostr <<
"* file position: " << pos;
1088 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1094 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
1102 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
1109 bool comment =
false;
1110 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1112 if( ( !aBoardFile.good() && !aBoardFile.eof() ) || iline.empty() )
1117 ostr <<
"* violation: premature end\n";
1118 ostr <<
"* file position: " << pos;
1120 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1130 ostr <<
"* violation: comment within .BOARD_OUTLINE section\n";
1131 ostr <<
"* line: '" << iline <<
"'\n";
1132 ostr <<
"* file position: " << pos;
1134 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1142 ostr <<
"* violation: no thickness specified\n";
1143 ostr <<
"* file position: " << pos;
1145 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1148 std::stringstream teststr;
1153 if( teststr.fail() )
1158 ostr <<
"* violation: invalid RECORD 2 (thickness)\n";
1159 ostr <<
"* line: '" << iline <<
"'\n";
1160 ostr <<
"* file position: " << pos;
1162 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1176 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
1178 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1187 ERROR_IDF <<
"\n* WARNING: setting board thickness to default 1.6mm (";
1194 ERROR_IDF <<
"\n* WARNING: setting board thickness to positive number (";
1203 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1205 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
1210 ostr <<
"* violation: premature end\n";
1211 ostr <<
"* file position: " << pos;
1213 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1223 ostr <<
"* violation: comment within section\n";
1224 ostr <<
"* line: '" << iline <<
"'\n";
1225 ostr <<
"* file position: " << pos;
1227 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1235 ostr <<
"* violation: no .END_BOARD_OUTLINE found\n";
1236 ostr <<
"* file position: " << pos;
1238 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1248 aBoardFile <<
".BOARD_OUTLINE ";
1253 aBoardFile << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
"\n";
1255 aBoardFile << setiosflags( ios::fixed ) << setprecision( 1 )
1260 aBoardFile <<
".END_BOARD_OUTLINE\n\n";
1275#ifndef DISABLE_IDF_OWNERSHIP
1300 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1301 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
1307 if( *itS == aOutline )
1308 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
1309 "duplicate outline pointer" ) );
1317 catch(
const std::exception& e )
1330#ifndef DISABLE_IDF_OWNERSHIP
1341 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1342 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
1347 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1348 ostr <<
"* BUG: nullptr aOutline pointer\n";
1369 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1370 ostr <<
"* BUG: attempting to delete first outline in list\n";
1383 if( *itS == aOutline )
1399 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1410 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1411 ostr <<
"* BUG: index out of bounds (" << aIndex <<
" / " <<
outlines.size() <<
")\n";
1426 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1427 ostr <<
"* BUG: attempting to delete first outline in list\n";
1440 for( ; aIndex > 0; --aIndex )
1467 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1468 ostr <<
"* aIndex (" << aIndex <<
") is out of range (" <<
outlines.size() <<
")";
1474 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1476 for( ; aIndex > 0; --aIndex )
1491#ifndef DISABLE_IDF_OWNERSHIP
1509 std::list< IDF_OUTLINE* >::iterator itS =
outlines.begin();
1510 std::list< IDF_OUTLINE* >::iterator itE =
outlines.end();
1524 if( aComment.empty() )
1548 std::list< std::string >::iterator itS =
comments.begin();
1550 for( ; aIndex > 0; --aIndex )
1562 std::list< std::string >::iterator itS =
comments.begin();
1564 for( ; aIndex > 0; --aIndex )
1589#ifndef DISABLE_IDF_OWNERSHIP
1608#ifndef DISABLE_IDF_OWNERSHIP
1624 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
1625 ostr <<
"* BUG: invalid side (" <<
static_cast<int>( aSide ) <<
"); must be one of TOP/BOTTOM\n";
1656 bool quoted =
false;
1658 std::streampos pos = aBoardFile.tellg();
1663 ostr <<
"\n* BUG: invalid invocation: blank header line\n";
1665 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1673 ostr <<
"* violation: section names must not be in quotes\n";
1674 ostr <<
"* line: '" << aHeader <<
"'\n";
1675 ostr <<
"* file position: " << pos;
1677 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1687 ostr <<
"* BUG: not an .OTHER outline\n";
1689 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1699 ostr <<
"* BUG: not a .VIA_KEEPOUT outline\n";
1701 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1708 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
1716 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
1722 bool comment =
false;
1728 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1730 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
1735 ostr <<
"* violation: premature end\n";
1736 ostr <<
"* file position: " << pos;
1738 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1747 ostr <<
"* violation: comment within .OTHER_OUTLINE section\n";
1748 ostr <<
"* line: '" << iline <<
"'\n";
1749 ostr <<
"* file position: " << pos;
1751 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1759 ostr <<
"* violation: no outline identifier\n";
1760 ostr <<
"* line: '" << iline <<
"'\n";
1761 ostr <<
"* file position: " << pos;
1763 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1773 ostr <<
"* violation: no thickness\n";
1774 ostr <<
"* line: '" << iline <<
"'\n";
1775 ostr <<
"* file position: " << pos;
1777 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1780 std::stringstream teststr;
1785 if( teststr.fail() )
1790 ostr <<
"* violation: invalid thickness\n";
1791 ostr <<
"* line: '" << iline <<
"'\n";
1792 ostr <<
"* file position: " << pos;
1794 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1808 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
1810 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1824 ostr <<
"* violation: no board side\n";
1825 ostr <<
"* line: '" << iline <<
"'\n";
1826 ostr <<
"* file position: " << pos;
1828 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1836 ostr <<
"* violation: invalid side (must be TOP or BOTTOM only)\n";
1837 ostr <<
"* line: '" << iline <<
"'\n";
1838 ostr <<
"* file position: " << pos;
1840 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1850 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
1852 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
1857 ostr <<
"* violation: premature end\n";
1858 ostr <<
"* file position: " << pos;
1860 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1870 ostr <<
"* violation: comment within section\n";
1871 ostr <<
"* line: '" << iline <<
"'\n";
1872 ostr <<
"* file position: " << pos;
1874 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1884 ostr <<
"* violation: no .END_OTHER_OUTLINE found\n";
1885 ostr <<
"* file position: " << pos;
1887 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1897 ostr <<
"* violation: no .END_VIA_KEEPOUT found\n";
1898 ostr <<
"* file position: " << pos;
1900 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1916 aBoardFile <<
".OTHER_OUTLINE ";
1918 aBoardFile <<
".VIA_KEEPOUT ";
1928 aBoardFile << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
" ";
1930 aBoardFile << setiosflags( ios::fixed ) << setprecision( 1 )
1944 ostr <<
"\n* invalid OTHER_OUTLINE side (neither top nor bottom): ";
1945 ostr << static_cast<int>(
side );
1946 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
1958 aBoardFile <<
".END_OTHER_OUTLINE\n\n";
1960 aBoardFile <<
".END_VIA_KEEPOUT\n\n";
1966#ifndef DISABLE_IDF_OWNERSHIP
1990#ifndef DISABLE_IDF_OWNERSHIP
2017 bool quoted =
false;
2019 std::streampos pos = aBoardFile.tellg();
2023 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2024 "\n* BUG: invalid invocation; blank header line" ) );
2032 ostr <<
"* violation: section names must not be in quotes\n";
2033 ostr <<
"* line: '" << aHeader <<
"'\n";
2034 ostr <<
"* file position: " << pos;
2036 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2042 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2043 "\n* BUG: not a ROUTE outline" ) );
2048 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2049 "\n* BUG: not a ROUTE KEEPOUT outline" ) );
2055 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
2063 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
2071 bool comment =
false;
2075 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2077 if( !aBoardFile.good() )
2082 ostr <<
"* violation: premature end\n";
2083 ostr <<
"* file position: " << pos;
2085 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2095 ostr <<
"* violation: comment within a section\n";
2096 ostr <<
"* line: '" << iline <<
"'\n";
2097 ostr <<
"* file position: " << pos;
2099 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2107 ostr <<
"* violation: no layers specification\n";
2108 ostr <<
"* line: '" << iline <<
"'\n";
2109 ostr <<
"* file position: " << pos;
2111 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2119 ostr <<
"* violation: layers specification must not be in quotes\n";
2120 ostr <<
"* line: '" << iline <<
"'\n";
2121 ostr <<
"* file position: " << pos;
2123 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2131 ostr <<
"* violation: invalid layers specification\n";
2132 ostr <<
"* line: '" << iline <<
"'\n";
2133 ostr <<
"* file position: " << pos;
2135 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2145 ostr <<
"* violation: IDFv2 allows only TOP/BOTTOM/BOTH; layer was '";
2146 ostr << token <<
"'\n";
2147 ostr <<
"* line: '" << iline <<
"'\n";
2148 ostr <<
"* file position: " << pos;
2150 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2163 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2165 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
2170 ostr <<
"* violation: premature end\n";
2171 ostr <<
"* file position: " << pos;
2173 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2183 ostr <<
"* violation: comment within section\n";
2184 ostr <<
"* line: '" << iline <<
"'\n";
2185 ostr <<
"* file position: " << pos;
2187 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2197 ostr <<
"* violation: no .END_ROUTE_OUTLINE found\n";
2198 ostr <<
"* file position: " << pos;
2200 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2210 ostr <<
"* violation: no .END_ROUTE_KEEPOUT found\n";
2211 ostr <<
"* file position: " << pos;
2213 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2226 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2227 "layer not specified" ) );
2233 aBoardFile <<
".ROUTE_OUTLINE ";
2235 aBoardFile <<
".ROUTE_KEEPOUT ";
2248 aBoardFile <<
".END_ROUTE_OUTLINE\n\n";
2250 aBoardFile <<
".END_ROUTE_KEEPOUT\n\n";
2256#ifndef DISABLE_IDF_OWNERSHIP
2280#ifndef DISABLE_IDF_OWNERSHIP
2298 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
2299 ostr <<
"* BUG: invalid layer (" <<
static_cast<int>( aSide ) <<
"): must be one of TOP/BOTTOM/BOTH\n";
2321#ifndef DISABLE_IDF_OWNERSHIP
2333 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
2334 ostr <<
"* BUG: invalid height (" << aHeight <<
"): must be >= 0.0";
2363 bool quoted =
false;
2365 std::streampos pos = aBoardFile.tellg();
2368 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2369 "\n* BUG: invalid invocation: blank header line\n" ) );
2376 ostr <<
"* violation: section name must not be in quotes\n";
2377 ostr <<
"* line: '" << aHeader <<
"'\n";
2378 ostr <<
"* file position: " << pos;
2380 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2386 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2387 "\n* BUG: not a .PLACE_OUTLINE" ) );
2392 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2393 "\n* BUG: not a .PLACE_KEEPOUT" ) );
2399 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
2407 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
2415 bool comment =
false;
2419 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2421 if( !aBoardFile.good() )
2426 ostr <<
"* violation: premature end\n";
2427 ostr <<
"* file position: " << pos;
2429 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2439 ostr <<
"* violation: comment within the section\n";
2440 ostr <<
"* line: '" << iline <<
"'\n";
2441 ostr <<
"* file position: " << pos;
2443 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2451 ostr <<
"* violation: no board side information\n";
2452 ostr <<
"* line: '" << iline <<
"'\n";
2453 ostr <<
"* file position: " << pos;
2455 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2464 ostr <<
"* violation: invalid board side: must be one of TOP/BOTTOM/BOTH\n";
2465 ostr <<
"* line: '" << iline <<
"'\n";
2466 ostr <<
"* file position: " << pos;
2468 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2473 std::stringstream teststr;
2478 if( teststr.fail() )
2483 ostr <<
"* violation: invalid height\n";
2484 ostr <<
"* line: '" << iline <<
"'\n";
2485 ostr <<
"* file position: " << pos;
2487 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2495 ostr <<
"* violation: thickness < 0\n";
2496 ostr <<
"* line: '" << iline <<
"'\n";
2497 ostr <<
"* file position: " << pos;
2499 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2513 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
2515 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2529 ostr <<
"* violation: missing thickness\n";
2530 ostr <<
"* line: '" << iline <<
"'\n";
2531 ostr <<
"* file position: " << pos;
2533 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2549 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2551 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
2556 ostr <<
"* violation: premature end\n";
2557 ostr <<
"* file position: " << pos;
2559 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2569 ostr <<
"* violation: comment within section\n";
2570 ostr <<
"* line: '" << iline <<
"'\n";
2571 ostr <<
"* file position: " << pos;
2573 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2580 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2581 "invalid .PLACE_OUTLINE section: no .END_PLACE_OUTLINE found" ) );
2587 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2588 "invalid .PLACE_KEEPOUT section: no .END_PLACE_KEEPOUT found" ) );
2603 aBoardFile <<
".PLACE_OUTLINE ";
2605 aBoardFile <<
".PLACE_KEEPOUT ";
2622 ostr <<
"\n* invalid PLACE_OUTLINE/KEEPOUT side (";
2623 ostr << static_cast<int>(
side ) <<
"); must be one of TOP/BOTTOM/BOTH";
2624 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2640 aBoardFile << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
"\n";
2642 aBoardFile << setiosflags( ios::fixed ) << setprecision( 1 )
2651 aBoardFile <<
".END_PLACE_OUTLINE\n\n";
2653 aBoardFile <<
".END_PLACE_KEEPOUT\n\n";
2661#ifndef DISABLE_IDF_OWNERSHIP
2711#ifndef DISABLE_IDF_OWNERSHIP
2728 ostr <<
"invalid side (" <<
static_cast<int>( aSide ) <<
"); must be one of TOP/BOTTOM/BOTH\n";
2750#ifndef DISABLE_IDF_OWNERSHIP
2777 bool quoted =
false;
2779 std::streampos pos = aBoardFile.tellg();
2782 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2783 "\n* BUG: invalid invocation: blank header line" ) );
2790 ostr <<
"* violation: section name must not be in quotes\n";
2791 ostr <<
"* line: '" << aHeader <<
"'\n";
2792 ostr <<
"* file position: " << pos;
2794 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2798 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
"\n* BUG: not a .PLACE_REGION" ) );
2803 ERROR_IDF <<
"no OWNER; setting to UNOWNED\n";
2811 ERROR_IDF <<
"invalid OWNER (reverting to UNOWNED): " << token <<
"\n";
2817 bool comment =
false;
2821 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2823 if( !aBoardFile.good() )
2828 ostr <<
"* violation: premature end\n";
2829 ostr <<
"* file position: " << pos;
2831 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2841 ostr <<
"* violation: comment within section\n";
2842 ostr <<
"* line: '" << iline <<
"'\n";
2843 ostr <<
"* file position: " << pos;
2845 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2853 ostr <<
"* violation: no board side specified\n";
2854 ostr <<
"* line: '" << iline <<
"'\n";
2855 ostr <<
"* file position: " << pos;
2857 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2866 ostr <<
"* violation: invalid board side, must be one of TOP/BOTTOM/BOTH\n";
2867 ostr <<
"* line: '" << iline <<
"'\n";
2868 ostr <<
"* file position: " << pos;
2870 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2878 ostr <<
"* violation: no outline identifier\n";
2879 ostr <<
"* line: '" << iline <<
"'\n";
2880 ostr <<
"* file position: " << pos;
2882 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2891 while( aBoardFile.good() && !
FetchIDFLine( aBoardFile, iline, comment, pos ) );
2893 if( ( !aBoardFile.good() && aBoardFile.eof() ) || iline.empty() )
2898 ostr <<
"* violation: premature end\n";
2899 ostr <<
"* file position: " << pos;
2901 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2911 ostr <<
"* violation: comment within section\n";
2912 ostr <<
"* line: '" << iline <<
"'\n";
2913 ostr <<
"* file position: " << pos;
2915 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2920 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
2921 "\n* invalid .PLACE_REGION section: no .END_PLACE_REGION found" ) );
2935 aBoardFile <<
".PLACE_REGION ";
2952 ostr <<
"\n* invalid PLACE_REGION side (must be TOP/BOTTOM/BOTH): ";
2953 ostr << static_cast<int>(
side );
2955 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
2967 aBoardFile <<
".END_PLACE_REGION\n\n";
2973#ifndef DISABLE_IDF_OWNERSHIP
3000 bool quoted =
false;
3001 bool comment =
false;
3009 while( aLibFile.good() )
3021 ostr <<
"* violation: comment within section\n";
3022 ostr <<
"* line: '" << iline <<
"'\n";
3023 ostr <<
"* file position: " << pos;
3025 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3033 ostr <<
"* violation: bad property section (no PROP)\n";
3034 ostr <<
"* line: '" << iline <<
"'\n";
3035 ostr <<
"* file position: " << pos;
3037 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3045 ostr <<
"* violation: PROP or .END must not be quoted\n";
3046 ostr <<
"* line: '" << iline <<
"'\n";
3047 ostr <<
"* file position: " << pos;
3049 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3052 if( token.size() >= 5 &&
CompareToken(
".END_", token.substr( 0, 5 ) ) )
3057 aLibFile.seekg( pos );
3066 ostr <<
"* violation: expecting PROP or .END_ELECTRICAL\n";
3067 ostr <<
"* line: '" << iline <<
"'\n";
3068 ostr <<
"* file position: " << pos;
3070 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3078 ostr <<
"* violation: no PROP name\n";
3079 ostr <<
"* line: '" << iline <<
"'\n";
3080 ostr <<
"* file position: " << pos;
3082 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3092 ostr <<
"* violation: no PROP value\n";
3093 ostr <<
"* line: '" << iline <<
"'\n";
3094 ostr <<
"* file position: " << pos;
3096 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3101 if(
props.insert( pair< string, string >(pname, pval) ).second ==
false )
3107 ostr <<
"* line: '" << iline <<
"'\n";
3108 ostr <<
"* file position: " << pos;
3110 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3121 std::map< std::string, std::string >::const_iterator itS =
props.begin();
3122 std::map< std::string, std::string >::const_iterator itE =
props.end();
3131 return !aLibFile.fail();
3144 bool quoted =
false;
3146 std::streampos pos = aLibFile.tellg();
3149 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
3150 "\n* BUG: invalid invocation: blank header line" ) );
3157 ostr <<
"* violation: section name must not be in quotes\n";
3158 ostr <<
"* line: '" << aHeader <<
"'\n";
3159 ostr <<
"* file position: " << pos;
3161 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3177 ostr <<
"* violation: expecting .ELECTRICAL or .MECHANICAL header\n";
3178 ostr <<
"* line: '" << aHeader <<
"'\n";
3179 ostr <<
"* file position: " << pos;
3181 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3187 bool comment =
false;
3189 while( aLibFile.good() && !
FetchIDFLine( aLibFile, iline, comment, pos ) );
3191 if( !aLibFile.good() )
3196 ostr <<
"* violation: premature end\n";
3197 ostr <<
"* file position: " << pos;
3199 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3209 ostr <<
"* violation: comment within section\n";
3210 ostr <<
"* line: '" << iline <<
"'\n";
3211 ostr <<
"* file position: " << pos;
3213 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3221 ostr <<
"* violation: no GEOMETRY NAME\n";
3222 ostr <<
"* line: '" << iline <<
"'\n";
3223 ostr <<
"* file position: " << pos;
3225 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3235 ostr <<
"* violation: no PART NAME\n";
3236 ostr <<
"* line: '" << iline <<
"'\n";
3237 ostr <<
"* file position: " << pos;
3239 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3249 ostr <<
"* violation: both GEOMETRY and PART names are empty\n";
3250 ostr <<
"* line: '" << iline <<
"'\n";
3251 ostr <<
"* file position: " << pos;
3253 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3261 ostr <<
"* violation: no UNIT type\n";
3262 ostr <<
"* line: '" << iline <<
"'\n";
3263 ostr <<
"* file position: " << pos;
3265 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3285 ostr <<
"* violation: invalid UNIT '" << token <<
"': must be one of MM or THOU\n";
3286 ostr <<
"* line: '" << iline <<
"'\n";
3287 ostr <<
"* file position: " << pos;
3289 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3297 ostr <<
"* violation: no height specified\n";
3298 ostr <<
"* line: '" << iline <<
"'\n";
3299 ostr <<
"* file position: " << pos;
3301 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3304 std::istringstream teststr;
3305 teststr.str( token );
3308 if( teststr.fail() )
3313 ostr <<
"* violation: invalid height '" << token <<
"'\n";
3314 ostr <<
"* line: '" << iline <<
"'\n";
3315 ostr <<
"* file position: " << pos;
3317 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3331 ostr <<
"\n* BUG: invalid UNIT type: " <<
static_cast<int>(
unit );
3333 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3343 while( aLibFile.good() && !
FetchIDFLine( aLibFile, iline, comment, pos ) );
3345 if( ( !aLibFile.good() && aLibFile.eof() ) && iline.empty() )
3350 ostr <<
"* violation: premature end\n";
3351 ostr <<
"* file position: " << pos;
3353 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3363 ostr <<
"* violation: comment within section\n";
3364 ostr <<
"* line: '" << iline <<
"'\n";
3365 ostr <<
"* file position: " << pos;
3367 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3377 ostr <<
"* violation: no .END_ELECTRICAL found\n";
3378 ostr <<
"* line: '" << iline <<
"'\n";
3379 ostr <<
"* file position: " << pos;
3381 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3391 ostr <<
"* violation: no .END_MECHANICAL found\n";
3392 ostr <<
"* line: '" << iline <<
"'\n";
3393 ostr <<
"* file position: " << pos;
3395 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3409 ostr <<
"\n* component type not set or invalid: " <<
static_cast<int>(
compType );
3411 throw(
IDF_ERROR( __FILE__, __FUNCTION__, __LINE__, ostr.str() ) );
3418 aLibFile <<
".ELECTRICAL\n";
3420 aLibFile <<
".MECHANICAL\n";
3429 aLibFile <<
"MM " << setiosflags( ios::fixed ) << setprecision( 5 ) <<
thickness <<
"\n";
3433 aLibFile <<
"THOU " << setiosflags( ios::fixed ) << setprecision( 1 )
3442 aLibFile <<
".END_ELECTRICAL\n\n";
3446 aLibFile <<
".END_MECHANICAL\n\n";
3453#ifndef DISABLE_IDF_OWNERSHIP
3472 switch( aCompClass )
3483 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
3484 ostr <<
"* BUG: invalid component class (must be ELECTRICAL or MECHANICAL): ";
3485 ostr << static_cast<int>( aCompClass ) <<
"\n";
3555 ostr << __FILE__ <<
":" << __LINE__ <<
":" << __FUNCTION__ <<
"():\n";
3556 ostr <<
"* BUG: decrementing refNum beyond 0";
3571 if( aGeom.empty() && aPart.empty() )
3575 uid =
"NOGEOM_NOPART";
3581 uid = aGeom +
"_" + aPart;
3597 p1.
x = 1.5 * cos( a );
3598 p1.
y = 1.5 * sin( a );
3604 catch( std::bad_alloc& )
3609 for(
int i = 0; i < 10; ++i )
3613 p2.
x = 2.5 * cos( a );
3614 p2.
y = 2.5 * sin( a );
3618 p2.
x = 1.5 * cos( a );
3619 p2.
y = 1.5 * sin( a );
3626 catch( std::bad_alloc& )
3638 p2.
x = 1.5 * cos( a );
3639 p2.
y = 1.5 * sin( a );
3645 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.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...