worked on windows

This commit is contained in:
k-a-z-u
2018-07-25 18:12:48 +02:00
parent 0d22d91470
commit baeb8bef11
4 changed files with 91 additions and 12 deletions

View File

@@ -264,7 +264,6 @@ namespace Floorplan3D {
strip.add(p4); strip.add(p4);
for (const Floorplan::FloorObstacleWallDoor* door : doors) { for (const Floorplan::FloorObstacleWallDoor* door : doors) {
Polygon2 pDoor;
const Point2 pds = door->getStart(wall.line); const Point2 pds = door->getStart(wall.line);
const Point2 pde = door->getEnd(wall.line); const Point2 pde = door->getEnd(wall.line);
@@ -274,17 +273,17 @@ namespace Floorplan3D {
const Point3 dp2u(pde.x, pde.y, z1+door->height); const Point3 dp2u(pde.x, pde.y, z1+door->height);
const Point3 dp1u(pds.x, pds.y, z1+door->height); const Point3 dp1u(pds.x, pds.y, z1+door->height);
//auto flattenD1 = [dp1,a] (const Point3 p) {return (p - dp1).rotZ(-a).xz();}; Polygon2 pDoor;
//auto unFlatten1 = [dp1,a] (const Point3 p) {return Point3(p.x, 0, p.y).rotZ(a)+dp1;};
pDoor.add(flatten(dp1)); pDoor.add(flatten(dp1));
pDoor.add(flatten(dp2)); pDoor.add(flatten(dp2));
pDoor.add(flatten(dp2u)); pDoor.add(flatten(dp2u));
pDoor.add(flatten(dp1u)); pDoor.add(flatten(dp1u));
// wall cutout (front/back)
gpFront.remove(pDoor); gpFront.remove(pDoor);
gpBack.remove(pDoor); gpBack.remove(pDoor);
// 3D framing
strip.add(unFlattenFront2(pDoor[0])); strip.add(unFlattenFront2(pDoor[0]));
strip.add(unFlattenBack2(pDoor[0])); strip.add(unFlattenBack2(pDoor[0]));
@@ -313,11 +312,55 @@ namespace Floorplan3D {
obs.triangles.push_back(t); obs.triangles.push_back(t);
} }
// std::vector<Point3> ptsToConnect3; // process all windows within the wall
// for (const Point2 p2 : ptsToConnect) {
// const Point3 p3 = unf
// }
for (const Floorplan::FloorObstacleWallWindow* win : wall.line->windows) {
const Point2 pws = win->getStart(wall.line);
const Point2 pwe = win->getEnd(wall.line);
const float wz1 = z1 + win->startsAtHeight;
const float wz2 = z1 + win->startsAtHeight + win->height;
const Point3 dp1(pws.x, pws.y, wz1);
const Point3 dp2(pwe.x, pwe.y, wz1);
const Point3 dp2u(pwe.x, pwe.y, wz2);
const Point3 dp1u(pws.x, pws.y, wz2);
Polygon2 pWindow;
pWindow.add(flatten(dp1));
pWindow.add(flatten(dp2));
pWindow.add(flatten(dp2u));
pWindow.add(flatten(dp1u));
// wall cutout (front/back)
gpFront.remove(pWindow);
gpBack.remove(pWindow);
// 3D framing
TriangleStrip strip;
strip.add(unFlattenFront2(pWindow[0]));
strip.add(unFlattenBack2(pWindow[0]));
strip.add(unFlattenFront2(pWindow[3]));
strip.add(unFlattenBack2(pWindow[3]));
strip.add(unFlattenFront2(pWindow[2]));
strip.add(unFlattenBack2(pWindow[2]));
strip.add(unFlattenFront2(pWindow[1]));
strip.add(unFlattenBack2(pWindow[1]));
strip.add(unFlattenFront2(pWindow[0]));
strip.add(unFlattenBack2(pWindow[0]));
for (Triangle3 t : strip.toTriangles()) {
t.reverse();
obs.triangles.push_back(t);
}
}
// Frontseite triangulieren // Frontseite triangulieren
std::vector<Triangle3> triasFront = gpFront.getTriangles(); std::vector<Triangle3> triasFront = gpFront.getTriangles();

View File

@@ -424,9 +424,8 @@ namespace Floorplan {
float startsAtHeight; float startsAtHeight;
float width; float width;
float height; float height;
bool leftRight = false;
bool inOut = false; bool inOut = false;
FloorObstacleWallWindow(const WindowType type, const Material material, const float atLinePos, const float startsAtHeight, const float width, const float height, const bool lr = false, const bool io = false) : FloorObstacle(material), type(type), atLinePos(atLinePos), startsAtHeight(startsAtHeight), width(width), height(height), leftRight(lr), inOut(io) {;} FloorObstacleWallWindow(const WindowType type, const Material material, const float atLinePos, const float startsAtHeight, const float width, const float height, const bool io = false) : FloorObstacle(material), type(type), atLinePos(atLinePos), startsAtHeight(startsAtHeight), width(width), height(height), inOut(io) {;}
Point2 getStart(const FloorObstacleWall* wall) const { Point2 getStart(const FloorObstacleWall* wall) const {
const Point2 dir = wall->to - wall->from; const Point2 dir = wall->to - wall->from;
const Point2 cen = wall->from + dir * atLinePos; const Point2 cen = wall->from + dir * atLinePos;

View File

@@ -415,7 +415,7 @@ namespace Floorplan {
FloorObstacleWallDoor* door = new FloorObstacleWallDoor( FloorObstacleWallDoor* door = new FloorObstacleWallDoor(
parseDoorType(n->Attribute("type")), parseDoorType(n->Attribute("type")),
parseMaterial(n->Attribute("material")), parseMaterial(n->Attribute("material")),
n->FloatAttribute("at"), n->FloatAttribute("x01"),
n->FloatAttribute("width"), n->FloatAttribute("width"),
n->FloatAttribute("height"), n->FloatAttribute("height"),
n->BoolAttribute("lr"), n->BoolAttribute("lr"),
@@ -425,6 +425,22 @@ namespace Floorplan {
} }
} }
// windows
FOREACH_NODE(n, el) {
if (std::string("window") == n->Name()) {
FloorObstacleWallWindow* win = new FloorObstacleWallWindow(
parseWindowType(n->Attribute("type")),
parseMaterial(n->Attribute("material")),
n->FloatAttribute("x01"),
n->FloatAttribute("y"),
n->FloatAttribute("width"),
n->FloatAttribute("height"),
n->BoolAttribute("io")
);
wall->windows.push_back(win);
}
}
return wall; return wall;
} }
@@ -534,6 +550,10 @@ namespace Floorplan {
try { return (DoorType) std::stoi(type); } catch (...) { return DoorType::UNKNOWN; } try { return (DoorType) std::stoi(type); } catch (...) { return DoorType::UNKNOWN; }
} }
static WindowType parseWindowType(const std::string type) {
try { return (WindowType) std::stoi(type); } catch (...) { return WindowType::UNKNOWN; }
}
static Material parseMaterial(const std::string material) { static Material parseMaterial(const std::string material) {
try { try {
return (Material) std::stoi(material); return (Material) std::stoi(material);

View File

@@ -38,6 +38,7 @@ namespace Floorplan {
private: private:
static std::string toString(const ObstacleType t) { return std::to_string((int)t); } static std::string toString(const ObstacleType t) { return std::to_string((int)t); }
static std::string toString(const WindowType t) { return std::to_string((int)t); }
static std::string toString(const DoorType t) { return std::to_string((int)t); } static std::string toString(const DoorType t) { return std::to_string((int)t); }
static std::string toString(const Material m) { return std::to_string((int)m); } static std::string toString(const Material m) { return std::to_string((int)m); }
static std::string toString(const OutlineMethod m) { return std::to_string((int)m); } static std::string toString(const OutlineMethod m) { return std::to_string((int)m); }
@@ -349,7 +350,7 @@ namespace Floorplan {
oDoor->SetAttribute("type", toString(door->type).c_str()); oDoor->SetAttribute("type", toString(door->type).c_str());
oDoor->SetAttribute("material", toString(door->material).c_str()); oDoor->SetAttribute("material", toString(door->material).c_str());
oDoor->SetAttribute("at", door->atLinePos); oDoor->SetAttribute("x01", door->atLinePos);
oDoor->SetAttribute("width", door->width); oDoor->SetAttribute("width", door->width);
oDoor->SetAttribute("height", door->height); oDoor->SetAttribute("height", door->height);
oDoor->SetAttribute("io", door->inOut); oDoor->SetAttribute("io", door->inOut);
@@ -357,6 +358,22 @@ namespace Floorplan {
} }
// windows?
for (const FloorObstacleWallWindow* win : wall->windows) {
XMLElem* oDoor = doc.NewElement("window");
oWall->InsertEndChild(oDoor);
oDoor->SetAttribute("type", toString(win->type).c_str());
oDoor->SetAttribute("material", toString(win->material).c_str());
oDoor->SetAttribute("x01", win->atLinePos);
oDoor->SetAttribute("y", win->startsAtHeight);
oDoor->SetAttribute("width", win->width);
oDoor->SetAttribute("height", win->height);
oDoor->SetAttribute("io", win->inOut);
}
} }
/** write a line obstacle (old walls, handrail, ..) */ /** write a line obstacle (old walls, handrail, ..) */