GlobeEngine
TrafficObject.h
Go to the documentation of this file.
1 
8 #ifndef GlobeEngine_TrafficObject_h
9 #define GlobeEngine_TrafficObject_h
10 
11 #include <vector>
12 #include "OpenGL_Includes.h"
13 #include "PolyLine.h"
14 #include "LineFeatureObject.h"
15 #include "SceneBluePrint.h"
16 #include "ReferenceSystem.h"
17 #include "PointCloud.h"
18 #include "BSpline.h"
20 #include "ColorisationTable.h"
21 #include "Timer.h"
22 
23 #undef min
24 #undef max
25 using std::min;
26 using std::max;
27 
28 #ifndef Q_MOC_RUN
29 #include <pcl/point_cloud.h>
30 #include <pcl/search/kdtree.h>
31 
32 // Boost includes
33 #include <boost/config.hpp>
34 #include <boost/graph/adjacency_list.hpp>
35 #include <boost/graph/dijkstra_shortest_paths.hpp>
36 #include <boost/graph/graph_traits.hpp>
37 #endif // Q_MOC_RUN
38 
39 namespace geGIS {
40 
41  class ModelLayer;
42 
43  typedef boost::adjacency_list_traits<boost::vecS, boost::vecS, boost::undirectedS>::vertex_descriptor GraphVertex;
44  typedef boost::property < boost::edge_weight_t, double > EdgeWeight;
45 
46  typedef boost::adjacency_list<
47  boost::listS,
48  boost::vecS,
49  boost::undirectedS,
50  boost::property<boost::vertex_distance_t, double,
51  boost::property<boost::vertex_predecessor_t, GraphVertex> >, // Vertex properties
52  EdgeWeight//boost::property<boost::edge_weight_t, double> // Edge properties
54 
56  {
57  std::vector<int> pointIndices;
58  std::vector<float> pointSquaredDistances;
60  NearestNeighborSearchResult(int _K): pointIndices(_K), pointSquaredDistances(_K) {}
61  };
62 
64  {
65  unsigned int idx;
66  float weight;
67  std::vector<int> finalPoints;
68 
70  FinishedEdgeInfo(unsigned int _idx, float _weight , std::vector<int> _finalPoints): idx(_idx), weight(_weight), finalPoints(_finalPoints){}
71  };
72 
74  {
75 
76  public:
77  TrafficObject();
79  void clear();
80  void create(ModelLayer* _modelLayerref, std::shared_ptr<TrafficBlueprint> _blueprint, std::shared_ptr<ReferenceSystem> _referenceSystem);
81  void update();
82 
83  void loadData(std::string filename);
84  void reduceGraphData();
85  void buildKDtree();
86 
87  NearestNeighborSearchResult* findNearestNeighbor(pcl::PointXYZ _point, int _K);
88 
89  int createPointCloud(std::vector<ge::VBOVertex3d> _vertices, vmml::Vector3f _color, std::string _name);
90  int createPointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr _cloud, vmml::Vector3f _color, std::string _name);
91  void createMultiLineGraph(vmml::Vector3f _color, std::string _name);
92 
93  void createPolyLine(std::vector<int> _indices, vmml::Vector3f _color, double _lineWeight, ge::VBOVertex3d _commuterPoint_1, ge::VBOVertex3d _commuterPoint_2, int _bundlingIdx);
94 
95  std::vector<int> getShortestPath(int _source, int _dest);
96  pcl::PointXYZ getKdTreePoint(int _index);
98 
99  void printKDtree();
100  void printKDtreeIndex(int _index);
101 
102  int getCrossingsID() const;
103  int getEndPointsID() const;
104  int getGraphCloudID() const;
105  int getBasePointsID() const;
106  void setVisibility(bool _in);
107  unsigned int getNumberOfLineWithZeroLineCount() const {
108  return numberOfLinesWithZeroLineCount;
109  }
110 
111  void setGraphNetworkProperties(int _idx, vmml::Vector3f _color, vmml::Vector3f _pos, std::string _name);
113  void setupColorInformation(const std::shared_ptr<geData::ColorisationTable>& _table = NULL);
114 
118 
119  void createGraph();
120  void createCloudData();
122  void createGeometry();
123 
124  int createPath(std::shared_ptr<geData::PolyLine> _path, std::string _name, bool _inLocalCoordinates);
125 
126  void exportGraphData(std::string _path);
127 
128  private:
129  using ge::DrawableComponent::create; // implicitly hidden
130 
131  void setPointCloudProperties(int idx, vmml::Vector3f _color, std::string _name);
132  void clearInitial();
133  std::shared_ptr<TrafficBlueprint> blueprint;
134 
135  /* ModelLayer Reference */
136  ModelLayer* modelLayerRef;
137 
139 
140  /* index to multilineobject */
141  int graphMLOidx;
142 
143  /* Conversion map von kdtree zu edge info */
144  std::map< int, int > kdtreeToEdgeMap;
145 
146  /* nearest neighbor cloud */
147  std::vector<int> nearestNeigbors;
148 
149  /* Graph information*/
150  SimpleUndirectedGraph trafficgraph;
151 
152  /* kdtree */
153  pcl::search::KdTree<pcl::PointXYZ>* kdtree;
154 
155  /* Rendering structures */
156  GLsizei* lineStripLenght;
157 
158  /* is this traffic network a reference graph */
159  bool isReferenceNetwork;
160 
161  /* colorisation table */
162  //const std::shared_ptr<geData::ColorisationTable> bundlingColorisation;
163  std::shared_ptr<geData::ColorisationTable> bundlingColorisation;
164 
165  // Pointclouds
166  int crossingsPCidx;
167  int endPointsPCidx;
168  int basePointsPCidx;
169  int graphPCidx;
170 
171  unsigned int numberOfLinesWithZeroLineCount;
172 
173  // Debugtimer
174  ge::Timer timer;
175  };
176 }
177 #endif
int getBasePointsID() const
Definition: TrafficObject.cpp:639
void exportGraphData(std::string _path)
Definition: TrafficObject.cpp:153
std::vector< int > getShortestPath(int _source, int _dest)
Definition: TrafficObject.cpp:318
void setGraphNetworkProperties(int _idx, vmml::Vector3f _color, vmml::Vector3f _pos, std::string _name)
Definition: TrafficObject.cpp:567
void printKDtree()
Definition: TrafficObject.cpp:617
void create(ModelLayer *_modelLayerref, std::shared_ptr< TrafficBlueprint > _blueprint, std::shared_ptr< ReferenceSystem > _referenceSystem)
Definition: TrafficObject.cpp:44
Definition: TrafficObject.h:55
Definition: TrafficObject.h:63
unsigned int getNumberOfLineWithZeroLineCount() const
Definition: TrafficObject.h:107
ge::VBOVertex3d getGraphNodeContent(int _nodeIdx)
Definition: TrafficObject.cpp:344
void setupColorInformation(const std::shared_ptr< geData::ColorisationTable > &_table=NULL)
Definition: TrafficObject.cpp:402
Definition: ClusterGrid.h:17
boost::property< boost::edge_weight_t, double > EdgeWeight
Definition: TrafficObject.h:44
NearestNeighborSearchResult(int _K)
Definition: TrafficObject.h:60
void buildKDtree()
Definition: TrafficObject.cpp:272
void disableAsReferenceNetwork()
Definition: TrafficObject.cpp:642
void updateMultiLineObjectColorInformation()
Definition: TrafficObject.cpp:631
boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, boost::property< boost::vertex_distance_t, double, boost::property< boost::vertex_predecessor_t, GraphVertex > >, EdgeWeight > SimpleUndirectedGraph
Definition: TrafficObject.h:53
Definition: ReducableUndirectedGraph.h:232
void createCloudData()
Definition: TrafficObject.cpp:205
boost::adjacency_list_traits< boost::vecS, boost::vecS, boost::undirectedS >::vertex_descriptor GraphVertex
Definition: TrafficObject.h:41
FinishedEdgeInfo()
Definition: TrafficObject.h:69
bool checkIfReferenceNetwork()
Definition: TrafficObject.cpp:640
~TrafficObject()
Definition: TrafficObject.cpp:15
Definition: ModelLayer.h:107
virtual void create()=0
void update()
Definition: TrafficObject.cpp:397
void createMultiLineGraph(vmml::Vector3f _color, std::string _name)
int createPointCloud(std::vector< ge::VBOVertex3d > _vertices, vmml::Vector3f _color, std::string _name)
Definition: TrafficObject.cpp:583
float weight
Definition: TrafficObject.h:66
int getCrossingsID() const
Definition: TrafficObject.cpp:636
std::vector< int > finalPoints
Definition: TrafficObject.h:67
pcl::PointXYZ getKdTreePoint(int _index)
Definition: TrafficObject.cpp:339
FinishedEdgeInfo(unsigned int _idx, float _weight, std::vector< int > _finalPoints)
Definition: TrafficObject.h:70
Definition: VBOVertex.h:115
unsigned int idx
Definition: TrafficObject.h:65
void loadData(std::string filename)
Definition: TrafficObject.cpp:55
NearestNeighborSearchResult * findNearestNeighbor(pcl::PointXYZ _point, int _K)
Definition: TrafficObject.cpp:348
int getEndPointsID() const
Definition: TrafficObject.cpp:637
std::vector< float > pointSquaredDistances
Definition: TrafficObject.h:58
Definition: TrafficObject.h:73
void setMinMaxWeightInformationToGraphWeight()
Definition: TrafficObject.cpp:364
void printKDtreeIndex(int _index)
Definition: TrafficObject.cpp:625
NearestNeighborSearchResult()
Definition: TrafficObject.h:59
Definition: LineFeatureObject.h:21
void clear()
Definition: TrafficObject.cpp:20
int getGraphCloudID() const
Definition: TrafficObject.cpp:638
int createPath(std::shared_ptr< geData::PolyLine > _path, std::string _name, bool _inLocalCoordinates)
Definition: TrafficObject.cpp:578
void createGraph()
Definition: TrafficObject.cpp:178
void setVisibility(bool _in)
TrafficObject()
Definition: TrafficObject.cpp:9
void reduceGraphData()
Definition: TrafficObject.cpp:233
Definition: Timer.h:17
void createPolyLine(std::vector< int > _indices, vmml::Vector3f _color, double _lineWeight, ge::VBOVertex3d _commuterPoint_1, ge::VBOVertex3d _commuterPoint_2, int _bundlingIdx)
Definition: TrafficObject.cpp:432
void createGeometry()
Definition: TrafficObject.cpp:385
std::vector< int > pointIndices
Definition: TrafficObject.h:57
void enableAsReferenceNetwork()
Definition: TrafficObject.cpp:641