diff --git a/Analysis.cpp b/Analysis.cpp index b6736b8877f73e45a992d95cf064a68874459fc0..bbafdb43ae0d7528a1abb579e81875c44c1487cb 100644 --- a/Analysis.cpp +++ b/Analysis.cpp @@ -37,6 +37,7 @@ #include "methods/Method_B.h" #include "methods/Method_C.h" #include "methods/Method_D.h" +#include "methods/Method_I.h" #include "methods/PedData.h" #include <iostream> diff --git a/general/Macros.h b/general/Macros.h index 689e97117b4ff4d4e43e4d7ed93732a44029e2e9..cab68769cae0fc562707d277c1a53d836c73014c 100644 --- a/general/Macros.h +++ b/general/Macros.h @@ -38,6 +38,36 @@ #include <sstream> #include <iostream> +#include <boost/polygon/voronoi.hpp> +using boost::polygon::voronoi_builder; +using boost::polygon::voronoi_diagram; + +#include <boost/geometry.hpp> +#include <boost/geometry/geometry.hpp> +#include <boost/geometry/geometries/point_xy.hpp> +#include <boost/geometry/geometries/polygon.hpp> +#include <boost/geometry/geometries/adapted/c_array.hpp> +#include <boost/geometry/geometries/ring.hpp> +#include <boost/geometry/algorithms/intersection.hpp> +#include <boost/geometry/algorithms/within.hpp> +#include <boost/foreach.hpp> +//#include "../general/Macros.h" + +typedef boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian> point_2d; +typedef boost::geometry::model::polygon<point_2d> polygon_2d; +typedef std::vector<polygon_2d > polygon_list; +typedef boost::geometry::model::segment<boost::geometry::model::d2::point_xy<double> > segment; + +typedef boost::polygon::point_data<double> point_type2; +typedef double coordinate_type; +typedef boost::polygon::voronoi_diagram<double> VD; +typedef VD::edge_type edge_type; +typedef VD::cell_type cell_type; +typedef VD::cell_type::source_index_type source_index_type; + + + + #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -174,6 +204,37 @@ inline char xmltoc(const char * t, const char v = '\0') return v; } +inline std::string polygon_to_string(const polygon_2d & polygon) +{ + std::string polygon_str = "(("; + for(auto point: boost::geometry::exterior_ring(polygon) ) + { + double x = boost::geometry::get<0>(point); + double y = boost::geometry::get<1>(point); + polygon_str.append("("); + polygon_str.append(std::to_string(x)); + polygon_str.append(", "); + polygon_str.append(std::to_string(y)); + polygon_str.append("), "); + } + for(auto ring: boost::geometry::interior_rings(polygon) ) + { + for(auto point: ring ) + { + double x = boost::geometry::get<0>(point); + double y = boost::geometry::get<1>(point); + polygon_str.append("("); + polygon_str.append(std::to_string(x)); + polygon_str.append(", "); + polygon_str.append(std::to_string(y)); + polygon_str.append("), "); + } + } + polygon_str.pop_back(); polygon_str.pop_back(); //remove last komma + polygon_str.append("))"); + return polygon_str; +} + /** * @return true if the element is present in the vector */ diff --git a/methods/Method_D.cpp b/methods/Method_D.cpp index c72fd7c22f00fe498786f863eaabc5f5cbac3c79..465e79022032544f438b66a0015637d139b08240 100644 --- a/methods/Method_D.cpp +++ b/methods/Method_D.cpp @@ -530,7 +530,7 @@ void Method_D::OutputVoroGraph(const string & frameId, std::vector<std::pair<po velo.close(); } -std::string polygon_to_string(const polygon_2d & polygon) +/*std::string polygon_to_string(const polygon_2d & polygon) { string polygon_str = "(("; for(auto point: boost::geometry::exterior_ring(polygon) ) @@ -559,7 +559,7 @@ std::string polygon_to_string(const polygon_2d & polygon) polygon_str.pop_back(); polygon_str.pop_back(); //remove last komma polygon_str.append("))"); return polygon_str; -} +}*/ void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const vector<int>& Id, const polygon_2d& measureArea, const string& frid) { diff --git a/methods/Method_I.cpp b/methods/Method_I.cpp index 3f65c2c3011cd177cde7dc75a005636bbc996229..a5e4ce87960a6a860ea7eb2d89c0e33a2d8f5217 100644 --- a/methods/Method_I.cpp +++ b/methods/Method_I.cpp @@ -530,7 +530,7 @@ void Method_I::OutputVoroGraph(const string & frameId, std::vector<std::pair<po velo.close(); } -std::string polygon_to_string2(const polygon_2d & polygon) +/*std::string polygon_to_string2(const polygon_2d & polygon) { string polygon_str = "(("; for(auto point: boost::geometry::exterior_ring(polygon) ) @@ -559,7 +559,7 @@ std::string polygon_to_string2(const polygon_2d & polygon) polygon_str.pop_back(); polygon_str.pop_back(); //remove last komma polygon_str.append("))"); return polygon_str; -} +}*/ void Method_I::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const vector<int>& Id, const polygon_2d& measureArea, const string& frid) { @@ -573,10 +573,10 @@ void Method_I::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d intersection(measureArea, polygon_iterator, v); if(!v.empty()) { - string polygon_str = polygon_to_string2(polygon_iterator); + string polygon_str = polygon_to_string(polygon_iterator); // string measureArea_str = // polygon_to_string(measureArea); // maybe used for debugging - string v_str = polygon_to_string2(v[0]); + string v_str = polygon_to_string(v[0]); uniquedensity=1.0/(area(polygon_iterator)*CMtoM*CMtoM); uniquevelocity=Velocity[temp]; diff --git a/methods/VoronoiDiagram.h b/methods/VoronoiDiagram.h index 88ec2091e796b1ac6d9f5eb07fe6a90ce2521869..6a4211a0114257edfd377329d0ccf216caeb379d 100644 --- a/methods/VoronoiDiagram.h +++ b/methods/VoronoiDiagram.h @@ -36,32 +36,32 @@ #define PI 3.14159265 -#include <boost/polygon/voronoi.hpp> -using boost::polygon::voronoi_builder; -using boost::polygon::voronoi_diagram; +//#include <boost/polygon/voronoi.hpp> +//using boost::polygon::voronoi_builder; +//using boost::polygon::voronoi_diagram; -#include <boost/geometry.hpp> -#include <boost/geometry/geometry.hpp> -#include <boost/geometry/geometries/point_xy.hpp> -#include <boost/geometry/geometries/polygon.hpp> -#include <boost/geometry/geometries/adapted/c_array.hpp> -#include <boost/geometry/geometries/ring.hpp> -#include <boost/geometry/algorithms/intersection.hpp> -#include <boost/geometry/algorithms/within.hpp> -#include <boost/foreach.hpp> +//#include <boost/geometry.hpp> +//#include <boost/geometry/geometry.hpp> +//#include <boost/geometry/geometries/point_xy.hpp> +//#include <boost/geometry/geometries/polygon.hpp> +//#include <boost/geometry/geometries/adapted/c_array.hpp> +//#include <boost/geometry/geometries/ring.hpp> +//#include <boost/geometry/algorithms/intersection.hpp> +//#include <boost/geometry/algorithms/within.hpp> +//#include <boost/foreach.hpp> #include "../general/Macros.h" - -typedef boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian> point_2d; -typedef boost::geometry::model::polygon<point_2d> polygon_2d; -typedef std::vector<polygon_2d > polygon_list; -typedef boost::geometry::model::segment<boost::geometry::model::d2::point_xy<double> > segment; - -typedef boost::polygon::point_data<double> point_type2; -typedef double coordinate_type; -typedef boost::polygon::voronoi_diagram<double> VD; -typedef VD::edge_type edge_type; -typedef VD::cell_type cell_type; -typedef VD::cell_type::source_index_type source_index_type; +// +//typedef boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian> point_2d; +//typedef boost::geometry::model::polygon<point_2d> polygon_2d; +//typedef std::vector<polygon_2d > polygon_list; +//typedef boost::geometry::model::segment<boost::geometry::model::d2::point_xy<double> > segment; +// +//typedef boost::polygon::point_data<double> point_type2; +//typedef double coordinate_type; +//typedef boost::polygon::voronoi_diagram<double> VD; +//typedef VD::edge_type edge_type; +//typedef VD::cell_type cell_type; +//typedef VD::cell_type::source_index_type source_index_type; class VoronoiDiagram {