PlaneMap::scan is now working, with unit tests.

This commit is contained in:
2022-07-13 01:08:54 -04:00
parent d54d6e4433
commit 69efb12c26
6 changed files with 444 additions and 96 deletions

View File

@@ -91,15 +91,15 @@ class PlaneScan : public eng::nevernew {
public:
friend class PlaneMap;
friend class PlaneTree;
enum Shape { BOX, CYLINDER, SPHEROID };
enum Shape { BOX, CYLINDER, SPHERE };
private:
// The plane to scan.
eng::string plane_;
// The bounding box of the scan.
util::XYZ lo_, hi_, center_;
util::XYZ lo_, hi_, center_, invradius_;
// If you scan a cylinder or spheroid, it actually
// If you scan a cylinder or SPHERE, it actually
// scans the bounding box first, then clips out
// the parts that aren't correct.
Shape shape_;
@@ -117,14 +117,18 @@ private:
// If this is true, items on the nowhere plane are not scanned.
bool omit_nowhere_;
private:
// Derived variables. These are populated by PlaneTree::scan.
uint64_t bblo_;
uint64_t bbhi_;
public:
PlaneScan() : plane_(""), shape_(BOX), sorted_(true), special_(0), omit_special_(0), omit_nowhere_(false) {}
void clear() {
plane_ = "";
shape_ = BOX;
sorted_ = true;
special_ = 0;
omit_special_ = false;
omit_nowhere_ = false;
lo_ = hi_ = center_ = util::XYZ();
}
PlaneScan() { clear(); }
// Convert a lua table into a scan configuration.
void configure(LuaStack &LS, LuaSlot slot);
@@ -137,6 +141,9 @@ public:
hi_.y = std::max(a.y, b.y);
hi_.z = std::max(a.z, b.z);
center_ = (lo_ + hi_) * 0.5;
invradius_.x = 2.0 / (hi_.x - lo_.x);
invradius_.y = 2.0 / (hi_.y - lo_.y);
invradius_.z = 2.0 / (hi_.z - lo_.z);
}
// Set the bounding box given a center and a radius.
@@ -145,6 +152,7 @@ public:
lo_ = center - offset;
hi_ = center + offset;
center_ = center;
invradius_.x = invradius_.y = invradius_.z = (1.0 / r);
}
void set_plane(std::string_view p) { plane_ = p; }
@@ -212,9 +220,11 @@ public:
// Return a debug string for the specified plane.
// This is for unit testing.
eng::string tree_debug_string(const eng::string &plane) const;
eng::string outliers_debug_string(const eng::string &plane) const;
eng::string tree_debug_string(const eng::string &plane);
eng::string outliers_debug_string(const eng::string &plane);
eng::string search_bboxes_debug_string(const eng::string &plane, const PlaneScan &scan);
eng::string scan_steps_debug_string(const eng::string &plane, const PlaneScan &scan);
// Untrack all planeitems. This is for unit testing.
void untrack_all();