VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataLineEmbedder Class Reference

Not implemented. Takes a number of lines and embeds them in a mesh. More...

#include <vtkvmtkPolyDataLineEmbedder.h>

Inheritance diagram for vtkvmtkPolyDataLineEmbedder:
[legend]
Collaboration diagram for vtkvmtkPolyDataLineEmbedder:
[legend]

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataLineEmbedder * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual vtkIdList * GetEmbeddedLinePointIds ()
virtual void SetLines (vtkPolyData *)
virtual vtkPolyData * GetLines ()
virtual void SetEdgeArrayName (const char *)
virtual char * GetEdgeArrayName ()
virtual void SetEdgePCoordArrayName (const char *)
virtual char * GetEdgePCoordArrayName ()
virtual void SetSnapToMeshTolerance (double)
virtual double GetSnapToMeshTolerance ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkPolyDataLineEmbedder * SafeDownCast (vtkObjectBase *o)
static vtkvmtkPolyDataLineEmbedder * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataLineEmbedder ()
 ~vtkvmtkPolyDataLineEmbedder ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkIdType GetCellId (vtkPolyData *input, vtkIdList *pointIds)
void GetNeighbors (vtkIdType pointId, vtkIdList *neighborPointIds)
void OrderNeighborhood (vtkIdList *cellPointIds, vtkIdList *neighborIds, vtkIdList *addedPointIds, vtkIdList *snapToMeshIds, vtkDataArray *edgeArray, vtkDataArray *edgePCoordArray, vtkIdList *orderedNeighborIds)
void Triangulate (vtkIdList *cellPointIds, vtkIdList *orderedNeighborIds, vtkIdList *triangulationIds)

Protected Attributes

char * EdgeArrayName
char * EdgePCoordArrayName
double SnapToMeshTolerance
vtkPolyData * Lines
vtkIdList * EmbeddedLinePointIds

Detailed Description

Not implemented. Takes a number of lines and embeds them in a mesh.

The idea was to use this to try to partition triangles, but it became to messy (luca reports).

Definition at line 33 of file vtkvmtkPolyDataLineEmbedder.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataLineEmbedder::Superclass

Definition at line 36 of file vtkvmtkPolyDataLineEmbedder.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataLineEmbedder()

vtkvmtkPolyDataLineEmbedder::vtkvmtkPolyDataLineEmbedder ( )
protected

Definition at line 38 of file vtkvmtkPolyDataLineEmbedder.cxx.

39{
40 this->Lines = NULL;
41 this->EdgeArrayName = NULL;
42 this->EdgePCoordArrayName = NULL;
43 this->EmbeddedLinePointIds = vtkIdList::New();
44 this->EmbeddedLinePointIds->Register(this);
45 this->EmbeddedLinePointIds->Delete();
46 this->SnapToMeshTolerance = 0.0;
47}

◆ ~vtkvmtkPolyDataLineEmbedder()

vtkvmtkPolyDataLineEmbedder::~vtkvmtkPolyDataLineEmbedder ( )
protected

Definition at line 49 of file vtkvmtkPolyDataLineEmbedder.cxx.

50{
51 this->EmbeddedLinePointIds->UnRegister(this);
52
53 if (this->Lines)
54 {
55 this->Lines->Delete();
56 this->Lines = NULL;
57 }
58}

Member Function Documentation

◆ IsTypeOf()

int vtkvmtkPolyDataLineEmbedder::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkPolyDataLineEmbedder::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkPolyDataLineEmbedder * vtkvmtkPolyDataLineEmbedder::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataLineEmbedder::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataLineEmbedder * vtkvmtkPolyDataLineEmbedder::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkPolyDataLineEmbedder::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 594 of file vtkvmtkPolyDataLineEmbedder.cxx.

595{
596 this->Superclass::PrintSelf(os,indent);
597}

◆ New()

vtkvmtkPolyDataLineEmbedder * vtkvmtkPolyDataLineEmbedder::New ( )
static

◆ SetLines()

virtual void vtkvmtkPolyDataLineEmbedder::SetLines ( vtkPolyData * )
virtual

Set/Get the poly data holding the line(s) (VTK_LINE / VTK_POLY_LINE cells) to be embedded into the input surface mesh. Each point of Lines must carry, in EdgeArrayName and EdgePCoordArrayName, the mesh edge (pair of input point ids) it lies on and its parametric position along that edge.

◆ GetLines()

virtual vtkPolyData * vtkvmtkPolyDataLineEmbedder::GetLines ( )
virtual

Set/Get the poly data holding the line(s) (VTK_LINE / VTK_POLY_LINE cells) to be embedded into the input surface mesh. Each point of Lines must carry, in EdgeArrayName and EdgePCoordArrayName, the mesh edge (pair of input point ids) it lies on and its parametric position along that edge.

◆ SetEdgeArrayName()

virtual void vtkvmtkPolyDataLineEmbedder::SetEdgeArrayName ( const char * )
virtual

Set/Get the name of the 2-component point data array on Lines giving, for each line point, the ids of the two input mesh points bounding the edge it lies on (both -1 if the line point is not located on a mesh edge). Required input. Commonly named "EdgeArray".

◆ GetEdgeArrayName()

virtual char * vtkvmtkPolyDataLineEmbedder::GetEdgeArrayName ( )
virtual

Set/Get the name of the 2-component point data array on Lines giving, for each line point, the ids of the two input mesh points bounding the edge it lies on (both -1 if the line point is not located on a mesh edge). Required input. Commonly named "EdgeArray".

◆ SetEdgePCoordArrayName()

virtual void vtkvmtkPolyDataLineEmbedder::SetEdgePCoordArrayName ( const char * )
virtual

Set/Get the name of the point data array on Lines giving, for each line point, its parametric coordinate (0 to 1) along the mesh edge identified by EdgeArrayName. Required input. Commonly named "EdgePCoordArray".

◆ GetEdgePCoordArrayName()

virtual char * vtkvmtkPolyDataLineEmbedder::GetEdgePCoordArrayName ( )
virtual

Set/Get the name of the point data array on Lines giving, for each line point, its parametric coordinate (0 to 1) along the mesh edge identified by EdgeArrayName. Required input. Commonly named "EdgePCoordArray".

◆ SetSnapToMeshTolerance()

virtual void vtkvmtkPolyDataLineEmbedder::SetSnapToMeshTolerance ( double )
virtual

Set/Get the parametric-coordinate tolerance, along a mesh edge, within which a line point is snapped onto the existing mesh vertex at that end of the edge instead of inserting a new point. A value of 0 (default) disables snapping and always inserts a new point.

◆ GetSnapToMeshTolerance()

virtual double vtkvmtkPolyDataLineEmbedder::GetSnapToMeshTolerance ( )
virtual

Set/Get the parametric-coordinate tolerance, along a mesh edge, within which a line point is snapped onto the existing mesh vertex at that end of the edge instead of inserting a new point. A value of 0 (default) disables snapping and always inserts a new point.

◆ GetEmbeddedLinePointIds()

virtual vtkIdList * vtkvmtkPolyDataLineEmbedder::GetEmbeddedLinePointIds ( )
virtual

Get the ids, in the output mesh, of the points corresponding to each point of Lines (either newly inserted points or, where snapping occurred, ids of pre-existing mesh points). Valid only after Update() has been called.

◆ RequestData()

int vtkvmtkPolyDataLineEmbedder::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 262 of file vtkvmtkPolyDataLineEmbedder.cxx.

266{
267 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
268 vtkInformation *outInfo = outputVector->GetInformationObject(0);
269
270 vtkPolyData *input = vtkPolyData::SafeDownCast(
271 inInfo->Get(vtkDataObject::DATA_OBJECT()));
272 vtkPolyData *output = vtkPolyData::SafeDownCast(
273 outInfo->Get(vtkDataObject::DATA_OBJECT()));
274
275 vtkIdType i, j, k;
276 vtkIdType id, lineNumberOfPoints, lineNumberOfCells, cellId;
277 vtkIdType inputNumberOfPoints;
278 vtkIdType npts;
279 const vtkIdType *pts;
280 vtkIdType edgePointIds0[2], edgePointIds1[2];
281 double pCoord;
282 vtkPoints* newPoints;
283 vtkCellArray* newTriangles;
284 vtkIdList* embeddedPointIds;
285 vtkCellArray* addedTriangles;
286 vtkIdList* cellPointIds;
287 vtkIdList* newCellPointIds;
288 vtkIdList* cellsToRemove;
289 vtkPolygon* polygon;
290 vtkCell* polyLine;
291 vtkIdList* triangulationIds;
292 vtkTriangle* triangle;
293 vtkIdList* neighborIds;
294 vtkIdList* orderedNeighborIds;
295 vtkIdList* lineConnectedNeighbors;
296 vtkIdList* snapToMeshIds;
297 vtkDataArray* edgeArray;
298 vtkDataArray* edgePCoordArray;
299 double triangleArea, weights[3];
300
301 vtkPointData *inputPD = input->GetPointData();
302 vtkPointData *outputPD = output->GetPointData();
303
304 if (this->Lines->GetNumberOfPoints()==0)
305 {
306 vtkWarningMacro(<<"Line to embed has no points.");
307 return 1;
308 }
309
310 if (this->EdgeArrayName==NULL)
311 {
312 vtkErrorMacro(<<"Edge array name not specified.");
313 return 1;
314 }
315
316 if (this->EdgePCoordArrayName==NULL)
317 {
318 vtkErrorMacro(<<"EdgePCoord array name not specified.");
319 return 1;
320 }
321
322 edgeArray = this->Lines->GetPointData()->GetArray(this->EdgeArrayName);
323
324 if (edgeArray==NULL)
325 {
326 vtkErrorMacro(<<"Edge array with name specified does not exist.");
327 return 1;
328 }
329
330 edgePCoordArray = this->Lines->GetPointData()->GetArray(this->EdgePCoordArrayName);
331
332 if (edgePCoordArray==NULL)
333 {
334 vtkErrorMacro(<<"EdgePCoord array with name specified does not exist.");
335 return 1;
336 }
337
338 newPoints = vtkPoints::New();
339 newTriangles = vtkCellArray::New();
340 embeddedPointIds = vtkIdList::New();
341 addedTriangles = vtkCellArray::New();
342 cellPointIds = vtkIdList::New();
343 newCellPointIds = vtkIdList::New();
344 cellsToRemove = vtkIdList::New();
345 polygon = vtkPolygon::New();
346 triangulationIds = vtkIdList::New();
347 neighborIds = vtkIdList::New();
348 orderedNeighborIds = vtkIdList::New();
349 lineConnectedNeighbors = vtkIdList::New();
350 snapToMeshIds = vtkIdList::New();
351
352 newPoints->DeepCopy(input->GetPoints());
353
354 input->BuildCells();
355 input->BuildLinks();
356
357 this->Lines->BuildCells();
358 this->Lines->BuildLinks();
359
360 inputNumberOfPoints = input->GetNumberOfPoints();
361
362 lineNumberOfPoints = this->Lines->GetNumberOfPoints();
363 lineNumberOfCells = this->Lines->GetNumberOfCells();
364
365 outputPD->InterpolateAllocate(inputPD,inputNumberOfPoints+lineNumberOfPoints);
366
367 for (i=0; i<inputNumberOfPoints; i++)
368 {
369 outputPD->CopyData(inputPD,i,i);
370 }
371
372 snapToMeshIds->SetNumberOfIds(lineNumberOfPoints);
373 embeddedPointIds->SetNumberOfIds(lineNumberOfPoints);
374
375 for (i=0; i<lineNumberOfPoints; i++)
376 {
377 edgePointIds0[0] = static_cast<vtkIdType>(edgeArray->GetComponent(i,0));
378 edgePointIds0[1] = static_cast<vtkIdType>(edgeArray->GetComponent(i,1));
379 pCoord = edgePCoordArray->GetComponent(i,0);
380
381 if (this->SnapToMeshTolerance>0.0)
382 {
383 if (edgePointIds0[0] == -1)
384 {
385 snapToMeshIds->SetId(i,-1);
386 }
387 else
388 {
389 if (pCoord < this->SnapToMeshTolerance)
390 {
391 snapToMeshIds->SetId(i,edgePointIds0[0]);
392 }
393 else if (pCoord > 1.0-this->SnapToMeshTolerance)
394 {
395 snapToMeshIds->SetId(i,edgePointIds0[1]);
396 }
397 else
398 {
399 snapToMeshIds->SetId(i,-1);
400 }
401 }
402 }
403 else
404 {
405 snapToMeshIds->SetId(i,-1);
406 }
407
408 if (snapToMeshIds->GetId(i)==-1)
409 {
410 id = newPoints->InsertNextPoint(this->Lines->GetPoint(i));
411 if (edgePointIds0[0] != -1)
412 {
413 outputPD->InterpolateEdge(inputPD,id,edgePointIds0[0],edgePointIds0[1],pCoord);
414 }
415 }
416 else
417 {
418 id = snapToMeshIds->GetId(i);
419 }
420
421 embeddedPointIds->SetId(i,id);
422 }
423
424 for (k=0; k<lineNumberOfCells; k++)
425 {
426 polyLine = this->Lines->GetCell(k);
427 if (polyLine->GetCellType() != VTK_LINE && polyLine->GetCellType() != VTK_POLY_LINE)
428 {
429 continue;
430 }
431
432 for (i=1; i<polyLine->GetNumberOfPoints(); i++)
433 {
434 edgePointIds0[0] = static_cast<vtkIdType>(edgeArray->GetComponent(polyLine->GetPointId(i-1),0));
435 edgePointIds0[1] = static_cast<vtkIdType>(edgeArray->GetComponent(polyLine->GetPointId(i-1),1));
436 edgePointIds1[0] = static_cast<vtkIdType>(edgeArray->GetComponent(polyLine->GetPointId(i),0));
437 edgePointIds1[1] = static_cast<vtkIdType>(edgeArray->GetComponent(polyLine->GetPointId(i),1));
438
439 if ((snapToMeshIds->GetId(polyLine->GetPointId(i-1))!=-1)&&(snapToMeshIds->GetId(polyLine->GetPointId(i))!=-1))
440 {
441 continue;
442 }
443
444 if ((edgePointIds0[0]==-1)||(edgePointIds1[0]==-1))
445 {
446 continue;
447 }
448
449 cellPointIds->Initialize();
450 cellPointIds->InsertNextId(edgePointIds0[0]);
451 cellPointIds->InsertUniqueId(edgePointIds0[1]);
452 cellPointIds->InsertUniqueId(edgePointIds1[0]);
453 cellPointIds->InsertUniqueId(edgePointIds1[1]);
454
455 cellId = this->GetCellId(input,cellPointIds);
456
457 cellsToRemove->InsertUniqueId(cellId);
458 }
459 }
460
461 for (i=0; i<cellsToRemove->GetNumberOfIds(); i++)
462 {
463 cellId = cellsToRemove->GetId(i);
464 cellPointIds->Initialize();
465 input->GetCellPoints(cellId,cellPointIds);
466
467 neighborIds->Initialize();
468
469 for (k=0; k<lineNumberOfPoints; k++)
470 {
471 edgePointIds0[0] = static_cast<vtkIdType>(edgeArray->GetComponent(k,0));
472 edgePointIds0[1] = static_cast<vtkIdType>(edgeArray->GetComponent(k,1));
473
474 for (j=0; j<cellPointIds->GetNumberOfIds(); j++)
475 {
476 if (((cellPointIds->GetId(j)==edgePointIds0[0])&&(cellPointIds->GetId((j+1)%cellPointIds->GetNumberOfIds())==edgePointIds0[1]))||
477 ((cellPointIds->GetId(j)==edgePointIds0[1])&&(cellPointIds->GetId((j+1)%cellPointIds->GetNumberOfIds())==edgePointIds0[0])))
478 {
479 neighborIds->InsertNextId(k);
480 break;
481 }
482 }
483 }
484
485 orderedNeighborIds->Initialize();
486 this->OrderNeighborhood(cellPointIds,neighborIds,embeddedPointIds,snapToMeshIds,edgeArray,edgePCoordArray,orderedNeighborIds);
487
488 triangulationIds->Initialize();
489 this->Triangulate(cellPointIds,orderedNeighborIds,triangulationIds);
490
491 for (j=0; j<triangulationIds->GetNumberOfIds(); j+=3)
492 {
493 addedTriangles->InsertNextCell(3);
494 addedTriangles->InsertCellPoint(orderedNeighborIds->GetId(triangulationIds->GetId(j)));
495 addedTriangles->InsertCellPoint(orderedNeighborIds->GetId(triangulationIds->GetId(j+1)));
496 addedTriangles->InsertCellPoint(orderedNeighborIds->GetId(triangulationIds->GetId(j+2)));
497 }
498 }
499
500 for (i=0; i<lineNumberOfPoints; i++)
501 {
502 edgePointIds0[0] = static_cast<vtkIdType>(edgeArray->GetComponent(i,0));
503
504 if (edgePointIds0[0]!=-1)
505 {
506 continue;
507 }
508
509 neighborIds->Initialize();
510 this->GetNeighbors(i,neighborIds);
511
512 cellPointIds->Initialize();
513 for (j=0; j<neighborIds->GetNumberOfIds(); j++)
514 {
515 edgePointIds1[0] = static_cast<vtkIdType>(edgeArray->GetComponent(neighborIds->GetId(j),0));
516 edgePointIds1[1] = static_cast<vtkIdType>(edgeArray->GetComponent(neighborIds->GetId(j),1));
517 cellPointIds->InsertUniqueId(edgePointIds1[0]);
518 cellPointIds->InsertUniqueId(edgePointIds1[1]);
519 }
520
521 cellId = this->GetCellId(input,cellPointIds);
522
523 cellsToRemove->InsertUniqueId(cellId);
524
525 cellPointIds->Initialize();
526 input->GetCellPoints(cellId,cellPointIds);
527
528 orderedNeighborIds->Initialize();
529 this->OrderNeighborhood(cellPointIds,neighborIds,embeddedPointIds,snapToMeshIds,edgeArray,edgePCoordArray,orderedNeighborIds);
530
531 for (j=0; j<orderedNeighborIds->GetNumberOfIds(); j++)
532 {
533 addedTriangles->InsertNextCell(3);
534 addedTriangles->InsertCellPoint(embeddedPointIds->GetId(i));
535 addedTriangles->InsertCellPoint(orderedNeighborIds->GetId(j));
536 addedTriangles->InsertCellPoint(orderedNeighborIds->GetId((j+1)%orderedNeighborIds->GetNumberOfIds()));
537 }
538
539 double newPoint0[3], newPoint1[3], newPoint2[3], embeddedPoint[3];
540 newPoints->GetPoint(cellPointIds->GetId(0),newPoint0);
541 newPoints->GetPoint(cellPointIds->GetId(1),newPoint1);
542 newPoints->GetPoint(cellPointIds->GetId(2),newPoint2);
543 newPoints->GetPoint(embeddedPointIds->GetId(i),embeddedPoint);
544
545 triangleArea = vtkvmtkMath::TriangleArea(newPoint0,newPoint1,newPoint1);
546 weights[0] = vtkvmtkMath::TriangleArea(embeddedPoint,newPoint1,newPoint2) / triangleArea;
547 weights[1] = vtkvmtkMath::TriangleArea(newPoint0,embeddedPoint,newPoint2) / triangleArea;
548 weights[2] = vtkvmtkMath::TriangleArea(newPoint0,newPoint1,embeddedPoint) / triangleArea;
549
550 outputPD->InterpolatePoint(inputPD,embeddedPointIds->GetId(i),cellPointIds,weights);
551
552 }
553
554 for (addedTriangles->InitTraversal(); addedTriangles->GetNextCell(npts,pts); )
555 {
556 newTriangles->InsertNextCell(npts,pts);
557 }
558
559 for (i=0; i<input->GetNumberOfCells(); i++)
560 {
561 triangle = vtkTriangle::SafeDownCast(input->GetCell(i));
562 if (triangle==NULL)
563 {
564 continue;
565 }
566 if (cellsToRemove->IsId(i)==-1)
567 {
568 newTriangles->InsertNextCell(triangle);
569 }
570 }
571
572 output->SetPoints(newPoints);
573 output->SetPolys(newTriangles);
574
575 this->EmbeddedLinePointIds->DeepCopy(embeddedPointIds);
576
577 newPoints->Delete();
578 newTriangles->Delete();
579 embeddedPointIds->Delete();
580 addedTriangles->Delete();
581 cellPointIds->Delete();
582 newCellPointIds->Delete();
583 cellsToRemove->Delete();
584 polygon->Delete();
585 triangulationIds->Delete();
586 neighborIds->Delete();
587 orderedNeighborIds->Delete();
588 lineConnectedNeighbors->Delete();
589 snapToMeshIds->Delete();
590
591 return 1;
592}
static double TriangleArea(double point0[3], double point1[3], double point2[3])
void Triangulate(vtkIdList *cellPointIds, vtkIdList *orderedNeighborIds, vtkIdList *triangulationIds)
vtkIdType GetCellId(vtkPolyData *input, vtkIdList *pointIds)
void OrderNeighborhood(vtkIdList *cellPointIds, vtkIdList *neighborIds, vtkIdList *addedPointIds, vtkIdList *snapToMeshIds, vtkDataArray *edgeArray, vtkDataArray *edgePCoordArray, vtkIdList *orderedNeighborIds)
void GetNeighbors(vtkIdType pointId, vtkIdList *neighborPointIds)

◆ GetCellId()

vtkIdType vtkvmtkPolyDataLineEmbedder::GetCellId ( vtkPolyData * input,
vtkIdList * pointIds )
protected

Definition at line 60 of file vtkvmtkPolyDataLineEmbedder.cxx.

61{
62 vtkIdType i, cellId;
63 vtkIdList *cellIds, *neighborCellIds;
64
65 cellIds = vtkIdList::New();
66 neighborCellIds = vtkIdList::New();
67
68 for (i=0; i<pointIds->GetNumberOfIds(); i++)
69 {
70 input->GetCellEdgeNeighbors(-1,pointIds->GetId(i),pointIds->GetId(i+1),neighborCellIds);
71 if (cellIds->GetNumberOfIds()==0)
72 {
73 cellIds->DeepCopy(neighborCellIds);
74 }
75 else
76 {
77 cellIds->IntersectWith(neighborCellIds);
78 }
79 }
80
81 cellId = cellIds->GetId(0);
82
83 cellIds->Delete();
84 neighborCellIds->Delete();
85
86 return cellId;
87}

◆ GetNeighbors()

void vtkvmtkPolyDataLineEmbedder::GetNeighbors ( vtkIdType pointId,
vtkIdList * neighborPointIds )
protected

Definition at line 89 of file vtkvmtkPolyDataLineEmbedder.cxx.

90{
91 vtkIdType i, j;
92 vtkIdType *cells, npts;
93 const vtkIdType *pts;
94 vtkIdType ncells;
95
96 this->Lines->GetPointCells(pointId,ncells,cells);
97
98 for (i=0; i<ncells; i++)
99 {
100 this->Lines->GetCellPoints(cells[i],npts,pts);
101 for (j=0; j<npts; j++)
102 {
103 if (pts[j]==pointId)
104 {
105 if (j>0)
106 {
107 neighborPointIds->InsertUniqueId(pts[j-1]);
108 }
109 if (j<npts-1)
110 {
111 neighborPointIds->InsertUniqueId(pts[j+1]);
112 }
113 }
114 }
115 }
116}

◆ OrderNeighborhood()

void vtkvmtkPolyDataLineEmbedder::OrderNeighborhood ( vtkIdList * cellPointIds,
vtkIdList * neighborIds,
vtkIdList * addedPointIds,
vtkIdList * snapToMeshIds,
vtkDataArray * edgeArray,
vtkDataArray * edgePCoordArray,
vtkIdList * orderedNeighborIds )
protected

Definition at line 118 of file vtkvmtkPolyDataLineEmbedder.cxx.

119{
120 vtkIdType j, k, h;
121 vtkIdType lastCellPointIdId;
122 double pCoord;
123 vtkIdType edgePointIds[2];
124 vtkDoubleArray* orderedNeighborPCoordArray;
125
126 orderedNeighborPCoordArray = vtkDoubleArray::New();
127
128 for (j=0; j<cellPointIds->GetNumberOfIds(); j++)
129 {
130 orderedNeighborIds->InsertNextId(cellPointIds->GetId(j));
131 orderedNeighborPCoordArray->InsertNextValue(0.0);
132
133 lastCellPointIdId = orderedNeighborIds->GetNumberOfIds()-1;
134
135 for (k=0; k<neighborIds->GetNumberOfIds(); k++)
136 {
137 if (snapToMeshIds->GetId(neighborIds->GetId(k))!=-1)
138 {
139 continue;
140 }
141
142 edgePointIds[0] = (int)edgeArray->GetComponent(neighborIds->GetId(k),0);
143 edgePointIds[1] = (int)edgeArray->GetComponent(neighborIds->GetId(k),1);
144
145 if ((cellPointIds->GetId(j)==edgePointIds[0]) && (cellPointIds->GetId((j+1)%cellPointIds->GetNumberOfIds())==edgePointIds[1]))
146 {
147 pCoord = edgePCoordArray->GetComponent(neighborIds->GetId(k),0);
148 }
149 else if ((cellPointIds->GetId(j)==edgePointIds[1]) && (cellPointIds->GetId((j+1)%cellPointIds->GetNumberOfIds())==edgePointIds[0]))
150 {
151 pCoord = 1.0 - edgePCoordArray->GetComponent(neighborIds->GetId(k),0);
152 }
153 else
154 {
155 continue;
156 }
157
158 for (h=orderedNeighborIds->GetNumberOfIds()-1; h>=lastCellPointIdId; h--)
159 {
160 if (pCoord<orderedNeighborPCoordArray->GetValue(h))
161 {
162 orderedNeighborIds->InsertId(h+1,orderedNeighborIds->GetId(h));
163 orderedNeighborPCoordArray->InsertValue(h+1,orderedNeighborPCoordArray->GetValue(h));
164 }
165 else
166 {
167 orderedNeighborIds->InsertId(h+1,embeddedPointIds->GetId(neighborIds->GetId(k)));
168 orderedNeighborPCoordArray->InsertValue(h+1,pCoord);
169 break;
170 }
171 }
172 }
173 }
174
175 orderedNeighborPCoordArray->Delete();
176}

◆ Triangulate()

void vtkvmtkPolyDataLineEmbedder::Triangulate ( vtkIdList * cellPointIds,
vtkIdList * orderedNeighborIds,
vtkIdList * triangulationIds )
protected

Definition at line 178 of file vtkvmtkPolyDataLineEmbedder.cxx.

179{
180 vtkIdType triangleIds[3];
181 vtkIdType noMove[3];
182 vtkIdType numberOfNeighbors;
183 bool done;
184
185 numberOfNeighbors = orderedNeighborIds->GetNumberOfIds();
186
187 if (numberOfNeighbors==3)
188 {
189 triangulationIds->InsertNextId(0);
190 triangulationIds->InsertNextId(1);
191 triangulationIds->InsertNextId(2);
192 }
193
194 done = false;
195
196 triangleIds[0] = 0;
197 while (!done)
198 {
199 triangleIds[1] = (triangleIds[0]+1)%numberOfNeighbors;
200 triangleIds[2] = (triangleIds[0]-1+numberOfNeighbors)%numberOfNeighbors;
201
202 if ((cellPointIds->IsId(orderedNeighborIds->GetId(triangleIds[0]))==-1)||
203 (cellPointIds->IsId(orderedNeighborIds->GetId(triangleIds[1]))==-1)||
204 (cellPointIds->IsId(orderedNeighborIds->GetId(triangleIds[2]))==-1))
205 {
206 done = true;
207 break;
208 }
209
210 triangleIds[0] = triangleIds[1];
211 }
212
213
214 noMove[0] = 0;
215 noMove[1] = 0;
216 noMove[2] = 0;
217
218 done = false;
219 while (!done)
220 {
221 triangulationIds->InsertNextId(triangleIds[0]);
222 triangulationIds->InsertNextId(triangleIds[1]);
223 triangulationIds->InsertNextId(triangleIds[2]);
224
225 if (cellPointIds->IsId(orderedNeighborIds->GetId(triangleIds[1]))!=-1)
226 {
227 triangleIds[0] = triangleIds[1];
228 triangleIds[1] = (triangleIds[1]+1)%numberOfNeighbors;
229 noMove[1] = 0;
230 ++noMove[2];
231 }
232 else if (cellPointIds->IsId(orderedNeighborIds->GetId(triangleIds[2]))!=-1)
233 {
234 triangleIds[0] = triangleIds[2];
235 triangleIds[2] = (triangleIds[2]-1+numberOfNeighbors)%numberOfNeighbors;
236 ++noMove[1];
237 noMove[2] = 0;
238 }
239 else
240 {
241 if (noMove[1]>noMove[2])
242 {
243 triangleIds[0] = triangleIds[1];
244 triangleIds[1] = (triangleIds[1]+1)%numberOfNeighbors;
245 noMove[1] = 0;
246 ++noMove[2];
247 }
248 else
249 {
250 triangleIds[0] = triangleIds[2];
251 triangleIds[2] = (triangleIds[2]-1+numberOfNeighbors)%numberOfNeighbors;
252 ++noMove[1];
253 noMove[2] = 0;
254 }
255 }
256
257 if (triangleIds[1]==triangleIds[2])
258 done = true;
259 }
260}

Member Data Documentation

◆ EdgeArrayName

char* vtkvmtkPolyDataLineEmbedder::EdgeArrayName
protected

Definition at line 100 of file vtkvmtkPolyDataLineEmbedder.h.

◆ EdgePCoordArrayName

char* vtkvmtkPolyDataLineEmbedder::EdgePCoordArrayName
protected

Definition at line 101 of file vtkvmtkPolyDataLineEmbedder.h.

◆ SnapToMeshTolerance

double vtkvmtkPolyDataLineEmbedder::SnapToMeshTolerance
protected

Definition at line 102 of file vtkvmtkPolyDataLineEmbedder.h.

◆ Lines

vtkPolyData* vtkvmtkPolyDataLineEmbedder::Lines
protected

Definition at line 103 of file vtkvmtkPolyDataLineEmbedder.h.

◆ EmbeddedLinePointIds

vtkIdList* vtkvmtkPolyDataLineEmbedder::EmbeddedLinePointIds
protected

Definition at line 105 of file vtkvmtkPolyDataLineEmbedder.h.


The documentation for this class was generated from the following files: