24#include <boost/test/unit_test.hpp>
47 ARC arc{ 100.0, 200.0, 50.0, 45.0, 90.0 };
78 ARC arc{ 50.0, 50.0, 25.0, 0.0, 180.0 };
94 std::vector<ARC_POINT> points;
95 points.emplace_back( 10.0, 20.0 );
96 points.emplace_back( 30.0, 40.0 );
98 BOOST_REQUIRE_EQUAL( points.size(), 2 );
110 std::vector<ARC_POINT> points;
111 points.emplace_back( 0.0, 0.0 );
112 points.emplace_back( 100.0, 0.0,
ARC{ 50.0, 0.0, 50.0, 180.0, -180.0 } );
114 BOOST_REQUIRE_EQUAL( points.size(), 2 );
124 ARC arc{ 0.0, 0.0, 100.0, 0.0, 360.0 };
132 ARC arc{ 0.0, 0.0, 50.0, 90.0, -90.0 };
142 polyline.
width = 10.0;
145 BOOST_CHECK( polyline.
points.empty() );
154 polyline.
width = 5.0;
156 polyline.
points.emplace_back( 0.0, 0.0 );
157 polyline.
points.emplace_back( 100.0, 0.0 );
158 polyline.
points.emplace_back( 100.0, 100.0 );
160 BOOST_REQUIRE_EQUAL( polyline.
points.size(), 3 );
172 track.
points.emplace_back( 0.0, 0.0 );
173 track.
points.emplace_back( 50.0, 50.0 );
174 track.
points.emplace_back( 100.0, 50.0,
ARC{ 75.0, 50.0, 25.0, 180.0, -180.0 } );
176 BOOST_REQUIRE_EQUAL( track.
points.size(), 3 );
191 pour.
points.emplace_back( 0.0, 0.0 );
192 pour.
points.emplace_back( 100.0, 0.0 );
193 pour.
points.emplace_back( 100.0, 100.0 );
194 pour.
points.emplace_back( 0.0, 100.0 );
196 BOOST_REQUIRE_EQUAL( pour.
points.size(), 4 );
204 item.
type =
"CLOSED";
207 item.
points.emplace_back( 0.0, 0.0 );
208 item.
points.emplace_back( 50.0, 0.0 );
209 item.
points.emplace_back( 50.0, 50.0 );
210 item.
points.emplace_back( 0.0, 50.0 );
212 BOOST_REQUIRE_EQUAL( item.
points.size(), 4 );
222 double bboxMinX = -50.0, bboxMinY = -50.0;
223 double bboxMaxX = 50.0, bboxMaxY = 50.0;
224 int startAngleTenths = 900;
225 int deltaAngleTenths = -900;
227 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
228 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
229 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
230 double startAngle = startAngleTenths / 10.0;
231 double deltaAngle = deltaAngleTenths / 10.0;
233 BOOST_CHECK_CLOSE( cx, 0.0, 0.001 );
234 BOOST_CHECK_CLOSE( cy, 0.0, 0.001 );
235 BOOST_CHECK_CLOSE(
radius, 50.0, 0.001 );
236 BOOST_CHECK_CLOSE( startAngle, 90.0, 0.001 );
237 BOOST_CHECK_CLOSE( deltaAngle, -90.0, 0.001 );
245 double bboxMinX = 75.0, bboxMinY = 175.0;
246 double bboxMaxX = 125.0, bboxMaxY = 225.0;
248 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
249 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
250 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
252 BOOST_CHECK_CLOSE( cx, 100.0, 0.001 );
253 BOOST_CHECK_CLOSE( cy, 200.0, 0.001 );
254 BOOST_CHECK_CLOSE(
radius, 25.0, 0.001 );
261 std::string line =
"0 0 900 -900 -50 -50 50 50";
262 std::istringstream iss( line );
265 int startAngleTenths, deltaAngleTenths;
266 double bboxMinX, bboxMinY, bboxMaxX, bboxMaxY;
269 bool hasArc =
static_cast<bool>( iss >> startAngleTenths >> deltaAngleTenths
270 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY );
272 BOOST_CHECK( hasArc );
281 std::string line =
"100 200";
282 std::istringstream iss( line );
285 int startAngleTenths, deltaAngleTenths;
286 double bboxMinX, bboxMinY, bboxMaxX, bboxMaxY;
289 bool hasArc =
static_cast<bool>( iss >> startAngleTenths >> deltaAngleTenths
290 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY );
292 BOOST_CHECK( !hasArc );
293 BOOST_CHECK_CLOSE( dx, 100.0, 0.001 );
294 BOOST_CHECK_CLOSE( dy, 200.0, 0.001 );
A point that may be either a line endpoint or an arc segment.
ARC arc
Arc parameters (only valid when is_arc is true)
bool is_arc
True if this segment is an arc, false for line.
double y
Endpoint Y coordinate.
double x
Endpoint X coordinate.
Arc definition using center point, radius, and angles.
double cx
Center X coordinate.
double delta_angle
Arc sweep angle in degrees (positive = CCW)
double start_angle
Start angle in degrees (0 = +X, CCW positive)
double cy
Center Y coordinate.
std::vector< ARC_POINT > points
Shape points, may include arc segments.
std::string type
CLOSED, OPEN, CIRCLE, COPCLS, TAG, etc.
A polyline that may contain arc segments.
bool closed
True if polyline forms a closed shape.
std::vector< ARC_POINT > points
Polyline vertices, may include arcs.
std::vector< ARC_POINT > points
Pour outline, may include arc segments.
std::vector< ARC_POINT > points
Track points, may include arc segments.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Arc_DefaultConstruction)
BOOST_CHECK_EQUAL(result, "25.4")