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.
57 lines
1.4 KiB
57 lines
1.4 KiB
#ifndef SEGMENT_GENERATOR_HPP
|
|
#define SEGMENT_GENERATOR_HPP
|
|
|
|
#include "busbar_segment.hpp"
|
|
#include "busbar_config.hpp"
|
|
#include "space_analyzer.hpp"
|
|
#include <memory>
|
|
|
|
// 段候选
|
|
struct SegmentCandidate {
|
|
SegmentEndState end_state;
|
|
std::shared_ptr<BusbarSegment> segment;
|
|
float cost;
|
|
|
|
SegmentCandidate(const SegmentEndState& end,
|
|
std::shared_ptr<BusbarSegment> seg,
|
|
float c)
|
|
: end_state(end), segment(seg), cost(c) {}
|
|
};
|
|
|
|
// 段生成器
|
|
class SegmentGenerator {
|
|
private:
|
|
const BusbarConfig& config_;
|
|
const SpaceAnalyzer& analyzer_;
|
|
|
|
|
|
|
|
// 生成各类段
|
|
std::vector<SegmentCandidate> generateStraightCandidates(
|
|
const SegmentEndState& current) const;
|
|
|
|
std::vector<SegmentCandidate> generateFlatBendCandidates(
|
|
const SegmentEndState& current) const;
|
|
|
|
std::vector<SegmentCandidate> generateVerticalBendCandidates(
|
|
const SegmentEndState& current) const;
|
|
|
|
std::vector<SegmentCandidate> generateTwistCandidates(
|
|
const SegmentEndState& current) const;
|
|
|
|
|
|
|
|
public:
|
|
// 检查段是否有效(无碰撞)
|
|
bool isSegmentValid(const BusbarSegment& segment) const;
|
|
|
|
SegmentGenerator(const BusbarConfig& config,
|
|
const SpaceAnalyzer& analyzer)
|
|
: config_(config), analyzer_(analyzer) {}
|
|
|
|
// 主接口:生成所有可行的后继段
|
|
std::vector<SegmentCandidate> generateSuccessors(
|
|
const SegmentEndState& current) const;
|
|
};
|
|
|
|
#endif
|