started working on walling, dooring and windowing
refactoring
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "../../geo/Polygon2.h"
|
||||
#include "../../geo/GPCPolygon2.h"
|
||||
|
||||
#include "Walls.h"
|
||||
//#include "Walls.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include <functional>
|
||||
@@ -17,7 +17,7 @@ namespace Floorplan3D {
|
||||
* interpret walls als quads (polygons)
|
||||
* intersect them with each other to prevent overlaps
|
||||
*/
|
||||
class WallsViaCuttedQuads : public Walls {
|
||||
class WallsViaCuttedQuads {
|
||||
|
||||
private:
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace Floorplan3D {
|
||||
bool error = false;
|
||||
|
||||
/** original line from floorplan */
|
||||
const Floorplan::FloorObstacleLine* line;
|
||||
const Floorplan::FloorObstacleWall* line;
|
||||
|
||||
/** outlines after applying thickness */
|
||||
Line2 l1;
|
||||
Line2 l2;
|
||||
|
||||
Wall(const Floorplan::FloorObstacleLine* line) : line(line) {
|
||||
Wall(const Floorplan::FloorObstacleWall* line) : line(line) {
|
||||
|
||||
const Point2 from = line->from;
|
||||
const Point2 to = line->to;
|
||||
@@ -137,18 +137,17 @@ namespace Floorplan3D {
|
||||
public:
|
||||
|
||||
|
||||
void clear() override {
|
||||
void clear() {
|
||||
walls.clear();
|
||||
}
|
||||
|
||||
void add(const Floorplan::Floor* f, const Floorplan::FloorObstacleLine* fol, const Floorplan::FloorObstacleDoor* aboveDoor) override {
|
||||
if (fol->type != Floorplan::ObstacleType::WALL) {return;}
|
||||
if (aboveDoor) {return;}
|
||||
void add(const Floorplan::Floor* f, const Floorplan::FloorObstacleWall* fow) {
|
||||
if (fow->type != Floorplan::ObstacleType::WALL) {return;}
|
||||
this->floor = f;
|
||||
walls.push_back(Wall(fol));
|
||||
walls.push_back(Wall(fow));
|
||||
}
|
||||
|
||||
virtual const std::vector<Obstacle3D>& get() override {
|
||||
virtual const std::vector<Obstacle3D>& get() {
|
||||
std::vector<Wall> tmp = walls;
|
||||
tmp = cutConnected(tmp);
|
||||
tmp = cutProtruding(tmp);
|
||||
@@ -226,6 +225,9 @@ namespace Floorplan3D {
|
||||
auto unFlattenFront = [o,t,a] (const Point3 p) {return Point3(p.x, +t, p.y).rotZ(a)+o;};
|
||||
auto unFlattenBack = [o,t,a] (const Point3 p) {return Point3(p.x, -t, p.y).rotZ(a)+o;};
|
||||
|
||||
auto unFlattenFront2 = [o,t,a] (const Point2 p) {return Point3(p.x, +t, p.y).rotZ(a)+o;};
|
||||
auto unFlattenBack2 = [o,t,a] (const Point2 p) {return Point3(p.x, -t, p.y).rotZ(a)+o;};
|
||||
|
||||
const Point2 fp1 = flatten(p1);
|
||||
const Point2 fp2 = flatten(p2);
|
||||
const Point2 fp3 = flatten(p3);
|
||||
@@ -248,7 +250,20 @@ namespace Floorplan3D {
|
||||
GPCPolygon2 gpBack;
|
||||
gpBack.add(back);
|
||||
|
||||
for (const Floorplan::FloorObstacleWallDoor* door : wall.line->doors) {
|
||||
// sort doors by their position within the wall (first comes first)
|
||||
std::vector<Floorplan::FloorObstacleWallDoor*> doors = wall.line->doors;
|
||||
auto compDoors = [] (const Floorplan::FloorObstacleWallDoor* d1, Floorplan::FloorObstacleWallDoor* d2) {
|
||||
return d1->atLinePos < d2->atLinePos;
|
||||
};
|
||||
std::sort(doors.begin(), doors.end(), compDoors);
|
||||
|
||||
|
||||
TriangleStrip strip;
|
||||
|
||||
strip.add(p1);
|
||||
strip.add(p4);
|
||||
|
||||
for (const Floorplan::FloorObstacleWallDoor* door : doors) {
|
||||
Polygon2 pDoor;
|
||||
|
||||
const Point2 pds = door->getStart(wall.line);
|
||||
@@ -270,8 +285,41 @@ namespace Floorplan3D {
|
||||
gpFront.remove(pDoor);
|
||||
gpBack.remove(pDoor);
|
||||
|
||||
strip.add(unFlattenFront2(pDoor[0]));
|
||||
strip.add(unFlattenBack2(pDoor[0]));
|
||||
|
||||
strip.add(unFlattenFront2(pDoor[3]));
|
||||
strip.add(unFlattenBack2(pDoor[3]));
|
||||
|
||||
strip.add(unFlattenFront2(pDoor[2]));
|
||||
strip.add(unFlattenBack2(pDoor[2]));
|
||||
|
||||
strip.add(unFlattenFront2(pDoor[1]));
|
||||
strip.add(unFlattenBack2(pDoor[1]));
|
||||
|
||||
}
|
||||
|
||||
strip.add(p2);
|
||||
strip.add(p3);
|
||||
strip.add(p2u);
|
||||
strip.add(p3u);
|
||||
strip.add(p1u);
|
||||
strip.add(p4u);
|
||||
strip.add(p1);
|
||||
strip.add(p4);
|
||||
|
||||
for (Triangle3 t : strip.toTriangles()) {
|
||||
t.reverse();
|
||||
obs.triangles.push_back(t);
|
||||
}
|
||||
|
||||
// std::vector<Point3> ptsToConnect3;
|
||||
// for (const Point2 p2 : ptsToConnect) {
|
||||
// const Point3 p3 = unf
|
||||
// }
|
||||
|
||||
|
||||
// Frontseite triangulieren
|
||||
std::vector<Triangle3> triasFront = gpFront.getTriangles();
|
||||
|
||||
for (Triangle3 tria : triasFront) {
|
||||
@@ -280,6 +328,7 @@ namespace Floorplan3D {
|
||||
obs.triangles.push_back(tria);
|
||||
}
|
||||
|
||||
// Rückseite triangulieren
|
||||
std::vector<Triangle3> triasBack = gpBack.getTriangles();
|
||||
|
||||
for (Triangle3 tria : triasBack) {
|
||||
|
||||
Reference in New Issue
Block a user