20#include <boost/test/unit_test.hpp>
43 ARC arc{ 100.0, 200.0, 50.0, 45.0, 90.0 };
74 ARC arc{ 50.0, 50.0, 25.0, 0.0, 180.0 };
90 std::vector<ARC_POINT> points;
91 points.emplace_back( 10.0, 20.0 );
92 points.emplace_back( 30.0, 40.0 );
94 BOOST_REQUIRE_EQUAL( points.size(), 2 );
106 std::vector<ARC_POINT> points;
107 points.emplace_back( 0.0, 0.0 );
108 points.emplace_back( 100.0, 0.0,
ARC{ 50.0, 0.0, 50.0, 180.0, -180.0 } );
110 BOOST_REQUIRE_EQUAL( points.size(), 2 );
120 ARC arc{ 0.0, 0.0, 100.0, 0.0, 360.0 };
128 ARC arc{ 0.0, 0.0, 50.0, 90.0, -90.0 };
138 polyline.
width = 10.0;
141 BOOST_CHECK( polyline.
points.empty() );
150 polyline.
width = 5.0;
152 polyline.
points.emplace_back( 0.0, 0.0 );
153 polyline.
points.emplace_back( 100.0, 0.0 );
154 polyline.
points.emplace_back( 100.0, 100.0 );
156 BOOST_REQUIRE_EQUAL( polyline.
points.size(), 3 );
168 track.
points.emplace_back( 0.0, 0.0 );
169 track.
points.emplace_back( 50.0, 50.0 );
170 track.
points.emplace_back( 100.0, 50.0,
ARC{ 75.0, 50.0, 25.0, 180.0, -180.0 } );
172 BOOST_REQUIRE_EQUAL( track.
points.size(), 3 );
187 pour.
points.emplace_back( 0.0, 0.0 );
188 pour.
points.emplace_back( 100.0, 0.0 );
189 pour.
points.emplace_back( 100.0, 100.0 );
190 pour.
points.emplace_back( 0.0, 100.0 );
192 BOOST_REQUIRE_EQUAL( pour.
points.size(), 4 );
200 item.
type =
"CLOSED";
203 item.
points.emplace_back( 0.0, 0.0 );
204 item.
points.emplace_back( 50.0, 0.0 );
205 item.
points.emplace_back( 50.0, 50.0 );
206 item.
points.emplace_back( 0.0, 50.0 );
208 BOOST_REQUIRE_EQUAL( item.
points.size(), 4 );
218 double bboxMinX = -50.0, bboxMinY = -50.0;
219 double bboxMaxX = 50.0, bboxMaxY = 50.0;
220 int startAngleTenths = 900;
221 int deltaAngleTenths = -900;
223 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
224 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
225 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
226 double startAngle = startAngleTenths / 10.0;
227 double deltaAngle = deltaAngleTenths / 10.0;
229 BOOST_CHECK_CLOSE( cx, 0.0, 0.001 );
230 BOOST_CHECK_CLOSE( cy, 0.0, 0.001 );
231 BOOST_CHECK_CLOSE(
radius, 50.0, 0.001 );
232 BOOST_CHECK_CLOSE( startAngle, 90.0, 0.001 );
233 BOOST_CHECK_CLOSE( deltaAngle, -90.0, 0.001 );
241 double bboxMinX = 75.0, bboxMinY = 175.0;
242 double bboxMaxX = 125.0, bboxMaxY = 225.0;
244 double cx = ( bboxMinX + bboxMaxX ) / 2.0;
245 double cy = ( bboxMinY + bboxMaxY ) / 2.0;
246 double radius = ( bboxMaxX - bboxMinX ) / 2.0;
248 BOOST_CHECK_CLOSE( cx, 100.0, 0.001 );
249 BOOST_CHECK_CLOSE( cy, 200.0, 0.001 );
250 BOOST_CHECK_CLOSE(
radius, 25.0, 0.001 );
257 std::string line =
"0 0 900 -900 -50 -50 50 50";
258 std::istringstream iss( line );
261 int startAngleTenths, deltaAngleTenths;
262 double bboxMinX, bboxMinY, bboxMaxX, bboxMaxY;
265 bool hasArc =
static_cast<bool>( iss >> startAngleTenths >> deltaAngleTenths
266 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY );
268 BOOST_CHECK( hasArc );
277 std::string line =
"100 200";
278 std::istringstream iss( line );
281 int startAngleTenths, deltaAngleTenths;
282 double bboxMinX, bboxMinY, bboxMaxX, bboxMaxY;
285 bool hasArc =
static_cast<bool>( iss >> startAngleTenths >> deltaAngleTenths
286 >> bboxMinX >> bboxMinY >> bboxMaxX >> bboxMaxY );
288 BOOST_CHECK( !hasArc );
289 BOOST_CHECK_CLOSE( dx, 100.0, 0.001 );
290 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")