|
|
@ -9,40 +9,63 @@ void extrude_polyline_geometry_t::build() |
|
|
const auto& profile_desc = this->descriptor.profiles[0]; |
|
|
const auto& profile_desc = this->descriptor.profiles[0]; |
|
|
const auto& axis_desc = this->descriptor.axis; |
|
|
const auto& axis_desc = this->descriptor.axis; |
|
|
|
|
|
|
|
|
// 构建 axis 几何数据,同时得到 axis_to_world 坐标系
|
|
|
// 对 axis 折线插入微小圆角弧
|
|
|
axis_geom.build_as_axis(axis_desc, profile_desc.reference_normal, axis_to_world, polyline_aabb); |
|
|
std::cout << "[extrude_polyline_geometry_t::build]: inserting tiny curve for axis" |
|
|
|
|
|
<< " segment_ratio=" << 0.1 << ", min_turn_angle_deg=" << 0.0 << "\n"; |
|
|
|
|
|
std::vector<vector3d> filleted_axis_pts; |
|
|
|
|
|
std::vector<double> filleted_axis_bgs; |
|
|
|
|
|
const fillet_config_t axis_fillet_cfg{/*segment_ratio=*/0.1, |
|
|
|
|
|
/*min_turn_angle_deg=*/0.0}; |
|
|
|
|
|
insert_polyline_corner_fillets(axis_desc, filleted_axis_pts, filleted_axis_bgs, axis_fillet_cfg); |
|
|
|
|
|
|
|
|
// 从 axis_to_world 中提取投影方向
|
|
|
// 构建圆角后的 axis 临时描述符
|
|
|
const Eigen::Vector3d proj_x = axis_to_world.matrix().col(0).head<3>(); // Binormal
|
|
|
polyline_descriptor_t filleted_axis_desc{}; |
|
|
const Eigen::Vector3d proj_y = axis_to_world.matrix().col(1).head<3>(); // Normal
|
|
|
filleted_axis_desc.point_number = static_cast<uint32_t>(filleted_axis_pts.size()); |
|
|
const Eigen::Vector3d origin = axis_to_world.matrix().col(3).head<3>(); |
|
|
filleted_axis_desc.points = filleted_axis_pts.data(); |
|
|
|
|
|
filleted_axis_desc.bulge_number = static_cast<uint32_t>(filleted_axis_bgs.size()); |
|
|
|
|
|
filleted_axis_desc.bulges = filleted_axis_bgs.data(); |
|
|
|
|
|
filleted_axis_desc.reference_normal = axis_desc.reference_normal; |
|
|
|
|
|
filleted_axis_desc.is_close = axis_desc.is_close; |
|
|
|
|
|
|
|
|
|
|
|
std::cout << "[extrude_polyline_geometry_t::build] " |
|
|
|
|
|
<< "original axis points: " << axis_desc.point_number << ", after fillet: " << filleted_axis_desc.point_number |
|
|
|
|
|
<< "\n"; |
|
|
|
|
|
|
|
|
|
|
|
axis_geom.build_as_axis(filleted_axis_desc, // 改为 filleted_axis_desc
|
|
|
|
|
|
profile_desc.reference_normal, |
|
|
|
|
|
axis_to_world, |
|
|
|
|
|
polyline_aabb); |
|
|
|
|
|
|
|
|
// 对 profile 各衔接顶点插入微小圆角弧
|
|
|
std::cout << "[extrude_polyline_geometry_t::build]: inserting tiny curve for profile" |
|
|
// segment_ratio=0.05 意味着每段损失约 5%,棱角感仍然明显。
|
|
|
<< " segment_ratio=" << 0.05 << ", min_turn_angle_deg=" << 0.0 << "\n"; |
|
|
// 如需更锋利,将 segment_ratio 调至 0.01-0.02;
|
|
|
std::vector<vector3d> filleted_profile_pts; |
|
|
// 如需更平滑,调至 0.1-0.2。
|
|
|
std::vector<double> filleted_profile_bgs; |
|
|
std::vector<vector3d> filleted_pts; |
|
|
const fillet_config_t profile_fillet_cfg{/*segment_ratio=*/0.1, |
|
|
std::vector<double> filleted_bgs; |
|
|
/*min_turn_angle_deg=*/0.0}; |
|
|
const fillet_config_t fillet_cfg{/*segment_ratio=*/0.05, |
|
|
insert_polyline_corner_fillets(profile_desc, filleted_profile_pts, filleted_profile_bgs, profile_fillet_cfg); |
|
|
/*min_turn_angle_deg=*/0.5}; |
|
|
|
|
|
insert_profile_corner_fillets(profile_desc, filleted_pts, filleted_bgs, fillet_cfg); |
|
|
polyline_descriptor_t filleted_profile_desc{}; |
|
|
|
|
|
filleted_profile_desc.point_number = static_cast<uint32_t>(filleted_profile_pts.size()); |
|
|
// 构建临时 descriptor 指向圆角后的数据(不修改原始 descriptor)
|
|
|
filleted_profile_desc.points = filleted_profile_pts.data(); |
|
|
polyline_descriptor_t filleted_desc{}; |
|
|
filleted_profile_desc.bulge_number = static_cast<uint32_t>(filleted_profile_bgs.size()); |
|
|
filleted_desc.point_number = static_cast<uint32_t>(filleted_pts.size()); |
|
|
filleted_profile_desc.bulges = filleted_profile_bgs.data(); |
|
|
filleted_desc.points = filleted_pts.data(); |
|
|
filleted_profile_desc.reference_normal = profile_desc.reference_normal; |
|
|
filleted_desc.bulge_number = static_cast<uint32_t>(filleted_bgs.size()); |
|
|
filleted_profile_desc.is_close = profile_desc.is_close; |
|
|
filleted_desc.bulges = filleted_bgs.data(); |
|
|
|
|
|
filleted_desc.reference_normal = profile_desc.reference_normal; |
|
|
|
|
|
filleted_desc.is_close = profile_desc.is_close; |
|
|
|
|
|
|
|
|
|
|
|
std::cout << "[extrude_polyline_geometry_t::build] " |
|
|
std::cout << "[extrude_polyline_geometry_t::build] " |
|
|
<< "original profile points: " << profile_desc.point_number << ", after fillet: " << filleted_desc.point_number |
|
|
<< "original profile points: " << profile_desc.point_number |
|
|
|
|
|
<< ", after fillet: " << filleted_profile_desc.point_number |
|
|
<< "\n"; |
|
|
<< "\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从 axis_to_world 中提取投影方向
|
|
|
|
|
|
const Eigen::Vector3d proj_x = axis_to_world.matrix().col(0).head<3>(); // Binormal
|
|
|
|
|
|
const Eigen::Vector3d proj_y = axis_to_world.matrix().col(1).head<3>(); // Normal
|
|
|
|
|
|
const Eigen::Vector3d origin = axis_to_world.matrix().col(3).head<3>(); |
|
|
|
|
|
|
|
|
// 构建 profile 几何数据(使用插入圆角后的 descriptor)
|
|
|
// 构建 profile 几何数据(使用插入圆角后的 descriptor)
|
|
|
aabb_t_dim<2> profile_aabb; |
|
|
aabb_t_dim<2> profile_aabb; |
|
|
profile_geom.build_as_profile(filleted_desc, proj_x, proj_y, origin, profile_aabb); |
|
|
profile_geom.build_as_profile(filleted_profile_desc, proj_x, proj_y, origin, profile_aabb); |
|
|
|
|
|
|
|
|
// 将 profile 的最大范围扩展到 polyline_aabb
|
|
|
// 将 profile 的最大范围扩展到 polyline_aabb
|
|
|
const auto profile_max_extent = profile_aabb.max().cwiseMax(profile_aabb.min().cwiseAbs()).maxCoeff(); |
|
|
const auto profile_max_extent = profile_aabb.max().cwiseMax(profile_aabb.min().cwiseAbs()).maxCoeff(); |
|
|
|