Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

mapHandler.h 2.71 KB
Newer Older
1
2
#ifndef _MAPHANDLER_H_
#define _MAPHANDLER_H_
3

4
#include <QString>
5

6
#include "types.h"
7
8
#include "view.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
9
#include "Topology/generic/genericmap.h"
10
11
12
#include "Topology/generic/functor.h"
#include "Utils/vbo.h"
#include "Algo/Render/GL2/mapRender.h"
13
#include "Algo/Geometry/boundingbox.h"
14

Pierre Kraemer's avatar
Pierre Kraemer committed
15
16
17
18
19
20
namespace CGoGN
{

namespace SCHNApps
{

21
class MapHandlerGen
22
23
{
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
24
	MapHandlerGen(const QString& name, Window* window, GenericMap* map);
25
26
	virtual ~MapHandlerGen();

27
	const QString& getName() const { return m_name; }
28
	void setName(const QString& name) { m_name = name; }
29

30
	Window* getWindow() const { return m_window; }
31
32
	void setWindow(Window* w) { m_window = w; }

Pierre Kraemer's avatar
Pierre Kraemer committed
33
	GenericMap* getGenericMap() { return m_map; }
Pierre Kraemer's avatar
Pierre Kraemer committed
34

35
36
	const qglviewer::Vec& getBBmin() const { return m_bbMin; }
	const qglviewer::Vec& getBBmax() const { return m_bbMax; }
37
	float getBBdiagSize() { return m_bbDiagSize; }
38

Pierre Kraemer's avatar
Pierre Kraemer committed
39
40
	bool isUsed() const { return !l_views.empty(); }

41
	void draw(Utils::GLSLShader* shader, int primitive) { m_render->draw(shader, primitive); }
42

43
44
45
46
	/*********************************************************
	 * MANAGE VBOs
	 *********************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
47
	Utils::VBO* getVBO(const std::string& name);
48
	void deleteVBO(const std::string& name);
49

50
51
52
53
	/*********************************************************
	 * MANAGE LINKED VIEWS
	 *********************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
54
	void linkView(View* view);
55
	void unlinkView(View* view);
56
57
	const QList<View*>& getLinkedViews() const { return l_views; }
	bool isLinkedToView(View* view) const { return l_views.contains(view); }
58

59
protected:
60
	QString m_name;
61
	Window* m_window;
Pierre Kraemer's avatar
Pierre Kraemer committed
62
	GenericMap* m_map;
63

Pierre Kraemer's avatar
Pierre Kraemer committed
64
	Algo::Render::GL2::MapRender* m_render;
65

66
67
	qglviewer::Vec m_bbMin;
	qglviewer::Vec m_bbMax;
68
	float m_bbDiagSize;
69

70
71
	QList<View*> l_views;

72
	VBOHash h_vbo;
73
};
74

75
76
77
78
79
template <typename PFP>
class MapHandler : public MapHandlerGen
{
public:
	MapHandler(const QString& name, Window* window, typename PFP::MAP* map) :
Pierre Kraemer's avatar
Pierre Kraemer committed
80
		MapHandlerGen(name, window, map)
81
	{}
82
83
84
85
86
87
88

	~MapHandler()
	{
		if (m_map)
			delete m_map;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
89
	typename PFP::MAP* getMap() { return reinterpret_cast<typename PFP::MAP*>(m_map); }
90

91
92
93
94
95
96
97
98
	void updateBB(const VertexAttribute<typename PFP::VEC3>& position)
	{
		CGoGN::Geom::BoundingBox<typename PFP::VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*(reinterpret_cast<typename PFP::MAP*>(m_map)), position);
		m_bbMin = qglviewer::Vec(bb.min()[0], bb.min()[1], bb.min()[2]);
		m_bbMax = qglviewer::Vec(bb.max()[0], bb.max()[1], bb.max()[2]);
		m_bbDiagSize = (m_bbMax - m_bbMin).norm();
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
99
	void updatePrimitives(int primitive, const FunctorSelect& good)
100
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
101
		m_render->initPrimitives<PFP>(*(reinterpret_cast<typename PFP::MAP*>(m_map)), good, primitive) ;
102
	}
103
104
};

Pierre Kraemer's avatar
Pierre Kraemer committed
105
106
107
108
} // namespace SCHNApps

} // namespace CGoGN

109
#endif