extract explicit mesh with topology information from implicit surfaces with boolean operations, and do surface/volume integrating on them.
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.4 KiB

#pragma once
#include <numeric>
#include <primitive/pattern/pattern.hpp>
#include <math/math_defs.hpp>
#include <primitive_descriptor.h>
namespace internal
{
struct PE_API polyline_pattern final : public pattern {
~polyline_pattern() override = default;
std::pair<bool, Eigen::Vector2d> 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<Eigen::Vector2d> vertices{}; // 所有顶点(圆弧段为端点)
std::vector<double> bulges{}; // bulge = tan(theta/2)
};
} // namespace internal
namespace detail
{
template <>
struct hasher<internal::polyline_pattern> {
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<internal::polyline_pattern> {
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