diff --git a/Analysis.cpp b/Analysis.cpp index bbafdb43ae0d7528a1abb579e81875c44c1487cb..036abac12d3e54656b4c3f6851a1aea5bfb8c14d 100644 --- a/Analysis.cpp +++ b/Analysis.cpp @@ -247,7 +247,7 @@ std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, c if(geoPoly.count(area->_id)==0) { Log->Write("ERROR: \t No polygon containing the measurement id [%d]", area->_id); - exit(1); + geoPoly[area->_id] = area->_poly; } } diff --git a/general/ArgumentParser.cpp b/general/ArgumentParser.cpp index 0bcc4e097f1d28d2109d364a4df9a88d09c54fcc..34b2bf5a9080a0985d9090cd69f9f5d12ec38797 100644 --- a/general/ArgumentParser.cpp +++ b/general/ArgumentParser.cpp @@ -480,14 +480,55 @@ bool ArgumentParser::ParseIniFile(const string& inifile) { areaB->_zPos=10000001.0; } + // get bounding box + // loading geometry is done in analysis.cpp + // so this is done twice, which is not nice. + // For big geometries it could be slow. + Building* building = new Building(); + building->LoadGeometry(GetGeometryFilename().string()); + building->InitGeometry(); + building->AddSurroundingRoom(); // this is a big reactagle + // slightly bigger than the + // geometry boundaries + double geo_minX = building->_xMin; + double geo_minY = building->_yMin; + double geo_maxX = building->_xMax; + double geo_maxY = building->_yMax; + + + std::map<int, polygon_2d> geoPoly; polygon_2d poly; Log->Write("INFO: \tMeasure area id <%d> with type <%s>",areaB->_id, areaB->_type.c_str()); + int num_verteces = 0; for(TiXmlElement* xVertex=xMeasurementArea_B->FirstChildElement("vertex"); xVertex; xVertex=xVertex->NextSiblingElement("vertex") ) { double box_px = xmltof(xVertex->Attribute("x"))*M2CM; double box_py = xmltof(xVertex->Attribute("y"))*M2CM; boost::geometry::append(poly, boost::geometry::make<point_2d>(box_px, box_py)); Log->Write("\t\tMeasure area points < %.3f, %.3f>",box_px*CMtoM,box_py*CMtoM); + num_verteces++; + } + if(num_verteces < 3 && num_verteces > 0) + Log->Write("\tWARNING: Less than 3 measure area points given (%d). At least 3 or nothing at all!!", num_verteces); + if(num_verteces == 0) // big bounding box + { + Log->Write("\tWARNING: NO measure area points given (%d). default BB!!", num_verteces); + //1 + double box_px = geo_minX*M2CM; + double box_py = geo_minY*M2CM; + boost::geometry::append(poly, boost::geometry::make<point_2d>(box_px, box_py)); + //2 + box_px = geo_minX*M2CM; + box_py = geo_maxY*M2CM; + boost::geometry::append(poly, boost::geometry::make<point_2d>(box_px, box_py)); + //3 + box_px = geo_maxX*M2CM; + box_py = geo_maxY*M2CM; + boost::geometry::append(poly, boost::geometry::make<point_2d>(box_px, box_py)); + //4 + box_px = geo_maxX*M2CM; + box_py = geo_minY*M2CM; + boost::geometry::append(poly, boost::geometry::make<point_2d>(box_px, box_py)); } correct(poly); // in the case the Polygone is not closed areaB->_poly=poly; diff --git a/geometry/Building.cpp b/geometry/Building.cpp index 6722ea018fa07328d5e16a2e3d8ffc1cf9af496d..8c8272f68dd1c49991c012c943a67b1b539b263d 100644 --- a/geometry/Building.cpp +++ b/geometry/Building.cpp @@ -259,6 +259,10 @@ void Building::AddSurroundingRoom() bigRoom->SetCaption("outside"); bigRoom->SetID(_rooms.size()); AddRoom(bigRoom); + _xMin = x_min; + _xMax = x_max; + _yMin = y_min; + _yMax = y_max; } @@ -1411,5 +1415,3 @@ bool Building::SaveGeometry(const std::string &filename) } #endif // _SIMULATOR - - diff --git a/geometry/Building.h b/geometry/Building.h index 109d79866c9a867e2e0939d01d95c3649d593b1d..a2e163305bf61ebd7f607e6688240908c7c95a92 100644 --- a/geometry/Building.h +++ b/geometry/Building.h @@ -24,7 +24,7 @@ * * **/ - + #ifndef _BUILDING_H #define _BUILDING_H @@ -206,6 +206,11 @@ public: * output user specific informations. */ bool SanityCheck(); + // --- + double _xMin; + double _xMax; + double _yMin; + double _yMax; private: