added new sanity checks and compile-time assertions to prevent errors
fixed stair-building issue new test-cases added elevator support fixed/improved some walker modules
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
#include "../../../floorplan/v2/Floorplan.h"
|
||||
|
||||
#include "Helper.h"
|
||||
#include "Stairs.h"
|
||||
#include "Stairs2.h"
|
||||
#include "Elevators.h"
|
||||
|
||||
#include "../../../geo/Units.h"
|
||||
#include "../../GridNodeBBox.h"
|
||||
@@ -37,6 +38,9 @@ private:
|
||||
/** stair builder */
|
||||
Stairs<T> stairs;
|
||||
|
||||
/** elevator builder */
|
||||
Elevators<T> elevators;
|
||||
|
||||
|
||||
bool _buildStairs = true;
|
||||
bool _removeIsolated = true;
|
||||
@@ -44,7 +48,9 @@ private:
|
||||
public:
|
||||
|
||||
/** ctor with the grid to fill */
|
||||
GridFactory(Grid<T>& grid) : grid(grid), helper(grid), stairs(grid) {;}
|
||||
explicit GridFactory(Grid<T>& grid) : grid(grid), helper(grid), stairs(grid), elevators(grid) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** whether or not to build stairs */
|
||||
@@ -59,7 +65,7 @@ public:
|
||||
|
||||
Log::add(name, "building grid from IndoorMap", true);
|
||||
|
||||
const int total = map->floors.size()*2 + 1;
|
||||
const int total = map->floors.size()*3 + 1;
|
||||
int cur = 0;
|
||||
|
||||
// build all the floors
|
||||
@@ -78,6 +84,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// build all elevators
|
||||
if (listener) {listener->onGridBuildUpdateMajor("adding elevators");}
|
||||
if (_buildStairs) {
|
||||
for (Floorplan::Floor* f : map->floors) {
|
||||
buildElevators(f, listener);
|
||||
if (listener) {listener->onGridBuildUpdateMajor(total, ++cur);}
|
||||
}
|
||||
}
|
||||
|
||||
// remove isolated nodes
|
||||
if (_removeIsolated) {
|
||||
if (listener) {listener->onGridBuildUpdateMajor("removing isolated nodes");}
|
||||
@@ -180,78 +195,23 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void buildElevators(const Floorplan::Floor* floor, GridFactoryListener* listener = nullptr) {
|
||||
|
||||
const int total = floor->elevators.size();
|
||||
int cur = 0;
|
||||
|
||||
// process each elevator within the floor
|
||||
for (const Floorplan::Elevator* elevator : floor->elevators) {
|
||||
if (listener) {listener->onGridBuildUpdateMinor("adding " + floor->name + " elevator " + std::to_string(cur+1));}
|
||||
elevators.build(floor, elevator);
|
||||
if (listener) {listener->onGridBuildUpdateMinor(total, ++cur);}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// void addWithin(const Floorplan::Floor* floor, std::vector<Entry>& nodeList) {
|
||||
|
||||
// const int fz1_cm = floor->atHeight*100;
|
||||
// const int fz2_cm = (floor->atHeight+floor->height)*100;
|
||||
|
||||
// for (Entry& e : nodeList) {
|
||||
|
||||
// if ( (e.pos.z_cm <= fz1_cm) || (e.pos.z_cm >= fz2_cm) ) {
|
||||
// e.idx = grid.getNearestNode(e.pos).getIdx();
|
||||
// e.part = {9999};
|
||||
// } else {
|
||||
// const T t(e.pos.x_cm, e.pos.y_cm, e.pos.z_cm);
|
||||
// e.idx = grid.addUnaligned(t, false);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// void filter(std::vector<Entry>& nodeList) {
|
||||
|
||||
// const int gs_cm = grid.getGridSize_cm();
|
||||
// const int limit_cm = gs_cm * 0.50;
|
||||
|
||||
// // remove duplicate nodes or nodes, that are too close to each other
|
||||
// for(auto it = nodeList.begin(); it != nodeList.end(); ) {
|
||||
|
||||
// // currently examined node
|
||||
// const Entry& e1 = *it;
|
||||
|
||||
// // matches for nodes that are NOT the same instance AND nearby (< grid-size)
|
||||
// auto matches = [&] (const Entry& e2) { return (e1.pos != e2.pos) && (e1.pos.getDistanceInCM(e2.pos) <= limit_cm); };
|
||||
// auto match = std::find_if(nodeList.begin(), nodeList.end(), matches);
|
||||
|
||||
// // remove if this node has a nearby neighbor
|
||||
// if (match != nodeList.end()) {
|
||||
|
||||
// // combine both nodes within one:
|
||||
// // the node belongs to more than one stair-part
|
||||
// Entry& e2 = *match;
|
||||
// e2.part.insert(e2.part.end(), e1.part.begin(), e1.part.end());
|
||||
// it = nodeList.erase(it);
|
||||
|
||||
// } else {
|
||||
// ++it;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// std::vector<Entry> minOnly(const std::vector<Entry>& lst) {
|
||||
// auto comp = [&] (const Entry& a, const Entry& b) {return grid[a.idx].z_cm < grid[b.idx].z_cm;};
|
||||
// auto it = std::min_element(lst.begin(), lst.end(), comp);
|
||||
// T& min = grid[it->idx];
|
||||
// std::vector<Entry> res;
|
||||
// for (const Entry& e : lst) {
|
||||
// if (grid[e.idx].z_cm == min.z_cm) {res.push_back(e);}
|
||||
// }
|
||||
// return res;
|
||||
// }
|
||||
|
||||
/** connect all neighboring nodes part of the given index-vector */
|
||||
void connectAdjacent(const std::vector<int>& indices) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user