| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <cstdint> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "paramonov_v_bin_img_conv_hul/all/include/common.hpp" | ||
| 8 | #include "task/include/task.hpp" | ||
| 9 | |||
| 10 | namespace paramonov_v_bin_img_conv_hul_all { | ||
| 11 | |||
| 12 | class ConvexHullAll : public BaseTask { | ||
| 13 | public: | ||
| 14 | static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { | ||
| 15 | // Пробуем разные варианты: | ||
| 16 | // return ppc::task::TypeOfTask::kAll; // если есть | ||
| 17 | // return ppc::task::TypeOfTask::kGeneric; // если есть | ||
| 18 | return ppc::task::TypeOfTask::kSTL; // временно, чтобы собралось | ||
| 19 | } | ||
| 20 | |||
| 21 | explicit ConvexHullAll(const InputType &input); | ||
| 22 | |||
| 23 | bool ValidationImpl() override; | ||
| 24 | bool PreProcessingImpl() override; | ||
| 25 | bool RunImpl() override; | ||
| 26 | bool PostProcessingImpl() override; | ||
| 27 | |||
| 28 | private: | ||
| 29 | void BinarizeImage(uint8_t threshold = 128); | ||
| 30 | void ExtractConnectedComponents(); | ||
| 31 | |||
| 32 | [[nodiscard]] static std::vector<PixelPoint> ComputeConvexHull(const std::vector<PixelPoint> &points); | ||
| 33 | [[nodiscard]] static int64_t Orientation(const PixelPoint &p, const PixelPoint &q, const PixelPoint &r); | ||
| 34 | static size_t PixelIndex(int row, int col, int cols) { | ||
| 35 |
5/6✓ Branch 0 taken 148 times.
✓ Branch 1 taken 2876 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 350 times.
✓ Branch 5 taken 242 times.
|
3638 | return (static_cast<size_t>(row) * static_cast<size_t>(cols)) + static_cast<size_t>(col); |
| 36 | } | ||
| 37 | |||
| 38 | void FloodFill(int start_row, int start_col, std::vector<bool> &visited, std::vector<PixelPoint> &component) const; | ||
| 39 | |||
| 40 | [[nodiscard]] static PixelPoint FindLowestPoint(const std::vector<PixelPoint> &points); | ||
| 41 | [[nodiscard]] static std::vector<PixelPoint> SortPointsByAngle(const std::vector<PixelPoint> &points, | ||
| 42 | const PixelPoint &lowest_point); | ||
| 43 | [[nodiscard]] static std::vector<PixelPoint> RemoveCollinearPoints(const std::vector<PixelPoint> &sorted_points, | ||
| 44 | const PixelPoint &lowest_point); | ||
| 45 | [[nodiscard]] static std::vector<PixelPoint> BuildHull(const std::vector<PixelPoint> &unique_points, | ||
| 46 | const PixelPoint &lowest_point); | ||
| 47 | [[nodiscard]] static std::vector<PixelPoint> HandleCollinearCase(const std::vector<PixelPoint> &points, | ||
| 48 | const PixelPoint &lowest_point); | ||
| 49 | |||
| 50 | InputType working_image_; | ||
| 51 | }; | ||
| 52 | |||
| 53 | } // namespace paramonov_v_bin_img_conv_hul_all | ||
| 54 |