#pragma once #include #include #include #include namespace internal { struct PE_API polyline_pattern final : public pattern { ~polyline_pattern() override = default; std::pair eval_sdf(Eigen::Vector2d p) const override; double get_max_bounding_length() const override { Eigen::AlignedBox2d aabb{}; for (const auto& v : vertices) aabb.extend(v); return aabb.sizes().maxCoeff(); } std::vector vertices{}; // 所有顶点(圆弧段为端点) std::vector bulges{}; // bulge = tan(theta/2) }; } // namespace internal namespace detail { template <> struct hasher { size_t operator()(const internal::polyline_pattern& pattern) const { auto parity1 = hash_funcs(pattern.vertices.begin(), pattern.vertices.end()); auto parity2 = hash_funcs(pattern.bulges.begin(), pattern.bulges.end()); return hash_combine(size_t{0}, parity1, parity2); } }; template <> struct eq_compare { bool operator()(const internal::polyline_pattern& lhs, const internal::polyline_pattern& rhs) const { return eq_funcs(lhs.vertices.begin(), lhs.vertices.end(), rhs.vertices.begin()) && eq_funcs(lhs.bulges.begin(), lhs.bulges.end(), rhs.bulges.begin()); } }; } // namespace detail