GlobeEngine
VectorFieldTopology.h
Go to the documentation of this file.
1 //
2 // VectorFieldTopology.hpp
3 // GlobeEngine
4 //
5 // Created by Alireza Amiraghdam on 19/01/17.
6 //
7 //
8 
9 #ifndef GlobeEngine_VectorFieldTopology_h
10 #define GlobeEngine_VectorFieldTopology_h
11 
12 #include <stdio.h>
13 #include "DrawableComponent.h"
14 #include "Sphere.h"
16 #include <pcl/kdtree/kdtree_flann.h>
17 #include "CriticalPoint.h"
18 #include "CriticalEdge.h"
19 #include "CriticalRegion.h"
20 #include "SeedLine.h"
21 
22 namespace geClimateViewer {
23  class VectorField;
25  {
26  public:
27  VectorFieldTopology(VectorField *_vectorField);
29  void clear();
30  void clearRegions();
31  void create();
32  void draw(std::shared_ptr<ge::Camera> _cam);
33  void update();
34  void createVAOtopo();
35  void createVAOperp();
36  void createVAOstream();
37  void setdt(float _dt){dt=_dt;};
38  float getdt(){return dt;};
40  void setProgramForSpheres(std::shared_ptr<ge::Shader> _programForSpheres){programForSpheres=_programForSpheres;};
41  void setProgramForLines(std::shared_ptr<ge::Shader> _programForLines){programForLines=_programForLines;};
42  void calculateEdges();
43  void setPosition(vmml::Vector3f _p){position=_p;};
44  vmml::Vector3f getPosition(){return position;};
45  void setActivePointIndex(int _inx){activePointIndex=_inx;};
47  VectorField * getVectorField(){return vectorField;};
48  std::shared_ptr<ge::Shader> getProgramForLines(){return programForLines;};
50  void resetStreamlines();
51  //const std::vector<CriticalRegionptr>& getRegions() const {
52  // return regions;
53  //};
54  // void setDebuggedPoint(SeedLinePointptr _d){debuggedPoint=_d;};
55  void highlightStreamline(int _region, int _line);
56  void setPerpVisible(bool _v){perpVisible=_v;};
57 
58  shpio::SHPFileExportContainer* getRegionsAsSHPContainer();
59  shpio::SHPFileExportContainer* getStreamlinesAsSHPContainer();
60  shpio::SHPFileExportContainer* getTopologyAsSHPContainer();
61 
62  void exportToSHPFile(std::string _path, enum shpio::SHPFileExportContainer::EXPORT_TYPE _type, shpio::SHPFileExportContainer* _content);
63  void simplifyEdges(double _epsilon);
64  void setSphereSize(float _ss){sphereSize=_ss;};
65  float getTotalLength();
66  void removeEdge(CriticalEdgeptr _edge);
67  void closestCriticalPoint(vmml::Vector3f _key, CriticalPointptr &_result,float &_distance );
68  void setCallbackProgress(std::function<void(int const&)> const& _callbackProgress){ callbackProgress = _callbackProgress; };
69  void calculateRegions();
71 
72 
73 
74  private:
75  float dt=0.003;
76  VectorField *vectorField;
77  std::vector<CriticalPointptr> criticalPoints;
78  void calculateCriticalPointsOnEdges();
79  pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
80  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud;
81  std::vector<std::shared_ptr< ge::Sphere>> criticalPointsSpheres;
82  std::shared_ptr<ge::Shader> programForSpheres;
83  std::shared_ptr<ge::Shader> programForLines;
84  CriticalEdgeptr findNeighbor(CriticalPointptr _cpoint, vmml::Vector3f direction, float movingDirection);
85  std::vector<CriticalEdgeptr> edges;
86  void addCriticalPoint(CriticalPointptr _cPoint);
87  vmml::Vector3f position;
88  void connectBoundaryPoints();
89  int activePointIndex=-1;
90  std::vector<CriticalRegionptr> regions;
91  // SeedLinePointptr debuggedPoint;
92  bool perpVisible=true;
93  float sphereSize;
94  std::function<void(int const&)> callbackProgress=nullptr;
95  float progressedReal;
96  int progressed;
97  bool topoVAOcreated=false;
98  bool perpVAOcreated=false;
99  bool streamVAOcreated=false;
100 
101  };
102  typedef std::shared_ptr<VectorFieldTopology> VectorFieldTopologyptr;
103 }
104 #endif /* VectorFieldTopology_hpp */
Definition: DrawableComponent.h:25
void clear()
Definition: VectorFieldTopology.cpp:30
void setPerpVisible(bool _v)
Definition: VectorFieldTopology.h:56
shpio::SHPFileExportContainer * getRegionsAsSHPContainer()
Definition: VectorFieldTopology.cpp:2018
std::shared_ptr< ge::Shader > getProgramForLines()
Definition: VectorFieldTopology.h:48
void createVAOperp()
Definition: VectorFieldTopology.cpp:308
void createVAOstream()
Definition: VectorFieldTopology.cpp:317
std::shared_ptr< VectorFieldTopology > VectorFieldTopologyptr
Definition: VectorFieldTopology.h:102
float getdt()
Definition: VectorFieldTopology.h:38
float getTotalLength()
Definition: VectorFieldTopology.cpp:2055
void calculateEdges()
Definition: VectorFieldTopology.cpp:976
void draw(std::shared_ptr< ge::Camera > _cam)
Definition: VectorFieldTopology.cpp:329
void createStreamlinesForEachRegion()
Definition: VectorFieldTopology.cpp:1981
void highlightStreamline(int _region, int _line)
Definition: VectorFieldTopology.cpp:2008
VectorFieldTopology(VectorField *_vectorField)
Definition: VectorFieldTopology.cpp:21
void calculateRegions()
Definition: VectorFieldTopology.cpp:1924
std::shared_ptr< CriticalPoint > CriticalPointptr
Definition: CriticalPoint.h:18
void resetStreamlines()
Definition: VectorFieldTopology.cpp:2002
void setSphereSize(float _ss)
Definition: VectorFieldTopology.h:64
void setdt(float _dt)
Definition: VectorFieldTopology.h:37
void update()
Definition: VectorFieldTopology.cpp:324
std::shared_ptr< CriticalEdge > CriticalEdgeptr
Definition: CriticalPoint.h:20
void clearRegions()
Definition: VectorFieldTopology.cpp:40
void setProgramForSpheres(std::shared_ptr< ge::Shader > _programForSpheres)
Definition: VectorFieldTopology.h:40
void create()
Definition: VectorFieldTopology.cpp:50
void setCallbackProgress(std::function< void(int const &)> const &_callbackProgress)
Definition: VectorFieldTopology.h:68
vmml::Vector3f getPosition()
Definition: VectorFieldTopology.h:44
void createVAOtopo()
Definition: VectorFieldTopology.cpp:54
void closestCriticalPoint(vmml::Vector3f _key, CriticalPointptr &_result, float &_distance)
Definition: VectorFieldTopology.cpp:1339
void setActivePointIndex(int _inx)
Definition: VectorFieldTopology.h:45
shpio::SHPFileExportContainer * getStreamlinesAsSHPContainer()
Definition: VectorFieldTopology.cpp:2078
void calculateCriticalPoints()
Definition: VectorFieldTopology.cpp:370
VectorField * getVectorField()
Definition: VectorFieldTopology.h:47
void calculateRegionsAndPerps()
Definition: VectorFieldTopology.cpp:1862
shpio::SHPFileExportContainer * getTopologyAsSHPContainer()
Definition: VectorFieldTopology.cpp:2132
void setPosition(vmml::Vector3f _p)
Definition: VectorFieldTopology.h:43
Definition: ClimateViewerComposition.h:13
void removeEdge(CriticalEdgeptr _edge)
Definition: VectorFieldTopology.cpp:2063
void streamLinesStepForward()
Definition: VectorFieldTopology.cpp:1995
~VectorFieldTopology()
Definition: VectorFieldTopology.cpp:26
void simplifyEdges(double _epsilon)
Definition: VectorFieldTopology.cpp:2050
void setProgramForLines(std::shared_ptr< ge::Shader > _programForLines)
Definition: VectorFieldTopology.h:41
void exportToSHPFile(std::string _path, enum shpio::SHPFileExportContainer::EXPORT_TYPE _type, shpio::SHPFileExportContainer *_content)
Definition: VectorFieldTopology.cpp:2038
Definition: VectorField.h:19
Definition: VectorFieldTopology.h:24