linearTest.cpp 32.6 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 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 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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 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
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/                              *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "linearTest.h"

/**********************************************************************************************
 *                                 AntTweakBar CALLBACKS                                      *
 **********************************************************************************************/

void TW_CALL setRenderStyleCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->renderStyle = *(GLenum*)value ;
	if(mgw->renderStyle == MyGlutWin::FLAT)
		TwDefine("Viewer/FaceShrinkage visible=true") ;
	else
		TwDefine("Viewer/FaceShrinkage visible=false") ;
	glutPostRedisplay() ;
}
void TW_CALL getRenderStyleCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLenum*)value = mgw->renderStyle ;
}

void TW_CALL setShininessCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->shininess = *(float*)value ;
	glutPostRedisplay() ;
}
void TW_CALL getShininessCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(float*)value = mgw->shininess ;
}

void TW_CALL setFocalCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->setFocal(*(float*)value) ;
	mgw->reshape(-1, -1) ;
	glutPostRedisplay() ;
}
void TW_CALL getFocalCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(float*)value = mgw->getFocal() ;
}

void TW_CALL setRenderObjectCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->renderObject = *(GLboolean*)value ;
	glutPostRedisplay() ;
}
void TW_CALL getRenderObjectCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLboolean*)value = mgw->renderObject ;
}

void TW_CALL setRenderLinesCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->renderLines = *(GLboolean*)value ;
	glutPostRedisplay() ;
}
void TW_CALL getRenderLinesCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLboolean*)value = mgw->renderLines ;
}

void TW_CALL setRenderNormalsCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->renderNormals = *(GLboolean*)value ;
	if(mgw->renderNormals)
	{
		mgw->initDLNormals() ;
		TwDefine("Viewer/NormalScaleFactor visible=true") ;
	}
	else
		TwDefine("Viewer/NormalScaleFactor visible=false") ;
	glutPostRedisplay() ;
}
void TW_CALL getRenderNormalsCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLboolean*)value = mgw->renderNormals ;
}

void TW_CALL setNormalScaleFactorCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->normalScaleFactor = *(float*)value ;
	if(mgw->renderNormals) mgw->initDLNormals() ;
	glutPostRedisplay() ;
}
void TW_CALL getNormalScaleFactorCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(float*)value = mgw->normalScaleFactor ;
}

void TW_CALL setFaceShrinkageCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->faceShrinkage = *(float*)value ;
	glutPostRedisplay() ;
}
void TW_CALL getFaceShrinkageCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(float*)value = mgw->faceShrinkage ;
}

void TW_CALL setShowCurvatureCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->showCurvature = *(GLboolean*)value ;
	if(mgw->showCurvature)
	{
		mgw->updateVBOdata(Algo::Render::VBO::COLORS) ;
		TwDefine("Viewer/CurvatureDirections visible=true") ;
		TwDefine("Viewer/CurvType visible=true") ;
		TwDefine("Viewer/CurvDir visible=true") ;
		TwDefine("Viewer/CurvMultiplicator visible=true") ;
	}
	else
	{
		TwDefine("Viewer/CurvatureDirections visible=false") ;
		TwDefine("Viewer/CurvType visible=false") ;
		TwDefine("Viewer/CurvDir visible=false") ;
		TwDefine("Viewer/CurvMultiplicator visible=false") ;
	}
	glutPostRedisplay() ;
}
void TW_CALL getShowCurvatureCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLboolean*)value = mgw->showCurvature ;
}

void TW_CALL setShowCurvatureDirectionsCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->showCurvatureDirections = *(GLboolean*)value ;
	glutPostRedisplay() ;
}
void TW_CALL getShowCurvatureDirectionsCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLboolean*)value = mgw->showCurvatureDirections ;
}

void TW_CALL setCurvatureTypeCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->curvatureType = *(GLenum*)value ;
	mgw->updateVBOdata(Algo::Render::VBO::COLORS, false) ;
	glutPostRedisplay() ;
}
void TW_CALL getCurvatureTypeCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLenum*)value = mgw->curvatureType ;
}

void TW_CALL setCurvatureDirCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->curvatureDir = *(GLenum*)value ;
	glutPostRedisplay() ;
}
void TW_CALL getCurvatureDirCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLenum*)value = mgw->curvatureDir ;
}

void TW_CALL setCurvMultiplicatorCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->curvMultiplicator = *(float*)value ;
	mgw->updateVBOdata(Algo::Render::VBO::COLORS, false) ;
	glutPostRedisplay() ;
}
void TW_CALL getCurvMultiplicatorCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(float*)value = mgw->curvMultiplicator ;
}

void TW_CALL setSolverTypeCB(const void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->setSolverType(*(GLenum*)value) ;
}
void TW_CALL getSolverTypeCB(void* value, void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	*(GLenum*)value = mgw->getSolverType() ;
}

void TW_CALL smoothCB(void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->smooth() ;
	if(mgw->showCurvature)
		mgw->updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS | Algo::Render::VBO::COLORS) ;
	else
		mgw->updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
	glutPostRedisplay() ;
}

void TW_CALL smoothCurvatureCB(void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	if(mgw->showCurvature)
	{
		mgw->smoothCurvature() ;
		mgw->updateVBOdata(Algo::Render::VBO::COLORS, false) ;
		glutPostRedisplay() ;
	}
}

void TW_CALL lsmCB(void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->lsm() ;
	if(mgw->showCurvature)
		mgw->updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS | Algo::Render::VBO::COLORS) ;
	else
		mgw->updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
	glutPostRedisplay() ;
}

void TW_CALL diffCoordCB(void* clientData)
{
	MyGlutWin* mgw = static_cast<MyGlutWin*>(clientData) ;
	mgw->matchDiffCoord(false) ;
	if(mgw->showCurvature)
		mgw->updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS | Algo::Render::VBO::COLORS) ;
	else
		mgw->updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
	glutPostRedisplay() ;
}

/**********************************************************************************************
 *                                 MyGlutWin IMPLEMENTATION                                   *
 **********************************************************************************************/

MyGlutWin::MyGlutWin(int* argc, char **argv, int winX, int winY) :
	GlutWin_ATB(argc, argv, winX, winY),
	renderStyle(GOURAUD),
	renderObject(true),
	renderLines(false),
	renderNormals(false),
	showCurvature(false),
	showCurvatureDirections(false),
	curvatureType(MEAN),
	curvMultiplicator(1.0f),
	smoothAmount(0.5f),
	vbo_render(NULL),
	def_locked(true),
	def_handle(false),
	selecting(false),
	deselecting(false),
	dragging(false),
#ifdef WITH_CUDA
	gpuSolver(false),
#endif
	lockingMarker(myMap, VERTEX_ORBIT),
	handleMarker(myMap, VERTEX_ORBIT),
	solverType(ITERATIVE)
{
	normalScaleFactor = 1.0f ;
	faceShrinkage = 0.0f ;

	colClear = Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f) ;
	colDif = Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f) ;
	colSpec = Geom::Vec4f(0.9f, 0.9f, 0.9f, 1.0f) ;
	colNormal = Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f) ;
	shininess = 80.0f ;

	setFocal(5.0f) ;

	dl_norm = glGenLists(1) ;
	if(this->shaderOk)
	{
		shaders[0].loadShaders("phong_vs.txt", "phong_ps.txt") ;
		shaders[1].loadShaders("flat_vs.txt", "flat_ps.txt", "flat_gs.txt") ;
	}
}

void MyGlutWin::init()
{
	normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ;
	diffCoord = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "diffCoord") ;
	k1 = myMap.addAttribute<PFP::REAL>(VERTEX_ORBIT, "k1") ;
	k2 = myMap.addAttribute<PFP::REAL>(VERTEX_ORBIT, "k2") ;
	K1 = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "K1") ;
	K2 = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "K2") ;
	color = myMap.addAttribute<Geom::Vec4f>(VERTEX_ORBIT, "color") ;

329 330 331
	vbo_render = new Algo::Render::VBO::MapRender_VBO( ) ;
	vbo_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::TRIANGLES) ;
	vbo_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::LINES) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
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 441 442 443 444 445 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 472 473 474 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 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 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 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
	updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;

	Algo::Geometry::computeLaplacianVertices<PFP>(myMap, Algo::Geometry::TOPOLOGICAL, position, diffCoord) ;

	vIndex = myMap.addAttribute<unsigned int>(VERTEX_ORBIT, "index") ;
	nb_vertices = myMap.computeIndexCells(vIndex) ;

	solver = new LinearSolver<CPUSolverTraits>(nb_vertices) ;

	select_area = gWidthObj / (100.0f * getScale()) ;
}

void MyGlutWin::initGUI()
{
	viewer_bar = TwNewBar("Viewer") ;
	TwDefine("Viewer position='16 16' size='220 400' valueswidth='85'") ;

	TwType tw_render_style = TwDefineEnum("Shading","Flat,Gouraud,Phong") ;
	TwAddVarCB(viewer_bar, "RenderStyle", tw_render_style, setRenderStyleCB, getRenderStyleCB, this, "") ;
	TwAddVarCB(viewer_bar, "Shininess", TW_TYPE_FLOAT, setShininessCB, getShininessCB, this, "min=1 max=255 step=1") ;
	TwAddVarCB(viewer_bar, "Focal", TW_TYPE_FLOAT, setFocalCB, getFocalCB, this, "min=0.6 max=5.0 step=0.1") ;
	TwAddVarCB(viewer_bar, "Show Object", TW_TYPE_BOOL8, setRenderObjectCB, getRenderObjectCB, this, "") ;
	TwAddVarCB(viewer_bar, "Show Lines", TW_TYPE_BOOL8, setRenderLinesCB, getRenderLinesCB, this, "") ;
	TwAddVarCB(viewer_bar, "Show Normals", TW_TYPE_BOOL8, setRenderNormalsCB, getRenderNormalsCB, this, "") ;
	TwAddVarCB(viewer_bar, "NormalScaleFactor", TW_TYPE_FLOAT, setNormalScaleFactorCB, getNormalScaleFactorCB, this, "min=0.1 max=5.0 step=0.1") ;
	TwDefine("Viewer/NormalScaleFactor visible=false") ;
	TwAddVarCB(viewer_bar, "FaceShrinkage", TW_TYPE_FLOAT, setFaceShrinkageCB, getFaceShrinkageCB, this, "min=0.0 max=0.9 step=0.01") ;
	TwDefine("Viewer/FaceShrinkage visible=false") ;
	TwAddVarCB(viewer_bar, "Show Curvature", TW_TYPE_BOOL8, setShowCurvatureCB, getShowCurvatureCB, this, "") ;
	TwAddVarCB(viewer_bar, "CurvatureDirections", TW_TYPE_BOOL8, setShowCurvatureDirectionsCB, getShowCurvatureDirectionsCB, this, "") ;
	TwType tw_curvature_type = TwDefineEnum("CurvatureType","Mean,Gaussian") ;
	TwAddVarCB(viewer_bar, "CurvType", tw_curvature_type, setCurvatureTypeCB, getCurvatureTypeCB, this, "") ;
	TwType tw_curvature_dir = TwDefineEnum("CurvatureDir","Both,Min,Max") ;
	TwAddVarCB(viewer_bar, "CurvDir", tw_curvature_dir, setCurvatureDirCB, getCurvatureDirCB, this, "") ;
	TwAddVarCB(viewer_bar, "CurvMultiplicator", TW_TYPE_FLOAT, setCurvMultiplicatorCB, getCurvMultiplicatorCB, this, "min=0.1 max=10.0 step=0.1") ;
	TwDefine("Viewer/CurvatureDirections visible=false") ;
	TwDefine("Viewer/CurvType visible=false") ;
	TwDefine("Viewer/CurvDir visible=false") ;
	TwDefine("Viewer/CurvMultiplicator visible=false") ;

	TwAddSeparator(viewer_bar, "", "") ;

	TwType tw_solver_type = TwDefineEnum("Solver","Iterative,Direct") ;
	TwAddVarCB(viewer_bar, "SolverType", tw_solver_type, setSolverTypeCB, getSolverTypeCB, this, "") ;
#ifdef WITH_CUDA
	TwAddVarRW(viewer_bar, "GPUSolver", TW_TYPE_BOOL8, &gpuSolver, "") ;
#endif

	TwAddSeparator(viewer_bar, "", "") ;

	TwAddButton(viewer_bar, "Smooth", smoothCB, this, "") ;
	TwAddButton(viewer_bar, "SmoothCurvature", smoothCurvatureCB, this, "") ;
	TwAddVarRW(viewer_bar, "Smooth Amount", TW_TYPE_FLOAT, &smoothAmount, "min=0.01 max=1.0 step=0.01") ;
	TwAddButton(viewer_bar, "LSM", lsmCB, this, "") ;
	TwAddButton(viewer_bar, "DiffCoord", diffCoordCB, this, "") ;
}

void MyGlutWin::myRedraw()
{
	GLfloat black[4] = { 0.0f, 0.0f, 0.0f, 1.0f } ;
	GLfloat amb[4] = { 0.2f, 0.1f, 0.1f, 1.0f } ;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;

	glPushMatrix() ;

	float sc = 50. / gWidthObj ;
	glScalef(sc, sc, sc) ;
	glTranslatef(-gPosObj[0], -gPosObj[1], -gPosObj[2]) ;

	if(renderLines)
	{
		glDisable(GL_LIGHTING);
		glColor3f(0.0f,0.0f,0.0f);
		vbo_render->disableBuffers(Algo::Render::VBO::COLORS) ;
		vbo_render->draw(Algo::Render::VBO::LINES) ;
		vbo_render->enableBuffers(Algo::Render::VBO::COLORS) ;
	}

	if(renderNormals)
		glCallList(dl_norm) ;

	glEnable(GL_POLYGON_OFFSET_FILL) ;
	glPolygonOffset(1.0f, 1.0f) ;

	if(renderObject)
	{
		if(showCurvature)
		{
			glEnable(GL_COLOR_MATERIAL) ;
			if(showCurvatureDirections)
				render(CURVATURE_DIRECTIONS) ;
		}
		else
		{
			glDisable(GL_COLOR_MATERIAL) ;
			glMaterialfv(GL_FRONT, GL_DIFFUSE, colDif.data()) ;
			glMaterialfv(GL_FRONT, GL_AMBIENT, amb) ;
			if(renderStyle != PHONG)
			{
				glMaterialfv(GL_FRONT, GL_SPECULAR, black) ;
				glMaterialf(GL_FRONT, GL_SHININESS, 1.0f) ;
			}
			else
			{
				glMaterialfv(GL_FRONT, GL_SPECULAR, colSpec.data()) ;
				glMaterialf(GL_FRONT, GL_SHININESS, shininess) ;
			}
		}

		glEnable(GL_LIGHTING) ;
		glEnable(GL_CULL_FACE) ;
		glPolygonMode(GL_FRONT, GL_FILL) ;
		if(renderStyle == FLAT)
		{
			glShadeModel(GL_FLAT) ;
			shaders[1].bind() ;
			glUniform1fARB(glGetUniformLocationARB(shaders[1].program_handler(),"explode"), faceShrinkage) ;
			vbo_render->draw(Algo::Render::VBO::TRIANGLES) ;
			shaders[1].unbind() ;
		}
		else
		{
			glShadeModel(GL_SMOOTH) ;
			if(renderStyle == PHONG)
				shaders[0].bind() ;
			vbo_render->draw(Algo::Render::VBO::TRIANGLES) ;
			if(renderStyle == PHONG)
				shaders[0].unbind() ;
		}

		render(VERTICES) ;
	}

	glDisable(GL_POLYGON_OFFSET_FILL) ;

	glPopMatrix() ;

	glColor3f(1.0f, 1.0f, 1.0f) ;
	int x = getWinWidth() - 170 ;
	printString2D(
		x,
		20,
		"Keys :\n"
		"----\n"
		"'l' : define locked vertices\n"
		"'h' : define handle vertices\n"
		"'x' : deselect vertices\n"
	) ;
}

void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
{
	switch(keycode)
	{
		case 'l' : {
			def_locked = true ;
			def_handle = false ;
			break ;
		}

		case 'h' : {
			def_handle = true ;
			def_locked = false ;
			break ;
		}

		case 'x' : {
			deselectAllVertices() ;
			glutPostRedisplay() ;
			break ;
		}

		case '+' : {
			select_area *= 1.1f ;
			break ;
		}

		case '-' : {
			select_area /= 1.1f ;
			break ;
		}

		case 's' : {
			bool success = Algo::Export::exportOFF<PFP>(myMap, position, "export.off") ;
			if(!success)
			{
				std::cerr << "warning export of file export.off failed" << std::endl ;
			}
		}
	}
}

void MyGlutWin::myMouse(int button, int state, int x, int y)
{
	if(button == GLUT_LEFT_BUTTON && (glutGetModifiers() & GLUT_ACTIVE_SHIFT) && state == GLUT_DOWN)
		selecting = 1 ;
	else if(button == GLUT_RIGHT_BUTTON && (glutGetModifiers() & GLUT_ACTIVE_SHIFT) && state == GLUT_DOWN)
		deselecting = 1 ;
	else if(button == GLUT_LEFT_BUTTON && (glutGetModifiers() & GLUT_ACTIVE_CTRL) && state == GLUT_DOWN)
		dragging = 1 ;
	else
	{
		selecting = 0 ;
		deselecting = 0 ;
		dragging = 0 ;
	}

	if(selecting)
	{
		glPushMatrix() ;

		float sc = 50.0f / gWidthObj ;
		glScalef(sc, sc, sc) ;
		glTranslatef(-gPosObj[0], -gPosObj[1], -gPosObj[2]) ;

		Geom::Vec3f rayA, rayB ;
		getOrthoScreenRay(x, y, rayA, rayB) ;
		Geom::Vec3f AB = rayB - rayA ;
		Dart d ;
		Algo::Selection::vertexRaySelection<PFP>(myMap, position, rayA, AB, d) ;

		glPopMatrix();

		if(d != myMap.end())
			selectVertex(d) ;

		glutPostRedisplay() ;
	}
	else if(deselecting)
	{
		glPushMatrix() ;

		float sc = 50.0f / gWidthObj ;
		glScalef(sc, sc, sc) ;
		glTranslatef(-gPosObj[0], -gPosObj[1], -gPosObj[2]) ;

		Geom::Vec3f rayA, rayB ;
		getOrthoScreenRay(x, y, rayA, rayB) ;
		Geom::Vec3f AB = rayB - rayA ;
		Dart d ;
		Algo::Selection::vertexRaySelection<PFP>(myMap, position, rayA, AB, d) ;

		glPopMatrix();

		if(d != myMap.end())
			deselectVertex(d) ;

		glutPostRedisplay() ;
	}
}

void MyGlutWin::myMotion(int x, int y)
{
	if(dragging)
	{
		++skipCount ;
		if(skipCount % 5)
			return ;

		float sc = 1.0 / getScale() ;
		Geom::Vec4f d(0.01f*sc*(x-beginx), 0.01f*sc*(beginy-y), 0.0f, 1.0f) ;
		Geom::Vec4f t(0) ;
		GLfloat m[4][4] ;
		Utils::build_rotmatrix(m, getSceneQuaternion()) ;
		for(int i = 0; i < 4; ++i)
			for(int j = 0; j < 4; ++j)
				t[i] += m[i][j] * d[j] ;

		for(unsigned int i = 0; i < handle_vertices.size(); ++i)
		{
			PFP::VEC3& p = position[handle_vertices[i]] ;
			p[0] += t[0] / t[3] ;
			p[1] += t[1] / t[3] ;
			p[2] += t[2] / t[3] ;
		}

		matchDiffCoord(true) ;

		if(showCurvature)
			updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS | Algo::Render::VBO::COLORS) ;
		else
			updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
		if(renderNormals)
			initDLNormals() ;
		glutPostRedisplay() ;
	}
}

void MyGlutWin::updateVBOdata(int upType, bool recompute)
{
	if(upType & Algo::Render::VBO::POSITIONS)
		vbo_render->updateData(Algo::Render::VBO::POSITIONS, position) ;

	if(upType & Algo::Render::VBO::NORMALS)
	{
		if(recompute)
			Algo::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
		vbo_render->updateData(Algo::Render::VBO::NORMALS, normal) ;
		if(renderNormals)
			initDLNormals() ;
	}

	if(upType & Algo::Render::VBO::COLORS)
	{
		if(recompute)
			Algo::Geometry::computeCurvatureVertices<PFP>(myMap, position, normal, k1, k2, K1, K2) ;
		float minC = std::numeric_limits<float>::max() ;
		float maxC = std::numeric_limits<float>::min() ;
		AttribContainer& vertexAttr = myMap.getAttributeContainer(VERTEX_ORBIT) ;
		for(unsigned int i = vertexAttr.begin(); i < vertexAttr.end(); vertexAttr.next(i))
		{
			PFP::REAL c=0.0;
			if(curvatureType == MEAN)
				c = ( k1[i] + k2[i] ) / PFP::REAL(2) ;
			else if(curvatureType == GAUSSIAN)
				c = k1[i] * k2[i] ;
			minC = c < minC ? c : minC ;
			maxC = c > maxC ? c : maxC ;
		}
		float r = 0.0f, g = 0.0f, b = 0.0f ;
		for(unsigned int i = vertexAttr.begin(); i < vertexAttr.end(); vertexAttr.next(i))
		{
			PFP::REAL c=0.0;
			if(curvatureType == MEAN)
				c = ( k1[i] + k2[i] ) / PFP::REAL(2) ;
			else if(curvatureType == GAUSSIAN)
				c = k1[i] * k2[i] ;
			c *= curvMultiplicator ;
			if(c < 0.0f) { c = c / minC ; r = 1.0f ; g = 1.0f - (2.0f*c) ; b = 1.0f - (2.0f*c) ; }
			else { c = c / maxC ; r = 1.0f - (2.0f*c) ; g = 1.0f - (2.0f*c) ; b = 1.0f ; }
			color[i] = Geom::Vec4f(r,g,b,1.0f) ;
		}
		vbo_render->updateData(Algo::Render::VBO::COLORS, color) ;
	}
}

void MyGlutWin::initDLNormals()
{
	glNewList(dl_norm, GL_COMPILE) ;
	render(NORMAL) ;
	glEndList() ;
}

void MyGlutWin::render(int renderMode)
{
	switch(renderMode)
	{
		case VERTICES : {
			glDisable(GL_LIGHTING) ;
			glPointSize(4.0f);
			glBegin(GL_POINTS);
			glColor3f(1.0f, 0.0f, 0.0f) ;
			for(unsigned int i = 0; i < locked_vertices.size(); ++i)
			{
				if (!handleMarker.isMarked(locked_vertices[i]))
					glVertex3fv(position[locked_vertices[i]].data()) ;
			}
			glColor3f(0.0f, 0.0f, 1.0f) ;
			for(unsigned int i = 0; i < handle_vertices.size(); ++i)
				glVertex3fv(position[handle_vertices[i]].data()) ;
			glEnd() ;
			break ;
		}

		case NORMAL : {
			glLineWidth(1.0f) ;
			glDisable(GL_LIGHTING) ;
			glColor3fv(colNormal.data()) ;
			Algo::Render::Direct::renderNormalVertices<PFP>(myMap, position, normal, normalScaleFactor * normalBaseSize) ;
			break ;
		}

		case CURVATURE_DIRECTIONS : {
			glLineWidth(1.0f) ;
			glDisable(GL_LIGHTING) ;
			AttribContainer vertexAttr = myMap.getAttributeContainer(VERTEX_ORBIT) ;
			if(curvatureDir == 0 || curvatureDir == 2)
			{
				glColor3f(0.0f, 1.0f, 0.0f) ;
				glBegin(GL_LINES) ;
				for(unsigned int i = vertexAttr.begin(); i < vertexAttr.end(); vertexAttr.next(i))
				{
					PFP::VEC3 dir = K1[i] * normalScaleFactor * normalBaseSize * 0.5f ;
					PFP::VEC3 p1 = position[i] - dir ;
					PFP::VEC3 p2 = position[i] + dir ;
					glVertex3fv(p1.data()) ;
					glVertex3fv(p2.data()) ;
				}
				glEnd() ;
			}
			if(curvatureDir == 0 || curvatureDir == 1)
			{
				glColor3f(0.0f, 1.0f, 0.0f) ;
				glBegin(GL_LINES) ;
				for(unsigned int i = vertexAttr.begin(); i < vertexAttr.end(); vertexAttr.next(i))
				{
					PFP::VEC3 dir = K2[i] * normalScaleFactor * normalBaseSize * 0.5f ;
					PFP::VEC3 p1 = position[i] - dir ;
					PFP::VEC3 p2 = position[i] + dir ;
					glVertex3fv(p1.data()) ;
					glVertex3fv(p2.data()) ;
				}
				glEnd() ;
			}
			break ;
		}
	}
}
/*
void MyGlutWin::selectVertices(Dart d, float dist)
{
	gmtl::Vec3f p = myMap.getVertexEmb(d)->getPosition() ;
	std::vector<Embedding*> selected_vertices ;

	Marker visited = myMap.getNewMarker() ;
	std::list<Dart> darts ;
	darts.push_back(d) ;
	std::list<Dart>::iterator it = darts.begin() ;
	do
	{
		myMap.markOrbit(0, *it, visited) ;
		EMB* e = reinterpret_cast<EMB*>(myMap.getVertexEmb(*it)) ;
		gmtl::Vec3f pos = e->getPosition() ;
		pos -= p ;
		if(gmtl::lengthSquared(pos) < dist*dist)
		{
			selected_vertices.push_back(e) ;
			Dart vit = *it ;
			do
			{
				if(!myMap.isMarkedDart(myMap.phi2(vit), visited))
					darts.push_back(myMap.phi2(vit)) ;
				vit = myMap.phi1(myMap.phi2(vit)) ;
			} while(vit != *it) ;
		}
		++it ;
	} while(it != darts.end()) ;
	for(it = darts.begin(); it != darts.end(); ++it)
		myMap.unmarkOrbit(0, *it, visited) ;
	myMap.releaseMarker(visited) ;

	if(def_locked)
	{
		for(unsigned int i = 0; i < selected_vertices.size(); ++i)
		{
			Embedding* sv = selected_vertices[i] ;
			if(!sv->testMarker(lockingMarker))
			{
				locked_vertices.push_back(sv) ;
				sv->setMarker(lockingMarker) ;
			}
		}
		solver->reset(false) ;
	}
	else if(def_handle)
	{
		for(unsigned int i = 0; i < selected_vertices.size(); ++i)
		{
			Embedding* sv = selected_vertices[i] ;
			if(!sv->testMarker(handleMarker))
			{
				handle_vertices.push_back(sv) ;
				sv->setMarker(handleMarker) ;
			}
			if(!sv->testMarker(lockingMarker))
			{
				locked_vertices.push_back(sv) ;
				sv->setMarker(lockingMarker) ;
			}
		}
		solver->reset(false) ;
	}
}
*/
void MyGlutWin::selectVertex(Dart sd)
{
	unsigned int v = myMap.getEmbedding(sd, VERTEX_ORBIT) ;

	if(def_locked)
	{
		if (!lockingMarker.isMarked(v))
		{
			locked_vertices.push_back(v) ;
			lockingMarker.mark(v);
			LinearSolving::resetSolver(solver, false) ;
		}
	}
	else if(def_handle)
	{
		if(!handleMarker.isMarked(v))
		{
			handle_vertices.push_back(v) ;
			handleMarker.mark(v);
		}
		if(!lockingMarker.isMarked(v))
		{
			locked_vertices.push_back(v) ;
			lockingMarker.mark(v) ;
			LinearSolving::resetSolver(solver, false) ;
		}
	}
}

void MyGlutWin::deselectVertex(Dart d)
{
	unsigned int v = myMap.getEmbedding(d, VERTEX_ORBIT) ;

	if(def_locked)
	{
		bool found = false ;
		unsigned int i ;
		for(i = 0; i < locked_vertices.size() && !found; ++i)
		{
			if(locked_vertices[i] == v)
				found = true ;
		}
		if(found)
		{
			lockingMarker.unmark(locked_vertices[i-1]);
			locked_vertices[i-1] = locked_vertices.back() ;
			locked_vertices.pop_back() ;
			LinearSolving::resetSolver(solver, false) ;
		}
		found = false ;
		for(i = 0; i < handle_vertices.size() && !found; ++i)
		{
			if(handle_vertices[i] == v)
				found = true ;
		}
		if(found)
		{
			handleMarker.unmark(handle_vertices[i-1]);
			handle_vertices[i-1] = handle_vertices.back() ;
			handle_vertices.pop_back() ;
		}
	}
	else if(def_handle)
	{
		bool found = false ;
		unsigned int i ;
		for(i = 0; i < handle_vertices.size() && !found; ++i)
		{
			if(handle_vertices[i] == v)
				found = true ;
		}
		if(found)
		{
			handleMarker.unmark(handle_vertices[i-1]);
			handle_vertices[i-1] = handle_vertices.back() ;
			handle_vertices.pop_back() ;
		}
	}
}

void MyGlutWin::deselectAllVertices()
{
	if(def_locked)
	{
		for(unsigned int i = 0; i < locked_vertices.size(); ++i)
			lockingMarker.unmark(locked_vertices[i]);
		locked_vertices.clear() ;
		for(unsigned int i = 0; i < handle_vertices.size(); ++i)
			handleMarker.unmark(handle_vertices[i]);
		handle_vertices.clear() ;
		LinearSolving::resetSolver(solver, false) ;
	}
	else if(def_handle)
	{
		for(unsigned int i = 0; i < handle_vertices.size(); ++i)
			handleMarker.unmark(handle_vertices[i]);
		handle_vertices.clear() ;
	}
}

/**********************************************************************************************
 *                                      SMOOTH & DEFORM                                       *
 **********************************************************************************************/

void MyGlutWin::smooth()
{
	std::cout << "Start smoothing.." << std::flush ;
    GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;

	LinearSolving::initSolver(solver, nb_vertices, true, solverType == DIRECT ? true : false) ;
	LinearSolving::resetSolver(solver, false) ;
	float params[1] ;
	params[0] = smoothAmount ;
	for(int coord = 0; coord < 3; ++coord)
	{
		LinearSolving::setupVariables<PFP, PFP::VEC3>(myMap, solver, lockingMarker, position, coord, vIndex) ;
		LinearSolving::startMatrix(solver) ;
		LinearSolving::addMatrixRows<PFP, PFP::VEC3>(myMap, solver, position, LinearSolving::LAPLACIAN_TOPO, coord, vIndex) ;
		LinearSolving::addMatrixRows<PFP, PFP::VEC3>(myMap, solver, position, LinearSolving::EQUALITY, coord, vIndex, params) ;
		LinearSolving::endMatrix(solver) ;
		LinearSolving::solve(solver) ;
		LinearSolving::getResult<PFP, PFP::VEC3>(myMap, solver, position, coord, vIndex) ;
		LinearSolving::resetSolver(solver, true) ;
	}

	GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
	GLfloat seconds = (t2 - t1) / 1000.0f ;
	std::cout << "..done (" << seconds << " sec)" << std::endl ;
}

void MyGlutWin::smoothCurvature()
{
	std::cout << "Start smoothing curvature.." << std::flush ;
	GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;

	LinearSolving::initSolver(solver, nb_vertices, true, solverType == DIRECT ? true : false) ;
	LinearSolving::resetSolver(solver, false) ;
	float params[1] ;
	params[0] = smoothAmount ;

	LinearSolving::setupVariables<PFP, PFP::REAL>(myMap, solver, lockingMarker, k1, vIndex) ;
	LinearSolving::startMatrix(solver) ;
	LinearSolving::addMatrixRows<PFP, PFP::REAL>(myMap, solver, k1, LinearSolving::LAPLACIAN_TOPO, vIndex) ;
	LinearSolving::addMatrixRows<PFP, PFP::REAL>(myMap, solver, k1, LinearSolving::EQUALITY, vIndex, params) ;
	LinearSolving::endMatrix(solver) ;
	LinearSolving::solve(solver) ;
	LinearSolving::getResult<PFP, PFP::REAL>(myMap, solver, k1, vIndex) ;

	LinearSolving::resetSolver(solver, true) ;

	LinearSolving::setupVariables<PFP, PFP::REAL>(myMap, solver, lockingMarker, k2, vIndex) ;
	LinearSolving::startMatrix(solver) ;
	LinearSolving::addMatrixRows<PFP, PFP::REAL>(myMap, solver, k2, LinearSolving::LAPLACIAN_TOPO, vIndex) ;
	LinearSolving::addMatrixRows<PFP, PFP::REAL>(myMap, solver, k2, LinearSolving::EQUALITY, vIndex, params) ;
	LinearSolving::endMatrix(solver) ;
	LinearSolving::solve(solver) ;
	LinearSolving::getResult<PFP, PFP::REAL>(myMap, solver, k2, vIndex) ;

	GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
	GLfloat seconds = (t2 - t1) / 1000.0f ;
	std::cout << "..done (" << seconds << " sec)" << std::endl ;
}

void MyGlutWin::lsm()
{
	if(locked_vertices.size() > 4)
	{
		std::cout << "Start least square mesh.." << std::flush ;
	    GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;

		LinearSolving::initSolver(solver, nb_vertices, true, solverType == DIRECT ? true : false) ;
		LinearSolving::resetSolver(solver, false) ;
		for(int coord = 0; coord < 3; ++coord)
		{
			LinearSolving::setupVariables<PFP, PFP::VEC3>(myMap, solver, lockingMarker, position, coord, vIndex) ;
			LinearSolving::startMatrix(solver) ;
			LinearSolving::addMatrixRows<PFP, PFP::VEC3>(myMap, solver, position, LinearSolving::LAPLACIAN_TOPO, coord, vIndex) ;
			LinearSolving::endMatrix(solver) ;
			LinearSolving::solve(solver) ;
			LinearSolving::getResult<PFP, PFP::VEC3>(myMap, solver, position, coord, vIndex) ;
			LinearSolving::resetSolver(solver, true) ;
		}

	    GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
	    GLfloat seconds = (t2 - t1) / 1000.0f ;
		std::cout << "..done (" << seconds << " sec)" << std::endl ;
	}
}

void MyGlutWin::matchDiffCoord(bool keepMatrix)
{
//	std::cout << "Start matching diff coord.." << std::flush ;
//	GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;

	LinearSolving::initSolver(solver, nb_vertices, true, solverType == DIRECT ? true : false) ;
	if(!keepMatrix)
		LinearSolving::resetSolver(solver, false) ;
	for(int coord = 0; coord < 3; ++coord)
	{
		LinearSolving::setupVariables<PFP, PFP::VEC3>(myMap, solver, lockingMarker, position, coord, vIndex) ;
		LinearSolving::startMatrix(solver) ;
		FunctorMatrixRowDiffCoord<PFP, CPUSolverTraits> fmrdc(myMap, solver, diffCoord, coord, vIndex) ;
		myMap.foreach_orbit(VERTEX_ORBIT, fmrdc) ;
		LinearSolving::endMatrix(solver) ;
		LinearSolving::solve(solver) ;
		LinearSolving::getResult<PFP, PFP::VEC3>(myMap, solver, position, coord, vIndex) ;
		LinearSolving::resetSolver(solver, true) ;
	}

//	GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
//	GLfloat seconds = (t2 - t1) / 1000.0f ;
//	std::cout << "..done (" << seconds << " sec)" << std::endl ;
}

/**********************************************************************************************
 *                                      MAIN FUNCTION                                         *
 **********************************************************************************************/

int main(int argc, char** argv)
{
	if(argc < 2)
	{
		std::cerr << "syntax: " << argv[0] << " filename" << std::endl ;
		return 1 ;
	}

	MyGlutWin* mgw = new MyGlutWin(&argc, argv, 1200, 800) ;

	char* filename = argv[1] ;

	GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
1037 1038
	std::vector<std::string> attrNames ;
	if(!Algo::Import::importMesh<PFP>(myMap, filename, attrNames))
Pierre Kraemer's avatar
Pierre Kraemer committed
1039 1040 1041 1042
	{
		std::cerr << "could not import "<< filename << std::endl ;
		return 1 ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
1043
	mgw->position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
	GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
	GLfloat seconds = (t2 - t1) / 1000.0f ;
	std::cout << "import: " << seconds << " sec" << std::endl ;

	// compute width and position of object for centering
	Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, mgw->position) ;
	mgw->gPosObj = bb.center() ;
	float tailleX = bb.size(0) ;
	float tailleY = bb.size(1) ;
	float tailleZ = bb.size(2) ;

	mgw->gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
	mgw->normalBaseSize = std::min<float>(std::min<float>(tailleX,tailleY),tailleZ) / 50.0f ;

	mgw->init() ;
	mgw->initGUI() ;
	mgw->mainLoop() ;

	return 0 ;
}