Merge branch 'master' of https://git.frank-ebner.de/FHWS/Indoor
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Assert {
|
||||
template <typename STR> static inline void doThrow(const STR err) {
|
||||
#ifdef WITH_ASSERTIONS
|
||||
std::string str = "in: ";
|
||||
str += __PRETTY_FUNCTION__;
|
||||
str += __FUNCTION__;
|
||||
str += " error: ";
|
||||
str += err;
|
||||
throw Exception(err);
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Floorplan {
|
||||
/** possible issue types */
|
||||
enum class Type {
|
||||
WARN,
|
||||
ERROR,
|
||||
ERR,
|
||||
};
|
||||
|
||||
/** type -> string */
|
||||
static std::string getTypeStr(const Type t) {
|
||||
switch(t) {
|
||||
case Type::WARN: return "WARNING";
|
||||
case Type::ERROR: return "ERROR";
|
||||
case Type::ERR: return "ERROR";
|
||||
default: throw Exception("code error. invalid type. todo!");
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace Floorplan {
|
||||
int err = 0;
|
||||
for (const Issue& i : issues) {
|
||||
std::cout << i.asString() << std::endl;
|
||||
if (i.type == Type::ERROR) {++err;}
|
||||
if (i.type == Type::ERR) {++err;}
|
||||
}
|
||||
if (err > 0) {
|
||||
// throw Exception("detected floorplan errors");
|
||||
@@ -74,7 +74,7 @@ namespace Floorplan {
|
||||
|
||||
// outline present?
|
||||
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
|
||||
@@ -115,14 +115,14 @@ namespace Floorplan {
|
||||
static void checkOutline(Issues& res, const Floor* floor, const FloorOutlinePolygon* poly) {
|
||||
|
||||
// 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() > 1024) {res.push_back(Issue(Type::ERROR, floor, "' outline '" + poly->name + "' has too many 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::ERR, floor, "' outline '" + poly->name + "' has too many edges"));}
|
||||
|
||||
// outline size [bbox] valid?
|
||||
BBox2 outline;
|
||||
for (const Point2 pt : poly->poly.points) { outline.add(pt); }
|
||||
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) {
|
||||
const float len_m = door->from.getDistance(door->to);
|
||||
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) {
|
||||
const float len_m = circle->radius;
|
||||
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";
|
||||
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) {
|
||||
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()) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -191,19 +191,19 @@ namespace Floorplan {
|
||||
|
||||
// start == end?
|
||||
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)
|
||||
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)
|
||||
//if (quadE.p3.z != floor->getEndingZ()) {
|
||||
const int stairEndingZ_cm = std::round( quadE.p3.z * 100 );
|
||||
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?
|
||||
if (i > 0) {
|
||||
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) {
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
@@ -246,7 +246,7 @@ namespace Floorplan {
|
||||
// disconnected end? (must be long to ANY other floor within the map)
|
||||
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()) {
|
||||
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]"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
137
geo/GPCPolygon2.h
Normal file
137
geo/GPCPolygon2.h
Normal file
@@ -0,0 +1,137 @@
|
||||
#ifndef GPCPOLYGON2_H
|
||||
#define GPCPOLYGON2_H
|
||||
|
||||
#include "../lib/gpc/gpc.cpp.h"
|
||||
|
||||
class GPCPolygon2 {
|
||||
|
||||
struct GPCPolygon : gpc_polygon {
|
||||
GPCPolygon() {
|
||||
num_contours = 0;
|
||||
contour = nullptr;
|
||||
hole = nullptr;
|
||||
}
|
||||
|
||||
// no copy or move
|
||||
GPCPolygon(const GPCPolygon& o) = delete;
|
||||
GPCPolygon(GPCPolygon&& o) = delete;
|
||||
|
||||
~GPCPolygon() {
|
||||
if (contour) {
|
||||
gpc_free_polygon(this);
|
||||
//free(contour->vertex); contour->vertex = nullptr;
|
||||
}
|
||||
free(contour); contour = nullptr;
|
||||
free(hole); hole = nullptr;
|
||||
}
|
||||
|
||||
GPCPolygon& operator = (const GPCPolygon& o) = delete;
|
||||
GPCPolygon& operator = (GPCPolygon&& o) = delete;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
GPCPolygon state;
|
||||
float z;
|
||||
|
||||
public:
|
||||
|
||||
GPCPolygon2() : z(0) {
|
||||
;
|
||||
}
|
||||
|
||||
GPCPolygon2(float z) : z(z) {
|
||||
;
|
||||
}
|
||||
|
||||
void add(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur;
|
||||
toGPC(poly, cur);
|
||||
gpc_polygon_clip(GPC_UNION, &state, &cur, &state);
|
||||
}
|
||||
|
||||
void remove(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur;
|
||||
toGPC(poly, cur);
|
||||
gpc_polygon_clip(GPC_DIFF, &state, &cur, &state);
|
||||
}
|
||||
|
||||
std::vector<std::vector<Point3>> get() {
|
||||
|
||||
gpc_tristrip res;
|
||||
res.num_strips = 0;
|
||||
res.strip = nullptr;
|
||||
|
||||
//res.strip = (gpc_vertex_list*) malloc(1024);
|
||||
gpc_polygon_to_tristrip(&state, &res);
|
||||
|
||||
std::vector<std::vector<Point3>> trias;
|
||||
|
||||
for (int i = 0; i < res.num_strips; ++i) {
|
||||
gpc_vertex_list lst = res.strip[i];
|
||||
for (int j = 2; j < lst.num_vertices; ++j) {
|
||||
std::vector<Point3> tria;
|
||||
gpc_vertex& v1 = lst.vertex[j - 2];
|
||||
gpc_vertex& v2 = lst.vertex[j - 1];
|
||||
gpc_vertex& v3 = lst.vertex[j];
|
||||
tria.push_back(Point3(v1.x, v1.y, z));
|
||||
tria.push_back(Point3(v2.x, v2.y, z));
|
||||
tria.push_back(Point3(v3.x, v3.y, z));
|
||||
trias.push_back(tria);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gpc_free_tristrip(&res);
|
||||
|
||||
return std::move(trias);
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::vector<Point3>> get(float z) {
|
||||
|
||||
gpc_tristrip res;
|
||||
res.num_strips = 0;
|
||||
res.strip = nullptr;
|
||||
|
||||
//res.strip = (gpc_vertex_list*) malloc(1024);
|
||||
gpc_polygon_to_tristrip(&state, &res);
|
||||
|
||||
std::vector<std::vector<Point3>> trias;
|
||||
|
||||
for (int i = 0; i < res.num_strips; ++i) {
|
||||
gpc_vertex_list lst = res.strip[i];
|
||||
std::vector<Point3> tria;
|
||||
for (int j = 0; j < lst.num_vertices; ++j) {
|
||||
gpc_vertex& vert = lst.vertex[j];
|
||||
Point3 p3(vert.x, vert.y, z);
|
||||
tria.push_back(p3);
|
||||
}
|
||||
trias.push_back(tria);
|
||||
}
|
||||
|
||||
gpc_free_tristrip(&res);
|
||||
|
||||
return std::move(trias);
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void toGPC(Floorplan::Polygon2 poly, GPCPolygon& result) {
|
||||
|
||||
std::vector<gpc_vertex> verts;
|
||||
for (Point2 p2 : poly.points) {
|
||||
gpc_vertex vert; vert.x = p2.x; vert.y = p2.y;
|
||||
verts.push_back(vert);
|
||||
}
|
||||
|
||||
gpc_vertex_list list;
|
||||
list.num_vertices = verts.size();
|
||||
list.vertex = verts.data();
|
||||
gpc_add_contour(&result, &list, 0);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../floorplan/v2/FloorplanHelper.h"
|
||||
|
||||
#include "../geo/ConvexHull2.h"
|
||||
#include "../geo/GPCPolygon2.h"
|
||||
#include "../wifi/estimate/ray3/OBJPool.h"
|
||||
|
||||
#include "NavMesh.h"
|
||||
@@ -15,121 +16,11 @@
|
||||
#include "NavMeshType.h"
|
||||
#include "NavMeshSettings.h"
|
||||
|
||||
#include "../lib/gpc/gpc.cpp.h"
|
||||
#include "../lib/Recast/Recast.h"
|
||||
#include <string.h> // memset
|
||||
|
||||
namespace NM {
|
||||
|
||||
|
||||
class NavMeshPoly {
|
||||
|
||||
struct GPCPolygon : gpc_polygon {
|
||||
GPCPolygon() {
|
||||
num_contours = 0;
|
||||
contour = nullptr;
|
||||
hole = nullptr;
|
||||
}
|
||||
~GPCPolygon() {
|
||||
if (contour) {
|
||||
gpc_free_polygon(this);
|
||||
//free(contour->vertex); contour->vertex = nullptr;
|
||||
}
|
||||
free(contour); contour = nullptr;
|
||||
free(hole); hole = nullptr;
|
||||
|
||||
}
|
||||
GPCPolygon& operator = (const GPCPolygon& o) = delete;
|
||||
GPCPolygon& operator = (GPCPolygon& o) {
|
||||
this->contour = o.contour;
|
||||
this->hole = o.hole;
|
||||
this->num_contours = o.num_contours;
|
||||
o.contour = nullptr;
|
||||
o.hole = nullptr;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
GPCPolygon state;
|
||||
float z;
|
||||
|
||||
public:
|
||||
|
||||
NavMeshPoly(float z) : z(z) {
|
||||
;
|
||||
}
|
||||
|
||||
void add(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur = toGPC(poly);
|
||||
gpc_polygon_clip(GPC_UNION, &state, &cur, &state);
|
||||
}
|
||||
|
||||
void remove(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur = toGPC(poly);
|
||||
gpc_polygon_clip(GPC_DIFF, &state, &cur, &state);
|
||||
}
|
||||
|
||||
std::vector<std::vector<Point3>> get() {
|
||||
|
||||
gpc_tristrip res;
|
||||
res.num_strips = 0;
|
||||
res.strip = nullptr;
|
||||
|
||||
//res.strip = (gpc_vertex_list*) malloc(1024);
|
||||
gpc_polygon_to_tristrip(&state, &res);
|
||||
|
||||
std::vector<std::vector<Point3>> trias;
|
||||
|
||||
for (int i = 0; i < res.num_strips; ++i) {
|
||||
gpc_vertex_list lst = res.strip[i];
|
||||
for (int j = 2; j < lst.num_vertices; ++j) {
|
||||
std::vector<Point3> tria;
|
||||
gpc_vertex& v1 = lst.vertex[j-2];
|
||||
gpc_vertex& v2 = lst.vertex[j-1];
|
||||
gpc_vertex& v3 = lst.vertex[j];
|
||||
tria.push_back(Point3(v1.x, v1.y, z));
|
||||
tria.push_back(Point3(v2.x, v2.y, z));
|
||||
tria.push_back(Point3(v3.x, v3.y, z));
|
||||
trias.push_back(tria);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gpc_free_tristrip(&res);
|
||||
|
||||
return std::move(trias);
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
GPCPolygon toGPC(Floorplan::Polygon2 poly) {
|
||||
|
||||
std::vector<gpc_vertex> verts;
|
||||
for (Point2 p2 : poly.points) {
|
||||
gpc_vertex vert; vert.x = p2.x; vert.y = p2.y;
|
||||
verts.push_back(vert);
|
||||
}
|
||||
|
||||
GPCPolygon gpol;
|
||||
gpc_vertex_list list;
|
||||
list.num_vertices = verts.size();
|
||||
list.vertex = verts.data();
|
||||
gpc_add_contour(&gpol, &list, 0);
|
||||
|
||||
return gpol;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct TriangleIn {
|
||||
Point3 p1;
|
||||
Point3 p2;
|
||||
@@ -233,7 +124,7 @@ namespace NM {
|
||||
// if this is a to-be-added polygon, add it
|
||||
if (poly->method == Floorplan::OutlineMethod::ADD) {
|
||||
|
||||
NavMeshPoly nmPoly(floor->atHeight);
|
||||
GPCPolygon2 nmPoly(floor->atHeight);
|
||||
nmPoly.add(poly->poly);
|
||||
|
||||
// get all other polygons of this floor, that are tagged as "remove" and remove them (many will be outside of the added polygon)
|
||||
@@ -302,7 +193,7 @@ namespace NM {
|
||||
{
|
||||
|
||||
// add (overlay) all doors for tagging them within the plan
|
||||
NavMeshPoly nmDoors(floor->atHeight);
|
||||
GPCPolygon2 nmDoors(floor->atHeight);
|
||||
for (Floorplan::FloorObstacle* obs : floor->obstacles) {
|
||||
Floorplan::FloorObstacleDoor* door = dynamic_cast<Floorplan::FloorObstacleDoor*>(obs);
|
||||
if (door != nullptr) {
|
||||
|
||||
@@ -291,7 +291,7 @@ namespace NM {
|
||||
/** perform some pre-calculations to speed things up */
|
||||
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
|
||||
maxZ = std::max(p1.z, std::max(p2.z, p3.z)) + 0.15;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "Sensors.h"
|
||||
#include "Listener.h"
|
||||
|
||||
#warning "adjust to to use the new splitter for all parsers [gps, compass, etc. already do!]"
|
||||
#pragma message "adjust to to use the new splitter for all parsers [gps, compass, etc. already do!]"
|
||||
|
||||
namespace Offline {
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
#include "../../../floorplan/v2/Floorplan.h"
|
||||
#include "../../../geo/Triangle3.h"
|
||||
#include "ModelFactoryHelper.h"
|
||||
#include "../../../geo/GPCPolygon2.h"
|
||||
|
||||
#include "Obstacle3.h"
|
||||
#include "Cube.h"
|
||||
#include "Tube.h"
|
||||
@@ -132,7 +133,7 @@ namespace Ray3D {
|
||||
|
||||
// process all "add" regions by type
|
||||
// [this allows for overlaps of the same type]
|
||||
std::unordered_map<std::string, Polygon> types;
|
||||
std::unordered_map<std::string, GPCPolygon2> types;
|
||||
for (Floorplan::FloorOutlinePolygon* fop : f->outline) {
|
||||
if (fop->method == Floorplan::OutlineMethod::ADD) {
|
||||
if (fop->outdoor) {
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
#ifndef MODELFACTORYHELPER_H
|
||||
#define MODELFACTORYHELPER_H
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
#include "../../../lib/gpc/gpc.h"
|
||||
|
||||
namespace Ray3D {
|
||||
|
||||
class Polygon {
|
||||
|
||||
struct GPCPolygon : gpc_polygon {
|
||||
GPCPolygon() {
|
||||
num_contours = 0;
|
||||
contour = nullptr;
|
||||
hole = nullptr;
|
||||
}
|
||||
~GPCPolygon() {
|
||||
if (contour) {
|
||||
gpc_free_polygon(this);
|
||||
//free(contour->vertex); contour->vertex = nullptr;
|
||||
}
|
||||
free(contour); contour = nullptr;
|
||||
free(hole); hole = nullptr;
|
||||
|
||||
}
|
||||
GPCPolygon& operator = (const GPCPolygon& o) = delete;
|
||||
GPCPolygon& operator = (GPCPolygon& o) {
|
||||
this->contour = o.contour;
|
||||
this->hole = o.hole;
|
||||
this->num_contours = o.num_contours;
|
||||
o.contour = nullptr;
|
||||
o.hole = nullptr;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
GPCPolygon state;
|
||||
|
||||
public:
|
||||
|
||||
void add(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur = toGPC(poly);
|
||||
//GPCPolygon out;
|
||||
gpc_polygon_clip(GPC_UNION, &state, &cur, &state);
|
||||
//state = out;
|
||||
}
|
||||
|
||||
void remove(const Floorplan::Polygon2& poly) {
|
||||
GPCPolygon cur = toGPC(poly);
|
||||
//GPCPolygon out;
|
||||
gpc_polygon_clip(GPC_DIFF, &state, &cur, &state);
|
||||
//state = out;
|
||||
}
|
||||
|
||||
std::vector<std::vector<Point3>> get(float z) {
|
||||
|
||||
gpc_tristrip res;
|
||||
res.num_strips = 0;
|
||||
res.strip = nullptr;
|
||||
|
||||
//res.strip = (gpc_vertex_list*) malloc(1024);
|
||||
gpc_polygon_to_tristrip(&state, &res);
|
||||
|
||||
std::vector<std::vector<Point3>> trias;
|
||||
|
||||
for (int i = 0; i < res.num_strips; ++i) {
|
||||
gpc_vertex_list lst = res.strip[i];
|
||||
std::vector<Point3> tria;
|
||||
for (int j = 0; j < lst.num_vertices; ++j) {
|
||||
gpc_vertex& vert = lst.vertex[j];
|
||||
Point3 p3(vert.x, vert.y, z);
|
||||
tria.push_back(p3);
|
||||
}
|
||||
trias.push_back(tria);
|
||||
}
|
||||
|
||||
gpc_free_tristrip(&res);
|
||||
|
||||
return std::move(trias);
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
GPCPolygon toGPC(Floorplan::Polygon2 poly) {
|
||||
|
||||
std::vector<gpc_vertex> verts;
|
||||
for (Point2 p2 : poly.points) {
|
||||
gpc_vertex vert; vert.x = p2.x; vert.y = p2.y;
|
||||
verts.push_back(vert);
|
||||
}
|
||||
|
||||
GPCPolygon gpol;
|
||||
gpc_vertex_list list;
|
||||
list.num_vertices = verts.size();
|
||||
list.vertex = verts.data();
|
||||
gpc_add_contour(&gpol, &list, 0);
|
||||
|
||||
return gpol;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MODELFACTORYHELPER_H
|
||||
@@ -57,7 +57,6 @@ namespace Ray3D {
|
||||
scanFolder(folder);
|
||||
} catch (...) {;}
|
||||
}
|
||||
initDone = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -89,9 +88,9 @@ namespace Ray3D {
|
||||
}
|
||||
|
||||
for (std::experimental::filesystem::directory_entry entry : std::experimental::filesystem::directory_iterator(d)) {
|
||||
const std::string absFile = entry.path().native();
|
||||
const std::string absFile = entry.path().string();
|
||||
if (endsWith(absFile, ".obj")) {
|
||||
std::string name = entry.path().filename();
|
||||
std::string name = entry.path().filename().string();
|
||||
name = name.substr(0, name.length() - 4); // without extension
|
||||
load(absFile, name);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
/** one triangle */
|
||||
struct Face {
|
||||
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} {;}
|
||||
};
|
||||
|
||||
/** one object within the file */
|
||||
|
||||
Reference in New Issue
Block a user