You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
#pragma once
|
|
|
|
#include <math/math_defs.hpp>
|
|
#include <primitive/axis/extrude_axis.hpp>
|
|
|
|
namespace internal
|
|
{
|
|
// 参考平面法向量固定为(0, 0, 1),以第一个顶点为二维坐标原点,以第一条边为x轴轴向
|
|
struct PE_API polyline_extrude_axis final : public extrude_axis {
|
|
~polyline_extrude_axis() override = default;
|
|
|
|
double get_closest_param(Eigen::Vector3d p) const override;
|
|
std::pair<Eigen::Vector2d, Eigen::Projective2d> to_pattern_local(double t, Eigen::Vector3d p) const override;
|
|
Eigen::AffineCompact3d get_local_cap_mat(double t) const override;
|
|
|
|
aabb_t get_local_aabb() const override
|
|
{
|
|
aabb_t res{};
|
|
for (const auto& v : vertices) res.extend(Eigen::Vector3d{v[0], v[1], 0});
|
|
return res;
|
|
}
|
|
|
|
std::vector<Eigen::Vector2d> vertices{}; // 所有顶点(圆弧段为端点)
|
|
std::vector<double> bulges{}; // bulge = tan(theta/2)
|
|
};
|
|
} // namespace internal
|
|
|
|
namespace detail
|
|
{
|
|
template <>
|
|
struct hasher<internal::polyline_extrude_axis> {
|
|
size_t operator()(const internal::polyline_extrude_axis& axis) const
|
|
{
|
|
auto parity1 = hash_funcs(axis.vertices.begin(), axis.vertices.end());
|
|
auto parity2 = hash_funcs(axis.bulges.begin(), axis.bulges.end());
|
|
return hash_combine(size_t{0}, parity1, parity2);
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct eq_compare<internal::polyline_extrude_axis> {
|
|
bool operator()(const internal::polyline_extrude_axis& lhs, const internal::polyline_extrude_axis& 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
|