58 int numberOfCells = surface->GetNumberOfCells();
61 double point0[3], point1[3], point2[3];
62 double minTriangleArea = 1E20;
63 for (
int i=0; i<numberOfCells; i++)
65 surface->GetCellPoints(i,npts,pts);
72 vtkErrorMacro(<<
"Not triangle");
75 surface->GetPoint(pts[0],point0);
76 surface->GetPoint(pts[1],point1);
77 surface->GetPoint(pts[2],point2);
79 if (triangleArea < minTriangleArea)
81 minTriangleArea = triangleArea;
90 vtkDataArray* clampArray = surface->GetPointData()->GetArray(this->
ClampArrayName);
95 int numberOfPoints = surface->GetNumberOfPoints();
97 vtkPoints* newPoints = vtkPoints::New();
98 newPoints->DeepCopy(surface->GetPoints());
102 for (
int i=0; i<numberOfPoints; i++)
104 if (clampArray->GetTuple1(i) > this->ClampThreshold)
110 neighborhood->
Build();
118 surface->GetPoint(i,point);
120 double neighborPoint[3];
122 laplace[0] = laplace[1] = laplace[2] = 0.0;
124 double weight = 1.0 / double(numberOfNeighborhoodPoints);
125 for (
int j=0; j<numberOfNeighborhoodPoints; j++)
127 surface->GetPoint(neighborhood->
GetPointId(j),neighborPoint);
128 laplace[0] += weight * (neighborPoint[0] - point[0]);
129 laplace[1] += weight * (neighborPoint[1] - point[1]);
130 laplace[2] += weight * (neighborPoint[2] - point[2]);
134 newPoint[0] = point[0];
135 newPoint[1] = point[1];
136 newPoint[2] = point[2];
138 newPoint[0] += deltaT * laplace[0];
139 newPoint[1] += deltaT * laplace[1];
140 newPoint[2] += deltaT * laplace[2];
142 newPoints->SetPoint(i,newPoint);
145 surface->GetPoints()->DeepCopy(newPoints);
147 neighborhood->Delete();
153 vtkDataArray* clampArray = surface->GetPointData()->GetArray(this->
ClampArrayName);
155 vtkPolyDataNormals* normalsFilter = vtkPolyDataNormals::New();
156 normalsFilter->SetInputData(surface);
157 normalsFilter->FlipNormalsOff();
158 normalsFilter->ConsistencyOn();
159 normalsFilter->ComputePointNormalsOn();
160 normalsFilter->ComputeCellNormalsOn();
161 normalsFilter->Update();
162 vtkDataArray* normals = normalsFilter->GetOutput()->GetPointData()->GetNormals();
164 vtkCurvatures* curvaturesFilter = vtkCurvatures::New();
165 curvaturesFilter->SetInputData(surface);
167 curvaturesFilter->SetCurvatureTypeToMean();
168 curvaturesFilter->Update();
169 vtkDataArray* meanCurvatureArray = curvaturesFilter->GetOutput()->GetPointData()->GetScalars();
174 int numberOfPoints = surface->GetNumberOfPoints();
176 vtkPoints* newPoints = vtkPoints::New();
177 newPoints->DeepCopy(surface->GetPoints());
181 for (
int i=0; i<numberOfPoints; i++)
183 if (clampArray->GetTuple1(i) > this->ClampThreshold)
189 neighborhood->
Build();
197 surface->GetPoint(i,point);
199 double meanCurvature = meanCurvatureArray->GetTuple1(i);
201 double laplaceH = 0.0;
203 double weight = 1.0 / double(numberOfNeighborhoodPoints);
204 for (
int j=0; j<numberOfNeighborhoodPoints; j++)
206 double neighborMeanCurvature = meanCurvatureArray->GetTuple1(neighborhood->
GetPointId(j));
207 laplaceH += weight * (neighborMeanCurvature - meanCurvature);
211 normals->GetTuple(i,normal);
214 newPoint[0] = point[0];
215 newPoint[1] = point[1];
216 newPoint[2] = point[2];
218 newPoint[0] += deltaT * laplaceH * normal[0];
219 newPoint[1] += deltaT * laplaceH * normal[1];
220 newPoint[2] += deltaT * laplaceH * normal[2];
222 newPoints->SetPoint(i,newPoint);
225 surface->GetPoints()->DeepCopy(newPoints);
227 normalsFilter->Delete();
228 curvaturesFilter->Delete();
229 neighborhood->Delete();
234 vtkInformation *vtkNotUsed(request),
235 vtkInformationVector **inputVector,
236 vtkInformationVector *outputVector)
238 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
239 vtkInformation *outInfo = outputVector->GetInformationObject(0);
241 vtkPolyData *input = vtkPolyData::SafeDownCast(
242 inInfo->Get(vtkDataObject::DATA_OBJECT()));
243 vtkPolyData *output = vtkPolyData::SafeDownCast(
244 outInfo->Get(vtkDataObject::DATA_OBJECT()));
246 vtkDataArray* clampArray = NULL;
251 vtkErrorMacro(<<
"Clamp is on but ClampArrayName has not been specified");
256 clampArray = input->GetPointData()->GetArray(this->
ClampArrayName);
260 vtkErrorMacro(<<
"ClampArray with name specified does not exist");
265 vtkPolyData* surface = vtkPolyData::New();
266 surface->DeepCopy(input);
267 surface->BuildCells();
281 output->DeepCopy(surface);