tuto5.cpp 17.1 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-2011, 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.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

25
#include "tuto5.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
26

27
//void Tuto5::balls_onoff(bool x)
Pierre Kraemer's avatar
Pierre Kraemer committed
28 29 30 31 32 33
//{
//	render_balls = !render_balls;
//	updateGL();
//	CGoGNerr << " balls_onoff  "<< CGoGNendl;
//}
//
34
//void Tuto5::vectors_onoff(bool x)
Pierre Kraemer's avatar
Pierre Kraemer committed
35 36 37 38 39 40
//{
//	render_vectors = !render_vectors;
//	updateGL();
//	CGoGNerr << " vectors_onoff  "<< CGoGNflush;
//}
//
41
//void Tuto5::text_onoff(bool x)
Pierre Kraemer's avatar
Pierre Kraemer committed
42 43 44 45 46
//{
//	render_text = !render_text;
//	updateGL();
//	CGoGNerr << " text_onoff  " << CGoGNflush;
//}
Sylvain Thery's avatar
Sylvain Thery committed
47

untereiner's avatar
untereiner committed
48
void Tuto5::topo_onoff(bool x)
49 50 51
{
	render_topo = !render_topo;
	updateGL();
Sylvain Thery's avatar
Sylvain Thery committed
52
	CGoGNerr << " topo_onoff  " << CGoGNflush;
53
}
54

55
//void Tuto5::slider_balls(int x)
Pierre Kraemer's avatar
Pierre Kraemer committed
56 57 58 59 60
//{
//	m_sprite->setSize(0.05f*x);
//	updateGL();
//}
//
61
//void Tuto5::slider_vectors(int x)
Pierre Kraemer's avatar
Pierre Kraemer committed
62 63 64 65 66
//{
//	m_lines->setScale(0.02*x);
//	updateGL();
//}
//
67
//void Tuto5::slider_text(int x)
Pierre Kraemer's avatar
Pierre Kraemer committed
68 69 70 71
//{
//	m_strings->setScale(0.02f*x);
//	updateGL();
//}
Pierre Kraemer's avatar
Pierre Kraemer committed
72

untereiner's avatar
untereiner committed
73
void Tuto5::animate()
74 75 76 77 78 79
{
//	transfoMatrix() = glm::rotate(transfoMatrix(), 0.5f, glm::vec3(0.5773f,0.5773f,0.5773f));
	transfoRotate( 0.5f, 0.5773f,0.5773f,0.5773f);
	updateGLMatrices();
}

80
//void Tuto5::storeVerticesInfo()
Pierre Kraemer's avatar
Pierre Kraemer committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94
//{
//
//	CellMarker mv(myMap,VERTEX);
//	for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
//	{
//		if (!mv.isMarked(d))
//		{
//			mv.mark(d);
//			std::stringstream ss;
//			ss << d << " : "<< position[d];
//			m_strings->addString(ss.str(),position[d]);
//		}
//	}
//}
95

untereiner's avatar
untereiner committed
96
void Tuto5::cb_initGL()
Pierre Kraemer's avatar
Pierre Kraemer committed
97
{
Pierre Kraemer's avatar
Pierre Kraemer committed
98 99
//	Utils::GLSLShader::setCurrentOGLVersion(2);
	Utils::GLSLShader::setCurrentOGLVersion(1) ;
100

Pierre Kraemer's avatar
Pierre Kraemer committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
//	// create the render
//	m_render = new Algo::Render::GL2::MapRender();
//
//    m_render_topo = new Algo::Render::GL2::Topo3RenderMapD();
//
// 	// create VBO for position
//	m_positionVBO = new Utils::VBO();
//	m_positionVBO->updateData(position);
//
//	// using simple shader with color
//	m_shader = new Utils::ShaderSimpleColor();
//	m_shader->setAttributePosition(m_positionVBO);
//	m_shader->setColor(Geom::Vec4f(0.,1.,0.,0.));
//
//	m_sprite = new Utils::PointSprite();
//	m_sprite->setAttributePosition(m_positionVBO);
//
//	m_strings = new Utils::Strings3D(true, Geom::Vec3f(0.1f,0.0f,0.3f));
//	storeVerticesInfo();
//	m_strings->sendToVBO();
//
//	// copy de contenu de VBO a la creation
//	m_dataVBO = new Utils::VBO(*m_positionVBO);
//
//	m_lines = new Utils::ShaderVectorPerVertex();
//	m_lines->setAttributePosition(m_positionVBO);
//	m_lines->setAttributeVector(m_dataVBO);
//	m_lines->setScale(0.2f);
//	m_lines->setColor(Geom::Vec4f(0.0f, 1.0f, 0.2f, 0.0f));
//
//	// accede au buffer du VBO pour modification
//	PFP::VEC3* data = static_cast<PFP::VEC3*>(m_dataVBO->lockPtr());
//	for (unsigned int i=0; i< m_dataVBO->nbElts(); ++i)
//	{
//		data[i].normalize();
//	}
//	m_dataVBO->releasePtr();
//
//	registerShader(m_shader);
//	registerShader(m_strings);
//	registerShader(m_sprite);
//	registerShader(m_lines);
//
//	m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
//	m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
//	m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS);
//
//	m_render_topo->updateData<PFP>(myMap, allDarts, position,  0.9f, 0.9f, 0.9f);
149 150

	// timer example for animation
151
	m_timer = new QTimer( this );
152
	connect( m_timer, SIGNAL(timeout()), SLOT(animate()) );
153
}
Pierre Kraemer's avatar
Pierre Kraemer committed
154

untereiner's avatar
untereiner committed
155
void Tuto5::cb_redraw()
156
{
Pierre Kraemer's avatar
Pierre Kraemer committed
157 158 159 160 161 162 163 164 165 166 167
//	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//	glEnable(GL_LIGHTING);
//
//	m_render->draw(m_shader, Algo::Render::GL2::POINTS);
//
//	glLineWidth(2.0f);
//	m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.));
//	m_render->draw(m_shader, Algo::Render::GL2::LINES);
//
//	glEnable(GL_POLYGON_OFFSET_FILL);
//	glPolygonOffset(1.0f, 1.0f);
Pierre Kraemer's avatar
Pierre Kraemer committed
168

169
	if (render_topo)
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
170
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
171
		glDisable(GL_LIGHTING);
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
172
		glLineWidth(1.0f);
173 174
//		Algo::Render::GL1::renderTopoGMD3<PFP>(m, position, true, true, true, true, 0.9f, 0.9f, 0.9f, 0.9f);
		Algo::Render::GL1::renderTopoMD3<PFP>(m, position, true, true, true, 0.9f, 0.9f, 0.9f);
Pierre Kraemer's avatar
Pierre Kraemer committed
175
//		m_render_topo->drawTopo();
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
176
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199

//	Dart d = myMap.phi2(myMap.begin());
//	m_render_topo->overdrawDart(d, 5, 1.0f, 0.0f, 1.0f);
//	 d = myMap.phi1(myMap.begin());
//	m_render_topo->overdrawDart(d, 5, 1.0f, 0.0f, 1.0f);
//
//	glDisable(GL_POLYGON_OFFSET_FILL);
//
//	if (render_text)
//		m_strings->drawAll(Geom::Vec3f(0.0f, 1.0f, 1.0f));
//
//	if (render_balls)
//	{
//		m_sprite->predraw(Geom::Vec3f(1.0f, 0.0f ,0.0f));
//		m_render->draw(m_sprite, Algo::Render::GL2::POINTS);
//		m_sprite->postdraw();
//	}
//
//	if (render_vectors)
//	{
//		glLineWidth(1.0f);
//		m_render->draw(m_lines, Algo::Render::GL2::POINTS);
//	}
Pierre Kraemer's avatar
Pierre Kraemer committed
200 201
}

untereiner's avatar
untereiner committed
202
void Tuto5::cb_mousePress(int button, int x, int y)
Sylvain Thery's avatar
Sylvain Thery committed
203
{
Pierre Kraemer's avatar
Pierre Kraemer committed
204 205 206 207 208 209 210 211 212 213 214 215
//	if (Shift())
//	{
//		Dart d = m_render_topo->picking<PFP>(myMap, allDarts, x,y);
//		if (d != Dart::nil())
//		{
//			CGoGNout << "Dart "<< d << " clicked" << CGoGNendl;
//		}
//		else
//		{
//			statusMsg("");
//		}
//	}
Sylvain Thery's avatar
Sylvain Thery committed
216 217
}

untereiner's avatar
untereiner committed
218
void Tuto5::cb_keyPress(int code)
219
{
Pierre Kraemer's avatar
Pierre Kraemer committed
220 221 222 223 224 225 226 227 228 229
//	if (code == 's')
//	{
//		std::string filename = selectFileSave("Export SVG file ");
//		CGoGNout << "Exporting "<< filename << CGoGNendl;
//		Algo::Render::SVG::SVGOut svg(filename, modelViewMatrix(), projectionMatrix());
////		svg.renderLinesToSVG<PFP>(myMap,position);
//		svg.setColor(Geom::Vec3f(1.,0.,0.));
//		svg.renderFacesToSVG<PFP>(myMap,position,0.8f);
//		//svg destruction close the file
//	}
230 231 232 233 234 235 236
	if (code  == 't')
	{
		if (m_timer->isActive())
			m_timer->stop();
		else
			m_timer->start(1000/30); // 30 fps
	}
237 238
}

239
Dart Tuto5::embedCube1()
240
{
untereiner's avatar
untereiner committed
241
	Dart d = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,6);
242

untereiner's avatar
untereiner committed
243
	m.closeMap();
244 245 246

	Dart dres = d;
	position[d] = PFP::VEC3(0,0,0);
untereiner's avatar
untereiner committed
247 248 249 250
	position[m.phi1(d)] = PFP::VEC3(1,0,0);
	position[m.phi1(m.phi1(d))] = PFP::VEC3(1,0,1);
	position[m.phi_1(d)] = PFP::VEC3(0,0,1);
	d = m.phi_1(m.phi2(m.phi_1(m.phi_1(m.phi2(m.phi_1(d))))));
251
	position[d] = PFP::VEC3(1,1,0);
untereiner's avatar
untereiner committed
252 253 254
	position[m.phi1(d)] = PFP::VEC3(0,1,0);
	position[m.phi1(m.phi1(d))] = PFP::VEC3(0,1,1);
	position[m.phi_1(d)] = PFP::VEC3(1,1,1);
255

untereiner's avatar
untereiner committed
256
	return m.phi2(m.phi1(dres));
257
}
258

untereiner's avatar
untereiner committed
259
Dart Tuto5::embedCube2()
260
{
untereiner's avatar
untereiner committed
261
	Dart d = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,6);
262

untereiner's avatar
untereiner committed
263
	m.closeMap();
264 265 266

	Dart dres = d;
	position[d] = PFP::VEC3(2,0,0);
untereiner's avatar
untereiner committed
267 268 269 270
	position[m.phi1(d)] = PFP::VEC3(3,0,0);
	position[m.phi1(m.phi1(d))] = PFP::VEC3(3,0,1);
	position[m.phi_1(d)] = PFP::VEC3(2,0,1);
	d = m.phi_1(m.phi2(m.phi_1(m.phi_1(m.phi2(m.phi_1(d))))));
271
	position[d] = PFP::VEC3(3,1,0);
untereiner's avatar
untereiner committed
272 273 274 275 276 277 278 279 280 281
	position[m.phi1(d)] = PFP::VEC3(2,1,0);
	position[m.phi1(m.phi1(d))] = PFP::VEC3(2,1,1);
	position[m.phi_1(d)] = PFP::VEC3(3,1,1);

	return m.phi2(m.phi_1(dres));
}


Dart Tuto5::embedMapCollapse()
{
282

untereiner's avatar
untereiner committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
	Dart dd = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	Dart t1 = dd;
	// plongement
	position[t1] = PFP::VEC3(0.0f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.f, -1.f, -1.f);
	t1 = m.phi_1(m.phi2(dd));
	position[t1] = PFP::VEC3(-0.5f, -1.f, 0.f);

	Dart ee = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(dd,ee);
	t1 = ee;
	// plongement
	position[t1] = PFP::VEC3(0.0f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.f, -1.f, -1.f);
	t1 = m.phi_1(m.phi2(ee));
	position[t1] = PFP::VEC3(1.f, -1.f, 0.f);

	Dart ff = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(m.phi2(dd),ff);
	t1 = ff;
	// plongement
	position[t1] = PFP::VEC3(0.0f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(-0.5f, -1.f, 0.f);
	t1 = m.phi_1(m.phi2(ff));
	position[t1] = PFP::VEC3(0.f, -1.f, 1.f);

	Dart gg = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(gg,m.phi2(ee));
	m.sewVolumes(m.phi2(gg),m.phi2(ff));
	t1 = gg;
	// plongement
	position[t1] = PFP::VEC3(0.0f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(1.f, -1.f, 0.f);
	t1 = m.phi_1(m.phi2(gg));
	position[t1] = PFP::VEC3(0.f, -1.f, 1.f);

	Dart hh = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(m.phi2(m.phi_1(dd)),hh);
	t1 = hh;
	// plongement
	position[t1] = PFP::VEC3(0.0f, -1.0f, -1.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(-0.5f, -1.f, 0.f);
	t1 = m.phi_1(m.phi2(hh));
	position[t1] = PFP::VEC3(0.f, -0.2f, -0.8f);

	Dart jj = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(jj,m.phi<12>(ee));
	t1 = jj;
	// plongement
	position[t1] = PFP::VEC3(0.0f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, -1.0f, -1.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(1.f, -1.f, 0.f);
	t1 = m.phi_1(m.phi2(jj));
	position[t1] = PFP::VEC3(0.f, -0.2f, -0.8f);

	Dart kk = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(kk,m.phi<12>(dd));
	t1 = kk;
	// plongement
	position[t1] = PFP::VEC3(0.0f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, -1.0f, -1.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(-0.5f, -1.f, 0.f);
	t1 = m.phi_1(m.phi2(kk));
	position[t1] = PFP::VEC3(0.f, -1.8f, -0.6f);

	Dart ll = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(ll,m.phi2(m.phi_1(ee)));
	t1 = ll;
	// plongement
	position[t1] = PFP::VEC3(0.0f, -1.0f, -1.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(1.f, -1.f, 0.f);
	t1 = m.phi_1(m.phi2(ll));
	position[t1] = PFP::VEC3(0.f, -1.8f, -0.6f);

	/*4 tetra du pourtout de devant */
	Dart mm = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(mm,m.phi2(m.phi_1(ff)));
	t1 = mm;
	// plongement
	position[t1] = PFP::VEC3(-0.5f, -1.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.0f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.f, -1.f, 1.f);
	t1 = m.phi_1(m.phi2(mm));
	position[t1] = PFP::VEC3(0.f, -0.2f, 0.8f);

	Dart ww = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(ww,m.phi<12>(gg));
	t1 = ww;
	// plongement
	position[t1] = PFP::VEC3(0.f, 0.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(1.0f, -1.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.f, -1.f, 1.f);
	t1 = m.phi_1(m.phi2(ww));
	position[t1] = PFP::VEC3(0.f, -0.2f, 0.8f);

	Dart xx = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(xx,m.phi<12>(ff));
	t1 = xx;
	// plongement
	position[t1] = PFP::VEC3(0.f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(-0.5f, -1.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.f, -1.f, 1.f);
	t1 = m.phi_1(m.phi2(xx));
	position[t1] = PFP::VEC3(0.f, -1.6f, 0.6f);

	Dart cc = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(m,4);
	m.closeMap();
	m.sewVolumes(cc,m.phi2(m.phi_1(gg)));
	t1 = cc;
	// plongement
	position[t1] = PFP::VEC3(1.f, -1.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.f, -2.0f, 0.0f);
	t1 = m.phi1(t1);
	position[t1] = PFP::VEC3(0.f, -1.f, 1.f);
	t1 = m.phi_1(m.phi2(cc));
	position[t1] = PFP::VEC3(0.f, -1.6f, 0.6f);

	return dd;
441
}
442

Pierre Kraemer's avatar
Pierre Kraemer committed
443 444
int main(int argc, char **argv)
{
untereiner's avatar
untereiner committed
445 446 447
    // un peu d'interface
	QApplication app(argc, argv);
	Tuto5 sqt;
448
	
untereiner's avatar
untereiner committed
449
	sqt.position = sqt.m.addAttribute<PFP::VEC3>(VERTEX, "position");
450

451 452 453 454
	Dart t1 = Algo::Modelisation::Polyhedron<PFP>::createTetra(sqt.m) ;
	Dart t2 = Algo::Modelisation::Polyhedron<PFP>::createTetra(sqt.m) ;
	sqt.m.sewVolumes(t1, t2, false) ;
	sqt.m.closeHole(sqt.m.phi2(t1)) ;
455

456 457 458
	Algo::Modelisation::Primitive3D<PFP> primCat(sqt.m, sqt.position);
	Dart d = primCat.hexaGrid_topo(3, 3, 3);
	primCat.embedHexaGrid(1, 1, 1);
459

460 461 462 463 464 465 466 467 468
//	Dart d1 = sqt.embedMapCollapse();
//
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
//
//
//	sqt.m.collapseEdge(d1);
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
469

470 471
//	Dart d1 = embedCube1() ;
//	Dart d2 = embedCube2() ;
472

untereiner's avatar
untereiner committed
473
//	Dart dd = sqt.m.phi2(d1) ;
474

untereiner's avatar
untereiner committed
475 476
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
477

untereiner's avatar
untereiner committed
478
//	sqt.m.sewVolumes(d1, d2);
479

untereiner's avatar
untereiner committed
480 481
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
482

untereiner's avatar
untereiner committed
483
//	sqt.m.mergeVolumes(d1) ;
484

untereiner's avatar
untereiner committed
485 486
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
487

untereiner's avatar
untereiner committed
488 489 490 491 492 493 494 495 496 497
//	std::vector<Dart> v ;
//	v.push_back(dd) ;
//	dd = sqt.m.phi1(sqt.m.phi2(sqt.m.phi1(dd))) ;
//	v.push_back(dd) ;
//	dd = sqt.m.phi1(sqt.m.phi2(sqt.m.phi1(dd))) ;
//	v.push_back(dd) ;
//	dd = sqt.m.phi1(sqt.m.phi2(sqt.m.phi1(dd))) ;
//	v.push_back(dd) ;
//
//	sqt.m.splitVolume(v) ;
498

untereiner's avatar
untereiner committed
499 500
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
501

untereiner's avatar
untereiner committed
502 503 504
//	Dart f = sqt.m.phi2(v.front()) ;
//	Dart f3 = sqt.m.phi3(f) ;
//	sqt.m.unsewVolumes(f) ;
505

untereiner's avatar
untereiner committed
506 507
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
508

untereiner's avatar
untereiner committed
509
//	sqt.m.sewVolumes(f, f3) ;
510

untereiner's avatar
untereiner committed
511 512
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
513

untereiner's avatar
untereiner committed
514
//	sqt.m.splitFace(f, sqt.m.phi1(sqt.m.phi1(f))) ;
Sylvain Thery's avatar
bug  
Sylvain Thery committed
515

untereiner's avatar
untereiner committed
516 517
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
Sylvain Thery's avatar
Sylvain Thery committed
518

untereiner's avatar
untereiner committed
519 520 521 522
//	PFP::VEC3 p = sqt.position[f] + sqt.position[sqt.m.phi_1(f)] ;
//	p /= 2.0 ;
//	sqt.m.cutEdge(sqt.m.phi_1(f)) ;
//	sqt.position[sqt.m.phi_1(f)] = p ;
Sylvain Thery's avatar
bug  
Sylvain Thery committed
523

untereiner's avatar
untereiner committed
524 525 526 527 528 529 530 531 532 533 534 535
//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;

//	sqt.m.uncutEdge(sqt.m.phi_1(sqt.m.phi_1(f))) ;

//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;

//	sqt.m.deleteVolume(f) ;

//	sqt.m.check() ;
//	std::cout << "nb darts -> " << sqt.m.getNbDarts() << std::endl ;
536
//	Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
Pierre Kraemer's avatar
Pierre Kraemer committed
537

538 539 540
	// interface de tuto5.ui
    Utils::QT::uiDockInterface dock;
    sqt.setDock(&dock);
Pierre Kraemer's avatar
Pierre Kraemer committed
541

Pierre Kraemer's avatar
Pierre Kraemer committed
542 543 544 545 546 547 548 549 550 551 552
// 	// message d'aide
//	sqt.setHelpMsg("Enter pour dock on/off\nShift Enter pour console on/off\nShift Click gauche pour selectionner un brin");
//
//	CGoGNout.toStatusBar(&sqt);
//	CGoGNout << "CGoGNOut StatusBar" << Geom::Vec3f(2.5f, 2.2f, 4.3f) << CGoGNendl;
//
//	CGoGNout.toConsole(&sqt);
//
//	CGoGNout << "CGoGNOut dans la console" << Geom::Vec3f(2.5f, 2.2f, 4.3f) << CGoGNendl;
//
//	CGoGNout.toStatusBar(NULL);
553
	
554
	//  bounding box
untereiner's avatar
untereiner committed
555
    Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(sqt.m, sqt.position);
556 557
    float lWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2));
    Geom::Vec3f lPosObj = (bb.min() +  bb.max()) / PFP::REAL(2);
Pierre Kraemer's avatar
Pierre Kraemer committed
558

559
    // envoit info BB a l'interface
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
560
	sqt.setParamObject(lWidthObj, lPosObj.data());
Pierre Kraemer's avatar
Pierre Kraemer committed
561

Pierre Kraemer's avatar
Pierre Kraemer committed
562 563 564
//	sqt.setCallBack( dock.checkBox_balls, SIGNAL(toggled(bool)), SLOT(balls_onoff(bool)) );
//	sqt.setCallBack( dock.checkBox_vectors, SIGNAL(toggled(bool)), SLOT(vectors_onoff(bool)) );
//	sqt.setCallBack( dock.checkBox_text, SIGNAL(toggled(bool)), SLOT(text_onoff(bool)) );
565
	sqt.setCallBack( dock.checkBox_topo, SIGNAL(toggled(bool)), SLOT(topo_onoff(bool)) );
Pierre Kraemer's avatar
Pierre Kraemer committed
566

Pierre Kraemer's avatar
Pierre Kraemer committed
567 568 569
//	sqt.setCallBack( dock.slider_balls, SIGNAL(valueChanged(int)), SLOT(slider_balls(int)) );
//	sqt.setCallBack( dock.slider_vectors, SIGNAL(valueChanged(int)), SLOT(slider_vectors(int)) );
//	sqt.setCallBack( dock.slider_text, SIGNAL(valueChanged(int)), SLOT(slider_text(int)) );
Pierre Kraemer's avatar
Pierre Kraemer committed
570

571
	sqt.show();
Pierre Kraemer's avatar
Pierre Kraemer committed
572

Pierre Kraemer's avatar
Pierre Kraemer committed
573 574 575
//	sqt.slider_balls(50);
//	sqt.slider_vectors(50);
//	sqt.slider_text(50);
Pierre Kraemer's avatar
Pierre Kraemer committed
576

Pierre Kraemer's avatar
Pierre Kraemer committed
577 578 579 580 581 582
//	GLint texSize;
//	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
//	CGoGNdbg.toConsole(&sqt);
//	CGoGNerr.toConsole(&sqt);
//	CGoGNdbg << " TextureSize " <<  texSize << CGoGNendl;
//	CGoGNerr << " test ERROR  " <<  5*7 << CGoGNflush;
Pierre Kraemer's avatar
Pierre Kraemer committed
583

584 585
	// et on attend la fin.
	return app.exec();
Pierre Kraemer's avatar
Pierre Kraemer committed
586
}