tuto2.h 3.57 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

Pierre Kraemer's avatar
merge..    
Pierre Kraemer committed
25
26
#ifndef _TUTO2_
#define _TUTO2_
Pierre Kraemer's avatar
Pierre Kraemer committed
27

28
//#define USE_GMAP
29

30
#include "Utils/Qt/qtSimple.h"
Sylvain Thery's avatar
Sylvain Thery committed
31
32
#include "Utils/cgognStream.h"
#include "Topology/generic/parameters.h"
33
34
35
36
37
38

#ifdef USE_GMAP
	#include "Topology/gmap/embeddedGMap2.h"
#else
	#include "Topology/map/embeddedMap2.h"
#endif
Sylvain Thery's avatar
Sylvain Thery committed
39
40
41
42

#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
Thery Sylvain's avatar
Thery Sylvain committed
43
#include "Utils/vbo.h"
44
45


Sylvain Thery's avatar
Sylvain Thery committed
46
using namespace CGoGN ;
Pierre Kraemer's avatar
Pierre Kraemer committed
47

Sylvain Thery's avatar
Sylvain Thery committed
48
/**
Sylvain Thery's avatar
Sylvain Thery committed
49
50
 * Struct that contains some informations about the types of the manipulated objects
 * Mainly here to be used by the algorithms that are parameterized by it
Sylvain Thery's avatar
Sylvain Thery committed
51
 */
Sylvain Thery's avatar
Sylvain Thery committed
52
53
54
struct PFP: public PFP_STANDARD
{
	// definition of the type of the map
55
56
57
#ifdef USE_GMAP
	typedef EmbeddedGMap2 MAP;
#else
Sylvain Thery's avatar
Sylvain Thery committed
58
	typedef EmbeddedMap2 MAP;
59
#endif
Sylvain Thery's avatar
Sylvain Thery committed
60
61
};

Pierre Kraemer's avatar
Pierre Kraemer committed
62
typedef PFP::MAP MAP ;
Pierre Kraemer's avatar
Pierre Kraemer committed
63
typedef PFP::MAP::IMPL MAP_IMPL ;
Pierre Kraemer's avatar
Pierre Kraemer committed
64
65
typedef PFP::VEC3 VEC3 ;

Sylvain Thery's avatar
Sylvain Thery committed
66
class MyQT: public Utils::QT::SimpleQT
Pierre Kraemer's avatar
Pierre Kraemer committed
67
{
Sylvain Thery's avatar
Sylvain Thery committed
68
	Q_OBJECT
Sylvain Thery's avatar
Sylvain Thery committed
69
70
71
72
73
public:
	MyQT(): m_render(NULL), m_positionVBO(NULL), m_shader(NULL) {}

	void cb_redraw();
	void cb_initGL();
Sylvain Thery's avatar
Sylvain Thery committed
74

Sylvain Thery's avatar
Sylvain Thery committed
75
76
protected:
	// declaration of the map
Pierre Kraemer's avatar
Pierre Kraemer committed
77
	MAP myMap;
Sylvain Thery's avatar
Sylvain Thery committed
78
79
80

	// render (for the topo)
//	Algo::Render::GL2::TopoRenderMapD* m_render_topo;
Sylvain Thery's avatar
Sylvain Thery committed
81
82
83
84
85

	// render
	Algo::Render::GL2::MapRender* m_render;

	// VBO
Sylvain Thery's avatar
Sylvain Thery committed
86
87
88
	Utils::VBO* m_positionVBO;	// position 3D
	Utils::VBO* m_colorVBO1;	// color per vertex for face drawing
	Utils::VBO* m_colorVBO2;	// color per vertex for edge drawing
Sylvain Thery's avatar
Sylvain Thery committed
89

Sylvain Thery's avatar
Sylvain Thery committed
90
	//shaders
Sylvain Thery's avatar
Sylvain Thery committed
91
	Utils::ShaderSimpleColor* m_shader;
Sylvain Thery's avatar
Sylvain Thery committed
92
	Utils::ShaderColorPerVertex* m_shader2;
Sylvain Thery's avatar
Sylvain Thery committed
93

Sylvain Thery's avatar
Sylvain Thery committed
94
95
96
97
98
99
	// just for more compact writing
	inline Dart PHI1(Dart d)	{return myMap.phi1(d);}
	inline Dart PHI_1(Dart d)	{return myMap.phi_1(d);}
	inline Dart PHI2(Dart d)	{return myMap.phi2(d);}
	template<int X>
	Dart PHI(Dart d)	{return myMap.phi<X>(d);}
Sylvain Thery's avatar
Sylvain Thery committed
100

Sylvain Thery's avatar
Sylvain Thery committed
101
102
103
104
public:
	// example of simple map creation
	void createMap();
};
Sylvain Thery's avatar
Sylvain Thery committed
105
106

#endif