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.
 
 

46 lines
1.3 KiB

#ifndef SPACE_ANALYZER_HPP
#define SPACE_ANALYZER_HPP
#include "busbar_config.hpp"
#include <vector>
#include <cstdint>
class SpaceAnalyzer {
private:
const BusbarConfig& config_;
const std::vector<bool>& obstacles_;
uint64_t xsize_, ysize_, zsize_;
size_t getIndex(int64_t x, int64_t y, int64_t z) const {
return x + y * xsize_ + z * xsize_ * ysize_;
}
public:
SpaceAnalyzer(const BusbarConfig& config,
const std::vector<bool>& obstacles,
uint64_t xsize, uint64_t ysize, uint64_t zsize)
: config_(config), obstacles_(obstacles),
xsize_(xsize), ysize_(ysize), zsize_(zsize) {}
// 检查体素是否为障碍物
bool isObstacle(int64_t x, int64_t y, int64_t z) const;
bool isObstacle(const Point& p) const;
// 检查体素是否在边界内
bool isInBounds(int64_t x, int64_t y, int64_t z) const;
bool isInBounds(const Point& p) const;
// 检查体素是否可通过(考虑间隙)
bool isVoxelFree(const Point& p) const;
// 检查某个点在给定方向上是否有足够空间
bool hasSpace(const Point& p, const Vector3& tangent,
const Vector3& normal) const;
// 获取地图尺寸
uint64_t xsize() const { return xsize_; }
uint64_t ysize() const { return ysize_; }
uint64_t zsize() const { return zsize_; }
};
#endif