48 std::vector<SEG> pieces;
53 pieces.emplace_back( a, b );
58 for(
size_t ii = 0; ii < pieces.size(); )
64 while( jj < pieces.size() && pieces[jj].A ==
end )
71 runs.drawn.push_back( length );
73 if( jj < pieces.size() )
74 runs.gaps.push_back(
VECTOR2D( pieces[jj].
A -
end ).EuclideanNorm() );
106 double curveLength = 0.0;
108 for(
int ii = 0; ii <
chain.SegmentCount(); ++ii )
112 const double gapLength = settings.
GetGapLength( width );
116 BOOST_REQUIRE_MESSAGE( runs.
drawn.size() > 5,
117 "expected the curve to be broken into dashes, got " << runs.
drawn.size() <<
" run(s)" );
119 double drawn = std::accumulate( runs.
drawn.begin(), runs.
drawn.end(), 0.0 );
120 double expected = curveLength * dashLength / ( dashLength + gapLength );
123 "dashes should cover " <<
expected <<
" IU of the " << curveLength <<
" IU curve, they cover "
137 const double gapLength = settings.
GetGapLength( width );
141 BOOST_REQUIRE_MESSAGE( runs.
gaps.size() > 5,
"expected a row of dots, got " << runs.
drawn.size() <<
" run(s)" );
143 for(
size_t ii = 0; ii < runs.
gaps.size(); ++ii )
145 BOOST_CHECK_MESSAGE(
std::abs( runs.
gaps[ii] - gapLength ) < 0.03 * gapLength,
146 "dot " << ii <<
" sits " << runs.
gaps[ii] <<
" IU from the previous one, expected "
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
const std::vector< VECTOR2I > & GetBezierPoints() const
PCB specific render settings.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
double GetGapLength(int aLineWidth) const
double GetDashLength(int aLineWidth) const
void SetBezierC1(const VECTOR2I &aPt) override
void SetEnd(const VECTOR2I &aEnd) override
void SetStart(const VECTOR2I &aStart) override
void SetBezierC2(const VECTOR2I &aPt) override
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An abstract shape on 2D plane.
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
LINE_STYLE
Dashed line types.
std::vector< double > gaps
std::vector< double > drawn
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
static SHAPE_LINE_CHAIN makeBezierChain()
BOOST_AUTO_TEST_CASE(BezierDashedLineHasGaps)
static DASH_RUNS collectRuns(const SHAPE *aShape, LINE_STYLE aStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aSettings)
VECTOR3I expected(15, 30, 45)
const SHAPE_LINE_CHAIN chain
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D