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

Not implemented; smooths a surface via an elastic-forces method. More...

#include <vtkvmtkPolyDataDiscreteElasticaFilter.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataDiscreteElasticaFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataDiscreteElasticaFilter ()
 ~vtkvmtkPolyDataDiscreteElasticaFilter ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Detailed Description

Not implemented; smooths a surface via an elastic-forces method.

vtkvmtkPolyDataDiscreteElasticaFilter is a placeholder vtkPolyDataAlgorithm: its RequestData body (an iterative mean/Gaussian-curvature-driven point displacement scheme, intended as a discrete "elastica" surface-smoothing method) is currently disabled at compile time (guarded out with "#if 0" in the .cxx file), so this class has no functional implementation and should not be used.

Definition at line 35 of file vtkvmtkPolyDataDiscreteElasticaFilter.h.

Member Typedef Documentation

◆ Superclass

Definition at line 40 of file vtkvmtkPolyDataDiscreteElasticaFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataDiscreteElasticaFilter()

vtkvmtkPolyDataDiscreteElasticaFilter::vtkvmtkPolyDataDiscreteElasticaFilter ( )
protected

Definition at line 37 of file vtkvmtkPolyDataDiscreteElasticaFilter.cxx.

38{
39}

◆ ~vtkvmtkPolyDataDiscreteElasticaFilter()

vtkvmtkPolyDataDiscreteElasticaFilter::~vtkvmtkPolyDataDiscreteElasticaFilter ( )
protected

Definition at line 41 of file vtkvmtkPolyDataDiscreteElasticaFilter.cxx.

42{
43}

Member Function Documentation

◆ New()

vtkvmtkPolyDataDiscreteElasticaFilter * vtkvmtkPolyDataDiscreteElasticaFilter::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataDiscreteElasticaFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataDiscreteElasticaFilter * vtkvmtkPolyDataDiscreteElasticaFilter::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 566 of file vtkvmtkPolyDataDiscreteElasticaFilter.cxx.

567{
568 this->Superclass::PrintSelf(os,indent);
569}

◆ RequestData()

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

Definition at line 200 of file vtkvmtkPolyDataDiscreteElasticaFilter.cxx.

204{
205 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
206 vtkInformation *outInfo = outputVector->GetInformationObject(0);
207
208 vtkPolyData *input = vtkPolyData::SafeDownCast(
209 inInfo->Get(vtkDataObject::DATA_OBJECT()));
210 vtkPolyData *output = vtkPolyData::SafeDownCast(
211 outInfo->Get(vtkDataObject::DATA_OBJECT()));
212
213 vtkPolyData* surface = vtkPolyData::New();
214 surface->DeepCopy(input);
215
216 vtkPolyDataNormals* normalsFilter = vtkPolyDataNormals::New();
217 normalsFilter->SetInputData(surface);
218 normalsFilter->FlipNormalsOff();
219 normalsFilter->ConsistencyOn();
220 normalsFilter->ComputePointNormalsOn();
221 normalsFilter->ComputeCellNormalsOn();
222
223 vtkCurvatures* curvaturesFilter = vtkCurvatures::New();
224 curvaturesFilter->SetInputData(surface);
225// curvaturesFilter->InvertMeanCurvatureOn();
226
227 vtkvmtkPolyDataManifoldNeighborhood* neighborhood = vtkvmtkPolyDataManifoldNeighborhood::New();
228 neighborhood->SetDataSet(surface);
229
230 int numberOfPoints = surface->GetNumberOfPoints();
231
232 vtkPoints* newPoints = vtkPoints::New();
233 newPoints->SetNumberOfPoints(numberOfPoints);
234
235 vtkDoubleArray* meanCurvatureArray = vtkDoubleArray::New();
236
237 double deltaT = 1.0;
238
239 int numberOfIterations = 100;
240
241 for (int n=0; n<numberOfIterations; n++)
242 {
243 surface->Modified();
244 curvaturesFilter->SetCurvatureTypeToMean();
245 curvaturesFilter->Update();
246 meanCurvatureArray->DeepCopy(curvaturesFilter->GetOutput()->GetPointData()->GetScalars());
247 normalsFilter->Update();
248 vtkDataArray* normals = normalsFilter->GetOutput()->GetPointData()->GetNormals();
249
250 newPoints->DeepCopy(surface->GetPoints());
251
252 double minTriangleArea = 1E8;
253
254 for (int i=0; i<numberOfPoints; i++)
255 {
256 neighborhood->SetDataSetPointId(i);
257 neighborhood->Build();
258
259 if (neighborhood->GetIsBoundary())
260 {
261 continue;
262 }
263
264 double point[3];
265 surface->GetPoint(i,point);
266
267 if (surface->GetPointData()->GetArray("Clamp")->GetTuple1(i) > 0.5)
268 {
269 newPoints->SetPoint(i,point);
270 continue;
271 }
272
273 double meanCurvature = meanCurvatureArray->GetTuple1(i);
274
275 double laplaceH = 0.0;
276
277 double neighborPoint[3];
278 double laplace[3];
279 laplace[0] = laplace[1] = laplace[2] = 0.0;
280 int numberOfNeighborhoodPoints = neighborhood->GetNumberOfPoints();
281 double weight = 1.0 / double(numberOfNeighborhoodPoints);
282 for (int j=0; j<numberOfNeighborhoodPoints; j++)
283 {
284 double neighborMeanCurvature = meanCurvatureArray->GetTuple1(neighborhood->GetPointId(j));
285 laplaceH += weight * (neighborMeanCurvature - meanCurvature);
286 surface->GetPoint(neighborhood->GetPointId(j),neighborPoint);
287 laplace[0] += weight * (neighborPoint[0] - point[0]);
288 laplace[1] += weight * (neighborPoint[1] - point[1]);
289 laplace[2] += weight * (neighborPoint[2] - point[2]);
290 }
291
292 double point1[3], point2[3];
293 double area = 0.0;
294 double triangleArea;
295 for (int j=0; j<numberOfNeighborhoodPoints; j++)
296 {
297 surface->GetPoint(neighborhood->GetPointId(j),point1);
298 surface->GetPoint(neighborhood->GetPointId((j+1)%numberOfNeighborhoodPoints),point2);
299 triangleArea = vtkvmtkMath::TriangleArea(point,point1,point2);
300 area += triangleArea;
301 if (triangleArea < minTriangleArea)
302 {
303 minTriangleArea = triangleArea;
304 }
305 }
306
307 double normal[3];
308 normals->GetTuple(i,normal);
309
310 double newPoint[3];
311 newPoint[0] = point[0];
312 newPoint[1] = point[1];
313 newPoint[2] = point[2];
314
315 deltaT = minTriangleArea / 10.0;
316
317// newPoint[0] += deltaT * laplaceH * normal[0];
318// newPoint[1] += deltaT * laplaceH * normal[1];
319// newPoint[2] += deltaT * laplaceH * normal[2];
320
321// deltaT = 1E0;
322 double alpha = 1.0;
323 double beta = 0.0;
324
325 newPoint[0] += deltaT * (alpha * laplaceH * normal[0] + beta * laplace[0]);
326 newPoint[1] += deltaT * (alpha * laplaceH * normal[1] + beta * laplace[1]);
327 newPoint[2] += deltaT * (alpha * laplaceH * normal[2] + beta * laplace[2]);
328
329 newPoints->SetPoint(i,newPoint);
330 }
331
332 std::cout<<deltaT<<endl;
333
334 surface->GetPoints()->DeepCopy(newPoints);
335 }
336
337 output->DeepCopy(surface);
338
339 curvaturesFilter->Delete();
340 normalsFilter->Delete();
341 neighborhood->Delete();
342 meanCurvatureArray->Delete();
343 surface->Delete();
344 newPoints->Delete();
345
346 return 1;
347}
virtual void SetDataSetPointId(vtkIdType)
void SetDataSet(vtkDataSet *dataSet)
static double TriangleArea(double point0[3], double point1[3], double point2[3])
vtkIdType GetPointId(vtkIdType i)
virtual bool GetIsBoundary()
static vtkvmtkPolyDataManifoldNeighborhood * New()

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