simpleGMap2.cpp 3.37 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: https://iggservis.u-strasbg.fr/CGoGN/                              *
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"
Pierre Kraemer's avatar
Pierre Kraemer committed
29 30


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

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

42
void SimpleGMap2::initGUI()
Pierre Kraemer's avatar
Pierre Kraemer committed
43 44 45 46
{

}

47
void SimpleGMap2::cb_initGL()
Pierre Kraemer's avatar
Pierre Kraemer committed
48
{
49
	Utils::GLSLShader::setCurrentOGLVersion(1) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
50

51 52 53 54 55 56 57
	Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
	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
58 59
}

60
void SimpleGMap2::cb_redraw()
Pierre Kraemer's avatar
Pierre Kraemer committed
61
{
62 63
	glDisable(GL_LIGHTING);
	glLineWidth(1.0f);
Thomas's avatar
Thomas committed
64
	Algo::Render::GL1::renderTopoGMD2<PFP>(myMap, position, false, true, 0.9f, 0.9f);
Pierre Kraemer's avatar
Pierre Kraemer committed
65 66 67
}


68 69 70
/**********************************************************************************************
 *                                      MAIN FUNCTION                                         *
 **********************************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
71 72 73

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

76 77 78
	SimpleGMap2 sqt ;
	sqt.setGeometry(0, 0, 1000, 800) ;
 	sqt.show() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
79

80
	sqt.initGUI() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
81

82
	return app.exec() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
83
}
84