feat: 测试覆盖扩展 + 文档更新

This commit is contained in:
茂之钳
2026-07-23 12:36:39 +00:00
parent 41a8992332
commit f2203c7255
42 changed files with 3448 additions and 106 deletions
+19 -1
View File
@@ -1,6 +1,8 @@
#pragma once
#include "vde/spatial/spatial_index.h"
#include "vde/core/aabb.h"
#include <queue>
#include <limits>
namespace vde::spatial {
using core::Point3D;
@@ -8,6 +10,15 @@ using core::Vector3D;
using core::Ray3Dd;
using core::Triangle3D;
template <typename T>
struct RTreeNode {
AABB3D bbox;
bool is_leaf = true;
std::vector<size_t> children; // internal: indices into nodes_
std::vector<size_t> item_indices; // leaf: indices into items_
size_t parent = static_cast<size_t>(-1);
};
template <typename T>
class RTree : public SpatialIndex<T> {
public:
@@ -19,9 +30,16 @@ public:
std::vector<T> query_ray(const Ray3Dd& ray) const override;
void clear() override;
size_t size() const override { return count_; }
size_t node_count() const { return nodes_.size(); }
private:
void query_range_recursive(size_t node_idx, const AABB3D& range,
std::vector<T>& result) const;
std::vector<T> items_;
std::vector<AABB3D> bounds_;
std::vector<AABB3D> item_bounds_;
std::vector<RTreeNode<T>> nodes_;
size_t root_idx_ = 0;
size_t count_ = 0;
};