48#include <gtest/gtest.h>
64 return std::abs(a - b) < tol;
86 EXPECT_EQ(plane_default->get_wide(), 500);
87 EXPECT_EQ(plane_default->get_height(), 300);
88 EXPECT_EQ(plane_default->get_xoffset(), 0);
89 EXPECT_EQ(plane_default->get_yoffset(), 0);
94 EXPECT_EQ(plane_with_offset->get_wide(), 500);
95 EXPECT_EQ(plane_with_offset->get_height(), 300);
96 EXPECT_EQ(plane_with_offset->get_xoffset(), 10);
97 EXPECT_EQ(plane_with_offset->get_yoffset(), 20);
102 plane_default->set_resolution(0.1);
103 EXPECT_EQ(plane_default->get_resolution(), 0.1);
105 plane_default->set_resolution(0.05);
106 EXPECT_EQ(plane_default->get_resolution(), 0.05);
111 double original = plane_default->get_shade_thickness();
112 plane_default->set_shade_thickness(2.0);
113 EXPECT_EQ(plane_default->get_shade_thickness(), 2.0);
115 plane_default->set_shade_thickness(
original);
151 plane = std::make_unique<Eepic_Plane>(500, 500);
163 std::ostringstream
output;
166 std::string result =
output.str();
167 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
168 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
179 std::ostringstream
output;
182 std::string result =
output.str();
183 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
184 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
194 std::ostringstream
output;
197 std::string result =
output.str();
198 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
208 std::ostringstream
output;
211 std::string result =
output.str();
213 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
218 Point center(50, 50);
219 Ellipse ellipse(center, 20, 10);
222 std::ostringstream
output;
225 std::string result =
output.str();
226 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
240 std::ostringstream
output;
243 std::string result =
output.str();
244 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
256 std::ostringstream
output;
259 std::string result =
output.str();
260 EXPECT_TRUE(result.find(
"\\path") != std::string::npos);
272 std::ostringstream
output;
275 std::string result =
output.str();
276 EXPECT_TRUE(result.find(
"Hello") != std::string::npos);
290 std::ostringstream
output;
293 std::string result =
output.str();
295 EXPECT_TRUE(result.find(
"3 geometric objects were put in the plane") !=
308 plane = std::make_unique<Eepic_Plane>(500, 500);
321 std::ostringstream
output;
338 std::ostringstream
output;
355 std::ostringstream
output;
373 plane = std::make_unique<Eepic_Plane>(500, 500);
387 std::ostringstream
output;
390 std::string result =
output.str();
391 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
399 std::ostringstream
output;
402 std::string result =
output.str();
403 EXPECT_TRUE(result.find(
"\\dottedline") != std::string::npos);
411 std::ostringstream
output;
414 std::string result =
output.str();
415 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
423 std::ostringstream
output;
426 std::string result =
output.str();
427 EXPECT_TRUE(result.find(
"\\dottedline") != std::string::npos);
429 EXPECT_TRUE(result.find(
"arrow's edges") != std::string::npos);
437 std::ostringstream
output;
440 std::string result =
output.str();
441 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
453 plane = std::make_unique<Eepic_Plane>(500, 500);
467 std::ostringstream
output;
470 std::string result =
output.str();
484 std::ostringstream
output;
487 std::string result =
output.str();
496 Point p2(100, 50.001);
500 std::ostringstream
output;
503 std::string result =
output.str();
517 std::ostringstream
output;
520 std::string result =
output.str();
529 Point p2(50.001, 100);
533 std::ostringstream
output;
546 plane = std::make_unique<Eepic_Plane>(500, 500);
565 std::ostringstream
output;
568 std::string result =
output.str();
569 EXPECT_TRUE(result.find(
"\\shade") != std::string::npos);
577 std::ostringstream
output;
580 std::string result =
output.str();
581 EXPECT_TRUE(result.find(
"\\dottedline") != std::string::npos);
589 std::ostringstream
output;
592 std::string result =
output.str();
593 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
601 std::ostringstream
output;
604 std::string result =
output.str();
606 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
614 std::ostringstream
output;
617 std::string result =
output.str();
618 EXPECT_TRUE(result.find(
"\\spline") != std::string::npos);
626 std::ostringstream
output;
629 std::string result =
output.str();
630 EXPECT_TRUE(result.find(
"\\spline") != std::string::npos);
642 plane = std::make_unique<Eepic_Plane>(500, 500);
652 Ellipse ellipse(center, 20, 10);
655 std::ostringstream
output;
658 std::string result =
output.str();
659 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
667 std::ostringstream
output;
670 std::string result =
output.str();
671 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
672 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
680 std::ostringstream
output;
683 std::string result =
output.str();
684 EXPECT_TRUE(result.find(
"\\shade") != std::string::npos);
690 Ellipse circle(center, 15, 15);
693 std::ostringstream
output;
696 std::string result =
output.str();
697 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
709 plane = std::make_unique<Eepic_Plane>(500, 500);
724 std::ostringstream
output;
727 std::string result =
output.str();
728 EXPECT_TRUE(result.find(
"LeftAligned") != std::string::npos);
736 std::ostringstream
output;
739 std::string result =
output.str();
740 EXPECT_TRUE(result.find(
"RightAligned") != std::string::npos);
748 std::ostringstream
output;
751 std::string result =
output.str();
752 EXPECT_TRUE(result.find(
"Centered") != std::string::npos);
761 std::ostringstream
output;
764 std::string result =
output.str();
765 EXPECT_TRUE(result.find(
"Test$LaTeX$") != std::string::npos);
777 plane = std::make_unique<Eepic_Plane>(500, 500);
791 std::ostringstream
output;
794 std::string result =
output.str();
795 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
804 std::ostringstream
output;
807 std::string result =
output.str();
808 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
817 std::ostringstream
output;
820 std::string result =
output.str();
821 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
833 plane = std::make_unique<Eepic_Plane>(500, 500);
845 plane->set_resolution(0.1);
847 std::ostringstream
output;
850 std::string result =
output.str();
851 EXPECT_TRUE(result.find(
"\\setlength{\\unitlength}{0.1") != std::string::npos);
860 plane->set_fill_type(
"gray");
862 std::ostringstream
output;
865 std::string result =
output.str();
866 EXPECT_TRUE(result.find(
"\\filltype{gray}") != std::string::npos);
875 std::ostringstream
output;
878 std::string result =
output.str();
881 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
882 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
885 size_t begin_pos = result.find(
"\\begin{picture}");
886 size_t end_pos = result.find(
"\\end{picture}");
897 std::ostringstream
output;
900 std::string result =
output.str();
902 EXPECT_TRUE(result.find(
"\\thinlines") != std::string::npos);
912 std::ostringstream
output;
915 std::string result =
output.str();
918 EXPECT_TRUE(result.find(
"leftmost point") != std::string::npos);
919 EXPECT_TRUE(result.find(
"rightmost point") != std::string::npos);
920 EXPECT_TRUE(result.find(
"highest point") != std::string::npos);
921 EXPECT_TRUE(result.find(
"lowest point") != std::string::npos);
933 plane = std::make_unique<Eepic_Plane>(500, 300);
946 std::ostringstream
output;
947 plane->draw(
output,
true);
949 std::string result =
output.str();
950 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
960 std::ostringstream
output;
961 plane->draw(
output,
false);
963 std::string result =
output.str();
964 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
976 plane = std::make_unique<Eepic_Plane>(500, 500);
988 plane->put_cartesian_axis();
990 std::ostringstream
output;
994 std::string result =
output.str();
995 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
1007 plane = std::make_unique<Eepic_Plane>(500, 500);
1016 std::ostringstream
dummy;
1026 std::string str = plane->point_string(p);
1037 double result = plane->h_geom_number_to_eepic(x);
1046 double result = plane->v_geom_number_to_eepic(
y);
1066 std::ostringstream
output;
1084 std::ostringstream
output;
1095 Point center(50, 50);
1096 Ellipse ellipse(center, 20, 10);
1099 std::ostringstream
output;
1118 plane = std::make_unique<Eepic_Plane>(500, 500);
1132 std::ostringstream
output;
1135 std::string result =
output.str();
1136 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1137 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
1145 std::ostringstream
output;
1148 std::string result =
output.str();
1149 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1157 std::ostringstream
output;
1160 std::string result =
output.str();
1161 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1162 EXPECT_TRUE(result.find(
"\\dashline") != std::string::npos);
1174 plane = std::make_unique<Eepic_Plane>(500, 500);
1192 std::ostringstream
output;
1195 std::string result =
output.str();
1196 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1197 EXPECT_TRUE(result.find(
"\\spline") != std::string::npos);
1205 std::ostringstream
output;
1208 std::string result =
output.str();
1209 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1217 std::ostringstream
output;
1220 std::string result =
output.str();
1221 EXPECT_TRUE(result.find(
"\\Thicklines") != std::string::npos);
1222 EXPECT_TRUE(result.find(
"\\shade") != std::string::npos);
1237 plane = std::make_unique<Eepic_Plane>(500, 500);
1239 Point p1(0.001, 0.001);
1240 Point p2(0.002, 0.002);
1244 std::ostringstream
output;
1250 plane = std::make_unique<Eepic_Plane>(500, 500);
1252 Point p1(1000000, 1000000);
1253 Point p2(1000100, 1000100);
1257 std::ostringstream
output;
1263 plane = std::make_unique<Eepic_Plane>(500, 500);
1265 Point p1(-100, -100);
1270 std::ostringstream
output;
1277 plane = std::make_unique<Eepic_Plane>(500, 500);
1283 std::ostringstream
output;
1289 plane = std::make_unique<Eepic_Plane>(500, 500);
1296 std::ostringstream
output;
1303 plane = std::make_unique<Eepic_Plane>(500, 500);
1312 std::ostringstream
output;
1326 for (
int i = 0; i < 100; ++i)
1332 std::ostringstream
output;
1350 for (
int i = 0; i < 10; ++i)
1352 std::ostringstream
output;
1368 for (
int i = 0; i < 10; ++i)
1370 std::ostringstream
output;
1412 std::ostringstream
output;
1415 std::string result =
output.str();
1418 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
1419 EXPECT_TRUE(result.find(
"\\end{picture}") != std::string::npos);
1420 EXPECT_TRUE(result.find(
"Title") != std::string::npos);
1421 EXPECT_TRUE(result.find(
"\\ellipse") != std::string::npos);
1424 EXPECT_TRUE(result.find(
"geometric objects were put in the plane") !=
1458 std::ostringstream
output;
1461 std::string result =
output.str();
1462 EXPECT_TRUE(result.find(
"\\begin{picture}") != std::string::npos);
1463 EXPECT_TRUE(result.find(
"12 geometric objects were put in the plane") !=
1473 ::testing::InitGoogleTest(&
argc,
argv);
Represents a point with rectangular coordinates in a 2D plane.
const Geom_Number & get_x() const noexcept
Gets the x-coordinate value.
const Geom_Number & get_y() const noexcept
Gets the y-coordinate value.
A general (irregular) 2D polygon defined by a sequence of vertices.
void add_vertex(const Point &point)
Add a vertex to the polygon.
void close()
Close the polygon.
A regular polygon defined by center, side length, and vertex count.
Represents a line segment between two points.
Represents a text string positioned at a 2D point.
A non-degenerate triangle defined by three points.
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane_with_offset
std::unique_ptr< Eepic_Plane > plane_default
std::unique_ptr< Eepic_Plane > plane
2D canvas for generating EEPIC/LaTeX picture environments.
const double & get_height() const
Picture height (in EEPIC units).
void zoom(const double &factor)
Scale the EEPIC plane in real points (zoom in/out).
const double & get_wide() const
Plane accessors.
const Point & highest() const
const Point & lowest() const
const Point & rightmost() const
void draw(std::ostream &output, const bool &squarize=true)
Emits a complete LaTeX picture environment containing the geometric objects.
const Point & leftmost() const
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
std::unique_ptr< Eepic_Plane > plane
EEPIC/LaTeX geometric drawing utilities.
bool approx_equal(double a, double b, double tol=EPSILON)
TEST_F(EepicPlaneTest, DefaultConstruction)
bool tiny_keys
Global flag to enable tiny font size for keys/labels.
Main namespace for Aleph-w library functions.
void put_in_plane(Tikz_Plane &plane, const Geom &geom_obj)
Insert any supported geometry type in a Tikz_Plane.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Segment-drawing variants (types).