Chrysalis - Pattern Test Coverage


pattern/
File: pattern/src/CGAL.cpp
Date: 2026-08-27 18:35:18
Lines:
45/51
88.2%
Functions:
13/15
86.7%
Branches:
44/116
37.9%
Decisions:
4/4
100.0%
Calls:
155/252
61.5%

Line Branch Decision Call Exec Source
1 #include "CGAL.h"
2
3 using namespace Chrysalis;
4
5 237 double CG::sin(const double value) {
6
1/1
✓ Call 0 invoked.
237 return round(std::sin(value));
7 }
8
9 237 double CG::cos(const double value) {
10
1/1
✓ Call 0 invoked.
237 return round(std::cos(value));
11 }
12
13 72 double CG::radians(const double degrees) {
14 72 return degrees * CGAL_PI / 180;
15 }
16
17 474 double CG::round(const double value) {
18 static double factor = std::pow(10.0, PRECISION);
19 474 return std::round(value * factor) / factor;
20 }
21
22 3 CG::Vector CG::rotate(const Vector& vector, double angle) {
23 3 angle = angle * CGAL_PI / 180;
24
4/8
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 17 taken 3 times.
✗ Branch 18 not taken.
15/19
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
✓ Call 14 invoked.
✓ Call 15 invoked.
✓ Call 16 invoked.
✓ Call 19 invoked.
✓ Call 20 invoked.
✓ Call 21 invoked.
✓ Call 22 invoked.
✗ Call 23 not invoked.
✗ Call 24 not invoked.
✗ Call 25 not invoked.
✗ Call 26 not invoked.
9 return CGAL::Aff_transformation_2<LinearKernel>(CGAL::ROTATION, sin(angle), cos(angle))(vector);
25 }
26
27 6 double CG::angle(const Vector& vector1, const Vector& vector2) {
28
13/13
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 9 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
✓ Call 12 invoked.
6 return std::abs(std::atan2(vector1.y(), vector1.x()) - std::atan2(vector2.y(), vector2.x())) * 180.0 / CGAL_PI;
29 }
30
31 37 double CG::angle(const Point& pointFrom, const Point& pointTo) {
32
1/2
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
4/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
37 const Vector v = pointTo - pointFrom;
33
4/8
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 37 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 37 times.
✗ Branch 11 not taken.
4/4
✓ Call 0 invoked.
✓ Call 3 invoked.
✓ Call 6 invoked.
✓ Call 9 invoked.
74 return std::atan2(CGAL::to_double(v.y()), CGAL::to_double(v.x())) * 180.0 / CGAL_PI;
34 }
35
36 45 double CG::length(const Point& pointFrom, const Point& pointTo) {
37
1/2
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
4/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
45 const Vector v = pointFrom - pointTo;
38
2/4
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 45 times.
✗ Branch 7 not taken.
5/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 8 invoked.
✗ Call 9 not invoked.
90 return std::sqrt(CGAL::to_double(v.squared_length()));
39 }
40
41 12 CG::Point CG::mirror(const Point& point, const Point& center) {
42
2/4
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 12 times.
✗ Branch 10 not taken.
8/9
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 11 invoked.
✗ Call 12 not invoked.
12 return center + (center - point);
43 }
44
45 24 CG::Point CG::relativePoint(const Point& pointFrom, const Vector& vector) {
46
5/10
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 24 times.
✗ Branch 10 not taken.
✓ Branch 16 taken 24 times.
✗ Branch 17 not taken.
✓ Branch 21 taken 24 times.
✗ Branch 22 not taken.
✓ Branch 26 taken 24 times.
✗ Branch 27 not taken.
21/24
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 11 invoked.
✓ Call 12 invoked.
✓ Call 13 invoked.
✓ Call 14 invoked.
✓ Call 15 invoked.
✓ Call 18 invoked.
✓ Call 19 invoked.
✓ Call 20 invoked.
✓ Call 23 invoked.
✓ Call 24 invoked.
✓ Call 25 invoked.
✓ Call 28 invoked.
✓ Call 29 invoked.
✓ Call 30 invoked.
✗ Call 31 not invoked.
✗ Call 32 not invoked.
✗ Call 33 not invoked.
24 return Point(pointFrom.x() + vector.x(), pointFrom.y() + vector.y());
47 }
48
49 213 CG::Point CG::relativePoint(const Point& pointFrom, double angle, double length) {
50 213 angle = angle * CGAL_PI / 180;
51
5/10
✓ Branch 4 taken 213 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 213 times.
✗ Branch 9 not taken.
✓ Branch 14 taken 213 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 213 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 213 times.
✗ Branch 23 not taken.
17/20
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
✓ Call 12 invoked.
✓ Call 13 invoked.
✓ Call 16 invoked.
✓ Call 17 invoked.
✓ Call 20 invoked.
✓ Call 21 invoked.
✓ Call 24 invoked.
✓ Call 25 invoked.
✓ Call 26 invoked.
✗ Call 27 not invoked.
✗ Call 28 not invoked.
✗ Call 29 not invoked.
213 return Point(pointFrom.x() + length * cos(angle), pointFrom.y() + length * sin(angle));
52 }
53
54 3 CG::Point CG::projection(const Point& point, const Line& line) {
55
3/3
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
3 return line.projection(point);
56 }
57
58 ✗ std::optional<CG::Point> CG::xIntersection(const Point& pointFrom, const Point& pointTo) {
59
0/30
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
✗ Call 19 not invoked.
✗ Call 22 not invoked.
✗ Call 23 not invoked.
✗ Call 26 not invoked.
✗ Call 27 not invoked.
✗ Call 28 not invoked.
✗ Call 29 not invoked.
✗ Call 30 not invoked.
✗ Call 31 not invoked.
✗ Call 32 not invoked.
✗ Call 33 not invoked.
✗ Call 34 not invoked.
✗ Call 35 not invoked.
✗ Call 36 not invoked.
✗ Call 37 not invoked.
✗ Call 38 not invoked.
✗ Call 41 not invoked.
✗ static Line xAxis(Point(0, 0), Point(1, 0));
60
0/8
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ return CG::intersection(xAxis, Line(pointFrom, pointTo));
61 }
62
63 ✗ std::optional<CG::Point> CG::yIntersection(const Point& pointFrom, const Point& pointTo) {
64
0/30
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
✗ Call 19 not invoked.
✗ Call 22 not invoked.
✗ Call 23 not invoked.
✗ Call 26 not invoked.
✗ Call 27 not invoked.
✗ Call 28 not invoked.
✗ Call 29 not invoked.
✗ Call 30 not invoked.
✗ Call 31 not invoked.
✗ Call 32 not invoked.
✗ Call 33 not invoked.
✗ Call 34 not invoked.
✗ Call 35 not invoked.
✗ Call 36 not invoked.
✗ Call 37 not invoked.
✗ Call 38 not invoked.
✗ Call 41 not invoked.
✗ static Line yAxis(Point(0, 0), Point(0, 1));
65
0/8
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ return CG::intersection(yAxis, Line(pointFrom, pointTo));
66 }
67
68 6 CG::Point CG::circlesIntersection(const Point& anchor,
69 CPoint center1, const double radius1,
70 CPoint center2, const double radius2) {
71
2/4
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
8/10
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
6 const Circle circle1(center1, std::pow(radius1, 2));
72
2/4
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
8/10
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
6 const Circle circle2(center2, std::pow(radius2, 2));
73
74
1/1
✓ Call 0 invoked.
6 std::vector<CCIntersection> intersections;
75
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
2/2
✓ Call 0 invoked.
✓ Call 3 invoked.
6 CGAL::intersection(circle1, circle2, std::back_inserter(intersections));
76
77
1/2
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
2/2
✓ Call 0 invoked.
✓ Call 1 invoked.
6 Point intersectionPoint;
78 6 double minSDistance = std::numeric_limits<double>::max();
79
2/2
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 6 times.
2/2
✓ Decision 'true' taken 12 times.
✓ Decision 'false' taken 6 times.
10/10
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 9 invoked.
18 for (const auto& intersection : intersections) {
80
2/4
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 12 times.
✗ Branch 8 not taken.
5/5
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
12 const auto point = std::get<std::pair<CArcPoint, unsigned int>>(intersection).first;
81
2/4
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
3/3
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 4 invoked.
12 const double x = CGAL::to_double(point.x());
82
2/4
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
3/3
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 4 invoked.
12 const double y = CGAL::to_double(point.y());
83
4/6
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 6 times.
2/2
✓ Decision 'true' taken 6 times.
✓ Decision 'false' taken 6 times.
8/8
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
12 if (const double distance = std::pow(x - anchor.x(), 2) + std::pow(y - anchor.y(), 2); distance < minSDistance) {
84 6 minSDistance = distance;
85
1/2
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
5/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✗ Call 7 not invoked.
6 intersectionPoint = Point(x, y);
86 }
87
1/2
✓ Call 0 invoked.
✗ Call 1 not invoked.
12 }
88 6 return intersectionPoint;
89
3/6
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
6 }
90