106 vtkInformation *vtkNotUsed(request),
107 vtkInformationVector **inputVector,
108 vtkInformationVector *outputVector)
110 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
111 vtkInformation *outInfo = outputVector->GetInformationObject(0);
113 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
114 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
116 vtkPoints* inputPoints = input->GetPoints();
120 vtkErrorMacro(
"WarpVectors array name not specified.");
126 vtkErrorMacro(
"CellEntityIds array name not specified.");
130 if (!input->GetPointData()->GetArray(this->WarpVectorsArrayName))
132 vtkErrorMacro(<<
"WarpVectors array with name specified does not exist!");
142 vtkErrorMacro(
"LayerThickness array name not specified.");
146 if (!input->GetPointData()->GetArray(this->LayerThicknessArrayName))
148 vtkErrorMacro(<<
"LayerThickness array with name specified does not exist!");
157 vtkPoints* outputPoints = vtkPoints::New();
158 vtkPoints* warpedPoints = vtkPoints::New();
160 vtkCellArray* boundaryLayerCellArray = vtkCellArray::New();
161 vtkIdList* boundaryLayerCellTypes = vtkIdList::New();
163 vtkIntArray* cellEntityIdsArray = vtkIntArray::New();
166 vtkIntArray* innerSurfaceCellEntityIdsArray = vtkIntArray::New();
169 vtkUnsignedCharArray* checkArray = vtkUnsignedCharArray::New();
170 checkArray->SetNumberOfTuples(input->GetNumberOfCells());
171 checkArray->FillComponent(0,1);
173 vtkIdType numberOfInputPoints = inputPoints->GetNumberOfPoints();
174 vtkIdType numberOfInputCells = input->GetNumberOfCells();
177 cellType = input->GetCellType(0);
178 bool warpQuadratic =
false;
179 if (cellType == VTK_QUADRATIC_TRIANGLE)
181 warpQuadratic =
true;
184 vtkIdType numberOfLayerPoints = numberOfInputPoints;
187 numberOfLayerPoints = 2 * numberOfInputPoints;
190 vtkIdType numberOfOutputPoints = numberOfInputPoints + numberOfLayerPoints * this->
NumberOfSubLayers;
191 outputPoints->SetNumberOfPoints(numberOfOutputPoints);
194 for (i=0; i<numberOfInputPoints; i++)
196 inputPoints->GetPoint(i,point);
197 outputPoints->SetPoint(i,point);
201 const vtkIdType *pts;
202 vtkIdType *surfacePts;
206 for (i=0; i<numberOfInputCells; i++)
208 input->GetCellPoints(i,npts,pts);
209 cellType = input->GetCellType(i);
210 surfacePts =
new vtkIdType[npts];
214 boundaryLayerCellTypes->InsertNextId(VTK_TRIANGLE);
215 surfacePts[0] = pts[0];
216 surfacePts[1] = pts[1];
217 surfacePts[2] = pts[2];
220 boundaryLayerCellTypes->InsertNextId(VTK_QUAD);
221 surfacePts[0] = pts[0];
222 surfacePts[1] = pts[1];
223 surfacePts[2] = pts[2];
224 surfacePts[3] = pts[3];
226 case VTK_QUADRATIC_TRIANGLE:
227 boundaryLayerCellTypes->InsertNextId(VTK_QUADRATIC_TRIANGLE);
228 surfacePts[0] = pts[0];
229 surfacePts[1] = pts[1];
230 surfacePts[2] = pts[2];
231 surfacePts[3] = pts[3];
232 surfacePts[4] = pts[4];
233 surfacePts[5] = pts[5];
236 vtkErrorMacro(<<
"Unsupported surface element.");
240 boundaryLayerCellArray->InsertNextCell(npts,surfacePts);
246 vtkIdList* edgePointIds = vtkIdList::New();
247 vtkIdList* edgeNeighborCellIds = vtkIdList::New();
252 int finalNumberOfSubsteps = this->
NumberOfSubsteps - initialNumberOfSubsteps - intermediateNumberOfSubsteps;
261 std::cout <<
"untangle procedure.. " << tangled <<
" tangled cells" << std::endl;
271 int fewestTangled = tangled;
272 int roundsWithoutImprovement = 0;
273 while (tangled > 0 && iteration < maximumNumberOfIterations)
281 std::cout <<
"untangle iteration " << iteration <<
": untangled, sweeping the rest" << std::endl;
285 std::cout <<
"untangle iteration " << iteration <<
": " << tangled <<
" tangled cells" << std::endl;
286 if (tangled < fewestTangled)
288 fewestTangled = tangled;
289 roundsWithoutImprovement = 0;
293 std::cout <<
"untangle procedure stopped: " << tangled <<
" cells are still tangled after "
294 << roundsWithoutImprovement <<
" rounds without improvement" << std::endl;
301 for (k=0; k<this->NumberOfSubLayers; k++)
303 warpedPoints->Initialize();
304 this->
WarpPoints(inputPoints,warpedPoints,k,warpQuadratic);
306 for (i=0; i<numberOfLayerPoints; i++)
308 warpedPoints->GetPoint(i,point);
309 outputPoints->SetPoint(i + numberOfInputPoints + k*numberOfLayerPoints,point);
312 vtkIdType prismNPts, *prismPts;
313 vtkIdType quadNPts, *quadPts;
314 for (i=0; i<numberOfInputCells; i++)
316 input->GetCellPoints(i,npts,pts);
317 cellType = input->GetCellType(i);
318 if (cellType == VTK_TRIANGLE || cellType == VTK_QUAD)
320 prismNPts = npts * 2;
321 prismPts =
new vtkIdType[prismNPts];
323 quadPts =
new vtkIdType[quadNPts];
325 for (j=0; j<npts; j++)
327 prismPts[j] = pts[j] + k*numberOfLayerPoints;
329 for (j=0; j<npts; j++)
331 prismPts[j+npts] = pts[j] + (k+1)*numberOfLayerPoints;
333 boundaryLayerCellArray->InsertNextCell(prismNPts,prismPts);
336 if (cellType == VTK_TRIANGLE)
338 boundaryLayerCellTypes->InsertNextId(VTK_WEDGE);
340 else if (cellType == VTK_QUAD)
342 boundaryLayerCellTypes->InsertNextId(VTK_HEXAHEDRON);
347 for (j=0; j<npts; j++)
349 vtkIdType jnext = (j+1) % npts;
350 edgePointIds->Initialize();
351 edgePointIds->SetNumberOfIds(2);
352 edgePointIds->SetId(0,pts[j]);
353 edgePointIds->SetId(1,pts[jnext]);
354 input->GetCellNeighbors(i,edgePointIds,edgeNeighborCellIds);
356 if (edgeNeighborCellIds->GetNumberOfIds() > 0)
361 quadPts[0] = prismPts[j];
362 quadPts[1] = prismPts[jnext];
363 quadPts[2] = prismPts[jnext+npts];
364 quadPts[3] = prismPts[j+npts];
366 boundaryLayerCellArray->InsertNextCell(quadNPts,quadPts);
367 boundaryLayerCellTypes->InsertNextId(VTK_QUAD);
375 else if (cellType == VTK_QUADRATIC_TRIANGLE)
377 prismNPts = npts * 3 - 3;
378 prismPts =
new vtkIdType[prismNPts];
380 quadPts =
new vtkIdType[quadNPts];
382 boundaryLayerCellTypes->InsertNextId(VTK_QUADRATIC_WEDGE);
384 prismPts[0] = pts[0] + k*numberOfLayerPoints;
385 prismPts[1] = pts[1] + k*numberOfLayerPoints;
386 prismPts[2] = pts[2] + k*numberOfLayerPoints;
388 prismPts[3] = pts[0] + k*numberOfLayerPoints + numberOfLayerPoints;
389 prismPts[4] = pts[1] + k*numberOfLayerPoints + numberOfLayerPoints;
390 prismPts[5] = pts[2] + k*numberOfLayerPoints + numberOfLayerPoints;
392 prismPts[6] = pts[3] + k*numberOfLayerPoints;
393 prismPts[7] = pts[4] + k*numberOfLayerPoints;
394 prismPts[8] = pts[5] + k*numberOfLayerPoints;
396 prismPts[9] = pts[3] + k*numberOfLayerPoints + numberOfLayerPoints;
397 prismPts[10] = pts[4] + k*numberOfLayerPoints + numberOfLayerPoints;
398 prismPts[11] = pts[5] + k*numberOfLayerPoints + numberOfLayerPoints;
400 prismPts[12] = pts[0] + k*numberOfLayerPoints + numberOfLayerPoints/2;
401 prismPts[13] = pts[1] + k*numberOfLayerPoints + numberOfLayerPoints/2;
402 prismPts[14] = pts[2] + k*numberOfLayerPoints + numberOfLayerPoints/2;
404 boundaryLayerCellArray->InsertNextCell(prismNPts,prismPts);
409 for (
int j=0; j<npts/2; j++)
411 vtkIdType jnext = (j+1) % npts;
412 edgePointIds->Initialize();
413 edgePointIds->SetNumberOfIds(2);
414 edgePointIds->SetId(0,pts[j]);
415 edgePointIds->SetId(1,pts[jnext]);
416 input->GetCellNeighbors(i,edgePointIds,edgeNeighborCellIds);
418 if (edgeNeighborCellIds->GetNumberOfIds() > 0)
423 quadPts[0] = prismPts[j];
424 quadPts[1] = prismPts[jnext];
425 quadPts[2] = prismPts[jnext+npts/2];
426 quadPts[3] = prismPts[j+npts/2];
428 quadPts[4] = prismPts[j+npts];
429 quadPts[5] = prismPts[jnext+2*npts];
430 quadPts[6] = prismPts[j+npts+npts/2];
431 quadPts[7] = prismPts[j+2*npts];
433 boundaryLayerCellArray->InsertNextCell(quadNPts,quadPts);
434 boundaryLayerCellTypes->InsertNextId(VTK_QUAD);
444 vtkErrorMacro(<<
"Unsupported surface element.");
451 if (k==this->NumberOfSubLayers-1)
453 for (i=0; i<numberOfInputCells; i++)
455 input->GetCellPoints(i,npts,pts);
456 cellType = input->GetCellType(i);
457 surfacePts =
new vtkIdType[npts];
461 boundaryLayerCellTypes->InsertNextId(VTK_TRIANGLE);
462 surfacePts[0] = pts[0] + k*numberOfLayerPoints + numberOfLayerPoints;
463 surfacePts[1] = pts[1] + k*numberOfLayerPoints + numberOfLayerPoints;
464 surfacePts[2] = pts[2] + k*numberOfLayerPoints + numberOfLayerPoints;
467 boundaryLayerCellTypes->InsertNextId(VTK_QUAD);
468 surfacePts[0] = pts[0] + k*numberOfLayerPoints + numberOfLayerPoints;
469 surfacePts[1] = pts[1] + k*numberOfLayerPoints + numberOfLayerPoints;
470 surfacePts[2] = pts[2] + k*numberOfLayerPoints + numberOfLayerPoints;
471 surfacePts[3] = pts[3] + k*numberOfLayerPoints + numberOfLayerPoints;
473 case VTK_QUADRATIC_TRIANGLE:
474 boundaryLayerCellTypes->InsertNextId(VTK_QUADRATIC_TRIANGLE);
475 surfacePts[0] = pts[0] + k*numberOfLayerPoints + numberOfLayerPoints;
476 surfacePts[1] = pts[1] + k*numberOfLayerPoints + numberOfLayerPoints;
477 surfacePts[2] = pts[2] + k*numberOfLayerPoints + numberOfLayerPoints;
478 surfacePts[3] = pts[3] + k*numberOfLayerPoints + numberOfLayerPoints;
479 surfacePts[4] = pts[4] + k*numberOfLayerPoints + numberOfLayerPoints;
480 surfacePts[5] = pts[5] + k*numberOfLayerPoints + numberOfLayerPoints;
483 vtkErrorMacro(<<
"Unsupported surface element.");
487 boundaryLayerCellArray->InsertNextCell(npts,surfacePts);
495 output->SetPoints(outputPoints);
497 int* boundaryLayerCellTypesInt =
new int[boundaryLayerCellTypes->GetNumberOfIds()];
498 for (i=0; i<boundaryLayerCellTypes->GetNumberOfIds(); i++)
500 boundaryLayerCellTypesInt[i] = boundaryLayerCellTypes->GetId(i);
503 output->SetCells(boundaryLayerCellTypesInt,boundaryLayerCellArray);
505 delete[] boundaryLayerCellTypesInt;
507 output->GetCellData()->AddArray(cellEntityIdsArray);
518 vtkPoints* innerSurfacePoints = vtkPoints::New();
519 innerSurfacePoints->SetNumberOfPoints(numberOfInputPoints);
520 for (i=0; i<numberOfInputPoints; i++)
522 output->GetPoint(i + numberOfInputPoints * (this->NumberOfSubLayers),point);
523 innerSurfacePoints->SetPoint(i,point);
526 this->
InnerSurface->GetPoints()->DeepCopy(innerSurfacePoints);
527 innerSurfaceCellEntityIdsArray->SetNumberOfTuples(this->
InnerSurface->GetNumberOfCells());
529 this->
InnerSurface->GetCellData()->AddArray(innerSurfaceCellEntityIdsArray);
531 edgePointIds->Delete();
532 edgeNeighborCellIds->Delete();
534 outputPoints->Delete();
535 warpedPoints->Delete();
536 boundaryLayerCellArray->Delete();
537 boundaryLayerCellTypes->Delete();
538 innerSurfacePoints->Delete();
540 cellEntityIdsArray->Delete();
541 innerSurfaceCellEntityIdsArray->Delete();
542 checkArray->Delete();
628 vtkIdList* pointList=vtkIdList::New();
630 double warpVector1[3], warpVector2[3], warpVector3[3];
631 double basePoint1[3], basePoint2[3], basePoint3[3];
632 double warpedPoint1[3], warpedPoint2[3], warpedPoint3[3];
633 double baseNormal[3], warpedNormal[3];
636 for (vtkIdType j=0; j<input->GetNumberOfCells(); j++)
638 input->GetCellPoints(j,pointList);
640 input->GetPoint(pointList->GetId(0),basePoint1);
641 input->GetPoint(pointList->GetId(1),basePoint2);
642 input->GetPoint(pointList->GetId(2),basePoint3);
649 warpedPoint1[0] = basePoint1[0] + warpVector1[0];
650 warpedPoint1[1] = basePoint1[1] + warpVector1[1];
651 warpedPoint1[2] = basePoint1[2] + warpVector1[2];
652 warpedPoint2[0] = basePoint2[0] + warpVector2[0];
653 warpedPoint2[1] = basePoint2[1] + warpVector2[1];
654 warpedPoint2[2] = basePoint2[2] + warpVector2[2];
655 warpedPoint3[0] = basePoint3[0] + warpVector3[0];
656 warpedPoint3[1] = basePoint3[1] + warpVector3[1];
657 warpedPoint3[2] = basePoint3[2] + warpVector3[2];
660 vtkTriangle::ComputeNormal(basePoint1,basePoint2,basePoint3,baseNormal);
661 vtkTriangle::ComputeNormal(warpedPoint1,warpedPoint2,warpedPoint3,warpedNormal);
662 double prod = vtkMath::Dot(baseNormal,warpedNormal);
663 double baseArea = vtkTriangle::TriangleArea(basePoint1,basePoint2,basePoint3);
664 double warpedArea = vtkTriangle::TriangleArea(warpedPoint1,warpedPoint2,warpedPoint3);
665 double testArea = warpedArea / baseArea;
666 if (prod < 0 || testArea <= 0.1 )
669 checkArray->SetValue(j,1);
673 checkArray->SetValue(j,0);
682 vtkIdList* pointList=vtkIdList::New();
683 vtkIdList* pointList2=vtkIdList::New();
684 vtkIdList* cellList=vtkIdList::New();
686 double warpVector1[3], warpVector2[3], warpVector3[3];
687 double w1s[3], w2s[3], w3s[3], n[3];
688 double point1[3], point2[3], point3[3];
689 double c1[3], c2[3], c3[3];
691 vtkDoubleArray* correctionArray = vtkDoubleArray::New();
692 correctionArray->SetName(
"correctionVectors");
693 correctionArray->SetNumberOfComponents(3);
694 correctionArray->SetNumberOfTuples(input->GetNumberOfPoints());
695 correctionArray->FillComponent(0,0.0);
696 correctionArray->FillComponent(1,0.0);
697 correctionArray->FillComponent(2,0.0);
698 input->GetPointData()->AddArray(correctionArray);
700 for (vtkIdType j=0; j<input->GetNumberOfCells(); j++)
702 if (checkArray->GetValue(j)==1)
704 input->GetCellPoints(j,pointList);
709 double relaxation = 1.0;
710 for (
int r=0; r<relaxation; r++)
712 w1s[0] = w1s[1] = w1s[2] = 0.0;
713 w2s[0] = w2s[1] = w2s[2] = 0.0;
714 w3s[0] = w3s[1] = w3s[2] = 0.0;
715 n[0] = n[1] = n[2] = 0.0;
716 input->GetPointCells(pointList->GetId(0),cellList);
717 for (
int i=0; i<cellList->GetNumberOfIds();i++)
719 input->GetCellPoints(cellList->GetId(i),pointList2);
720 input->GetPoint(pointList2->GetId(0),point1);
721 input->GetPoint(pointList2->GetId(1),point2);
722 input->GetPoint(pointList2->GetId(2),point3);
723 vtkTriangle::ComputeNormal(point1,point2,point3,n);
724 w1s[0] += warpVector1[0] - vtkMath::Dot(warpVector1,n) * n[0];
725 w1s[1] += warpVector1[1] - vtkMath::Dot(warpVector1,n) * n[1];
726 w1s[2] += warpVector1[2] - vtkMath::Dot(warpVector1,n) * n[2];
728 vtkMath::Normalize(w1s);
729 input->GetPointCells(pointList->GetId(1),cellList);
730 for (
int i=0; i<cellList->GetNumberOfIds();i++)
732 input->GetCellPoints(cellList->GetId(i),pointList2);
733 input->GetPoint(pointList2->GetId(0),point1);
734 input->GetPoint(pointList2->GetId(1),point2);
735 input->GetPoint(pointList2->GetId(2),point3);
736 vtkTriangle::ComputeNormal(point1,point2,point3,n);
737 w2s[0] += warpVector2[0] - vtkMath::Dot(warpVector2,n) * n[0];
738 w2s[1] += warpVector2[1] - vtkMath::Dot(warpVector2,n) * n[1];
739 w2s[2] += warpVector2[2] - vtkMath::Dot(warpVector2,n) * n[2];
741 vtkMath::Normalize(w2s);
742 input->GetPointCells(pointList->GetId(2),cellList);
743 for (
int i=0; i<cellList->GetNumberOfIds();i++)
745 input->GetCellPoints(cellList->GetId(i),pointList2);
746 input->GetPoint(pointList2->GetId(0),point1);
747 input->GetPoint(pointList2->GetId(1),point2);
748 input->GetPoint(pointList2->GetId(2),point3);
749 vtkTriangle::ComputeNormal(point1,point2,point3,n);
750 w3s[0] += warpVector3[0] - vtkMath::Dot(warpVector3,n) * n[0];
751 w3s[1] += warpVector3[1] - vtkMath::Dot(warpVector3,n) * n[1];
752 w3s[2] += warpVector3[2] - vtkMath::Dot(warpVector3,n) * n[2];
754 vtkMath::Normalize(w3s);
755 correctionArray->GetTuple(pointList->GetId(0),c1);
756 correctionArray->GetTuple(pointList->GetId(1),c2);
757 correctionArray->GetTuple(pointList->GetId(2),c3);
758 c1[0] = c1[0] + alpha * w2s[0] + alpha * w3s[0];
759 c1[1] = c1[1] + alpha * w2s[1] + alpha * w3s[1];
760 c1[2] = c1[2] + alpha * w2s[2] + alpha * w3s[2];
761 c2[0] = c2[0] + alpha * w1s[0] + alpha * w3s[0];
762 c2[1] = c2[1] + alpha * w1s[1] + alpha * w3s[1];
763 c2[2] = c2[2] + alpha * w1s[2] + alpha * w3s[2];
764 c3[0] = c3[0] + alpha * w2s[0] + alpha * w1s[0];
765 c3[1] = c3[1] + alpha * w2s[1] + alpha * w1s[1];
766 c3[2] = c3[2] + alpha * w2s[2] + alpha * w1s[2];
767 correctionArray->SetTuple3(pointList->GetId(0),c1[0],c1[1],c1[2]);
768 correctionArray->SetTuple3(pointList->GetId(1),c2[0],c2[1],c2[2]);
769 correctionArray->SetTuple3(pointList->GetId(2),c3[0],c3[1],c3[2]);
774 double warp[3], correction[3];
775 for (vtkIdType i=0; i<input->GetNumberOfPoints();i++)
778 double layerThickness=vtkMath::Norm(warp);
779 correctionArray->GetTuple(i,correction);
780 warp[0] = warp[0] + correction[0];
781 warp[1] = warp[1] + correction[1];
782 warp[2] = warp[2] + correction[2];
783 vtkMath::Normalize(warp);
784 warp[0] = warp[0] * layerThickness;
785 warp[1] = warp[1] * layerThickness;
786 warp[2] = warp[2] * layerThickness;
790 correctionArray->Delete();
792 pointList2->Delete();
798 double point[3], warpedPoint[3], warpVector[3];
799 double layerThickness, subLayerThicknessRatio, subLayerThickness;
800 double totalLayerZeroSubLayerRatio, subLayerOffsetRatio, subLayerOffset;
802 vtkIdType numberOfInputPoints = inputPoints->GetNumberOfPoints();
804 totalLayerZeroSubLayerRatio = 0.0;
808 totalLayerZeroSubLayerRatio += pow(this->
SubLayerRatio,this->NumberOfSubLayers-i-1);
811 subLayerOffsetRatio = 0.0;
812 for (i=0; i<subLayerId; i++)
814 subLayerOffsetRatio += pow(this->
SubLayerRatio,this->NumberOfSubLayers-i-1);
816 subLayerOffsetRatio /= totalLayerZeroSubLayerRatio;
818 subLayerThicknessRatio = pow(this->
SubLayerRatio,this->NumberOfSubLayers-subLayerId-1) / totalLayerZeroSubLayerRatio;
822 warpedPoints->SetNumberOfPoints(numberOfInputPoints);
826 warpedPoints->SetNumberOfPoints(2*numberOfInputPoints);
829 for (i=0; i<numberOfInputPoints; i++)
831 inputPoints->GetPoint(i,point);
834 layerThickness = vtkMath::Norm(warpVector);
836 vtkMath::Normalize(warpVector);
838 subLayerOffset = subLayerOffsetRatio * layerThickness;
839 subLayerThickness = subLayerThicknessRatio * layerThickness;
843 warpedPoint[0] = point[0] + 0.5 * warpVector[0] * (subLayerOffset + subLayerThickness);
844 warpedPoint[1] = point[1] + 0.5 * warpVector[1] * (subLayerOffset + subLayerThickness);
845 warpedPoint[2] = point[2] + 0.5 * warpVector[2] * (subLayerOffset + subLayerThickness);
846 warpedPoints->SetPoint(i,warpedPoint);
847 warpedPoint[0] = point[0] + warpVector[0] * (subLayerOffset + subLayerThickness);
848 warpedPoint[1] = point[1] + warpVector[1] * (subLayerOffset + subLayerThickness);
849 warpedPoint[2] = point[2] + warpVector[2] * (subLayerOffset + subLayerThickness);
850 warpedPoints->SetPoint(i+numberOfInputPoints,warpedPoint);
854 warpedPoint[0] = point[0] + warpVector[0] * (subLayerOffset + subLayerThickness);
855 warpedPoint[1] = point[1] + warpVector[1] * (subLayerOffset + subLayerThickness);
856 warpedPoint[2] = point[2] + warpVector[2] * (subLayerOffset + subLayerThickness);
857 warpedPoints->SetPoint(i,warpedPoint);
864 double point[3], warpedPoint[3], warpVector[3];
865 double layerThickness;
867 vtkIdType numberOfInputPoints = basePoints->GetNumberOfPoints();
869 warpedPoints->SetNumberOfPoints(numberOfInputPoints);
871 for (vtkIdType i=0; i<numberOfInputPoints; i++)
873 basePoints->GetPoint(i,point);
876 layerThickness = vtkMath::Norm(warpVector);
877 vtkMath::Normalize(warpVector);
879 layerThickness /= numberOfSubsteps;
881 warpedPoint[0] = point[0] + warpVector[0] * layerThickness;
882 warpedPoint[1] = point[1] + warpVector[1] * layerThickness;
883 warpedPoint[2] = point[2] + warpVector[2] * layerThickness;
884 warpedPoints->SetPoint(i,warpedPoint);
888 const vtkIdType *pts;
889 vtkIdList* cellIds = vtkIdList::New();
892 vtkIdList* neighborIds = vtkIdList::New();
893 vtkIdList* edgePointIds = vtkIdList::New();
894 vtkIdList* edgeNeighborCellIds = vtkIdList::New();
896 for (vtkIdType j=0; j<numberOfInputPoints; j++)
898 input->GetPointCells(j,cellIds);
900 neighborIds->Initialize();
902 vtkIdType numberOfNeighborCells = cellIds->GetNumberOfIds();
903 for (
int k=0; k<numberOfNeighborCells; k++)
905 cellId = cellIds->GetId(k);
906 input->GetCellPoints(cellId,npts,pts);
908 neighborIds->InsertUniqueId(pts[0]);
909 neighborIds->InsertUniqueId(pts[1]);
910 neighborIds->InsertUniqueId(pts[2]);
912 neighborIds->DeleteId(j);
914 int numberOfNeighbors = neighborIds->GetNumberOfIds();
917 edgePointIds->Initialize();
918 edgeNeighborCellIds->Initialize();
919 edgePointIds->InsertId(0,j);
920 for (
int k=0; k<numberOfNeighbors; k++)
922 edgePointIds->InsertId(1,neighborIds->GetId(k));
923 input->GetCellNeighbors(-1,edgePointIds,edgeNeighborCellIds);
924 if (edgeNeighborCellIds->GetNumberOfIds() < 2)
936 double barycenter[3];
937 barycenter[0] = barycenter[1] = barycenter[2] = 0.0;
938 double neighborPoint[3];
939 for (
int k=0; k<numberOfNeighbors; k++)
941 warpedPoints->GetPoint(neighborIds->GetId(k),neighborPoint);
942 barycenter[0] += neighborPoint[0];
943 barycenter[1] += neighborPoint[1];
944 barycenter[2] += neighborPoint[2];
946 barycenter[0] /= numberOfNeighbors;
947 barycenter[1] /= numberOfNeighbors;
948 barycenter[2] /= numberOfNeighbors;
950 warpedPoints->GetPoint(j,warpedPoint);
956 warpedPoint[0] += relaxation * (barycenter[0] - warpedPoint[0]);
957 warpedPoint[1] += relaxation * (barycenter[1] - warpedPoint[1]);
958 warpedPoint[2] += relaxation * (barycenter[2] - warpedPoint[2]);
960 warpedPoints->SetPoint(j,warpedPoint);
964 neighborIds->Delete();
965 edgePointIds->Delete();
966 edgeNeighborCellIds->Delete();