#ifndef BUSBAR_CONFIG_HPP #define BUSBAR_CONFIG_HPP #include "busbar_types.hpp" #include #include class BusbarConfig { private: float width_; float thickness_; float clearance_; std::array allowed_segments_; public: // 弯曲/扭转系数 float flat_bend_factor; float vertical_bend_factor; float twist_factor; float bend_45_factor; float min_begin_length_; float segment_cost_multiplier_; // 段固定代价乘数,越大越鼓励少段数 bool smart_platform_; // 智能平台检测开关:true=投票探测, false=坐标推算 BusbarConfig(float w = 2.0f, float h = 1.0f, float c = 0.5f) : width_(w), thickness_(h), clearance_(c), flat_bend_factor(1.5f), vertical_bend_factor(0.6f), twist_factor(1.5f), bend_45_factor(1.0f), min_begin_length_(3.0f), segment_cost_multiplier_(0.6f), smart_platform_(true) { // 默认所有段类型都允许 allowed_segments_.fill(true); } BusbarConfig(float width, float thickness,float min_begin_length, float clearance, float flat_bend, float vertical_bend, float twist, float bend_45) : width_(width), thickness_(thickness), min_begin_length_(min_begin_length), clearance_(clearance), flat_bend_factor(flat_bend), vertical_bend_factor(vertical_bend), twist_factor(twist), bend_45_factor(bend_45), segment_cost_multiplier_(0.6f), smart_platform_(true) { allowed_segments_.fill(true); } // 访问器 float width() const { return width_; } float thickness() const { return thickness_; } float clearance() const { return clearance_; } bool smartPlatform() const { return smart_platform_; } void setSmartPlatform(bool v) { smart_platform_ = v; } // 每段固定代价:基于立弯代价,乘以段代价乘数 // 立弯代价 = radius * angle * 2.0,90度立弯 = 0.625*W * PI/2 * 2 = 2*W float segmentFixedCost() const { return vertical_bend_factor * width_ * (M_PI / 2.0f) * 2.0f * segment_cost_multiplier_; } void setSegmentCostMultiplier(float m) { segment_cost_multiplier_ = m; } // 段类型控制 void enableSegment(SegmentType type) { allowed_segments_[static_cast(type)] = true; } void disableSegment(SegmentType type) { allowed_segments_[static_cast(type)] = false; } bool isSegmentAllowed(SegmentType type) const { return allowed_segments_[static_cast(type)]; } }; #endif