| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <vector> | ||
| 5 | |||
| 6 | #include "peterson_r_graham_scan_seq/common/include/common.hpp" | ||
| 7 | #include "task/include/task.hpp" | ||
| 8 | |||
| 9 | namespace peterson_r_graham_scan_seq { | ||
| 10 | |||
| 11 | struct Point2D { | ||
| 12 | double coord_x; | ||
| 13 | double coord_y; | ||
| 14 | |||
| 15 | Point2D() = default; | ||
| 16 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
120 | Point2D(double x_val, double y_val) : coord_x(x_val), coord_y(y_val) {} |
| 17 | }; | ||
| 18 | |||
| 19 | using PointSet = std::vector<Point2D>; | ||
| 20 | |||
| 21 | class PetersonGrahamScanner : public TaskBase { | ||
| 22 | public: | ||
| 23 | static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { | ||
| 24 | return ppc::task::TypeOfTask::kSEQ; | ||
| 25 | } | ||
| 26 | |||
| 27 | explicit PetersonGrahamScanner(const InputValue &in); | ||
| 28 | |||
| 29 | void LoadPoints(const PointSet &points); | ||
| 30 | [[nodiscard]] PointSet GetConvexHull() const; | ||
| 31 | |||
| 32 | private: | ||
| 33 | bool ValidationImpl() override; | ||
| 34 | bool PreProcessingImpl() override; | ||
| 35 | bool RunImpl() override; | ||
| 36 | bool PostProcessingImpl() override; | ||
| 37 | |||
| 38 | PointSet input_points_; | ||
| 39 | PointSet hull_points_; | ||
| 40 | bool external_data_provided_ = false; | ||
| 41 | |||
| 42 | static double ComputeOrientation(const Point2D &origin, const Point2D &a, const Point2D &b); | ||
| 43 | static double ComputeDistanceSq(const Point2D &p1, const Point2D &p2); | ||
| 44 | static bool AreAllPointsIdentical(const PointSet &points); | ||
| 45 | static std::size_t FindLowestPoint(const PointSet &points); | ||
| 46 | static void SortByAngle(PointSet &points); | ||
| 47 | }; | ||
| 48 | |||
| 49 | } // namespace peterson_r_graham_scan_seq | ||
| 50 |