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

Construct a mesh-size field, sampled on the input surface points, from the local surface triangle size. More...

#include <vtkvmtkPolyDataSizingFunction.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataSizingFunction * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetSizingFunctionArrayName (const char *)
virtual char * GetSizingFunctionArrayName ()
virtual void SetScaleFactor (double)
virtual double GetScaleFactor ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

char * SizingFunctionArrayName
double ScaleFactor

Detailed Description

Construct a mesh-size field, sampled on the input surface points, from the local surface triangle size.

For every point of the input surface, this filter computes the average area of the triangles incident to that point, takes its square root as a local characteristic length, and stores the result – scaled by ScaleFactor – as a new point data array named SizingFunctionArrayName on a copy of the input, left unchanged otherwise. The resulting field is a local edge-length target that mimics the input surface's own triangle sizing.

This is used by the volume meshing pipeline (e.g. vmtkmeshgenerator) as an element-size field consumed by vtkvmtkTetGenWrapper (via vmtkTetGen's UseSizingFunction option) to grade the volume mesh element size according to the surface discretization, typically after the surface has been remeshed to the desired resolution.

See also
vtkvmtkTetGenWrapper

Definition at line 45 of file vtkvmtkPolyDataSizingFunction.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataSizingFunction::Superclass

Definition at line 48 of file vtkvmtkPolyDataSizingFunction.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataSizingFunction()

vtkvmtkPolyDataSizingFunction::vtkvmtkPolyDataSizingFunction ( )
protected

◆ ~vtkvmtkPolyDataSizingFunction()

vtkvmtkPolyDataSizingFunction::~vtkvmtkPolyDataSizingFunction ( )
protected

Definition at line 41 of file vtkvmtkPolyDataSizingFunction.cxx.

42{
44 {
45 delete[] this->SizingFunctionArrayName;
46 this->SizingFunctionArrayName = NULL;
47 }
48}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataSizingFunction::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataSizingFunction * vtkvmtkPolyDataSizingFunction::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 124 of file vtkvmtkPolyDataSizingFunction.cxx.

125{
126 this->Superclass::PrintSelf(os,indent);
127}

◆ New()

vtkvmtkPolyDataSizingFunction * vtkvmtkPolyDataSizingFunction::New ( )
static

◆ SetSizingFunctionArrayName()

virtual void vtkvmtkPolyDataSizingFunction::SetSizingFunctionArrayName ( const char * )
virtual

Set/Get the name of the point data array where the computed sizing function values are stored on the output. Must be specified before Update() is called. Commonly named "VolumeSizingFunction".

◆ GetSizingFunctionArrayName()

virtual char * vtkvmtkPolyDataSizingFunction::GetSizingFunctionArrayName ( )
virtual

Set/Get the name of the point data array where the computed sizing function values are stored on the output. Must be specified before Update() is called. Commonly named "VolumeSizingFunction".

◆ SetScaleFactor()

virtual void vtkvmtkPolyDataSizingFunction::SetScaleFactor ( double )
virtual

Set/Get the factor multiplying the square root of the local average incident-triangle area to produce the sizing function value at each point. Values greater than 1 coarsen the target element size, values less than 1 refine it. Default: 1.0.

◆ GetScaleFactor()

virtual double vtkvmtkPolyDataSizingFunction::GetScaleFactor ( )
virtual

Set/Get the factor multiplying the square root of the local average incident-triangle area to produce the sizing function value at each point. Values greater than 1 coarsen the target element size, values less than 1 refine it. Default: 1.0.

◆ RequestData()

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

Definition at line 50 of file vtkvmtkPolyDataSizingFunction.cxx.

54{
55 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
56 vtkInformation *outInfo = outputVector->GetInformationObject(0);
57
58 vtkPolyData *input = vtkPolyData::SafeDownCast(
59 inInfo->Get(vtkDataObject::DATA_OBJECT()));
60 vtkPolyData *output = vtkPolyData::SafeDownCast(
61 outInfo->Get(vtkDataObject::DATA_OBJECT()));
62
63 if (input->GetNumberOfPoints() < 1)
64 {
65 return 1;
66 }
67
68 if (!this->SizingFunctionArrayName)
69 {
70 vtkErrorMacro(<<"No SizingFunctionArrayName specified");
71 return 1;
72 }
73
74 input->BuildCells();
75 input->BuildLinks();
76
77 int numberOfPoints = input->GetNumberOfPoints();
78
79 vtkDoubleArray* sizingFunctionArray = vtkDoubleArray::New();
80 sizingFunctionArray->SetName(this->SizingFunctionArrayName);
81 sizingFunctionArray->SetNumberOfTuples(numberOfPoints);
82 sizingFunctionArray->FillComponent(0,0.0);
83
84 vtkIdList* pointCells = vtkIdList::New();
85
86 int i, j;
87 for (i=0; i<numberOfPoints; i++)
88 {
89 input->GetPointCells(i,pointCells);
90 int numberOfPointCells = pointCells->GetNumberOfIds();
91 double averageArea = 0.0;
92 if (numberOfPointCells == 0)
93 {
94 continue;
95 }
96 for (j=0; j<numberOfPointCells; j++)
97 {
98 vtkTriangle* triangle = vtkTriangle::SafeDownCast(input->GetCell(pointCells->GetId(j)));
99 if (!triangle)
100 {
101 vtkErrorMacro(<<"Cell not triangle: skipping cell for sizing function computation");
102 }
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);
108 }
109 averageArea /= numberOfPointCells;
110
111 double sizingFunction = sqrt(averageArea) * this->ScaleFactor;
112 sizingFunctionArray->SetValue(i,sizingFunction);
113 }
114
115 output->DeepCopy(input);
116 output->GetPointData()->AddArray(sizingFunctionArray);
117
118 sizingFunctionArray->Delete();
119 pointCells->Delete();
120
121 return 1;
122}

Member Data Documentation

◆ SizingFunctionArrayName

char* vtkvmtkPolyDataSizingFunction::SizingFunctionArrayName
protected

Definition at line 79 of file vtkvmtkPolyDataSizingFunction.h.

◆ ScaleFactor

double vtkvmtkPolyDataSizingFunction::ScaleFactor
protected

Definition at line 80 of file vtkvmtkPolyDataSizingFunction.h.


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