Some code cleanup
This commit is contained in:
parent
c40470ed0b
commit
b7e7cf9212
|
@ -72,8 +72,7 @@ C_MICROSTRIP::C_MICROSTRIP() : TRANSLINE(),
|
||||||
|
|
||||||
C_MICROSTRIP::~C_MICROSTRIP()
|
C_MICROSTRIP::~C_MICROSTRIP()
|
||||||
{
|
{
|
||||||
if( aux_ms )
|
delete aux_ms;
|
||||||
delete aux_ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,8 @@ using namespace std;
|
||||||
std::string source;
|
std::string source;
|
||||||
std::string message;
|
std::string message;
|
||||||
|
|
||||||
IDF_ERROR::IDF_ERROR( const char* aSourceFile,
|
IDF_ERROR::IDF_ERROR( const char* aSourceFile, const char* aSourceMethod, int aSourceLine,
|
||||||
const char* aSourceMethod,
|
const std::string& aMessage ) noexcept
|
||||||
int aSourceLine,
|
|
||||||
const std::string& aMessage ) throw()
|
|
||||||
{
|
{
|
||||||
ostringstream ostr;
|
ostringstream ostr;
|
||||||
|
|
||||||
|
@ -69,24 +67,23 @@ IDF_ERROR::IDF_ERROR( const char* aSourceFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IDF_ERROR::~IDF_ERROR() throw()
|
IDF_ERROR::~IDF_ERROR() noexcept
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* IDF_ERROR::what() const throw()
|
const char* IDF_ERROR::what() const noexcept
|
||||||
{
|
{
|
||||||
return message.c_str();
|
return message.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IDF_NOTE::IDF_NOTE()
|
IDF_NOTE::IDF_NOTE() :
|
||||||
|
xpos( 0.0 ),
|
||||||
|
ypos( 0.0 ),
|
||||||
|
height( 0.0 ),
|
||||||
|
length( 0.0 )
|
||||||
{
|
{
|
||||||
xpos = 0.0;
|
|
||||||
ypos = 0.0;
|
|
||||||
height = 0.0;
|
|
||||||
length = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,24 +271,21 @@ bool IDF_NOTE::writeNote( std::ostream& aBoardFile, IDF3::IDF_UNIT aBoardUnit )
|
||||||
void IDF_NOTE::SetText( const std::string& aText )
|
void IDF_NOTE::SetText( const std::string& aText )
|
||||||
{
|
{
|
||||||
text = aText;
|
text = aText;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDF_NOTE::SetPosition( double aXpos, double aYpos )
|
void IDF_NOTE::SetPosition( double aXpos, double aYpos )
|
||||||
{
|
{
|
||||||
xpos = aXpos;
|
xpos = aXpos;
|
||||||
ypos = aYpos;
|
ypos = aYpos;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDF_NOTE::SetSize( double aHeight, double aLength )
|
void IDF_NOTE::SetSize( double aHeight, double aLength )
|
||||||
{
|
{
|
||||||
height = aHeight;
|
height = aHeight;
|
||||||
length = aLength;
|
length = aLength;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& IDF_NOTE::GetText( void )
|
const std::string& IDF_NOTE::GetText()
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -300,31 +294,27 @@ void IDF_NOTE::GetPosition( double& aXpos, double& aYpos )
|
||||||
{
|
{
|
||||||
aXpos = xpos;
|
aXpos = xpos;
|
||||||
aYpos = ypos;
|
aYpos = ypos;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDF_NOTE::GetSize( double& aHeight, double& aLength )
|
void IDF_NOTE::GetSize( double& aHeight, double& aLength )
|
||||||
{
|
{
|
||||||
aHeight = height;
|
aHeight = height;
|
||||||
aLength = length;
|
aLength = length;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IDF_DRILL_DATA
|
* IDF_DRILL_DATA
|
||||||
*/
|
*/
|
||||||
IDF_DRILL_DATA::IDF_DRILL_DATA()
|
IDF_DRILL_DATA::IDF_DRILL_DATA() :
|
||||||
|
dia( 0.0 ),
|
||||||
|
x( 0.0 ),
|
||||||
|
y( 0.0 ),
|
||||||
|
plating( NPTH ),
|
||||||
|
kref( NOREFDES ),
|
||||||
|
khole( MTG ),
|
||||||
|
owner( UNOWNED )
|
||||||
{
|
{
|
||||||
dia = 0.0;
|
|
||||||
x = 0.0;
|
|
||||||
y = 0.0;
|
|
||||||
plating = NPTH;
|
|
||||||
kref = NOREFDES;
|
|
||||||
khole = MTG;
|
|
||||||
owner = UNOWNED;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -416,21 +406,27 @@ bool IDF_DRILL_DATA::read( std::istream& aBoardFile, IDF3::IDF_UNIT aBoardUnit,
|
||||||
while( !FetchIDFLine( aBoardFile, iline, isComment, pos ) && aBoardFile.good() );
|
while( !FetchIDFLine( aBoardFile, iline, isComment, pos ) && aBoardFile.good() );
|
||||||
|
|
||||||
if( ( !aBoardFile.good() && !aBoardFile.eof() ) || iline.empty() )
|
if( ( !aBoardFile.good() && !aBoardFile.eof() ) || iline.empty() )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"problems reading board drilled holes" ) );
|
"problems reading board drilled holes" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( isComment )
|
if( isComment )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: comment within a section (DRILLED HOLES)" ) );
|
"* Violation of specification: comment within a section (DRILLED HOLES)" ) );
|
||||||
|
}
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
GetIDFString( iline, token, quoted, idx );
|
GetIDFString( iline, token, quoted, idx );
|
||||||
|
|
||||||
if( quoted )
|
if( quoted )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: drill diameter must not be in quotes" ) );
|
"* Violation of specification: drill diameter must not be in quotes" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( CompareToken( ".END_DRILLED_HOLES", token ) )
|
if( CompareToken( ".END_DRILLED_HOLES", token ) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -440,9 +436,11 @@ bool IDF_DRILL_DATA::read( std::istream& aBoardFile, IDF3::IDF_UNIT aBoardUnit,
|
||||||
|
|
||||||
istr >> dia;
|
istr >> dia;
|
||||||
if( istr.fail() )
|
if( istr.fail() )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: drill diameter is not numeric" ) );
|
"* Violation of specification: drill diameter is not numeric" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( ( aBoardUnit == UNIT_MM && dia < IDF_MIN_DIA_MM )
|
if( ( aBoardUnit == UNIT_MM && dia < IDF_MIN_DIA_MM )
|
||||||
|| ( aBoardUnit == UNIT_THOU && dia < IDF_MIN_DIA_THOU )
|
|| ( aBoardUnit == UNIT_THOU && dia < IDF_MIN_DIA_THOU )
|
||||||
|
@ -456,49 +454,63 @@ bool IDF_DRILL_DATA::read( std::istream& aBoardFile, IDF3::IDF_UNIT aBoardUnit,
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !GetIDFString( iline, token, quoted, idx ) )
|
if( !GetIDFString( iline, token, quoted, idx ) )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: missing X position for drilled hole" ) );
|
"* Violation of specification: missing X position for drilled hole" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( quoted )
|
if( quoted )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: X position in DRILLED HOLES section must not be in quotes" ) );
|
"* Violation of specification: X position in DRILLED HOLES section must not be in quotes" ) );
|
||||||
|
}
|
||||||
|
|
||||||
istr.clear();
|
istr.clear();
|
||||||
istr.str( token );
|
istr.str( token );
|
||||||
|
|
||||||
istr >> x;
|
istr >> x;
|
||||||
if( istr.fail() )
|
if( istr.fail() )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: X position in DRILLED HOLES section is not numeric" ) );
|
"* Violation of specification: X position in DRILLED HOLES section is not numeric" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( !GetIDFString( iline, token, quoted, idx ) )
|
if( !GetIDFString( iline, token, quoted, idx ) )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: missing Y position for drilled hole" ) );
|
"* Violation of specification: missing Y position for drilled hole" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( quoted )
|
if( quoted )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: Y position in DRILLED HOLES section must not be in quotes" ) );
|
"* Violation of specification: Y position in DRILLED HOLES section must not be in quotes" ) );
|
||||||
|
}
|
||||||
|
|
||||||
istr.clear();
|
istr.clear();
|
||||||
istr.str( token );
|
istr.str( token );
|
||||||
|
|
||||||
istr >> y;
|
istr >> y;
|
||||||
if( istr.fail() )
|
if( istr.fail() )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDF file\n"
|
"invalid IDF file\n"
|
||||||
"* Violation of specification: Y position in DRILLED HOLES section is not numeric" ) );
|
"* Violation of specification: Y position in DRILLED HOLES section is not numeric" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( aIdfVersion > IDF_V2 )
|
if( aIdfVersion > IDF_V2 )
|
||||||
{
|
{
|
||||||
if( !GetIDFString( iline, token, quoted, idx ) )
|
if( !GetIDFString( iline, token, quoted, idx ) )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDFv3 file\n"
|
"invalid IDFv3 file\n"
|
||||||
"* Violation of specification: missing PLATING for drilled hole" ) );
|
"* Violation of specification: missing PLATING for drilled hole" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( CompareToken( "PTH", token ) )
|
if( CompareToken( "PTH", token ) )
|
||||||
{
|
{
|
||||||
|
@ -609,9 +621,11 @@ bool IDF_DRILL_DATA::read( std::istream& aBoardFile, IDF3::IDF_UNIT aBoardUnit,
|
||||||
if( aIdfVersion > IDF_V2 )
|
if( aIdfVersion > IDF_V2 )
|
||||||
{
|
{
|
||||||
if( !GetIDFString( iline, token, quoted, idx ) )
|
if( !GetIDFString( iline, token, quoted, idx ) )
|
||||||
|
{
|
||||||
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
throw( IDF_ERROR( __FILE__, __FUNCTION__, __LINE__,
|
||||||
"invalid IDFv3 file\n"
|
"invalid IDFv3 file\n"
|
||||||
"* Violation of specification: missing OWNER for drilled hole" ) );
|
"* Violation of specification: missing OWNER for drilled hole" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( !ParseOwner( token, owner ) )
|
if( !ParseOwner( token, owner ) )
|
||||||
{
|
{
|
||||||
|
@ -659,44 +673,19 @@ void IDF_DRILL_DATA::write( std::ostream& aBoardFile, IDF3::IDF_UNIT aBoardUnit
|
||||||
|
|
||||||
switch( khole )
|
switch( khole )
|
||||||
{
|
{
|
||||||
case PIN:
|
case PIN: holestr = "PIN"; break;
|
||||||
holestr = "PIN";
|
case VIA: holestr = "VIA"; break;
|
||||||
break;
|
case TOOL: holestr = "TOOL"; break;
|
||||||
|
case OTHER: holestr = "\"" + holetype + "\""; break;
|
||||||
case VIA:
|
default: holestr = "MTG"; break;
|
||||||
holestr = "VIA";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOOL:
|
|
||||||
holestr = "TOOL";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OTHER:
|
|
||||||
holestr = "\"" + holetype + "\"";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
holestr = "MTG";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( kref )
|
switch( kref )
|
||||||
{
|
{
|
||||||
case BOARD:
|
case BOARD: refstr = "BOARD"; break;
|
||||||
refstr = "BOARD";
|
case PANEL: refstr = "PANEL"; break;
|
||||||
break;
|
case REFDES: refstr = "\"" + refdes + "\""; break;
|
||||||
|
default: refstr = "NOREFDES"; break;
|
||||||
case PANEL:
|
|
||||||
refstr = "PANEL";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case REFDES:
|
|
||||||
refstr = "\"" + refdes + "\"";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
refstr = "NOREFDES";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( plating == PTH )
|
if( plating == PTH )
|
||||||
|
@ -706,17 +695,9 @@ void IDF_DRILL_DATA::write( std::ostream& aBoardFile, IDF3::IDF_UNIT aBoardUnit
|
||||||
|
|
||||||
switch( owner )
|
switch( owner )
|
||||||
{
|
{
|
||||||
case MCAD:
|
case MCAD: ownstr = "MCAD"; break;
|
||||||
ownstr = "MCAD";
|
case ECAD: ownstr = "ECAD"; break;
|
||||||
break;
|
default: ownstr = "UNOWNED"; break;
|
||||||
|
|
||||||
case ECAD:
|
|
||||||
ownstr = "ECAD";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ownstr = "UNOWNED";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aBoardUnit == UNIT_MM )
|
if( aBoardUnit == UNIT_MM )
|
||||||
|
@ -733,8 +714,6 @@ void IDF_DRILL_DATA::write( std::ostream& aBoardFile, IDF3::IDF_UNIT aBoardUnit
|
||||||
<< pltstr.c_str() << " " << refstr.c_str() << " "
|
<< pltstr.c_str() << " " << refstr.c_str() << " "
|
||||||
<< holestr.c_str() << " " << ownstr.c_str() << "\n";
|
<< holestr.c_str() << " " << ownstr.c_str() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
} // IDF_DRILL_DATA::Write( aBoardFile, unitMM )
|
} // IDF_DRILL_DATA::Write( aBoardFile, unitMM )
|
||||||
|
|
||||||
|
|
||||||
|
@ -762,20 +741,10 @@ const std::string& IDF_DRILL_DATA::GetDrillRefDes()
|
||||||
{
|
{
|
||||||
switch( kref )
|
switch( kref )
|
||||||
{
|
{
|
||||||
case BOARD:
|
case BOARD: refdes = "BOARD"; break;
|
||||||
refdes = "BOARD";
|
case PANEL: refdes = "PANEL"; break;
|
||||||
break;
|
case REFDES: break;
|
||||||
|
default: refdes = "NOREFDES"; break;
|
||||||
case PANEL:
|
|
||||||
refdes = "PANEL";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case REFDES:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
refdes = "NOREFDES";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return refdes;
|
return refdes;
|
||||||
|
@ -785,24 +754,11 @@ const std::string& IDF_DRILL_DATA::GetDrillHoleType()
|
||||||
{
|
{
|
||||||
switch( khole )
|
switch( khole )
|
||||||
{
|
{
|
||||||
case PIN:
|
case PIN: holetype = "PIN"; break;
|
||||||
holetype = "PIN";
|
case VIA: holetype = "VIA"; break;
|
||||||
break;
|
case TOOL: holetype = "TOOL"; break;
|
||||||
|
case OTHER: break;
|
||||||
case VIA:
|
default: holetype = "MTG"; break;
|
||||||
holetype = "VIA";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOOL:
|
|
||||||
holetype = "TOOL";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OTHER:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
holetype = "MTG";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return holetype;
|
return holetype;
|
||||||
|
@ -833,8 +789,6 @@ void IDF3::PrintSeg( IDF_SEGMENT* aSegment )
|
||||||
fprintf(stdout, "printSeg(): LINE: p1(%.3f, %.3f) p2(%.3f, %.3f)\n",
|
fprintf(stdout, "printSeg(): LINE: p1(%.3f, %.3f) p2(%.3f, %.3f)\n",
|
||||||
aSegment->startPoint.x, aSegment->startPoint.y,
|
aSegment->startPoint.x, aSegment->startPoint.y,
|
||||||
aSegment->endPoint.x, aSegment->endPoint.y );
|
aSegment->endPoint.x, aSegment->endPoint.y );
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1109,31 +1063,27 @@ bool IDF_SEGMENT::MatchesEnd( const IDF_POINT& aPoint, double aRadius )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IDF_SEGMENT::CalcCenterAndRadius( void )
|
void IDF_SEGMENT::CalcCenterAndRadius()
|
||||||
{
|
{
|
||||||
// NOTE: this routine does not check if the points are the same
|
// NOTE: this routine does not check if the points are the same
|
||||||
// or too close to be sensible in a production setting.
|
// or too close to be sensible in a production setting.
|
||||||
|
|
||||||
double offAng = IDF3::CalcAngleRad( startPoint, endPoint );
|
double offAng = IDF3::CalcAngleRad( startPoint, endPoint );
|
||||||
double d = startPoint.CalcDistance( endPoint ) / 2.0;
|
double d = startPoint.CalcDistance( endPoint ) / 2.0;
|
||||||
double xm = ( startPoint.x + endPoint.x ) * 0.5;
|
double xm = ( startPoint.x + endPoint.x ) * 0.5;
|
||||||
double ym = ( startPoint.y + endPoint.y ) * 0.5;
|
double ym = ( startPoint.y + endPoint.y ) * 0.5;
|
||||||
|
|
||||||
radius = d / sin( angle * M_PI / 360.0 );
|
radius = d / sin( angle * M_PI / 360.0 );
|
||||||
|
|
||||||
if( radius < 0.0 )
|
if( radius < 0.0 )
|
||||||
{
|
|
||||||
radius = -radius;
|
radius = -radius;
|
||||||
}
|
|
||||||
|
|
||||||
// calculate the height of the triangle with base d and hypotenuse r
|
// calculate the height of the triangle with base d and hypotenuse r
|
||||||
double dh2 = radius * radius - d * d;
|
double dh2 = radius * radius - d * d;
|
||||||
|
|
||||||
|
// this should only ever happen due to rounding errors when r == d
|
||||||
if( dh2 < 0 )
|
if( dh2 < 0 )
|
||||||
{
|
|
||||||
// this should only ever happen due to rounding errors when r == d
|
|
||||||
dh2 = 0;
|
dh2 = 0;
|
||||||
}
|
|
||||||
|
|
||||||
double h = sqrt( dh2 );
|
double h = sqrt( dh2 );
|
||||||
|
|
||||||
|
@ -1154,7 +1104,7 @@ void IDF_SEGMENT::CalcCenterAndRadius( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IDF_SEGMENT::IsCircle( void )
|
bool IDF_SEGMENT::IsCircle()
|
||||||
{
|
{
|
||||||
double diff = abs( angle ) - 360.0;
|
double diff = abs( angle ) - 360.0;
|
||||||
|
|
||||||
|
@ -1165,18 +1115,16 @@ bool IDF_SEGMENT::IsCircle( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double IDF_SEGMENT::GetMinX( void )
|
double IDF_SEGMENT::GetMinX()
|
||||||
{
|
{
|
||||||
if( angle == 0.0 )
|
if( angle == 0.0 )
|
||||||
return std::min( startPoint.x, endPoint.x );
|
return std::min( startPoint.x, endPoint.x );
|
||||||
|
|
||||||
// Calculate the leftmost point of the circle or arc
|
// Calculate the leftmost point of the circle or arc
|
||||||
|
|
||||||
|
// if only everything were this easy
|
||||||
if( IsCircle() )
|
if( IsCircle() )
|
||||||
{
|
|
||||||
// if only everything were this easy
|
|
||||||
return center.x - radius;
|
return center.x - radius;
|
||||||
}
|
|
||||||
|
|
||||||
// cases:
|
// cases:
|
||||||
// 1. CCW arc: if offset + included angle >= 180 deg then
|
// 1. CCW arc: if offset + included angle >= 180 deg then
|
||||||
|
@ -1190,26 +1138,20 @@ double IDF_SEGMENT::GetMinX( void )
|
||||||
{
|
{
|
||||||
// CCW case
|
// CCW case
|
||||||
if( ( offsetAngle + angle ) >= 180.0 )
|
if( ( offsetAngle + angle ) >= 180.0 )
|
||||||
{
|
|
||||||
return center.x - radius;
|
return center.x - radius;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return std::min( startPoint.x, endPoint.x );
|
return std::min( startPoint.x, endPoint.x );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CW case
|
// CW case
|
||||||
if( ( offsetAngle + angle ) <= -180.0 )
|
if( ( offsetAngle + angle ) <= -180.0 )
|
||||||
{
|
|
||||||
return center.x - radius;
|
return center.x - radius;
|
||||||
}
|
|
||||||
|
|
||||||
return std::min( startPoint.x, endPoint.x );
|
return std::min( startPoint.x, endPoint.x );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IDF_SEGMENT::SwapEnds( void )
|
void IDF_SEGMENT::SwapEnds()
|
||||||
{
|
{
|
||||||
if( IsCircle() )
|
if( IsCircle() )
|
||||||
{
|
{
|
||||||
|
@ -1232,7 +1174,7 @@ void IDF_SEGMENT::SwapEnds( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IDF_OUTLINE::IsCCW( void )
|
bool IDF_OUTLINE::IsCCW()
|
||||||
{
|
{
|
||||||
// note: when outlines are not valid, 'false' is returned
|
// note: when outlines are not valid, 'false' is returned
|
||||||
switch( outline.size() )
|
switch( outline.size() )
|
||||||
|
@ -1248,6 +1190,7 @@ bool IDF_OUTLINE::IsCCW( void )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1316,7 +1259,7 @@ bool IDF_OUTLINE::IsCCW( void )
|
||||||
|
|
||||||
|
|
||||||
// returns true if the outline is a circle
|
// returns true if the outline is a circle
|
||||||
bool IDF_OUTLINE::IsCircle( void )
|
bool IDF_OUTLINE::IsCircle()
|
||||||
{
|
{
|
||||||
if( outline.front()->IsCircle() )
|
if( outline.front()->IsCircle() )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -48,14 +48,12 @@ struct IDF_ERROR : std::exception
|
||||||
{
|
{
|
||||||
std::string message;
|
std::string message;
|
||||||
|
|
||||||
IDF_ERROR( const char* aSourceFile,
|
IDF_ERROR( const char* aSourceFile, const char* aSourceMethod, int aSourceLine,
|
||||||
const char* aSourceMethod,
|
const std::string& aMessage ) noexcept;
|
||||||
int aSourceLine,
|
|
||||||
const std::string& aMessage ) throw();
|
|
||||||
|
|
||||||
virtual ~IDF_ERROR() throw();
|
virtual ~IDF_ERROR() noexcept;
|
||||||
|
|
||||||
virtual const char* what() const throw() override;
|
virtual const char* what() const noexcept override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,7 +317,7 @@ public:
|
||||||
* Function GetText
|
* Function GetText
|
||||||
* returns the string stored in the note entry
|
* returns the string stored in the note entry
|
||||||
*/
|
*/
|
||||||
const std::string& GetText( void );
|
const std::string& GetText();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetText
|
* Function GetText
|
||||||
|
@ -457,7 +455,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const std::string& GetDrillHoleType();
|
const std::string& GetDrillHoleType();
|
||||||
|
|
||||||
IDF3::KEY_OWNER GetDrillOwner( void )
|
IDF3::KEY_OWNER GetDrillOwner()
|
||||||
{
|
{
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
@ -525,15 +523,15 @@ private:
|
||||||
*
|
*
|
||||||
* @var startPoint, @var endPoint, and @var angle must be set prior as per IDFv3
|
* @var startPoint, @var endPoint, and @var angle must be set prior as per IDFv3
|
||||||
*/
|
*/
|
||||||
void CalcCenterAndRadius( void );
|
void CalcCenterAndRadius();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IDF_POINT startPoint; ///< starting point coordinates in mm
|
IDF_POINT startPoint; ///< starting point coordinates in mm
|
||||||
IDF_POINT endPoint; ///< end point coordinates in mm
|
IDF_POINT endPoint; ///< end point coordinates in mm
|
||||||
IDF_POINT center; ///< center of an arc or circle; internally calculated and not to be set by the user
|
IDF_POINT center ; ///< center of an arc or circle; internally calculated and not to be set by the user
|
||||||
double angle; ///< included angle (degrees) according to IDFv3 specification
|
double angle; ///< included angle (degrees) according to IDFv3 specification
|
||||||
double offsetAngle; ///< angle between center and start of arc; internally calculated
|
double offsetAngle; ///< angle between center and start of arc; internally calculated
|
||||||
double radius; ///< radius of the arc or circle; internally calculated
|
double radius; ///< radius of the arc or circle; internally calculated
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor IDF_SEGMENT
|
* Constructor IDF_SEGMENT
|
||||||
|
@ -589,20 +587,20 @@ public:
|
||||||
* Function IsCircle
|
* Function IsCircle
|
||||||
* returns true if this segment is a circle
|
* returns true if this segment is a circle
|
||||||
*/
|
*/
|
||||||
bool IsCircle( void );
|
bool IsCircle();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetMinX()
|
* Function GetMinX()
|
||||||
* returns the minimum X coordinate of this segment
|
* returns the minimum X coordinate of this segment
|
||||||
*/
|
*/
|
||||||
double GetMinX( void );
|
double GetMinX();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SwapEnds()
|
* Function SwapEnds()
|
||||||
* Swaps the start and end points and alters internal
|
* Swaps the start and end points and alters internal
|
||||||
* variables as necessary for arcs
|
* variables as necessary for arcs
|
||||||
*/
|
*/
|
||||||
void SwapEnds( void );
|
void SwapEnds();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -624,19 +622,19 @@ public:
|
||||||
* Function IsCCW
|
* Function IsCCW
|
||||||
* returns true if the current list of points represents a counterclockwise winding
|
* returns true if the current list of points represents a counterclockwise winding
|
||||||
*/
|
*/
|
||||||
bool IsCCW( void );
|
bool IsCCW();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function IsCircle
|
* Function IsCircle
|
||||||
* returns true if this outline is a circle
|
* returns true if this outline is a circle
|
||||||
*/
|
*/
|
||||||
bool IsCircle( void );
|
bool IsCircle();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Clear
|
* Function Clear
|
||||||
* clears the internal list of outline segments
|
* clears the internal list of outline segments
|
||||||
*/
|
*/
|
||||||
void Clear( void )
|
void Clear()
|
||||||
{
|
{
|
||||||
dir = 0.0;
|
dir = 0.0;
|
||||||
|
|
||||||
|
@ -651,7 +649,7 @@ public:
|
||||||
* Function size
|
* Function size
|
||||||
* returns the size of the internal segment list
|
* returns the size of the internal segment list
|
||||||
*/
|
*/
|
||||||
size_t size( void )
|
size_t size()
|
||||||
{
|
{
|
||||||
return outline.size();
|
return outline.size();
|
||||||
}
|
}
|
||||||
|
@ -660,7 +658,7 @@ public:
|
||||||
* Function empty
|
* Function empty
|
||||||
* returns true if the internal segment list is empty
|
* returns true if the internal segment list is empty
|
||||||
*/
|
*/
|
||||||
bool empty( void )
|
bool empty()
|
||||||
{
|
{
|
||||||
return outline.empty();
|
return outline.empty();
|
||||||
}
|
}
|
||||||
|
@ -669,7 +667,7 @@ public:
|
||||||
* Function front
|
* Function front
|
||||||
* returns the front() iterator of the internal segment list
|
* returns the front() iterator of the internal segment list
|
||||||
*/
|
*/
|
||||||
IDF_SEGMENT*& front( void )
|
IDF_SEGMENT*& front()
|
||||||
{
|
{
|
||||||
return outline.front();
|
return outline.front();
|
||||||
}
|
}
|
||||||
|
@ -678,7 +676,7 @@ public:
|
||||||
* Function back
|
* Function back
|
||||||
* returns the back() iterator of the internal segment list
|
* returns the back() iterator of the internal segment list
|
||||||
*/
|
*/
|
||||||
IDF_SEGMENT*& back( void )
|
IDF_SEGMENT*& back()
|
||||||
{
|
{
|
||||||
return outline.back();
|
return outline.back();
|
||||||
}
|
}
|
||||||
|
@ -687,7 +685,7 @@ public:
|
||||||
* Function begin
|
* Function begin
|
||||||
* returns the begin() iterator of the internal segment list
|
* returns the begin() iterator of the internal segment list
|
||||||
*/
|
*/
|
||||||
std::list<IDF_SEGMENT*>::iterator begin( void )
|
std::list<IDF_SEGMENT*>::iterator begin()
|
||||||
{
|
{
|
||||||
return outline.begin();
|
return outline.begin();
|
||||||
}
|
}
|
||||||
|
@ -696,7 +694,7 @@ public:
|
||||||
* Function end
|
* Function end
|
||||||
* returns the end() iterator of the internal segment list
|
* returns the end() iterator of the internal segment list
|
||||||
*/
|
*/
|
||||||
std::list<IDF_SEGMENT*>::iterator end( void )
|
std::list<IDF_SEGMENT*>::iterator end()
|
||||||
{
|
{
|
||||||
return outline.end();
|
return outline.end();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue