worked on windows
This commit is contained in:
@@ -264,7 +264,6 @@ namespace Floorplan3D {
|
||||
strip.add(p4);
|
||||
|
||||
for (const Floorplan::FloorObstacleWallDoor* door : doors) {
|
||||
Polygon2 pDoor;
|
||||
|
||||
const Point2 pds = door->getStart(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 dp1u(pds.x, pds.y, z1+door->height);
|
||||
|
||||
//auto flattenD1 = [dp1,a] (const Point3 p) {return (p - dp1).rotZ(-a).xz();};
|
||||
//auto unFlatten1 = [dp1,a] (const Point3 p) {return Point3(p.x, 0, p.y).rotZ(a)+dp1;};
|
||||
|
||||
Polygon2 pDoor;
|
||||
pDoor.add(flatten(dp1));
|
||||
pDoor.add(flatten(dp2));
|
||||
pDoor.add(flatten(dp2u));
|
||||
pDoor.add(flatten(dp1u));
|
||||
|
||||
// wall cutout (front/back)
|
||||
gpFront.remove(pDoor);
|
||||
gpBack.remove(pDoor);
|
||||
|
||||
// 3D framing
|
||||
strip.add(unFlattenFront2(pDoor[0]));
|
||||
strip.add(unFlattenBack2(pDoor[0]));
|
||||
|
||||
@@ -313,11 +312,55 @@ namespace Floorplan3D {
|
||||
obs.triangles.push_back(t);
|
||||
}
|
||||
|
||||
// std::vector<Point3> ptsToConnect3;
|
||||
// for (const Point2 p2 : ptsToConnect) {
|
||||
// const Point3 p3 = unf
|
||||
// }
|
||||
// process all windows within the wall
|
||||
|
||||
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
|
||||
std::vector<Triangle3> triasFront = gpFront.getTriangles();
|
||||
|
||||
@@ -424,9 +424,8 @@ namespace Floorplan {
|
||||
float startsAtHeight;
|
||||
float width;
|
||||
float height;
|
||||
bool leftRight = 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 {
|
||||
const Point2 dir = wall->to - wall->from;
|
||||
const Point2 cen = wall->from + dir * atLinePos;
|
||||
|
||||
@@ -415,7 +415,7 @@ namespace Floorplan {
|
||||
FloorObstacleWallDoor* door = new FloorObstacleWallDoor(
|
||||
parseDoorType(n->Attribute("type")),
|
||||
parseMaterial(n->Attribute("material")),
|
||||
n->FloatAttribute("at"),
|
||||
n->FloatAttribute("x01"),
|
||||
n->FloatAttribute("width"),
|
||||
n->FloatAttribute("height"),
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -534,6 +550,10 @@ namespace Floorplan {
|
||||
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) {
|
||||
try {
|
||||
return (Material) std::stoi(material);
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Floorplan {
|
||||
private:
|
||||
|
||||
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 Material 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("material", toString(door->material).c_str());
|
||||
oDoor->SetAttribute("at", door->atLinePos);
|
||||
oDoor->SetAttribute("x01", door->atLinePos);
|
||||
oDoor->SetAttribute("width", door->width);
|
||||
oDoor->SetAttribute("height", door->height);
|
||||
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, ..) */
|
||||
|
||||
Reference in New Issue
Block a user