import.hpp 31 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-2012, 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.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/autoAttributeHandler.h"
#include "Container/fakeAttribute.h"
28
#include "Algo/Modelisation/polyhedron.h"
29
#include "Algo/Topo/basic.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
30 31 32 33 34 35 36

namespace CGoGN
{

namespace Algo
{

37 38 39
namespace Surface
{

Pierre Kraemer's avatar
Pierre Kraemer committed
40 41 42 43 44 45
namespace Import
{

template <typename PFP>
bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
{
46 47
	typedef typename PFP::MAP MAP;

48
	VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> >, MAP> vecDartsPerVertex(map, "incidents");
49

Pierre Kraemer's avatar
Pierre Kraemer committed
50 51 52 53 54
	unsigned nbf = mts.getNbFaces();
	int index = 0;
	// buffer for tempo faces (used to remove degenerated edges)
	std::vector<unsigned int> edgesBuffer;
	edgesBuffer.reserve(16);
55

56
	DartMarkerNoUnmark<MAP> m(map) ;
57

58 59
//	unsigned int vemb = EMBNULL;
//	auto fsetemb = [&] (Dart d) { map.template initDartEmbedding<VERTEX>(d, vemb); };
60

Pierre Kraemer's avatar
Pierre Kraemer committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	// for each face of table
	for(unsigned int i = 0; i < nbf; ++i)
	{
		// store face in buffer, removing degenerated edges
		unsigned int nbe = mts.getNbEdgesFace(i);
		edgesBuffer.clear();
		unsigned int prec = EMBNULL;
		for (unsigned int j = 0; j < nbe; ++j)
		{
			unsigned int em = mts.getEmbIdx(index++);
			if (em != prec)
			{
				prec = em;
				edgesBuffer.push_back(em);
			}
		}
		// check first/last vertices
		if (edgesBuffer.front() == edgesBuffer.back())
			edgesBuffer.pop_back();
80

Pierre Kraemer's avatar
Pierre Kraemer committed
81 82 83 84 85 86 87
		// create only non degenerated faces
		nbe = edgesBuffer.size();
		if (nbe > 2)
		{
			Dart d = map.newFace(nbe, false);
			for (unsigned int j = 0; j < nbe; ++j)
			{
88 89
				unsigned int vemb = edgesBuffer[j];	// get embedding
				map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
Pierre Kraemer's avatar
Pierre Kraemer committed
90 91

				m.mark(d) ;								// mark on the fly to unmark on second loop
92
				vecDartsPerVertex[vemb].push_back(d);	// store incident darts for fast adjacency reconstruction
Pierre Kraemer's avatar
Pierre Kraemer committed
93 94 95 96
				d = map.phi1(d);
			}
		}
	}
97

Pierre Kraemer's avatar
Pierre Kraemer committed
98
	bool needBijectiveCheck = false;
99

Pierre Kraemer's avatar
Pierre Kraemer committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
	// reconstruct neighbourhood
	unsigned int nbBoundaryEdges = 0;
	for (Dart d = map.begin(); d != map.end(); map.next(d))
	{
		if (m.isMarked(d))
		{
			// darts incident to end vertex of edge
			std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];

			unsigned int embd = map.template getEmbedding<VERTEX>(d);
			Dart good_dart = NIL;
			bool firstOK = true;
			for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
			{
				if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
				{
					good_dart = *it;
					if (good_dart == map.phi2(good_dart))
					{
						map.sewFaces(d, good_dart, false);
Pierre Kraemer's avatar
Pierre Kraemer committed
120
						m.template unmarkOrbit<EDGE>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
121 122 123 124 125 126 127 128
					}
					else
					{
						good_dart = NIL;
						firstOK = false;
					}
				}
			}
129

Pierre Kraemer's avatar
Pierre Kraemer committed
130 131
			if (!firstOK)
				needBijectiveCheck = true;
132

Pierre Kraemer's avatar
Pierre Kraemer committed
133 134
			if (good_dart == NIL)
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
135
				m.template unmarkOrbit<EDGE>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
136 137 138 139
				++nbBoundaryEdges;
			}
		}
	}
140

Pierre Kraemer's avatar
Pierre Kraemer committed
141 142 143 144 145
	if (nbBoundaryEdges > 0)
	{
		unsigned int nbH = map.closeMap();
		CGoGNout << "Map closed (" << nbBoundaryEdges << " boundary edges / " << nbH << " holes)" << CGoGNendl;
	}
146

Pierre Kraemer's avatar
Pierre Kraemer committed
147 148 149
	if (needBijectiveCheck)
	{
		// ensure bijection between topo and embedding
150
		Algo::Topo::bijectiveOrbitEmbedding<VERTEX>(map);
Pierre Kraemer's avatar
Pierre Kraemer committed
151
	}
152

Pierre Kraemer's avatar
Pierre Kraemer committed
153
	return true ;
Pierre Kraemer's avatar
Pierre Kraemer committed
154 155
}

156

157
template <typename PFP>
158 159
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, bool mergeCloseVertices)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
160
	MeshTablesSurface<PFP> mts(map);
161

Pierre Kraemer's avatar
Pierre Kraemer committed
162 163
	if(!mts.importMesh(filename, attrNames))
		return false;
164

Pierre Kraemer's avatar
Pierre Kraemer committed
165 166
	if (mergeCloseVertices)
		mts.mergeCloseVertices();
167

Pierre Kraemer's avatar
Pierre Kraemer committed
168
	return importMesh<PFP>(map, mts);
169 170
}

Pierre Kraemer's avatar
Pierre Kraemer committed
171 172 173
template <typename PFP>
bool importVoxellisation(typename PFP::MAP& map, Algo::Surface::Modelisation::Voxellisation& voxellisation, std::vector<std::string>& attrNames, bool mergeCloseVertices)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
174
	MeshTablesSurface<PFP> mts(map);
Pierre Kraemer's avatar
Pierre Kraemer committed
175

Pierre Kraemer's avatar
Pierre Kraemer committed
176 177
	if(!mts.importVoxellisation(voxellisation, attrNames))
		return false;
Pierre Kraemer's avatar
Pierre Kraemer committed
178

Pierre Kraemer's avatar
Pierre Kraemer committed
179 180
	if (mergeCloseVertices)
		mts.mergeCloseVertices();
Pierre Kraemer's avatar
Pierre Kraemer committed
181

Pierre Kraemer's avatar
Pierre Kraemer committed
182
	return importMesh<PFP>(map, mts);
Pierre Kraemer's avatar
Pierre Kraemer committed
183 184
}

185 186 187 188

template <typename PFP>
bool importMeshSAsV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
{
189 190
	typedef typename PFP::MAP MAP;

191
	VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> >, MAP> vecDartsPerVertex(map, "incidents");
192

Pierre Kraemer's avatar
Pierre Kraemer committed
193 194 195 196 197
	unsigned nbf = mts.getNbFaces();
	int index = 0;
	// buffer for tempo faces (used to remove degenerated edges)
	std::vector<unsigned int> edgesBuffer;
	edgesBuffer.reserve(16);
198

199
	DartMarkerNoUnmark<MAP> m(map) ;
200

201 202 203
	unsigned int vemb = EMBNULL;
	auto fsetemb = [&] (Dart d) { map.template initDartEmbedding<VERTEX>(d, vemb); };

Pierre Kraemer's avatar
Pierre Kraemer committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
	// for each face of table
	for(unsigned int i = 0; i < nbf; ++i)
	{
		// store face in buffer, removing degenerated edges
		unsigned int nbe = mts.getNbEdgesFace(i);
		edgesBuffer.clear();
		unsigned int prec = EMBNULL;
		for (unsigned int j = 0; j < nbe; ++j)
		{
			unsigned int em = mts.getEmbIdx(index++);
			if (em != prec)
			{
				prec = em;
				edgesBuffer.push_back(em);
			}
		}
		// check first/last vertices
		if (edgesBuffer.front() == edgesBuffer.back())
			edgesBuffer.pop_back();
223

Pierre Kraemer's avatar
Pierre Kraemer committed
224 225 226 227 228 229 230
		// create only non degenerated faces
		nbe = edgesBuffer.size();
		if (nbe > 2)
		{
			Dart d = map.newFace(nbe, false);
			for (unsigned int j = 0; j < nbe; ++j)
			{
231
				vemb = edgesBuffer[j];		// get embedding
Pierre Kraemer's avatar
Pierre Kraemer committed
232
				map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT2>(d, fsetemb);
233

Pierre Kraemer's avatar
Pierre Kraemer committed
234
				m.mark(d) ;								// mark on the fly to unmark on second loop
235
				vecDartsPerVertex[vemb].push_back(d);	// store incident darts for fast adjacency reconstruction
Pierre Kraemer's avatar
Pierre Kraemer committed
236 237 238 239
				d = map.phi1(d);
			}
		}
	}
240

Pierre Kraemer's avatar
Pierre Kraemer committed
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
	// reconstruct neighbourhood
	unsigned int nbBoundaryEdges = 0;
	for (Dart d = map.begin(); d != map.end(); map.next(d))
	{
		if (m.isMarked(d))
		{
			// darts incident to end vertex of edge
			std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];

			unsigned int embd = map.template getEmbedding<VERTEX>(d);
			Dart good_dart = NIL;
			for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
			{
				if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
					good_dart = *it;
			}

			if (good_dart != NIL)
			{
				map.sewFaces(d, good_dart, false);
				m.unmarkOrbit<EDGE>(d);
			}
			else
			{
				m.unmark(d);
				++nbBoundaryEdges;
			}
		}
	}
270

Pierre Kraemer's avatar
Pierre Kraemer committed
271 272 273 274 275
	unsigned int nbH = map.closeMap();
	CGoGNout << "Map closed (" << map.template getNbOrbits<FACE>() << " boundary faces / " << nbH << " holes)" << CGoGNendl;
	std::cout << "nb darts : " << map.getNbDarts() << std::endl ;
	// ensure bijection between topo and embedding
	//map.template bijectiveOrbitEmbedding<VERTEX>();
276

Pierre Kraemer's avatar
Pierre Kraemer committed
277
	return true ;
278 279 280 281 282
}

template <typename PFP>
bool importMeshSAsV(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
283
	MeshTablesSurface<PFP> mts(map);
284

Pierre Kraemer's avatar
Pierre Kraemer committed
285 286
	if(!mts.importMesh(filename, attrNames))
		return false;
287

Pierre Kraemer's avatar
Pierre Kraemer committed
288
	return importMeshSAsV<PFP>(map, mts);
289 290 291
}


292 293 294 295
} // namespace Import

} // namespace Surface

296 297 298 299 300 301 302 303 304 305


namespace Volume
{

namespace Import
{

template <typename PFP>
bool importMeshSToV(typename PFP::MAP& map, Surface::Import::MeshTablesSurface<PFP>& mts, float dist)
306
{
307 308 309
	typedef typename PFP::MAP MAP;
	typedef typename PFP::VEC3 VEC3;

310
	VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> >, MAP> vecDartsPerVertex(map, "incidents");
Pierre Kraemer's avatar
Pierre Kraemer committed
311 312 313 314 315
	unsigned nbf = mts.getNbFaces();
	int index = 0;
	// buffer for tempo faces (used to remove degenerated edges)
	std::vector<unsigned int> edgesBuffer;
	edgesBuffer.reserve(16);
316

317
	DartMarkerNoUnmark<MAP> m(map) ;
318

319 320 321 322 323
	unsigned int vemb1 = EMBNULL;
	auto fsetemb1 = [&] (Dart d) { map.template initDartEmbedding<VERTEX>(d, vemb1); };
	unsigned int vemb2 = EMBNULL;
	auto fsetemb2 = [&] (Dart d) { map.template initDartEmbedding<VERTEX>(d, vemb2); };

324
	VertexAttribute<VEC3, MAP> position = map.template getAttribute<VEC3, VERTEX>("position");
Pierre Kraemer's avatar
Pierre Kraemer committed
325
	std::vector<unsigned int > backEdgesBuffer(mts.getNbVertices(), EMBNULL);
326

Pierre Kraemer's avatar
Pierre Kraemer committed
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
	// for each face of table -> create a prism
	for(unsigned int i = 0; i < nbf; ++i)
	{
		// store face in buffer, removing degenerated edges
		unsigned int nbe = mts.getNbEdgesFace(i);
		edgesBuffer.clear();
		unsigned int prec = EMBNULL;
		for (unsigned int j = 0; j < nbe; ++j)
		{
			unsigned int em = mts.getEmbIdx(index++);
			if (em != prec)
			{
				prec = em;
				edgesBuffer.push_back(em);
			}
		}
		// check first/last vertices
		if (edgesBuffer.front() == edgesBuffer.back())
			edgesBuffer.pop_back();
346

Pierre Kraemer's avatar
Pierre Kraemer committed
347 348 349 350
		// create only non degenerated faces
		nbe = edgesBuffer.size();
		if (nbe > 2)
		{
351
			Dart d = Surface::Modelisation::createPrism<PFP>(map, nbe, false);
352

Pierre Kraemer's avatar
Pierre Kraemer committed
353 354 355
			//Embed the base faces
			for (unsigned int j = 0; j < nbe; ++j)
			{
356
				vemb1 = edgesBuffer[j];		// get embedding
357

358
				if(backEdgesBuffer[vemb1] == EMBNULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
359 360
				{
					unsigned int emn = map.template newCell<VERTEX>();
361 362
					map.template copyCell<VERTEX>(emn, vemb1);
					backEdgesBuffer[vemb1] = emn;
Pierre Kraemer's avatar
Pierre Kraemer committed
363 364
					position[emn] += typename PFP::VEC3(0,0,dist);
				}
365

366
				map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb1);
367

Pierre Kraemer's avatar
Pierre Kraemer committed
368 369
				//Embed the other base face
				Dart d2 = map.phi1(map.phi1(map.phi2(d)));
370 371
				vemb2 = backEdgesBuffer[vemb1];

Pierre Kraemer's avatar
Pierre Kraemer committed
372
				map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d2, fsetemb2);
373

Pierre Kraemer's avatar
Pierre Kraemer committed
374
				m.mark(d) ;								// mark on the fly to unmark on second loop
375
				vecDartsPerVertex[vemb1].push_back(d);	// store incident darts for fast adjacency reconstruction
Pierre Kraemer's avatar
Pierre Kraemer committed
376 377
				d = map.phi_1(d);
			}
378

Pierre Kraemer's avatar
Pierre Kraemer committed
379 380
		}
	}
381

Pierre Kraemer's avatar
Pierre Kraemer committed
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
	// reconstruct neighbourhood
	unsigned int nbBoundaryEdges = 0;
	for (Dart d = map.begin(); d != map.end(); map.next(d))
	{
		if (m.isMarked(d))
		{
			// darts incident to end vertex of edge
			std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];

			unsigned int embd = map.template getEmbedding<VERTEX>(d);
			Dart good_dart = NIL;
			for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
			{
				if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
					good_dart = *it;
			}

			if (good_dart != NIL)
			{
				map.sewVolumes(map.phi2(d), map.phi2(good_dart), false);
				m.unmarkOrbit<EDGE>(d);
			}
			else
			{
				m.unmark(d);
				++nbBoundaryEdges;
			}
		}
	}
411

Pierre Kraemer's avatar
Pierre Kraemer committed
412
	return true ;
413 414
}

415
template <typename PFP>
416
bool importMeshSurfToVol(typename PFP::MAP& map, Surface::Import::MeshTablesSurface<PFP>& mts, float scale, unsigned int nbStage)
417
{
418 419 420
	typedef typename PFP::MAP MAP;
	typedef typename PFP::VEC3 VEC3;

421
	VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> >, MAP> vecDartsPerVertex(map);
Pierre Kraemer's avatar
Pierre Kraemer committed
422 423 424 425 426
	unsigned nbf = mts.getNbFaces();
	int index = 0;
	// buffer for tempo faces (used to remove degenerated edges)
	std::vector<unsigned int> edgesBuffer;
	edgesBuffer.reserve(16);
427

428
	DartMarkerNoUnmark<MAP> m(map) ;
429

430
	unsigned int vemb1 = EMBNULL;
431
//	auto fsetemb1 = [&] (Dart d) { map.template initDartEmbedding<VERTEX>(d, vemb1); };
432
	unsigned int vemb2 = EMBNULL;
433
//	auto fsetemb2 = [&] (Dart d) { map.template initDartEmbedding<VERTEX>(d, vemb2); };
434

Pierre Kraemer's avatar
Pierre Kraemer committed
435
	unsigned int nbVertices = mts.getNbVertices();
436

437
	VertexAttribute<VEC3, MAP> position = map.template getAttribute<VEC3, VERTEX, MAP>("position");
Pierre Kraemer's avatar
Pierre Kraemer committed
438
	std::vector<unsigned int > backEdgesBuffer(nbVertices*nbStage, EMBNULL);
439

Pierre Kraemer's avatar
Pierre Kraemer committed
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
	// for each face of table -> create a prism
	for(unsigned int i = 0; i < nbf; ++i)
	{
		// store face in buffer, removing degenerated edges
		unsigned int nbe = mts.getNbEdgesFace(i);
		edgesBuffer.clear();
		unsigned int prec = EMBNULL;
		for (unsigned int j = 0; j < nbe; ++j)
		{
			unsigned int em = mts.getEmbIdx(index++);
			if (em != prec)
			{
				prec = em;
				edgesBuffer.push_back(em);
			}
		}
		// check first/last vertices
		if (edgesBuffer.front() == edgesBuffer.back())
			edgesBuffer.pop_back();
459

Pierre Kraemer's avatar
Pierre Kraemer committed
460 461 462 463 464
		// create only non degenerated faces
		nbe = edgesBuffer.size();
		if (nbe > 2)
		{
			Dart dprev = NIL;
465

Pierre Kraemer's avatar
Pierre Kraemer committed
466 467 468
			for(unsigned int k = 0 ; k < nbStage ; ++k)
			{
				Dart d = Surface::Modelisation::createPrism<PFP>(map, nbe,false);
469

Pierre Kraemer's avatar
Pierre Kraemer committed
470 471 472
				//Embed the base faces
				for (unsigned int j = 0; j < nbe; ++j)
				{
473
					vemb1 = edgesBuffer[j];		// get embedding
Pierre Kraemer's avatar
Pierre Kraemer committed
474 475 476 477
					Dart d2 = map.phi1(map.phi1(map.phi2(d)));

					if(k==0)
					{
478
						map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb1); });
479
						vecDartsPerVertex[vemb1].push_back(d);	// store incident darts for fast adjacency reconstruction
Pierre Kraemer's avatar
Pierre Kraemer committed
480 481 482 483
						m.mark(d) ;								// mark on the fly to unmark on second loop
					}
					else
					{
484 485
						//						unsigned int emn = backEdgesBuffer[((k-1)*nbVertices) + em];
						vemb2 = backEdgesBuffer[((k-1)*nbVertices) + vemb1];
486
						map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb2); });
487
						vecDartsPerVertex[vemb2].push_back(d);	// store incident darts for fast adjacency reconstruction
Pierre Kraemer's avatar
Pierre Kraemer committed
488 489 490
						m.mark(d) ;								// mark on the fly to unmark on second loop
					}

491
					if(backEdgesBuffer[(k*nbVertices) + vemb1] == EMBNULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
492
					{
493 494 495 496
						vemb2 = map.template newCell<VERTEX>();
						map.template copyCell<VERTEX>(vemb2, vemb1);
						backEdgesBuffer[(k*nbVertices) + vemb1] = vemb2;
						position[vemb2] += typename PFP::VEC3(0,0, (k+1) * scale);
Pierre Kraemer's avatar
Pierre Kraemer committed
497 498
					}

499
					vemb2 = backEdgesBuffer[(k*nbVertices) + vemb1];
500
					map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d2, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb2); });
Pierre Kraemer's avatar
Pierre Kraemer committed
501 502 503

					d = map.phi_1(d);
				}
504 505


Pierre Kraemer's avatar
Pierre Kraemer committed
506 507
				if(dprev != NIL)
					map.sewVolumes(d, map.phi2(map.phi1(map.phi1(map.phi2(dprev)))), false);
508

Pierre Kraemer's avatar
Pierre Kraemer committed
509 510 511 512
				dprev = d;
			}
		}
	}
513

Pierre Kraemer's avatar
Pierre Kraemer committed
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
	// reconstruct neighbourhood
	unsigned int nbBoundaryEdges = 0;
	for (Dart d = map.begin(); d != map.end(); map.next(d))
	{
		if (m.isMarked(d))
		{
			// darts incident to end vertex of edge
			std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];

			unsigned int embd = map.template getEmbedding<VERTEX>(d);
			Dart good_dart = NIL;
			for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
			{
				if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
					good_dart = *it;
			}

			if (good_dart != NIL)
			{
				map.sewVolumes(map.phi2(d), map.phi2(good_dart), false);
Pierre Kraemer's avatar
Pierre Kraemer committed
534
				m.template unmarkOrbit<EDGE>(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
535 536 537 538 539 540 541 542
			}
			else
			{
				m.unmark(d);
				++nbBoundaryEdges;
			}
		}
	}
543

Pierre Kraemer's avatar
Pierre Kraemer committed
544
	map.closeMap();
545

Pierre Kraemer's avatar
Pierre Kraemer committed
546
	return true ;
547 548
}

549

Pierre Kraemer's avatar
Pierre Kraemer committed
550 551 552
template <typename PFP>
bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
{
553 554 555
	typedef typename PFP::MAP MAP;
	typedef typename PFP::VEC3 VEC3;

556
	VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> >, MAP> vecDartsPerVertex(map, "incidents");
557

558 559 560 561
	unsigned int nbv = mtv.getNbVolumes();
	unsigned int index = 0;
	// buffer for tempo faces (used to remove degenerated edges)
	std::vector<unsigned int> edgesBuffer;
Pierre Kraemer's avatar
Pierre Kraemer committed
562
	edgesBuffer.reserve(16);
563

564
	DartMarkerNoUnmark<MAP> m(map) ;
565

566
	unsigned int vemb = EMBNULL;
567
//	auto fsetemb = [&] (Dart d) { map.template initDartEmbedding<VERTEX>(d, vemb); };
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584

	//for each volume of table
	for(unsigned int i = 0 ; i < nbv ; ++i)
	{
		// store volume in buffer, removing degenated faces
		unsigned int nbf = mtv.getNbFacesVolume(i);

		edgesBuffer.clear();
		unsigned int prec = EMBNULL;
		for (unsigned int j = 0; j < nbf; ++j)
		{
			unsigned int em = mtv.getEmbIdx(index++);
			if (em != prec)
			{
				prec = em;
				edgesBuffer.push_back(em);
			}
585
		}
586 587 588 589 590 591 592 593 594

		if(nbf == 4) //tetrahedral case
		{
			Dart d = Surface::Modelisation::createTetrahedron<PFP>(map,false);

			// Embed three "base" vertices
			for(unsigned int j = 0 ; j < 3 ; ++j)
			{
				vemb = edgesBuffer[j];		// get embedding
595
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612

				//store darts per vertices to optimize reconstruction
				Dart dd = d;
				do
				{
					m.mark(dd) ;
					vecDartsPerVertex[vemb].push_back(dd);
					dd = map.phi1(map.phi2(dd));
				} while(dd != d);

				d = map.phi1(d);
			}

			//Embed the last "top" vertex
			d = map.phi_1(map.phi2(d));

			vemb = edgesBuffer[3];		// get embedding
613
			map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
614 615 616 617 618 619 620 621 622

			//store darts per vertices to optimize reconstruction
			Dart dd = d;
			do
			{
				m.mark(dd) ;
				vecDartsPerVertex[vemb].push_back(dd);
				dd = map.phi1(map.phi2(dd));
			} while(dd != d);
623

624
		}
625 626 627 628 629 630
		else if(nbf == 5) //pyramidal case
		{
			Dart d = Surface::Modelisation::createQuadrangularPyramid<PFP>(map,false);

			// 1.
			vemb = edgesBuffer[0];		// get embedding
631
			map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
632 633 634 635 636 637 638 639
			Dart dd = d;
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

			// 2.
			d = map.phi1(d);
			vemb = edgesBuffer[1];
640
			map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
641 642 643 644 645 646 647 648
			dd = d;
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

			// 3.
			d = map.phi1(d);
			vemb = edgesBuffer[2];
649
			map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
650 651 652 653 654 655 656 657
			dd = d;
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

			// 4.
			d = map.phi1(d);
			vemb = edgesBuffer[3];
658
			map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
659 660 661 662 663 664 665 666
			dd = d;
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

			// 5.
			d = map.phi_1(map.phi2(d));
			vemb = edgesBuffer[4];
667
			map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
668 669 670 671 672 673 674 675 676 677 678 679 680
			dd = d;
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
			vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);
		}
		else
			if(nbf == 6) //prism case
			{
				Dart d = Surface::Modelisation::createTriangularPrism<PFP>(map,false);

				// 1.
				vemb = edgesBuffer[0];		// get embedding
681
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
682 683 684 685 686 687 688 689
				Dart dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 2.
				d = map.phi1(d);
				vemb = edgesBuffer[1];
690
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
691 692 693 694 695 696 697 698
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 3.
				d = map.phi1(d);
				vemb = edgesBuffer[2];
699
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
700 701 702 703 704 705 706 707
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 5.
				d = map.template phi<2112>(d);
				vemb = edgesBuffer[3];
708
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
709 710 711 712 713 714 715 716
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 6.
				d = map.phi_1(d);
				vemb = edgesBuffer[4];
717
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
718 719 720 721 722 723 724 725
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 7.
				d = map.phi_1(d);
				vemb = edgesBuffer[5];
726
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
727 728 729 730 731 732 733 734 735 736 737 738
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

			}
			else if(nbf == 8) //hexahedral case
			{
				Dart d = Surface::Modelisation::createHexahedron<PFP>(map,false);

				// 1.
				vemb = edgesBuffer[0];		// get embedding
739
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
740 741 742 743 744 745 746 747
				Dart dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 2.
				d = map.phi1(d);
				vemb = edgesBuffer[1];
748
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
749 750 751 752 753 754 755 756
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 3.
				d = map.phi1(d);
				vemb = edgesBuffer[2];
757
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
758 759 760 761 762 763 764 765
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 4.
				d = map.phi1(d);
				vemb = edgesBuffer[3];
766
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
767 768 769 770 771 772 773 774
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 5.
				d = map.template phi<2112>(d);
				vemb = edgesBuffer[4];
775
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
776 777 778 779 780 781 782 783
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 6.
				d = map.phi_1(d);
				vemb = edgesBuffer[5];
784
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
785 786 787 788 789 790 791 792
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 7.
				d = map.phi_1(d);
				vemb = edgesBuffer[6];
793
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
794 795 796 797 798 799 800 801
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

				// 8.
				d = map.phi_1(d);
				vemb = edgesBuffer[7];
802
				map.template foreach_dart_of_orbit<MAP::VERTEX_OF_PARENT>(d, [&] (Dart dd) { map.template initDartEmbedding<VERTEX>(dd, vemb); });
803 804 805 806 807 808 809 810
				dd = d;
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
				vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);

			}  //end of hexa

	}
811

812 813
	std	::cout << " elements created " << std::endl;

814 815
	//reconstruct neighbourhood
	unsigned int nbBoundaryFaces = 0 ;
untereiner's avatar
untereiner committed
816 817
	for (Dart d = map.begin(); d != map.end(); map.next(d))
	{
818 819 820 821 822 823 824 825
		if (m.isMarked(d))
		{
			std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];

			Dart good_dart = NIL;
			for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
			{
				if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(d) &&
untereiner's avatar
untereiner committed
826
				   map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi1(map.phi1(d))))
827 828 829 830
				{
					good_dart = *it ;
				}
			}
831

832 833 834 835
			if (good_dart != NIL)
			{
				unsigned int degD = map.faceDegree(d);
				unsigned int degGD = map.faceDegree(good_dart);
836

837 838
				//				std::cout << "degD = " << degD << std::endl;
				//				std::cout << "degGD = " << degGD << std::endl << std::endl;
839

840 841
				if(degD < degGD)
				{
842 843 844 845 846 847
					Dart dt = map.phi1(good_dart);
					map.PFP::MAP::ParentMap::splitFace(dt,map.phi_1(good_dart));

					map.template initDartEmbedding<VERTEX>(map.phi1(good_dart), map.template getEmbedding<VERTEX>(dt)) ;
					map.template initDartEmbedding<VERTEX>(map.phi_1(dt), map.template getEmbedding<VERTEX>(map.phi_1(good_dart))) ;

untereiner's avatar
untereiner committed
848
					m.mark(map.phi1(good_dart));
849
					m.mark(map.phi2(map.phi1(good_dart)));
850

untereiner's avatar
untereiner committed
851
					unsigned int emb2 = map.template getEmbedding<VERTEX>(map.phi1(map.phi1(d)));
852
					vecDartsPerVertex[emb2].push_back(map.phi2(map.phi1(good_dart)));
853

untereiner's avatar
untereiner committed
854 855 856 857 858
					unsigned int emb1 = map.template getEmbedding<VERTEX>(d);
					vecDartsPerVertex[emb1].push_back(map.phi1(good_dart));

					//m.unmarkOrbit<PFP::MAP::FACE_OF_PARENT>(d);
					//m.unmarkOrbit<PFP::MAP::FACE_OF_PARENT>(good_dart);
859 860 861
				}
				else if(degD > degGD)
				{
862 863 864 865 866
					Dart dt = map.phi1(map.phi1(d));
					map.PFP::MAP::ParentMap::splitFace(d,dt);

					map.template initDartEmbedding<VERTEX>(map.phi_1(dt), map.template getEmbedding<VERTEX>(d)) ;
					map.template initDartEmbedding<VERTEX>(map.phi_1(d), map.template getEmbedding<VERTEX>(dt)) ;
867

untereiner's avatar
untereiner committed
868
					m.mark(map.phi_1(d));
869
					m.mark(map.phi2(map.phi_1(d)));
870

871
					//ne change rien sur l'exemple test
untereiner's avatar
untereiner committed
872
					unsigned int emb1 = map.template getEmbedding<VERTEX>(map.phi1(map.phi1(good_dart)));
873
					vecDartsPerVertex[emb1].push_back(map.phi2(map.phi_1(d)));
untereiner's avatar
untereiner committed
874 875 876 877 878 879

					unsigned int emb2 = map.template getEmbedding<VERTEX>(good_dart);
					vecDartsPerVertex[emb2].push_back(map.phi_1(d));

					//m.unmarkOrbit<PFP::MAP::FACE_OF_PARENT>(d);
					//m.unmarkOrbit<PFP::MAP::FACE_OF_PARENT>(good_dart);
880
				}
untereiner's avatar
untereiner committed
881
				else if(degD == degGD)
882
				{
untereiner's avatar
untereiner committed
883
					map.sewVolumes(d, good_dart, false);
untereiner's avatar
untereiner committed
884
					m.template unmarkOrbit<FACE>(d);
untereiner's avatar
untereiner committed
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
				//				else if(degD > 3 && degGD > 3)
				//				{
				//					if(map.template getEmbedding<VERTEX>(map.phi1(map.phi1(good_dart))) != map.template getEmbedding<VERTEX>(map.phi_1(d)))
				//					{
				//						std::cout << "2 faces quad" << std::endl;
				//						Dart dtgd = map.phi1(good_dart);
				//						map.PFP::MAP::ParentMap::splitFace(dtgd,map.phi_1(good_dart));

				//						map.template initDartEmbedding<VERTEX>(map.phi1(good_dart), map.template getEmbedding<VERTEX>(dtgd)) ;
				//						map.template initDartEmbedding<VERTEX>(map.phi_1(dtgd), map.template getEmbedding<VERTEX>(map.phi_1(good_dart))) ;


				//						Dart dt = map.phi1(map.phi1(d));
				//						map.PFP::MAP::ParentMap::splitFace(d,dt);

				//						map.template initDartEmbedding<VERTEX>(map.phi_1(dt), map.template getEmbedding<VERTEX>(d)) ;
				//						map.template initDartEmbedding<VERTEX>(map.phi_1(d), map.template getEmbedding<VERTEX>(dt)) ;
				//					}
				//				}

				//				map.sewVolumes(d, good_dart, false);
				//				m.unmarkOrbit<FACE>(d);
			}
			else
			{
911
				m.template unmarkOrbit<PFP::MAP::FACE_OF_PARENT>(d);
912 913 914
				++nbBoundaryFaces;
			}
		}
untereiner's avatar
untereiner committed
915 916 917 918 919 920 921 922 923
	}

	for (Dart d = map.begin(); d != map.end(); map.next(d))
	{
		if (m.isMarked(d))
		{
			std::cout << "marked " << std::endl;
		}
	}
924

925 926
	if (nbBoundaryFaces > 0)
	{
927
		unsigned int nbH =  map.closeMap();
928 929
		CGoGNout << "Map closed (" << nbBoundaryFaces << " boundary faces / " << nbH << " holes)" << CGoGNendl;
	}
930

Pierre Kraemer's avatar
Pierre Kraemer committed
931
	return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
932 933
}

934
template <typename PFP>
Sylvain Thery's avatar
Sylvain Thery committed
935
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames/* bool mergeCloseVertices*/)
936
{
Pierre Kraemer's avatar
Pierre Kraemer committed
937
	MeshTablesVolume<PFP> mtv(map);
938

Pierre Kraemer's avatar
Pierre Kraemer committed
939 940
	if(!mtv.importMesh(filename, attrNames))
		return false;
Sylvain Thery's avatar
Sylvain Thery committed
941

Pierre Kraemer's avatar
Pierre Kraemer committed
942 943
	//sif(mergeCloseVertices)
	//mtv.mergeCloseVertices();
Sylvain Thery's avatar
Sylvain Thery committed
944

Pierre Kraemer's avatar
Pierre Kraemer committed
945
	return importMesh<PFP>(map, mtv);
Pierre Kraemer's avatar
Pierre Kraemer committed
946 947
}

948
template <typename PFP>
949 950
bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, float scale, unsigned int nbStage)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
951
	Surface::Import::MeshTablesSurface<PFP> mts(map);
952

Pierre Kraemer's avatar
Pierre Kraemer committed
953 954
	if(!mts.importMesh(filename, attrNames))
		return false;
955

Pierre Kraemer's avatar
Pierre Kraemer committed
956
	return importMeshSurfToVol<PFP>(map, mts, scale, nbStage);
957 958
}

959
} // namespace Import
960 961

} // namespace Volume
962

Pierre Kraemer's avatar
Pierre Kraemer committed
963 964 965
} // namespace Algo

} // namespace CGoGN