importSvg.hpp 17.7 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
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
* Web site: http://cgogn.unistra.fr/                                           *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

untereiner's avatar
...    
untereiner committed
25
26
27
28
#include <iostream>
#include "Geometry/bounding_box.h"
#include "Geometry/plane_3d.h"
#include "Algo/BooleanOperator/mergeVertices.h"
untereiner's avatar
untereiner committed
29
#include "Container/fakeAttribute.h"
untereiner's avatar
...    
untereiner committed
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
#include <limits>

namespace CGoGN
{

namespace Algo
{

namespace Import
{

inline bool checkXmlNode(xmlNodePtr node, const std::string& name)
{
	return (strcmp((char*)(node->name),(char*)(name.c_str())) == 0);
}

template<typename T>
inline bool valueOf(const std::string &s, T &obj)
{
  std::istringstream is(s);
  return is >> obj;
}

template <typename VEC>
bool posSort(const std::pair<VEC, Dart>& a1, const std::pair<VEC, Dart>& a2)
{
	VEC v1 = a1.first;
	VEC v2 = a2.first;
	return v1[0] < v2[0] || (v1[0] == v2[0] && v1[1] < v2[1]);
}

template <typename VEC3>
void getPolygonFromSVG(std::string allcoords, std::vector<VEC3>& curPoly, bool& closedPoly)
{
	closedPoly=false;
	std::stringstream is(allcoords);
	bool relative=false;
	bool push_point;
	std::string coord;
	int mode = -1;

	while ( std::getline( is, coord, ' ' ) )
	{
		float x,y;
		push_point=false;

		if(coord[0]=='m' || coord[0]=='l' || coord[0]=='t') //start point, line or quadratic bezier curve
		{
			mode = 0;
			relative=true;
		}
		else if(coord[0]=='M' || coord[0] == 'L' || coord[0]=='T') //same in absolute coordinates
		{
			mode = 1;
			relative=false;
		}
		else if(coord[0]=='h' || coord[0] == 'H') //horizontal line
		{
			mode = 2;
			relative=(coord[0]=='h');
		}
		else if(coord[0]=='v' || coord[0] == 'V') //vertical line
		{
			mode = 3;
			relative=(coord[0]=='v');
		}
		else if(coord[0]=='c' || coord[0] == 'C') //bezier curve
		{
			mode = 4;
			relative=(coord[0]=='c');
		}
		else if(coord[0]=='s' || coord[0] == 'S' || coord[0]=='q' || coord[0] == 'Q') //bezier curve 2
		{
			mode = 5;
			relative= ((coord[0]=='s') || (coord[0]=='q'));
		}
		else if(coord[0]=='a' || coord[0] == 'A') //elliptic arc
		{
			mode =6;
			relative= (coord[0]=='a');
		}
111
		else if(coord[0]=='z') //end of path
untereiner's avatar
...    
untereiner committed
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
		{
			closedPoly = true;
		}
		else //coordinates
		{
			switch(mode)
			{
				case 0 : //relative
				break;
				case 1 : //absolute
				break;
				case 2 : //horizontal
				{
					std::stringstream streamCoord(coord);
					std::string xS;
					std::getline(streamCoord, xS, ',' );

					valueOf(xS,x);

					VEC3 previous = (curPoly)[(curPoly).size()-1];
					y = previous[1];

					push_point=true;
				}
				break;
				case 3 : //vertical
				{
					std::stringstream streamCoord(coord);
					std::string yS;
					std::getline(streamCoord, yS, ',' );

					valueOf(yS,y);

untereiner's avatar
untereiner committed
145
					VEC3 previous = (curPoly)[(curPoly).size()-1];
untereiner's avatar
...    
untereiner committed
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
					x = previous[0];

					push_point=true;
				}
				break;
				case 4 : //bezier
				{
					std::getline( is, coord, ' ' ); //ignore first control point
					std::getline( is, coord, ' ' ); //ignore second control point
				}
				break;
				case 5 : //bezier 2
				{
					std::getline( is, coord, ' ' ); //ignore control point

				}
				break;
				case 6 : //elliptic
					std::getline( is, coord, ' ' ); //ignore rx
					std::getline( is, coord, ' ' ); //ignore ry
					std::getline( is, coord, ' ' ); //ignore x-rotation
					std::getline( is, coord, ' ' ); //ignore large arc flag
					std::getline( is, coord, ' ' ); //ignore sweep flag
				break;
			}

			std::stringstream streamCoord(coord);
			std::string xS,yS;
			std::getline(streamCoord, xS, ',' );
			std::getline(streamCoord, yS, ',' );

			valueOf(xS,x);
			valueOf(yS,y);

			push_point = true;
		}

		//if there is a point to push
		if(push_point)
		{

			VEC3 previous;

			if(curPoly.size()>0)
				previous = (curPoly)[(curPoly).size()-1];

			if(relative)
			{
				x += previous[0];
				y += previous[1];
			}

			if(curPoly.size()==0 || (curPoly.size()>0 && (x!=previous[0] || y!= previous[1])))
				curPoly.push_back(VEC3(x,y,0));
		}
	}
}

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
template <typename PFP>
void readCoordAndStyle(xmlNode* cur_path,
		std::vector<std::vector<VEC3 > >& allPoly,
		std::vector<std::vector<VEC3 > >& allBrokenLines,
		std::vector<float>& allBrokenLinesWidth)
{
	typedef typename PFP::VEC3 VEC3;
	typedef std::vector<VEC3 > POLYGON;

	bool closedPoly;
	POLYGON curPoly;

//	CGoGNout << "--load a path--"<< CGoGNendl;
	xmlChar* prop = xmlGetProp(cur_path, BAD_CAST "d");
	std::string allcoords((reinterpret_cast<const char*>(prop)));
	getPolygonFromSVG(allcoords,curPoly,closedPoly);

	//check orientation : set in CCW
	if(curPoly.size()>2)
	{
		VEC3 v1(curPoly[1]-curPoly[0]);
		VEC3 v2(curPoly[2]-curPoly[1]);
		if((v1^v2)[2]<0)
		{
			std::reverse(curPoly.begin(), curPoly.end());
		}
	}

	//closed polygon ?
	if(closedPoly)
		allPoly.push_back(curPoly);
	else
	{
		//if not : read the linewidth for further dilatation
		allBrokenLines.push_back(curPoly);
		xmlChar* prop = xmlGetProp(cur_path, BAD_CAST "style");
		std::string allstyle((reinterpret_cast<const char*>(prop)));
		std::stringstream is(allstyle);
		std::string style;
		while ( std::getline( is, style, ';' ) )
		{
			if(style.find("stroke-width:")!=std::string::npos)
			{
				std::stringstream isSize(style);
				std::getline( isSize, style, ':' );
				float sizeOfLine;
				isSize >> sizeOfLine;
				allBrokenLinesWidth.push_back(sizeOfLine);
			}
		}
	}
}

untereiner's avatar
...    
untereiner committed
257
template <typename PFP>
258
bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& polygons, CellMarker<FACE>& polygonsFaces)
untereiner's avatar
...    
untereiner committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
{
	typedef typename PFP::VEC3 VEC3;
	typedef std::vector<VEC3 > POLYGON;

	xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
	xmlNodePtr map_node = xmlDocGetRootElement(doc);

	if (!checkXmlNode(map_node,"svg"))
	{
		CGoGNerr << "Wrong xml format: Root node != svg"<< CGoGNendl;
		return false;
	}

	std::vector<POLYGON> allPoly;
	std::vector<POLYGON> allBrokenLines;
	std::vector<float> allBrokenLinesWidth;

	for (xmlNode* cur_node = map_node->children; cur_node; cur_node = cur_node->next)
	{
		// for each layer
		if (checkXmlNode(cur_node, "g"))
			for (xmlNode* cur_path = cur_node->children ; cur_path; cur_path = cur_path->next)
			{
				if (checkXmlNode(cur_path, "path"))
283
					readCoordAndStyle<PFP>(cur_path, allPoly, allBrokenLines, allBrokenLinesWidth);
untereiner's avatar
...    
untereiner committed
284
			}
285
286
		else if (checkXmlNode(cur_node, "path"))
				readCoordAndStyle<PFP>(cur_node, allPoly, allBrokenLines, allBrokenLinesWidth);
untereiner's avatar
...    
untereiner committed
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
	}

	xmlFreeDoc(doc);

	Geom::BoundingBox<typename PFP::VEC3> * bb;
	if(allBrokenLines.size()>0)
		bb = new Geom::BoundingBox<typename PFP::VEC3>(*(allBrokenLines.begin()->begin()));
	else if(allPoly.size()>0)
		bb = new Geom::BoundingBox<typename PFP::VEC3>(*(allPoly.begin()->begin()));
	else
	{
		std::cerr << " no usable data in svg file " << std::endl;
		return false;
	}

302
303
	std::cout << "importSVG : XML read." << std::endl;

304
	CellMarker<EDGE> brokenMark(map);
305
306
	EdgeAttribute<float> edgeWidth = map.template addAttribute<float, EDGE>("width");
	EdgeAttribute<NoMathAttribute<Geom::Plane3D<typename PFP::REAL> > > edgePlanes = map.template addAttribute<NoMathAttribute<Geom::Plane3D<typename PFP::REAL> >, EDGE>("planes");
untereiner's avatar
...    
untereiner committed
307
308
309
310
311

	/////////////////////////////////////////////////////////////////////////////////////////////
	//create broken lines
	DartMarker brokenL(map);

312
313
	unsigned int nbVertices = 0 ;

untereiner's avatar
...    
untereiner committed
314
315
316
317
318
319
320
321
322
323
	std::vector<float >::iterator itW = allBrokenLinesWidth.begin();
	for(typename std::vector<POLYGON >::iterator it = allBrokenLines.begin() ; it != allBrokenLines.end() ; ++it)
	{
		if(it->size()<2)
		{
			it = allBrokenLines.erase(it);
			itW = allBrokenLinesWidth.erase(itW);
		}
		else
		{
324
			nbVertices += it->size() ;
untereiner's avatar
...    
untereiner committed
325

326
			Dart d = map.newFace(it->size()*2-2,false);
untereiner's avatar
...    
untereiner committed
327
328
329

			Dart d1=d;
			Dart d_1=map.phi_1(d);
330
			//build a degenerated "line" face
331
			for(unsigned int i = 0; i<it->size() ; ++i)
untereiner's avatar
...    
untereiner committed
332
333
334
335
			{
				brokenL.mark(d1);
				brokenL.mark(d_1);

336
337
338
339
				map.sewFaces(d1,d_1,false) ;

				edgeWidth[d1] = *itW;

untereiner's avatar
...    
untereiner committed
340
341
342
343
				d1 = map.phi1(d1);
				d_1 = map.phi_1(d_1);
			}

344
345
			polygonsFaces.mark(d);

346
			//embed the line
347
			d1 = d;
untereiner's avatar
...    
untereiner committed
348
349
350
			for(typename POLYGON::iterator emb = it->begin(); emb != it->end() ; emb++)
			{
				bb->addPoint(*emb);
351
352
				position[d1] = *emb;
				d1 = map.phi1(d1);
untereiner's avatar
...    
untereiner committed
353
			}
354
		}
untereiner's avatar
...    
untereiner committed
355

356
357
358
		itW++;
	}

359
	std::cout << "importSVG : broken lines created : " << nbVertices << " vertices"<< std::endl;
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

	/////////////////////////////////////////////////////////////////////////////////////////////
	//create polygons
//	typename std::vector<POLYGON >::iterator it;
//	for(it = allPoly.begin() ; it != allPoly.end() ; ++it)
//	{
//
//		if(it->size()<4)
//		{
//			it = allPoly.erase(it);
//		}
//		else
//		{
//			Dart d = map.newFace(it->size()-1);
////			std::cout << "newFace1 " << it->size()-1 << std::endl;
//			polygonsFaces.mark(d);
//
//			Dart dd = d;
//			typename POLYGON::iterator emb = it->begin();
untereiner's avatar
...    
untereiner committed
379
380
381
382
383
384
//			do
//			{
//				bb->addPoint(*emb);
//				position[dd] = *emb;
//				emb++;
//				dd = map.phi1(dd);
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
//			} while(dd!=d);
//		}
//	}
//
//	for(Dart d = map.begin();d != map.end(); map.next(d))
//	{
//		if(position[d][0] == position[map.phi1(d)][0] && position[d][1] == position[map.phi1(d)][1])
//			std::cout << "prob d " << d << std::endl;
//	}
//
//	DartMarker inside(map);
//
//	for(Dart d = map.begin(); d != map.end(); map.next(d))
//	{
//		polygons.mark(d);
//		inside.mark(d);
//	}
//
//	std::cout << "importSVG : Polygons generated." << std::endl;
untereiner's avatar
...    
untereiner committed
404
405
406

	/////////////////////////////////////////////////////////////////////////////////////////////

407
408
409
//	DartMarker close(map);
//	map.closeMap(close);
//	map.closeMap();
untereiner's avatar
...    
untereiner committed
410

411
	std::cout << "importSVG : Vertices merging..." << std::endl;
untereiner's avatar
...    
untereiner committed
412
	Algo::BooleanOperator::mergeVertices<PFP>(map,position);
413
	std::cout << "importSVG : Vertices merged." << std::endl;
untereiner's avatar
...    
untereiner committed
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

	/////////////////////////////////////////////////////////////////////////////////////////////
	//cut the edges to have a more regular sampling
//	float maxDist=60.0f;
//	CellMarker treated(map,EDGE);
//	for(Dart d = map.begin(); d != map.end(); map.next(d))
//	{
//		if(!treated.isMarked(d))
//		{
//			treated.mark(d);
//			VEC3 p1 =position[d];
//			VEC3 p2 =position[map.phi1(d)];
//
//			if((p1-p2).norm()>maxDist)
//			{
//				unsigned int nbSeg = ((p1-p2).norm())/int(maxDist);
//				for(unsigned int i=0;i<nbSeg-1;++i)
//				{
//					map.cutEdge(d);
//
//					if(boundingBox.isMarked(d))
//						boundingBox.mark(map.phi1(d));
//				}
//
//				Dart dd = map.phi1(d);
//				VEC3 interv(p2-p1);
//				interv /= nbSeg;
//
//				for(unsigned int i=1;i<nbSeg;++i)
//				{
//					position[dd] = p1+interv*i;
//					dd = map.phi1(dd);
//				}
//			}
//		}
//	}

	/////////////////////////////////////////////////////////////////////////////////////////////
	//process broken lines
453
	CellMarker<EDGE> eMTreated(map);
untereiner's avatar
...    
untereiner committed
454
455
	for(Dart d = map.begin();d != map.end(); map.next(d))
	{
456
		if(brokenL.isMarked(d) && !eMTreated.isMarked(d))
untereiner's avatar
...    
untereiner committed
457
458
459
460
		{
			// -> we convert broken lines to faces to represent their width

			Dart d1 = d;
461
			Dart d2 = map.phi2(d);
untereiner's avatar
...    
untereiner committed
462
463
			VEC3 p1 = position[d1];
			VEC3 p2 = position[d2];
464

untereiner's avatar
...    
untereiner committed
465
466
467
468
			float width = edgeWidth[d1]/2.0f;
			if(width==0)
				std::cout << "importSVG : error width of path is equal to zero" << std::endl;

469
470
			eMTreated.mark(d1);
			eMTreated.mark(d2);
untereiner's avatar
...    
untereiner committed
471

472
			VEC3 v = p2-p1;
untereiner's avatar
...    
untereiner committed
473
474
475
476
477
478
479
480

			//take the orthogonal direction to the path to apply width afterward
			VEC3 ortho = v^VEC3(0,0,1);
			ortho.normalize();
			v.normalize();

			//if the valence of one of the vertex is equal to one
			//cut the edge to insert the quadrangular face
481
482
//			if(map.phi2_1(d1)==d1)
			if(map.phi_1(d1)==d2)
untereiner's avatar
...    
untereiner committed
483
484
485
			{
				map.cutEdge(d2);

486
487
				Dart dC = map.phi1(d2);
				eMTreated.mark(dC);
untereiner's avatar
...    
untereiner committed
488
489
490
491

				position[map.phi_1(d1)]=p1;
				edgePlanes[map.phi_1(d1)] = Geom::Plane3D<typename PFP::REAL>(v,p1);
			}
492
493
494
495
496
497
498
			else
			{
				if(d1 != map.phi1(d2) && map.phi_1(d1)!=map.phi1(d2))
				{
					map.splitFace(d1,map.phi1(d2));
				}
			}
untereiner's avatar
...    
untereiner committed
499

500
501
//			if(map.phi2_1(d2)==d2)
			if(map.phi_1(d2)==d1)
untereiner's avatar
...    
untereiner committed
502
503
504
			{
				map.cutEdge(d1);

505
506
				Dart dC = map.phi1(d1);
				eMTreated.mark(dC);
untereiner's avatar
...    
untereiner committed
507
508
509
510

				position[map.phi_1(d2)]=p2;
				edgePlanes[map.phi_1(d2)] = Geom::Plane3D<typename PFP::REAL>(-1.0f*v, p2);
			}
511
512
513
514
515
516
517
			else
			{
				if(d2 != map.phi1(d1) && map.phi_1(d2)!=map.phi1(d1))
				{
					map.splitFace(d2,map.phi1(d1));
				}
			}
untereiner's avatar
...    
untereiner committed
518

519
520
//			map.sewFaces(d1, dN);
//			map.sewFaces(d2, map.phi1(map.phi1(dN)));
untereiner's avatar
...    
untereiner committed
521
522
523
524
525
526

			edgePlanes[d1] = Geom::Plane3D<typename PFP::REAL>(ortho, p1-(width*ortho));
			edgePlanes[d2] = Geom::Plane3D<typename PFP::REAL>(-1.0f*ortho, p2+(width*ortho));
		}
	}

527
528
529
530
531
532
533
534
	std::cout << "Broken line faces : inserted" << std::endl;

//	//close the intersections
//	for(Dart d = map.begin();d != map.end(); map.next(d))
//	{
//		if(map.isBoundaryMarked(map.phi2(d)))
//			 map.closeHole(d);
//	}
untereiner's avatar
...    
untereiner committed
535
536
537
538
539
540
541
542

	//embed the path
	for(Dart d = map.begin();d != map.end(); map.next(d))
	{
		if(brokenL.isMarked(d))
		{
			Geom::Plane3D<typename PFP::REAL> pl = edgePlanes[d];

543
			std::cout << "pl " << pl << std::endl;
untereiner's avatar
...    
untereiner committed
544

545
			VEC3 pos = position[d];
untereiner's avatar
...    
untereiner committed
546
			pl.project(pos);
547
548
549
			pl = edgePlanes[map.phi_1(d)];

			pl.project(pos);
untereiner's avatar
...    
untereiner committed
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
			position[d] = pos;
		}
	}

	/////////////////////////////////////////////////////////////////////////////////////////////
	//process polygons


//	std::vector<std::pair<VEC3,Dart> > toConnect;
//	CellMarker connected(map,VERTEX);
//	for(Dart d = map.begin(); d != map.end(); map.next(d))
//	{
//		if( ((!boundingBox.isMarked(d) && !inside.isMarked(d)) || (boundingBox.isMarked(d) && inside.isMarked(d)))
//			&& !connected.isMarked(d)
//		  )
//		{
//			connected.mark(d);
//			toConnect.push_back(std::make_pair(position[d],d));
//		}
//	}
//
//	std::sort(toConnect.begin(), toConnect.end(),posSort<VEC3>);
//
//	for(typename std::vector<std::pair<VEC3 ,Dart > >::iterator it = toConnect.begin(); it != toConnect.end() ; ++it)
//	{
//		Dart d = it->second;
//		typename std::vector<std::pair<VEC3,Dart> >::iterator it2 = it+1;
//		if(it2!= toConnect.end())
//		{
//			Dart dd = it2->second;
//			if(!map.sameFace(map.phi2(d),map.phi2(dd)))
//			{
//				if(!map.sameFace(dd,d)) {
//					std::cout << "link" << std::endl;
//					map.linkVertices(dd,d);
//				}
//				else
//				{
//					map.splitFace(dd,d);
//					std::cout << "split" << std::endl;
//				}
//			}
//		}
//
//	}

//	CellMarker connected(map,VERTEX);
//	unsigned int i=0;
//	for(Dart d = map.begin();d != map.end(); map.next(d))
//	{
//		if(!connected.isMarked(d) && !boundingBox.isMarked(d) && !inside.isMarked(d))
//		{
//			i++;
//			Dart dMin=map.end();
//			float distMin = std::numeric_limits<float>::max();
//			for(Dart dd = map.begin(); dd != map.end(); map.next(dd))
//			{
//				if(    (
//						(boundingBox.isMarked(dd) && inside.isMarked(dd))
//					|| (!boundingBox.isMarked(dd) && !inside.isMarked(dd))
//					   )
//						&& !map.sameFace(map.phi2(d),map.phi2(dd)))
//				{
//					if(Geom::testOrientation2D(position[dd], position[d], position[map.phi1(d)]) == Geom::LEFT
//							&& Geom::testOrientation2D(position[dd], position[d], position[map.phi_1(d)]) == Geom::RIGHT)
//					{
//						float dist = (position[dd]-position[d]).norm();
//						if(dist<distMin)
//						{
//							distMin = dist;
//							dMin = dd;
//						}
//					}
//				}
//			}
//
//			if(dMin!=map.end())
//			{
//				bool noIntersect=true;
//				CellMarker edgeM(map,EDGE);
//				edgeM.mark(d);
//				edgeM.mark(dMin);
////				edgeM.mark(map.phi1(d));
////				edgeM.mark(map.phi_1(d));
////				edgeM.mark(map.phi1(dMin));
////				edgeM.mark(map.phi_1(dMin));
//				for(Dart dd = map.begin();noIntersect &&  dd != map.end(); map.next(dd))
//				{
//					if(!edgeM.isMarked(dd))
//					{
//						edgeM.mark(dd);
//						VEC3 inter;
//						Geom::Intersection eeI = Geom::intersection2DSegmentSegment(position[dd],position[map.phi1(dd)],position[dMin],position[d],inter);
//						if(eeI ==Geom::EDGE_INTERSECTION)
//						{
//							noIntersect=false;
////							std::cout << "dd " << dd << " d " << d << " dMin " << dMin << std::endl;
//							std::cout << " pos " << position[dd] << " ; " << position[map.phi1(dd)] << std::endl;
//						}
//					}
//				}
//
//				if(noIntersect)
//				{
//					if(!map.sameFace(dMin,d)) {
//						connected.mark(d);
//						connected.mark(dMin);
//						map.linkVertices(dMin,d);
//					}
//					else
//					{
//						map.splitFace(dMin,d);
//						connected.mark(d);
//						connected.mark(dMin);
//					}
//				}
//			}
//		}
//	}

	return true ;
}

Pierre Kraemer's avatar
Pierre Kraemer committed
673
} // namespace Import
untereiner's avatar
...    
untereiner committed
674

Pierre Kraemer's avatar
Pierre Kraemer committed
675
} // namespace Algo
untereiner's avatar
...    
untereiner committed
676

Pierre Kraemer's avatar
Pierre Kraemer committed
677
} // namespace CGoGN