51 vtkInformation *vtkNotUsed(request),
52 vtkInformationVector **inputVector,
53 vtkInformationVector *outputVector)
55 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
56 vtkInformation *outInfo = outputVector->GetInformationObject(0);
58 vtkPolyData *input = vtkPolyData::SafeDownCast(
59 inInfo->Get(vtkDataObject::DATA_OBJECT()));
60 vtkPolyData *output = vtkPolyData::SafeDownCast(
61 outInfo->Get(vtkDataObject::DATA_OBJECT()));
63 if (input->GetNumberOfPoints() < 1)
70 vtkErrorMacro(<<
"No SizingFunctionArrayName specified");
77 int numberOfPoints = input->GetNumberOfPoints();
79 vtkDoubleArray* sizingFunctionArray = vtkDoubleArray::New();
81 sizingFunctionArray->SetNumberOfTuples(numberOfPoints);
82 sizingFunctionArray->FillComponent(0,0.0);
84 vtkIdList* pointCells = vtkIdList::New();
87 for (i=0; i<numberOfPoints; i++)
89 input->GetPointCells(i,pointCells);
90 int numberOfPointCells = pointCells->GetNumberOfIds();
91 double averageArea = 0.0;
92 if (numberOfPointCells == 0)
96 for (j=0; j<numberOfPointCells; j++)
98 vtkTriangle* triangle = vtkTriangle::SafeDownCast(input->GetCell(pointCells->GetId(j)));
101 vtkErrorMacro(<<
"Cell not triangle: skipping cell for sizing function computation");
103 double point0[3], point1[3], point2[3];
104 triangle->GetPoints()->GetPoint(0,point0);
105 triangle->GetPoints()->GetPoint(1,point1);
106 triangle->GetPoints()->GetPoint(2,point2);
107 averageArea += vtkTriangle::TriangleArea(point0,point1,point2);
109 averageArea /= numberOfPointCells;
111 double sizingFunction = sqrt(averageArea) * this->
ScaleFactor;
112 sizingFunctionArray->SetValue(i,sizingFunction);
115 output->DeepCopy(input);
116 output->GetPointData()->AddArray(sizingFunctionArray);
118 sizingFunctionArray->Delete();
119 pointCells->Delete();