eeschema-gal: don't use kiROUND in the geometry library as it brings in a s*****load of wx dependencies due to #include <base_units.h>

This commit is contained in:
Tomasz Wlostowski 2018-08-27 15:24:08 +02:00 committed by Jeff Young
parent d8b9899516
commit b604f007d7
5 changed files with 21 additions and 18 deletions

View File

@ -27,8 +27,6 @@
* @brief a few functions useful in geometry calculations.
*/
#include <math.h>
#include <common.h>
#include <geometry/geometry_utils.h>
int GetArcToSegmentCount( int aRadius, int aErrorMax, double aArcAngleDegree )
@ -41,7 +39,7 @@ int GetArcToSegmentCount( int aRadius, int aErrorMax, double aArcAngleDegree )
// minimal arc increment in degrees:
double step = 180 / M_PI * acos( 1.0 - rel_error ) * 2;
// the minimal seg count for a arc
int segCount = KiROUND( fabs( aArcAngleDegree ) / step );
int segCount = round_nearest( fabs( aArcAngleDegree ) / step );
// Ensure at least one segment is used
return std::max( segCount, 1 );

View File

@ -24,7 +24,6 @@
#include <vector>
#include <base_units.h>
#include <geometry/geometry_utils.h>
#include <geometry/shape_arc.h>
#include <geometry/shape_line_chain.h>

View File

@ -24,7 +24,6 @@
#include <algorithm>
#include <common.h>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_circle.h>
#include "clipper.hpp"
@ -400,7 +399,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
const VECTOR2D diff = p2 - p1;
if( aP.x >= p1.x && aP.x <= p2.x )
{
if( KiROUND( p1.y + ( diff.y / diff.x ) * ( aP.x - p1.x ) ) == aP.y )
if( round_nearest( p1.y + ( diff.y / diff.x ) * ( aP.x - p1.x ) ) == aP.y )
return true;
}
}

View File

@ -33,11 +33,13 @@
#include <list>
#include <algorithm>
#include <unordered_set>
#include <memory>
#include <common.h>
#include <md5_hash.h>
#include <map>
#include <make_unique.h>
#include <geometry/geometry_utils.h>
#include <geometry/shape.h>
#include <geometry/shape_line_chain.h>
@ -1707,13 +1709,13 @@ SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon( CORNER_MODE aMode,
if( 0.5 * lenb < distance )
distance = 0.5 * lenb;
int nx1 = KiROUND( distance * xa / lena );
int ny1 = KiROUND( distance * ya / lena );
int nx1 = round_nearest( distance * xa / lena );
int ny1 = round_nearest( distance * ya / lena );
newContour.Append( x1 + nx1, y1 + ny1 );
int nx2 = KiROUND( distance * xb / lenb );
int ny2 = KiROUND( distance * yb / lenb );
int nx2 = round_nearest( distance * xb / lenb );
int ny2 = round_nearest( distance * yb / lenb );
newContour.Append( x1 + nx2, y1 + ny2 );
}
@ -1773,11 +1775,11 @@ SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon( CORNER_MODE aMode,
double nx = xc + xs;
double ny = yc + ys;
newContour.Append( KiROUND( nx ), KiROUND( ny ) );
newContour.Append( round_nearest( nx ), round_nearest( ny ) );
// Store the previous added corner to make a sanity check
int prevX = KiROUND( nx );
int prevY = KiROUND( ny );
int prevX = round_nearest( nx );
int prevY = round_nearest( ny );
for( int j = 0; j < segments; j++ )
{
@ -1785,11 +1787,11 @@ SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon( CORNER_MODE aMode,
ny = yc - sin( startAngle + ( j + 1 ) * deltaAngle ) * radius;
// Sanity check: the rounding can produce repeated corners; do not add them.
if( KiROUND( nx ) != prevX || KiROUND( ny ) != prevY )
if( round_nearest( nx ) != prevX || round_nearest( ny ) != prevY )
{
newContour.Append( KiROUND( nx ), KiROUND( ny ) );
prevX = KiROUND( nx );
prevY = KiROUND( ny );
newContour.Append( round_nearest( nx ), round_nearest( ny ) );
prevX = round_nearest( nx );
prevY = round_nearest( ny );
}
}
}

View File

@ -53,4 +53,9 @@ int rescale( int aNumerator, int aValue, int aDenominator );
template <>
int64_t rescale( int64_t aNumerator, int64_t aValue, int64_t aDenominator );
static inline int round_nearest( double v )
{
return int( v < 0 ? v - 0.5 : v + 0.5 );
}
#endif // __MATH_UTIL_H