This commit is contained in:
2018-03-27 13:59:47 +02:00
parent 705763f03c
commit e6444ceeb7
5 changed files with 24 additions and 24 deletions

View File

@@ -22,7 +22,7 @@ namespace Assert {
template <typename STR> static inline void doThrow(const STR err) { template <typename STR> static inline void doThrow(const STR err) {
#ifdef WITH_ASSERTIONS #ifdef WITH_ASSERTIONS
std::string str = "in: "; std::string str = "in: ";
str += __PRETTY_FUNCTION__; str += __FUNCTION__;
str += " error: "; str += " error: ";
str += err; str += err;
throw Exception(err); throw Exception(err);

View File

@@ -16,14 +16,14 @@ namespace Floorplan {
/** possible issue types */ /** possible issue types */
enum class Type { enum class Type {
WARN, WARN,
ERROR, ERR,
}; };
/** type -> string */ /** type -> string */
static std::string getTypeStr(const Type t) { static std::string getTypeStr(const Type t) {
switch(t) { switch(t) {
case Type::WARN: return "WARNING"; case Type::WARN: return "WARNING";
case Type::ERROR: return "ERROR"; case Type::ERR: return "ERROR";
default: throw Exception("code error. invalid type. todo!"); default: throw Exception("code error. invalid type. todo!");
} }
} }
@@ -57,7 +57,7 @@ namespace Floorplan {
int err = 0; int err = 0;
for (const Issue& i : issues) { for (const Issue& i : issues) {
std::cout << i.asString() << std::endl; std::cout << i.asString() << std::endl;
if (i.type == Type::ERROR) {++err;} if (i.type == Type::ERR) {++err;}
} }
if (err > 0) { if (err > 0) {
// throw Exception("detected floorplan errors"); // throw Exception("detected floorplan errors");
@@ -74,7 +74,7 @@ namespace Floorplan {
// outline present? // outline present?
if (floor->outline.empty()) { if (floor->outline.empty()) {
res.push_back(Issue(Type::ERROR, floor, "has no outline")); res.push_back(Issue(Type::ERR, floor, "has no outline"));
} }
// check outline // check outline
@@ -115,14 +115,14 @@ namespace Floorplan {
static void checkOutline(Issues& res, const Floor* floor, const FloorOutlinePolygon* poly) { static void checkOutline(Issues& res, const Floor* floor, const FloorOutlinePolygon* poly) {
// number of points valid? // number of points valid?
if (poly->poly.points.size() < 3) {res.push_back(Issue(Type::ERROR, floor, "' outline '" + poly->name + "' needs at least 3 edges"));} if (poly->poly.points.size() < 3) {res.push_back(Issue(Type::ERR, floor, "' outline '" + poly->name + "' needs at least 3 edges"));}
if (poly->poly.points.size() > 1024) {res.push_back(Issue(Type::ERROR, floor, "' outline '" + poly->name + "' has too many edges"));} if (poly->poly.points.size() > 1024) {res.push_back(Issue(Type::ERR, floor, "' outline '" + poly->name + "' has too many edges"));}
// outline size [bbox] valid? // outline size [bbox] valid?
BBox2 outline; BBox2 outline;
for (const Point2 pt : poly->poly.points) { outline.add(pt); } for (const Point2 pt : poly->poly.points) { outline.add(pt); }
const Point2 size = outline.getSize(); const Point2 size = outline.getSize();
if (size.x < 1.0 || size.y < 1.0) {res.push_back(Issue(Type::ERROR, floor, "' outline '" + poly->name + "' seems too small"));} if (size.x < 1.0 || size.y < 1.0) {res.push_back(Issue(Type::ERR, floor, "' outline '" + poly->name + "' seems too small"));}
} }
@@ -143,7 +143,7 @@ namespace Floorplan {
if (door) { if (door) {
const float len_m = door->from.getDistance(door->to); const float len_m = door->from.getDistance(door->to);
if (len_m < 0.40) { if (len_m < 0.40) {
res.push_back(Issue(Type::ERROR, floor, "' door is too narrow: " + std::to_string(len_m) + " meter from " + door->from.asString() + " to " + door->to.asString())); res.push_back(Issue(Type::ERR, floor, "' door is too narrow: " + std::to_string(len_m) + " meter from " + door->from.asString() + " to " + door->to.asString()));
} }
} }
@@ -152,7 +152,7 @@ namespace Floorplan {
if (circle) { if (circle) {
const float len_m = circle->radius; const float len_m = circle->radius;
if (len_m < 0.20) { if (len_m < 0.20) {
res.push_back(Issue(Type::ERROR, floor, "' pillar is too narrow: " + std::to_string(len_m) + " meter at " + circle->center.asString())); res.push_back(Issue(Type::ERR, floor, "' pillar is too narrow: " + std::to_string(len_m) + " meter at " + circle->center.asString()));
} }
} }
@@ -162,7 +162,7 @@ namespace Floorplan {
const std::string note = "does it belong to a stair? if so: fine! Note: fingerprints are currently measured using smartphones and smartphone are held by the pedestian. thus: fingerprints are ~1.3 meter above ground"; const std::string note = "does it belong to a stair? if so: fine! Note: fingerprints are currently measured using smartphones and smartphone are held by the pedestian. thus: fingerprints are ~1.3 meter above ground";
if (fpl->heightAboveFloor < 0.8) { if (fpl->heightAboveFloor < 0.8) {
res.push_back(Issue(Type::ERROR, floor, std::string() + "fingerprint " + fpl->name + " @ " + fpl->getPosition(*floor).asString() + " is too near to the floor. " + note)); res.push_back(Issue(Type::ERR, floor, std::string() + "fingerprint " + fpl->name + " @ " + fpl->getPosition(*floor).asString() + " is too near to the floor. " + note));
} else if (fpl->heightAboveFloor > 2.0) { } else if (fpl->heightAboveFloor > 2.0) {
res.push_back(Issue(Type::WARN, floor, std::string() + "fingerprint " + fpl->name + " @ " + fpl->getPosition(*floor).asString() + " is too high above the floor. " + note)); res.push_back(Issue(Type::WARN, floor, std::string() + "fingerprint " + fpl->name + " @ " + fpl->getPosition(*floor).asString() + " is too high above the floor. " + note));
} }
@@ -179,7 +179,7 @@ namespace Floorplan {
} }
if (stair->getParts().empty()) { if (stair->getParts().empty()) {
res.push_back(Issue(Type::ERROR, floor, "stair does not contain any parts! [empty stair]")); res.push_back(Issue(Type::ERR, floor, "stair does not contain any parts! [empty stair]"));
return; return;
} }
@@ -191,19 +191,19 @@ namespace Floorplan {
// start == end? // start == end?
if (quadS.p1.z == quadE.p3.z) { if (quadS.p1.z == quadE.p3.z) {
res.push_back(Issue(Type::ERROR, floor, "stair start and end must not belong to the same floor!")); res.push_back(Issue(Type::ERR, floor, "stair start and end must not belong to the same floor!"));
} }
// disconnected start? (MUST belong to the floor the stair is attached to) // disconnected start? (MUST belong to the floor the stair is attached to)
if (quadS.p1.z != floor->getStartingZ()) { if (quadS.p1.z != floor->getStartingZ()) {
res.push_back(Issue(Type::ERROR, floor, "stair is not connected to the starting floor's ground! [open stair start]")); res.push_back(Issue(Type::ERR, floor, "stair is not connected to the starting floor's ground! [open stair start]"));
} }
// disconnected end? (must be long to ANY other floor within the map) // disconnected end? (must be long to ANY other floor within the map)
//if (quadE.p3.z != floor->getEndingZ()) { //if (quadE.p3.z != floor->getEndingZ()) {
const int stairEndingZ_cm = std::round( quadE.p3.z * 100 ); const int stairEndingZ_cm = std::round( quadE.p3.z * 100 );
if(std::find(floorAtHeight_cm.begin(), floorAtHeight_cm.end(), stairEndingZ_cm) == floorAtHeight_cm.end()) { if(std::find(floorAtHeight_cm.begin(), floorAtHeight_cm.end(), stairEndingZ_cm) == floorAtHeight_cm.end()) {
res.push_back(Issue(Type::ERROR, floor, "stair is not connected to the ending floor's ground! [open stair end]")); res.push_back(Issue(Type::ERR, floor, "stair is not connected to the ending floor's ground! [open stair end]"));
} }
@@ -214,7 +214,7 @@ namespace Floorplan {
// disconnected within? // disconnected within?
if (i > 0) { if (i > 0) {
if (quads[i-1].p4.z != quads[i-0].p1.z) { if (quads[i-1].p4.z != quads[i-0].p1.z) {
res.push_back(Issue(Type::ERROR, floor, "stair is disconnected within!")); res.push_back(Issue(Type::ERR, floor, "stair is disconnected within!"));
} }
} }
@@ -225,15 +225,15 @@ namespace Floorplan {
static void checkElevator(Issues& res, const IndoorMap* map, const Floor* floor, const Elevator* e) { static void checkElevator(Issues& res, const IndoorMap* map, const Floor* floor, const Elevator* e) {
if (e->depth < 0.5) { if (e->depth < 0.5) {
res.push_back(Issue(Type::ERROR, floor, "elevator's @" + e->center.asString() + ": depth is too small: " + std::to_string(e->depth) + "m")); res.push_back(Issue(Type::ERR, floor, "elevator's @" + e->center.asString() + ": depth is too small: " + std::to_string(e->depth) + "m"));
} }
if (e->width < 0.5) { if (e->width < 0.5) {
res.push_back(Issue(Type::ERROR, floor, "elevator's @" + e->center.asString() + ": width is too small: " + std::to_string(e->width) + "m")); res.push_back(Issue(Type::ERR, floor, "elevator's @" + e->center.asString() + ": width is too small: " + std::to_string(e->width) + "m"));
} }
if (e->height_m < 0.1) { if (e->height_m < 0.1) {
res.push_back(Issue(Type::ERROR, floor, "elevator's @" + e->center.asString() + ": height is too small: " + std::to_string(e->height_m) + "m")); res.push_back(Issue(Type::ERR, floor, "elevator's @" + e->center.asString() + ": height is too small: " + std::to_string(e->height_m) + "m"));
} }
// list of all heights where there is a floor; // list of all heights where there is a floor;
@@ -246,7 +246,7 @@ namespace Floorplan {
// disconnected end? (must be long to ANY other floor within the map) // disconnected end? (must be long to ANY other floor within the map)
const int elevEndZ_cm = std::round( (floor->getStartingZ() + e->height_m) * 100 ); const int elevEndZ_cm = std::round( (floor->getStartingZ() + e->height_m) * 100 );
if(std::find(floorAtHeight_cm.begin(), floorAtHeight_cm.end(), elevEndZ_cm) == floorAtHeight_cm.end()) { if(std::find(floorAtHeight_cm.begin(), floorAtHeight_cm.end(), elevEndZ_cm) == floorAtHeight_cm.end()) {
res.push_back(Issue(Type::ERROR, floor, "elevator @" + e->center.asString() + " is not connected to the ending floor's ground! [open elevator end]")); res.push_back(Issue(Type::ERR, floor, "elevator @" + e->center.asString() + " is not connected to the ending floor's ground! [open elevator end]"));
} }
} }

View File

@@ -291,7 +291,7 @@ namespace NM {
/** perform some pre-calculations to speed things up */ /** perform some pre-calculations to speed things up */
void precompute() { void precompute() {
#warning "TODO, z buffer" #pragma message "TODO, z buffer"
minZ = std::min(p1.z, std::min(p2.z, p3.z)) - 0.15; // TODO the builder does not align on the same height as we did minZ = std::min(p1.z, std::min(p2.z, p3.z)) - 0.15; // TODO the builder does not align on the same height as we did
maxZ = std::max(p1.z, std::max(p2.z, p3.z)) + 0.15; maxZ = std::max(p1.z, std::max(p2.z, p3.z)) + 0.15;

View File

@@ -54,10 +54,10 @@ namespace Ray3D {
//while ((dir = readdir(d)) != NULL) { //while ((dir = readdir(d)) != NULL) {
for (std::experimental::filesystem::directory_entry entry : std::experimental::filesystem::directory_iterator(d)) { for (std::experimental::filesystem::directory_entry entry : std::experimental::filesystem::directory_iterator(d)) {
//const std::string absFile = folder + "/" + dir->d_name; //const std::string absFile = folder + "/" + dir->d_name;
const std::string absFile = entry.path().native(); const std::string absFile = entry.path().string();
if (endsWith(absFile, ".obj")) { if (endsWith(absFile, ".obj")) {
//std::string name = std::string(dir->d_name); //std::string name = std::string(dir->d_name);
std::string name = entry.path().filename(); std::string name = entry.path().filename().string();
name = name.substr(0, name.length() - 4); // without extension name = name.substr(0, name.length() - 4); // without extension
load(absFile, name); load(absFile, name);
} }

View File

@@ -28,7 +28,7 @@ public:
/** one triangle */ /** one triangle */
struct Face { struct Face {
VNT vnt[3]; VNT vnt[3];
Face(VNT v1, VNT v2, VNT v3) : vnt({v1,v2,v3}) {;} Face(VNT v1, VNT v2, VNT v3) : vnt{v1,v2,v3} {;}
}; };
/** internal data */ /** internal data */