tuto_oper3.cpp 16.3 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
*                                                                              *
* 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.           *
*                                                                              *
* Web site: http://cgogn.unistra.fr/                                           *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "tuto_oper3.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/polyhedron.h"
28
#include "Algo/Modelisation/tetrahedralization.h"
Sylvain Thery's avatar
Sylvain Thery committed
29 30
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Geometry/centroid.h"
untereiner's avatar
untereiner committed
31
#include "Algo/Geometry/normal.h"
Sylvain Thery's avatar
Sylvain Thery committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"

using namespace CGoGN ;


int main(int argc, char **argv)
{
	//	// interface
	QApplication app(argc, argv);
	MyQT sqt;

    sqt.setDock(& sqt.dock);
    sqt.setCallBack( sqt.dock.listOper, SIGNAL(currentRowChanged(int)), SLOT(operation(int)) );
    sqt.setCallBack( sqt.dock.svg, SIGNAL(clicked()), SLOT(svg()) );
    sqt.setCallBack( sqt.dock.widthSlider, SIGNAL(valueChanged(int)), SLOT(width(int)) );
48 49
	sqt.setCallBack( sqt.dock.checkBox_hide, SIGNAL(toggled(bool)), SLOT(hide_onoff(bool)) );
	sqt.setCallBack( sqt.dock.checkBox_plane, SIGNAL(toggled(bool)), SLOT(clipping_onoff(bool)) );
Sylvain Thery's avatar
Sylvain Thery committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
	int n=3;
	if (argc==2)
		n = atoi(argv[1]);

	// example code itself
	sqt.createMap(n);

	sqt.width(5);

	// set help message in menu
	sqt.setHelpMsg("First Tuto: \nCreate two faces\nsew them\nand affect positions");
	// final show for redraw
	sqt.show();
	// and wait for the end
	return app.exec();
}

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
void MyQT::clipping_onoff(bool x)
{
	clip_volume = x;

	if (clip_volume)
	{
		Geom::Vec3f pos = m_PlanePick->getPosition();
		float pipo;
		Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
		m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, normal, pos);
		m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, normal, pos);
	}
	else
	{
		m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
		m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
		m_render_topo->shader1()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
		m_render_topo->shader2()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
	}
	updateMap();
	updateGL();
}

void MyQT::hide_onoff(bool x)
{
	hide_clipping = !hide_clipping;
	updateMap();
	updateGL();
}

Sylvain Thery's avatar
Sylvain Thery committed
97 98 99 100 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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
void MyQT::operation(int x)
{
	switch(x)
	{
	case 0:
		CGoGNout <<"delete vertex"<<CGoGNendl;
		if (m_selected != NIL)
		{
			dm.markAll();
			m_selected=myMap.deleteVertex(m_selected);
			m_selected = NIL;
			updateMap();
		}
		break;
	case 1:
		CGoGNout <<"cut edge"<<CGoGNendl;
		if (m_selected != NIL)
		{
			dm.markAll();
			PFP::VEC3 Q = position[myMap.phi1(m_selected)];
			myMap.cutEdge(m_selected);
			position[myMap.phi1(m_selected)] = (position[m_selected] + Q)/2.0f;
			updateMap();
		}
		break;
	case 2:
		CGoGNout <<"uncut edge"<<CGoGNendl;
		if (m_selected != NIL)
		{
			dm.markAll();
			myMap.uncutEdge(m_selected);
			updateMap();
		}
		break;
	case 3:
		CGoGNout <<"delete edge"<<CGoGNendl;
		if (m_selected != NIL)
		{
			if (myMap.deleteEdgePreCond(m_selected))
			{
				dm.markAll();
				myMap.deleteEdge(m_selected);
				m_selected = NIL;
				updateMap();
			}
			else
			{
				CGoGNerr << "Could not delete this edge" << CGoGNendl;
			}
		}
		break;
	case 4:
		CGoGNout <<"collapse edge"<<CGoGNendl;
		if (m_selected != NIL)
		{
			PFP::VEC3 Q = (position[myMap.phi1(m_selected)] + position[m_selected])/2.0f;
			Dart x = myMap.collapseEdge(m_selected);
			dm.markAll();
			position[x]= Q;
			m_selected = NIL;
			updateMap();
		}
		break;
	case 5:
		CGoGNout <<"split face"<<CGoGNendl;
		if (m_selected != NIL)
		{
			myMap.splitFace(m_selected,m_selected2);
			dm.markAll();
			updateMap();
		}
		break;
	case 6:
		CGoGNout <<"merge volume"<<CGoGNendl;
		if (m_selected != NIL)
		{
			myMap.mergeVolumes(m_selected);
			dm.markAll();
			updateMap();
		}
		break;

	case 7:
		CGoGNout <<"split volume"<<CGoGNendl;
		if (!m_selecteds.empty())
		{
183 184 185 186 187
			std::cout << "start" << std::endl;
			for(std::vector<Dart>::iterator it = m_selecteds.begin() ; it != m_selecteds.end() ; ++it)
				std::cout << *it << " et phi2() = " << myMap.phi2(*it) <<  std::endl;
			std::cout << "end" << std::endl;

Sylvain Thery's avatar
Sylvain Thery committed
188
			myMap.splitVolume(m_selecteds);
untereiner's avatar
untereiner committed
189
			m_selecteds.clear();
190

Sylvain Thery's avatar
Sylvain Thery committed
191 192 193 194
			dm.markAll();
			updateMap();
		}
		break;
195 196 197 198
	case 8:
		CGoGNout <<"collapse face"<<CGoGNendl;
		if (m_selected != NIL)
		{
199
			PFP::VEC3 Q = Algo::Surface::Geometry::faceCentroid<PFP>(myMap,m_selected,position);
200 201 202 203 204 205 206 207 208 209 210
			Dart x = myMap.collapseFace(m_selected);
			dm.markAll();
			position[x]= Q;
			m_selected = NIL;
			updateMap();
		}
		break;
	case 9:
		CGoGNout <<"collapse volume"<<CGoGNendl;
		if (m_selected != NIL)
		{
211
			PFP::VEC3 Q = Algo::Surface::Geometry::volumeCentroid<PFP>(myMap,m_selected,position);
212 213 214 215 216 217 218
			Dart x = myMap.collapseVolume(m_selected);
			dm.markAll();
			position[x]= Q;
			m_selected = NIL;
			updateMap();
		}
		break;
untereiner's avatar
untereiner committed
219 220
	case 10:
		CGoGNout <<"split vertex"<<CGoGNendl;
221
		if (!m_selecteds.empty() && m_selected != NIL)
untereiner's avatar
untereiner committed
222
		{
Lionel Untereiner's avatar
Lionel Untereiner committed
223
			Dart dit = m_selecteds.front();
224 225
			PFP::VEC3 Q = (position[myMap.phi1(m_selected)] + position[m_selected])/2.0f;
			//PFP::VEC3 c1 = Algo::Geometry::volumeCentroid<PFP>(myMap, dit, position);
226 227
			Dart dres = myMap.splitVertex(m_selecteds);
			//Dart dres = Algo::Modelisation::Tetrahedralization::splitVertex<PFP>(myMap, m_selecteds);
228 229
			position[dres] = position[dit] + Q*0.25f;
			//position[dit] = position[dit] - c1*0.5f;
untereiner's avatar
untereiner committed
230
			m_selecteds.clear();
231
			m_selected = NIL;
untereiner's avatar
untereiner committed
232
			dm.markAll();
untereiner's avatar
untereiner committed
233
			updateMap();
untereiner's avatar
untereiner committed
234
			std::cout << "nb darts after = " << myMap.getNbDarts() << std::endl;
untereiner's avatar
untereiner committed
235 236
		}
		break;
Sylvain Thery's avatar
Sylvain Thery committed
237 238 239 240 241 242 243 244 245 246 247
	default:
		break;
	}

	updateGL();
	dock.listOper->setCurrentRow(-1);
}

void MyQT::createMap(int n)
{
	myMap.clear(true);
248
	position = myMap.getAttribute<VEC3, VERTEX>("position");
Sylvain Thery's avatar
Sylvain Thery committed
249
	if (!position.isValid())
250
		position = myMap.addAttribute<VEC3, VERTEX>("position");
251
	Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
Sylvain Thery's avatar
Sylvain Thery committed
252 253 254 255
	prim.hexaGrid_topo(n,n,n);
	prim.embedHexaGrid(1.0f,1.0f,1.0f);

    //  bounding box of scene
256
	bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
Sylvain Thery's avatar
Sylvain Thery committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
	setParamObject(bb.maxSize(), bb.center().data()) ;
	m_shift = bb.maxSize()/200.0f;

	// first show for be sure that GL context is binded
	show();

	// render the topo of the map without boundary darts

	m_render_topo->setDartWidth(3.0f);
	m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
	m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
}

void MyQT::updateMap()
{
	m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
}

// initialization GL callback
void MyQT::cb_initGL()
{
	glClearColor(1.0f,1.0f,1.0f,1.0f);
	m_render_topo = new Algo::Render::GL2::Topo3Render() ;
280 281 282 283 284 285 286 287 288 289 290 291 292 293

    m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
	m_frame = new Utils::FrameManipulator();
	m_frame->setSize(bb.maxSize());

	m_render_topo->shader1()->insertClippingCode();
	m_render_topo->shader2()->insertClippingCode();

	clip_id1 = m_render_topo->shader1()->addClipPlane();
	clip_id2 = m_render_topo->shader2()->addClipPlane();

	m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), bb.center());
	m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), bb.center());

Sylvain Thery's avatar
Sylvain Thery committed
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
}

// redraw GL callback (clear and swap already done)
void MyQT::cb_redraw()
{
	glEnable( GL_POLYGON_OFFSET_FILL );
	glPolygonOffset( 1.0f, 1.0f );

	m_render_topo->drawTopo();

	glDisable( GL_POLYGON_OFFSET_FILL );

	if (m_selected != NIL)
		m_render_topo->overdrawDart(m_selected, 11, 1.0f, 0.0f, 0.0f);

	if (m_selected2 != NIL)
		m_render_topo->overdrawDart(m_selected2, 11, 0.0f, 1.0f, 0.0f);

	for (std::vector<Dart>::iterator it = m_selecteds.begin(); it != m_selecteds.end(); ++it)
	{
		m_render_topo->overdrawDart(*it, 11, 0.0f, 0.0f, 1.0f);
	}
316 317 318 319 320 321

	if (clip_volume && !hide_clipping)
	{
		m_frame->draw();
		m_PlanePick->draw();
	}
Sylvain Thery's avatar
Sylvain Thery committed
322 323 324 325 326 327 328 329 330 331 332
}

void MyQT::cb_mousePress(int button, int x, int y)
{
	if (Shift())
	{
		Dart d = m_render_topo->picking<PFP>(myMap, x,y, nb);
		if (button == Qt::LeftButton)
		{
			if (d != Dart::nil())
				m_selected = d;
333
			std::cout << myMap.edgeCanCollapse(d) << std::endl;
Sylvain Thery's avatar
Sylvain Thery committed
334 335 336 337 338 339 340
		}
		if (button == Qt::RightButton)
		{
			if (d != Dart::nil())
				m_selected2 = d;
		}
		updateGL();
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363

		if (hide_clipping || !clip_volume)
			return;

		m_begX = x;
		m_begY = y;

		// get ray of selection
		Geom::Vec3f rayA,rayB;
		float dist = getOrthoScreenRay(x,y,rayA,rayB);
		Geom::Vec3f AB = rayB-rayA;

		unsigned int fr_picked =0;
		// picking the frame -> axis
		fr_picked = m_frame->pick(rayA,AB,dist);

		if (fr_picked != 0)
		{
			m_pickedAxis=fr_picked;
			m_frame->highlight(m_pickedAxis);
			m_frame->storeProjection(m_pickedAxis);
			updateGL();
		}
Sylvain Thery's avatar
Sylvain Thery committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377
	}

	if (Control())
	{
		Dart d = m_render_topo->picking<PFP>(myMap, x,y, nb);
		if (button == Qt::LeftButton)
		{
			if (d != Dart::nil())
				m_selecteds.push_back(d);
		}
		updateGL();
	}
}

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 441 442 443 444 445
void  MyQT::cb_mouseRelease(int button, int x, int y)
{

	if (hide_clipping || !clip_volume)
		return;

	m_pickedAxis=0;
	m_frame->highlight(m_pickedAxis);
	updateGL();

}

void  MyQT::cb_mouseMove(int buttons, int x, int y)
{
	if (!Shift())
		return;

	if (hide_clipping || !clip_volume)
		return;

	// rotation selected ?
	if (Utils::FrameManipulator::rotationAxis(m_pickedAxis))
	{
		if (buttons&1)
		{
			float angle = m_frame->angleFromMouse(x,y,x-m_begX, y-m_begY);
			m_frame->rotate(m_pickedAxis, angle);
		}
		else if (buttons&2)
			m_frame->rotateInScreen(x-m_begX, y-m_begY);

		m_PlanePick->transfo() = m_frame->transfo();
	}
	// translation selected
	else if (Utils::FrameManipulator::translationAxis(m_pickedAxis))
	{
		if (buttons&1)
		{
			float dist =  m_frame->distanceFromMouse(x-m_begX, y-m_begY);
			m_frame->translate(m_pickedAxis, dist);
		}
		else if (buttons&2)
			m_frame->translateInScreen(x-m_begX, y-m_begY);

		m_PlanePick->transfo() = m_frame->transfo();
	}
	// scale selected
	else if (Utils::FrameManipulator::scaleAxis(m_pickedAxis) )
	{
		float scale = m_frame->scaleFromMouse(x-m_begX, y-m_begY);
		m_frame->scale(m_pickedAxis, scale );
		m_PlanePick->transfo() = m_frame->transfo();
	}

	Geom::Vec3f pos = m_PlanePick->getPosition();
	float pipo;
	Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal

	m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, normal, pos);
	m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, normal, pos);

	m_begX = x;
	m_begY = y;
	updateGL();
	return;

}

Sylvain Thery's avatar
Sylvain Thery committed
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
void MyQT::cb_keyPress(int keycode)
{
	switch(keycode)
	{

	case ' ':
		m_selecteds.clear();
		m_selected=NIL;
		m_selected2=NIL;
		updateGL();
		break;
	case '2':
		createMap(2);
		updateMap();
		updateGL();
		break;
	case '3':
		createMap(3);
		updateMap();
		updateGL();
		break;
	case '4':
		createMap(4);
		updateMap();
		updateGL();
		break;
472 473 474
	case 'c':
		myMap.check();
		break;
Sylvain Thery's avatar
Sylvain Thery committed
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
	case 'a':
		m_selected = myMap.phi1(m_selected);
		updateGL();
		break;
	case 'z':
		m_selected = myMap.phi_1(m_selected);
		updateGL();
		break;
	case 'e':
		m_selected = myMap.phi2(m_selected);
		updateGL();
		break;
	case 'r':
		m_selected = myMap.phi3(m_selected);
		updateGL();
		break;
	case 'q':
		m_selected2 = myMap.phi1(m_selected2);
		updateGL();
		break;
	case 's':
		m_selected2 = myMap.phi_1(m_selected2);
		updateGL();
		break;
	case 'd':
		m_selected2 = myMap.phi2(m_selected2);
		updateGL();
		break;
	case 'f':
		m_selected2 = myMap.phi3(m_selected2);
		updateGL();
		break;
	case 'w':
		m_ex1 = 0.99f;
		m_ex2 = 0.99f;
		m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
		updateGL();
		break;
	case 'W':
		m_ex1 = 0.9f;
		m_ex2 = 0.9f;
		m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
		updateGL();
		break;

//	case 'c':
//		for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
//		{
Thery Sylvain's avatar
Thery Sylvain committed
523
//			if (!myMap.isBoundaryMarked3(d))
Sylvain Thery's avatar
Sylvain Thery committed
524 525 526 527 528 529 530 531 532 533 534 535 536
//			{
//				int n = random();
//				float r = float(n&0x7f)/255.0f + 0.25f;
//				float g = float((n>>8)&0x7f)/255.0f + 0.25f;
//				float b = float((n>>16)&0x7f)/255.0 + 0.25f;
//				colorDarts[d] =  Geom::Vec3f(r,g,b);
//				m_render_topo->setDartColor(d,r,g,b);
//			}
//		}
//		break;
//	case 'g':
//		for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
//		{
Thery Sylvain's avatar
Thery Sylvain committed
537
//			if (!myMap.isBoundaryMarked3(d))
Sylvain Thery's avatar
Sylvain Thery committed
538 539 540 541 542 543 544 545 546 547
//			{
//				colorDarts[d] =  Geom::Vec3f(0.5f,0.5f,0.5f);
//				m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
//			}
//		}
//		break;
//
//	case 'b':
//		for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
//		{
Thery Sylvain's avatar
Thery Sylvain committed
548
//			if (!myMap.isBoundaryMarked3(d))
Sylvain Thery's avatar
Sylvain Thery committed
549 550 551 552 553 554 555 556
//			{
//				colorDarts[d] =  Geom::Vec3f(0.0f,0.0f,0.0f);
//				m_render_topo->setDartColor(d,0.0f,0.0f,0.0f);
//			}
//		}
//		break;
	case Qt::Key_Up:
		if (m_selected!=NIL)
557
			position[m_selected][1] += m_shift;
Sylvain Thery's avatar
Sylvain Thery committed
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
		updateMap();
		updateGL();
		break;
	case Qt::Key_Down:
		if (m_selected!=NIL)
			position[m_selected][1] -= m_shift;
		updateMap();
		updateGL();
		break;
	case Qt::Key_Left:
		if (m_selected!=NIL)
			position[m_selected][0] -= m_shift;
		updateMap();
		updateGL();
		break;
	case Qt::Key_Right:
		if (m_selected!=NIL)
			position[m_selected][0] += m_shift;
		updateMap();
		updateGL();
		break;
	}
	updateGL();
}

void MyQT::svg()
{
585 586 587 588
	if (m_selected != NIL)
		m_render_topo->setDartColor(m_selected, 0.8f, 0.0f, 0.0f);
	if (m_selected2 != NIL)
		m_render_topo->setDartColor(m_selected2, 0.0f, 0.8f, 0.0f);
Sylvain Thery's avatar
Sylvain Thery committed
589 590

	std::string filename = selectFileSave("snapshot file", ".", "(*.svg)");
591
	m_render_topo->svgout2D(filename, modelViewMatrix(), projectionMatrix());
Sylvain Thery's avatar
Sylvain Thery committed
592 593 594 595
}

void MyQT::cb_Open()
{
596
	std::string filters("all (*.*);; map (*.map)") ;
Sylvain Thery's avatar
Sylvain Thery committed
597 598 599 600 601 602 603 604 605
	std::string filename = selectFile("Open Mesh", "", filters) ;
	if (!filename.empty())
		importMesh(filename);
	updateGL();
}

void MyQT::cb_Save()
{
	std::string filename = selectFileSave("Export SVG file ",".","(*.off)");
606
	Algo::Surface::Export::exportOFF<PFP>(myMap, position, filename.c_str()); // ???
Sylvain Thery's avatar
Sylvain Thery committed
607 608 609 610 611 612 613 614
}

void MyQT::importMesh(std::string& filename)
{
	myMap.clear(true) ;

	size_t pos = filename.rfind(".");    // position of "." in filename
	std::string extension = filename.substr(pos);
615
	std::vector<std::string> attrNames ;
Sylvain Thery's avatar
Sylvain Thery committed
616 617 618 619

	if (extension == std::string(".map"))
	{
		myMap.loadMapBin(filename);
620
		position = myMap.getAttribute<VEC3, VERTEX>("position") ;
Sylvain Thery's avatar
Sylvain Thery committed
621
	}
622
	else if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
623 624
	{
		std::cerr << "could not import " << filename << std::endl ;
625
		return ;
626
	}
627 628
	else
		position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
Sylvain Thery's avatar
Sylvain Thery committed
629 630 631 632

	m_selected  = NIL;
	m_selected2 = NIL;

633 634
	m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);

635
	bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
Sylvain Thery's avatar
Sylvain Thery committed
636 637 638
	setParamObject(bb.maxSize(), bb.center().data()) ;
	m_shift = bb.maxSize()/200.0f;

639 640
	m_frame->setSize(bb.maxSize());

Sylvain Thery's avatar
Sylvain Thery committed
641 642 643 644 645 646 647 648 649 650
	updateMap();
	updateGLMatrices() ;
}

void MyQT::width(int w)
{
	m_ex3 = 0.9f - 0.025f*w;
	m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
	updateGL();
}