simpleGMap2.cpp 3.77 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, 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                                        *
*                                                                              *
*******************************************************************************/

25
#include "simpleGMap2.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
26 27
#include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h"
28
#include "Algo/Modelisation/polyhedron.h"
untereiner's avatar
untereiner committed
29
#include "Algo/Tiling/Surface/square.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
30

31
SimpleGMap2::SimpleGMap2()
Pierre Kraemer's avatar
Pierre Kraemer committed
32
{
33
	 position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
Pierre Kraemer's avatar
Pierre Kraemer committed
34

35
     Dart d = Algo::Surface::Modelisation::createTetrahedron<PFP>(myMap);
36
     position[d] = VEC3(0,0,0);
thomas's avatar
thomas committed
37 38 39
     position[myMap.phi1(d)] = VEC3(10,0,15);
     position[myMap.phi_1(d)] = VEC3(10,20,15);
     position[myMap.phi_1(myMap.phi2(d))] = VEC3(0,0,30);
Pierre Kraemer's avatar
Pierre Kraemer committed
40

41
     VEC3 mid = (position[d] + position[myMap.phi1(d)]) / 2.0f;
42 43
     myMap.cutEdge(d);
     position[myMap.phi1(d)] = mid;
Pierre Kraemer's avatar
Pierre Kraemer committed
44

untereiner's avatar
untereiner committed
45 46 47
     Algo::Surface::Tilings::Square::Cylinder<PFP> poly(myMap, 5 ,1, false, false);
     d = poly.getDart();
     poly.embedIntoCylinder(position, 10, 10, 5);
Pierre Kraemer's avatar
Pierre Kraemer committed
48

thomas's avatar
thomas committed
49 50 51
     d = myMap.phi1(d);
     Dart dd = myMap.beta2(d);
     myMap.unsewFaces(d);
52
     myMap.sewFaces(d, dd);
Pierre Kraemer's avatar
Pierre Kraemer committed
53

thomas's avatar
thomas committed
54
     position[d][1] += 3.0f;
Pierre Kraemer's avatar
Pierre Kraemer committed
55 56
}

57
void SimpleGMap2::initGUI()
Pierre Kraemer's avatar
Pierre Kraemer committed
58 59 60
{
}

61
void SimpleGMap2::cb_initGL()
Pierre Kraemer's avatar
Pierre Kraemer committed
62
{
63
	Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
64 65 66 67 68 69
	VEC3 gPosObj = bb.center() ;
	float tailleX = bb.size(0) ;
	float tailleY = bb.size(1) ;
	float tailleZ = bb.size(2) ;
	float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
	setParamObject(gWidthObj, gPosObj.data());
Pierre Kraemer's avatar
Pierre Kraemer committed
70 71
}

72
void SimpleGMap2::cb_redraw()
Pierre Kraemer's avatar
Pierre Kraemer committed
73
{
74 75
	glDisable(GL_LIGHTING);
	glLineWidth(1.0f);
Thomas's avatar
Thomas committed
76
	Algo::Render::GL1::renderTopoGMD2<PFP>(myMap, position, true, true, true, 0.9f, 0.9f, 0.9f);
Pierre Kraemer's avatar
Pierre Kraemer committed
77 78
}

79 80 81
/**********************************************************************************************
 *                                      MAIN FUNCTION                                         *
 **********************************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
82 83 84

int main(int argc, char **argv)
{
85
	QApplication app(argc, argv) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
86

87 88 89
	SimpleGMap2 sqt ;
	sqt.setGeometry(0, 0, 1000, 800) ;
 	sqt.show() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
90

91
	sqt.initGUI() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
92

93
	return app.exec() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
94
}