volumeExplorer.cpp 15.6 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1 2 3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Sylvain Thery's avatar
Sylvain Thery 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/                                           *
Sylvain Thery's avatar
Sylvain Thery committed
21 22 23 24 25 26 27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "volumeExplorer.h"
#include <iostream>

untereiner's avatar
untereiner committed
28
#include "Algo/Tiling/Volume/cubic.h"
Sylvain Thery's avatar
Sylvain Thery committed
29 30
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Import/import.h"
31
#include "Algo/Geometry/volume.h"
Lionel Untereiner's avatar
Lionel Untereiner committed
32
#include "Algo/Modelisation/tetrahedralization.h"
33
#include "Algo/Geometry/area.h"
Sylvain Thery's avatar
Sylvain Thery committed
34 35


36 37
#include "Utils/chrono.h"

38 39
#include "Algo/Export/exportVol.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
40
MAP myMap;
41 42
VertexAttribute<VEC3, MAP> position ;
VolumeAttribute<VEC3, MAP> color ;
Sylvain Thery's avatar
Sylvain Thery committed
43

44
void MyQT::volumes_onoff(bool /*x*/)
Sylvain Thery's avatar
Sylvain Thery committed
45 46 47 48 49
{
	render_volumes = !render_volumes;
	updateGL();
}

50
void MyQT::edges_onoff(bool /*x*/)
Sylvain Thery's avatar
Sylvain Thery committed
51 52 53 54 55
{
	render_edges = !render_edges;
	updateGL();
}

56
void MyQT::topo_onoff(bool /*x*/)
Sylvain Thery's avatar
Sylvain Thery committed
57 58 59 60
{
	render_topo = !render_topo;
	if (render_topo)
	{
61
//		SelectorDartNoBoundary<MAP> nb(myMap);
62
		//TODO MapBrowser
Pierre Kraemer's avatar
Pierre Kraemer committed
63
		m_topo_render->updateData(myMap, position, 0.8f, m_explode_factorf-0.05f, m_explode_factor);
Sylvain Thery's avatar
Sylvain Thery committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	}

	updateGL();
}

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
		float d = -(pos*normal);
		m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
Sylvain Thery's avatar
Sylvain Thery committed
80 81
		m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
		m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
Sylvain Thery's avatar
Sylvain Thery committed
82 83 84 85
	}
	else
	{
		m_explode_render->setNoClippingPlane();
Sylvain Thery's avatar
Sylvain Thery committed
86 87 88 89
		m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
		m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
		m_sh1->setClipColorAttenuationFactorRelative(0.0f,0.0f);
		m_sh2->setClipColorAttenuationFactorRelative(0.0f,0.0f);
Sylvain Thery's avatar
Sylvain Thery committed
90 91 92 93
	}
	updateGL();
}

94
void MyQT::hide_onoff(bool /*x*/)
Sylvain Thery's avatar
Sylvain Thery committed
95 96 97 98 99 100 101
{
	hide_clipping = !hide_clipping;
	updateGL();
}

void MyQT::slider_explode(int x)
{
102
	m_explode_factor = 0.01f*(x+1)-0.0001f;
Sylvain Thery's avatar
Sylvain Thery committed
103 104 105 106
	m_explode_render->setExplodeVolumes(m_explode_factor);
	updateGL();
}

107 108 109 110 111 112 113
void MyQT::slider_explodeF(int x)
{
	m_explode_factorf = 0.01f*(x+1);
	m_explode_render->setExplodeFaces(m_explode_factorf);
	updateGL();
}

Sylvain Thery's avatar
Sylvain Thery committed
114 115 116 117 118 119 120 121 122 123 124 125
void MyQT::slider_pressed()
{
	render_topoTemp = render_topo;
	render_topo = false;
	updateGL();
}

void MyQT::slider_released()
{
	render_topo = render_topoTemp;
	if (render_topo)
	{
126
//		SelectorDartNoBoundary<MAP> nb(myMap);
127
		//TODO MapBrowser
Pierre Kraemer's avatar
Pierre Kraemer committed
128
		m_topo_render->updateData(myMap, position, 0.8f, m_explode_factorf-0.05f, m_explode_factor );
Sylvain Thery's avatar
Sylvain Thery committed
129 130 131 132
	}
	updateGL();
}

133 134
void MyQT::cb_Open()
{
135
    std::string filters("all (*.*)") ;
136 137 138 139 140 141 142 143
	std::string filename = selectFile("Open Mesh", "", filters) ;
	if (filename.empty())
		return ;

	myMap.clear(true);

	std::vector<std::string> attrNames ;

144 145
    size_t pos = filename.rfind(".");    // position of "." in filename
    std::string extension = filename.substr(pos);
146

147 148 149 150 151 152 153 154 155
//	if(extension == std::string(".off"))
//	{
//		if(!Algo::Volume::Import::importMeshToExtrude<PFP>(myMap, filename, attrNames))
//		{
//			std::cerr << "could not import " << filename << std::endl ;
//			return ;
//		}
//		else
//		{
156
//			position = myMap.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
157 158 159
//			myMap.closeMap();
//		}
//	}
160 161
//	else
//	{
162
		if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
163 164 165 166 167
		{
			std::cerr << "could not import " << filename << std::endl ;
			return ;
		}
		else
168
			position = myMap.getAttribute<VEC3, VERTEX, MAP>(attrNames[0]) ;
169
    //}
170

171
	color = myMap.addAttribute<VEC3, VOLUME, MAP>("color");
172

173
	TraversorCell<MAP, VOLUME> tra(myMap);
174 175
	for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
	{
untereiner's avatar
untereiner committed
176
//		float v = Algo::Geometry::tetrahedronVolume<PFP>(myMap, d, position);
untereiner's avatar
untereiner committed
177
		color[d] = PFP::VEC3(1.0,0,0);
178
//		color[d] = VEC3(v,0,0);
179

untereiner's avatar
untereiner committed
180 181 182
//		if (v>maxV)
//			maxV=v;

183
		if(myMap.isVolumeIncidentToBoundary(d))
184
            color[d] = VEC3(1,0.41,0.706);
185
	}
untereiner's avatar
untereiner committed
186 187 188 189 190
//	for (unsigned int i = color.begin(); i != color.end(); color.next(i))
//	{
//		color[i][0] /= maxV;
//		color[i][2] = 1.0f - color[i][0];
//	}
191

192
//	SelectorDartNoBoundary<MAP> nb(myMap);
Pierre Kraemer's avatar
Pierre Kraemer committed
193
	m_topo_render->updateData(myMap, position,  0.8f, 0.8f, 0.8f);
194 195 196 197 198
	m_explode_render->updateData<PFP>(myMap, position, color);

	updateGL() ;
}

199 200 201 202 203 204 205
void MyQT::cb_Save()
{
	std::string filters("all (*.*);; tetmesh (*.tetmesh);; tet (*.tet);; node (*.node);; msh (*.msh);; vtu (*.vtu);; nas (*.nas);; vbgz (*.vbgz)") ;
	std::string filename = selectFileSave("Save Mesh", "", filters) ;
	if (filename.empty())
		return ;

206
	Algo::Volume::Export::exportMesh<PFP>(myMap, position, filename);
207 208
}

Sylvain Thery's avatar
Sylvain Thery committed
209 210 211
void MyQT::cb_initGL()
{
	// create the renders
Pierre Kraemer's avatar
Pierre Kraemer committed
212
	m_topo_render = new Algo::Render::GL2::Topo3RenderMap<PFP>();
Lionel Untereiner's avatar
Lionel Untereiner committed
213
    m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
Sylvain Thery's avatar
Sylvain Thery committed
214

215
//	SelectorDartNoBoundary<MAP> nb(myMap);
Pierre Kraemer's avatar
Pierre Kraemer committed
216
	m_topo_render->updateData(myMap, position,  0.8f, 0.8f, 0.8f);
217
	m_explode_render->updateData<PFP>(myMap, position, color);
Sylvain Thery's avatar
Sylvain Thery committed
218
	m_explode_render->setExplodeVolumes(0.8f);
219
	m_explode_render->setExplodeFaces(0.9f);
Sylvain Thery's avatar
Sylvain Thery committed
220
	m_explode_render->setAmbiant(Geom::Vec4f(0.2f,0.2f,0.2f,1.0f));
221
	m_explode_render->setBackColor(Geom::Vec4f(0.9f,0.9f,0.9f,1.0f));
Sylvain Thery's avatar
Sylvain Thery committed
222 223
	m_explode_render->setColorLine(Geom::Vec4f(0.8f,0.2f,0.2f,1.0f));

Sylvain Thery's avatar
Sylvain Thery committed
224 225 226
	m_sh1 = static_cast<Utils::ClippingShader*>(m_topo_render->shader1());
	m_sh2 = static_cast<Utils::ClippingShader*>(m_topo_render->shader2());

Sylvain Thery's avatar
Sylvain Thery committed
227 228 229 230 231 232 233 234
	registerShader(m_explode_render->shaderFaces());
	registerShader(m_explode_render->shaderLines());

    m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
	m_frame = new Utils::FrameManipulator();
	m_frame->setSize(m_WidthObj/2.0f);


Sylvain Thery's avatar
Sylvain Thery committed
235 236
	m_sh1->insertClippingCode();
	m_sh2->insertClippingCode();
Sylvain Thery's avatar
Sylvain Thery committed
237

Sylvain Thery's avatar
Sylvain Thery committed
238 239
	clip_id1 = m_sh1->addClipPlane();
	clip_id2 = m_sh2->addClipPlane();
Sylvain Thery's avatar
Sylvain Thery committed
240

Sylvain Thery's avatar
Sylvain Thery committed
241 242
	m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), m_PosObj);
	m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), m_PosObj);
Sylvain Thery's avatar
Sylvain Thery committed
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
	m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1)));

}



void MyQT::cb_redraw()
{
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glEnable(GL_LIGHTING);

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

	if (render_topo)
		m_topo_render->drawTopo();

	if (render_edges)
	{
		glLineWidth(2.0f);
		m_explode_render->drawEdges();
	}

	glDisable(GL_POLYGON_OFFSET_FILL);

	if (render_volumes)
	{
		m_explode_render->drawFaces();
	}

	if (clip_volume && !hide_clipping)
	{
		m_frame->draw();
		m_PlanePick->draw();
	}
}


281
void  MyQT::cb_mousePress(int /*button*/, int x, int y)
Sylvain Thery's avatar
Sylvain Thery committed
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
{
	if (!Shift())
		return;

	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();
	}
}

310
void  MyQT::cb_mouseRelease(int /*button*/, int /*x*/, int /*y*/)
Sylvain Thery's avatar
Sylvain Thery committed
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
{

	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
	float d = -(pos*normal);
	m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));

Sylvain Thery's avatar
Sylvain Thery committed
370 371
	m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
	m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
Sylvain Thery's avatar
Sylvain Thery committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385

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

}

int main(int argc, char **argv)
{
	if (argc>1)
	{
		std::vector<std::string> attrNames ;
		std::string filename(argv[1]);
386 387
        size_t pos = filename.rfind(".");    // position of "." in filename
        std::string extension = filename.substr(pos);
388
/*
389
		if(extension == std::string(".off"))
Sylvain Thery's avatar
Sylvain Thery committed
390
		{
391
			if(!Algo::Volume::Import::importMeshToExtrude<PFP>(myMap, filename, attrNames))
Sylvain Thery's avatar
Sylvain Thery committed
392
			{
393
				std::cerr << "could not import " << filename << std::endl ;
Sylvain Thery's avatar
Sylvain Thery committed
394 395 396
				return 1;
			}
			else
untereiner's avatar
untereiner committed
397
			{
398
				position = myMap.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
399
				myMap.closeMap();
untereiner's avatar
untereiner committed
400 401
			}
		}
402
		else
403
		{
404
*/
Sylvain Thery's avatar
Sylvain Thery committed
405

406
		if(extension == std::string(".mapbin"))
Sylvain Thery's avatar
Sylvain Thery committed
407 408 409 410 411 412
		{
			myMap.loadMapBin(filename);
			position = myMap.getAttribute<VEC3, VERTEX,MAP>("position") ;
		}
		else
		{
413
			if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
414 415 416 417 418
			{
				std::cerr << "could not import " << filename << std::endl ;
				return 1;
			}
			else
419
				position = myMap.getAttribute<VEC3, VERTEX, MAP>(attrNames[0]) ;
Sylvain Thery's avatar
Sylvain Thery committed
420
		}
untereiner's avatar
untereiner committed
421

Sylvain Thery's avatar
Sylvain Thery committed
422
		color = myMap.addAttribute<VEC3, VOLUME, MAP>("colorVol");
423

424
		TraversorCell<MAP, VOLUME> tra(myMap);
425 426
		float maxV = 0.0f;
		for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
427
		{
428

429
//			float v = Algo::Geometry::tetrahedronVolume<PFP>(myMap, d, position);
untereiner's avatar
untereiner committed
430
			color[d] = PFP::VEC3(1.0,0,0);
untereiner's avatar
untereiner committed
431 432 433
//			if (v>maxV)
//				maxV=v;

434 435
            if(myMap.isVolumeIncidentToBoundary(d))
                color[d] = PFP::VEC3(1,0.41,0.706);
untereiner's avatar
untereiner committed
436 437
			//else
			//    color[d] = PFP::VEC3(1.0,0,0);
438
/*
439
			float v = Algo::Geometry::tetrahedronVolume<PFP>(myMap, d, position);
440
			color[d] = VEC3(v,0,0);
441 442
			if (v>maxV)
				maxV=v;
untereiner's avatar
untereiner committed
443

444
//			if(myMap.isVolumeIncidentToBoundary(d))
445
//				color[d] = VEC3(0,0,0);
446
//			else
447
				color[d] = VEC3(v,0,0);
448
		}
449 450 451 452
		for (unsigned int i = color.begin(); i != color.end(); color.next(i))
		{
			color[i][0] /= maxV;
			color[i][2] = 1.0f - color[i][0];
453
*/
454
		}
455

Sylvain Thery's avatar
Sylvain Thery committed
456 457 458
	}
	else
	{
459
		position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
untereiner's avatar
untereiner committed
460

461
		int nb = 32;
462 463
		Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
		cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
464

465
		for (unsigned int i = position.begin(); i != position.end(); position.next(i))
466
		{
467
			VEC3 pert(float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0));
468 469 470
			position[i]+= pert;
		}

471 472
		color = myMap.addAttribute<VEC3, VOLUME, MAP>("color");
		TraversorW<MAP> tra(myMap);
473
		for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
474
			color[d] = position[d] + VEC3(0.5,0.5,0.5);
475 476 477
//		Algo::Volume::Export::exportMSH<PFP>(myMap,position,"/tmp/test2.msh");
//		Algo::Volume::Export::exportNAS<PFP>(myMap,position,"/tmp/test1.nas");
//		Algo::Volume::Export::exportVTU<PFP>(myMap,position,"/tmp/test3.vtu");
Sylvain Thery's avatar
Sylvain Thery committed
478
	}
Lionel Untereiner's avatar
Lionel Untereiner committed
479 480 481

    myMap.check();

Sylvain Thery's avatar
Sylvain Thery committed
482 483 484 485 486 487 488 489 490
    // un peu d'interface
	QApplication app(argc, argv);
	MyQT sqt;

	// interface de tuto5.ui
    Utils::QT::uiDockInterface dock;
    sqt.setDock(&dock);

	//  bounding box
491 492 493
	Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
	sqt.m_WidthObj = std::max<REAL>(std::max<REAL>(bb.size(0), bb.size(1)), bb.size(2));
	sqt.m_PosObj = (bb.min() +  bb.max()) / REAL(2);
Sylvain Thery's avatar
Sylvain Thery committed
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508

    // envoit info BB a l'interface
	sqt.setParamObject(sqt.m_WidthObj, sqt.m_PosObj.data());

	sqt.setCallBack( dock.checkBox_volumes, SIGNAL(toggled(bool)), SLOT(volumes_onoff(bool)) );
	sqt.setCallBack( dock.checkBox_edges, SIGNAL(toggled(bool)), SLOT(edges_onoff(bool)) );
	sqt.setCallBack( dock.checkBox_topo, SIGNAL(toggled(bool)), SLOT(topo_onoff(bool)) );

	sqt.setCallBack( dock.checkBox_hide, SIGNAL(toggled(bool)), SLOT(hide_onoff(bool)) );
	sqt.setCallBack( dock.checkBox_plane, SIGNAL(toggled(bool)), SLOT(clipping_onoff(bool)) );
	sqt.setCallBack( dock.slider_explode, SIGNAL(valueChanged(int)), SLOT(slider_explode(int)) );

	sqt.setCallBack( dock.slider_explode, SIGNAL(sliderPressed()), SLOT(slider_pressed()) );
	sqt.setCallBack( dock.slider_explode, SIGNAL(sliderReleased()), SLOT(slider_released()) );

509 510 511 512 513
	sqt.setCallBack( dock.slider_explode_face, SIGNAL(valueChanged(int)), SLOT(slider_explodeF(int)) );

	sqt.setCallBack( dock.slider_explode_face, SIGNAL(sliderPressed()), SLOT(slider_pressed()) );
	sqt.setCallBack( dock.slider_explode_face, SIGNAL(sliderReleased()), SLOT(slider_released()) );

Sylvain Thery's avatar
Sylvain Thery committed
514 515
	sqt.show();
	dock.slider_explode->setValue(80);
516
	dock.slider_explode_face->setValue(80);
Sylvain Thery's avatar
Sylvain Thery committed
517 518
	sqt.clipping_onoff(true);

519 520
	Utils::Chrono ch;

Sylvain Thery's avatar
Sylvain Thery committed
521 522
//	Vertex v(myMap.begin());
//	VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(myMap,v,position);
523

Sylvain Thery's avatar
Sylvain Thery committed
524 525
//	Vol w(myMap.begin());
//	VEC3 q = Algo::Surface::Geometry::volumeCentroid<PFP>(myMap,w,position);
526

527 528 529 530 531 532 533
	ch.start();
	float vol = Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
	vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
	vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
	vol += Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
	std::cout << ch.elapsed()<< " ms //  val="<<vol<< std::endl;

534 535
	std::cout << "Compute Volume ->"<< std::endl;
	ch.start();
536
	vol = Algo::Geometry::totalVolume<PFP>(myMap, position);
537 538
	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
	ch.start();
539
	vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
540 541
	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
	ch.start();
542
	vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
543 544
	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
	ch.start();
545 546 547
	vol += Algo::Geometry::totalVolume<PFP>(myMap, position);
	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;

Sylvain Thery's avatar
Sylvain Thery committed
548 549 550
	// et on attend la fin.
	return app.exec();
}