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

Convert quadratic mesh elements to linear mesh elements by discarding mid-side nodes. More...

#include <vtkvmtkLinearizeMeshFilter.h>

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

Public Types

typedef vtkUnstructuredGridAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkLinearizeMeshFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetCleanOutput (int)
virtual int GetCleanOutput ()
virtual void CleanOutputOn ()
virtual void CleanOutputOff ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

int CleanOutput

Detailed Description

Convert quadratic mesh elements to linear mesh elements by discarding mid-side nodes.

This filter takes an unstructured grid whose cells may be linear or quadratic (triangles, quads, tetrahedra, hexahedra, wedges, and their quadratic/biquadratic/triquadratic variants) and rebuilds every cell using only its corner nodes, dropping all mid-edge/mid-face/mid-volume nodes; the corresponding linear cell type (e.g. VTK_QUADRATIC_TETRA becomes VTK_TETRA) is emitted for each input cell, with cell data copied unchanged. Point data is copied only for corner points that survive into the output. Points that end up unused by any output cell (i.e. former mid-side nodes) are dropped from the output when CleanOutput is on.

This is the filter behind the vmtkmeshlinearize pype script, used to strip a second-order (quadratic) volume or surface mesh back down to first-order (linear) elements, e.g. for tools that only support linear elements.

See also
vtkvmtkLinearToQuadraticMeshFilter, vtkvmtkLinearToQuadraticSurfaceMeshFilter

Definition at line 44 of file vtkvmtkLinearizeMeshFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkUnstructuredGridAlgorithm vtkvmtkLinearizeMeshFilter::Superclass

Definition at line 47 of file vtkvmtkLinearizeMeshFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkLinearizeMeshFilter()

vtkvmtkLinearizeMeshFilter::vtkvmtkLinearizeMeshFilter ( )
protected

Definition at line 37 of file vtkvmtkLinearizeMeshFilter.cxx.

◆ ~vtkvmtkLinearizeMeshFilter()

vtkvmtkLinearizeMeshFilter::~vtkvmtkLinearizeMeshFilter ( )
protected

Definition at line 42 of file vtkvmtkLinearizeMeshFilter.cxx.

43{
44}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkLinearizeMeshFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkLinearizeMeshFilter * vtkvmtkLinearizeMeshFilter::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 220 of file vtkvmtkLinearizeMeshFilter.cxx.

221{
222 this->Superclass::PrintSelf(os,indent);
223}

◆ New()

vtkvmtkLinearizeMeshFilter * vtkvmtkLinearizeMeshFilter::New ( )
static

◆ SetCleanOutput()

virtual void vtkvmtkLinearizeMeshFilter::SetCleanOutput ( int )
virtual

Toggle discarding, from the output, points that are not used by any output (linear) cell – i.e. the mid-side nodes dropped during linearization. When off, all input points are kept in the output even though some are no longer referenced by any cell. Default: on.

◆ GetCleanOutput()

virtual int vtkvmtkLinearizeMeshFilter::GetCleanOutput ( )
virtual

Toggle discarding, from the output, points that are not used by any output (linear) cell – i.e. the mid-side nodes dropped during linearization. When off, all input points are kept in the output even though some are no longer referenced by any cell. Default: on.

◆ CleanOutputOn()

virtual void vtkvmtkLinearizeMeshFilter::CleanOutputOn ( )
virtual

Toggle discarding, from the output, points that are not used by any output (linear) cell – i.e. the mid-side nodes dropped during linearization. When off, all input points are kept in the output even though some are no longer referenced by any cell. Default: on.

◆ CleanOutputOff()

virtual void vtkvmtkLinearizeMeshFilter::CleanOutputOff ( )
virtual

Toggle discarding, from the output, points that are not used by any output (linear) cell – i.e. the mid-side nodes dropped during linearization. When off, all input points are kept in the output even though some are no longer referenced by any cell. Default: on.

◆ RequestData()

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

Definition at line 46 of file vtkvmtkLinearizeMeshFilter.cxx.

50{
51 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
52 vtkInformation *outInfo = outputVector->GetInformationObject(0);
53
54 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
55 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
56
57 vtkPoints* outputPoints = vtkPoints::New();
58
59 vtkCellArray* outputCellArray = vtkCellArray::New();
60 vtkIdList* outputCellTypes = vtkIdList::New();
61
62 int numberOfPoints = input->GetNumberOfPoints();
63 int numberOfCells = input->GetNumberOfCells();
64
65 vtkPointData* inputPointData = input->GetPointData();
66 vtkPointData* outputPointData = output->GetPointData();
67 outputPointData->CopyAllocate(inputPointData,numberOfPoints);
68
69 vtkCellData* inputCellData = input->GetCellData();
70 vtkCellData* outputCellData = output->GetCellData();
71 outputCellData->CopyAllocate(inputCellData,numberOfCells);
72
73 vtkIdTypeArray* pointUsedArray = vtkIdTypeArray::New();
74 pointUsedArray->SetNumberOfTuples(numberOfPoints);
75 pointUsedArray->FillComponent(0,0.0);
76
77 vtkIdList* cellPoints = vtkIdList::New();
78 vtkIdList* outputCellPoints = vtkIdList::New();
79 int pointId;
80 int outputCellId;
81 int i,j;
82 for (i=0; i<numberOfCells; i++)
83 {
84 int cellType = input->GetCellType(i);
85 cellPoints->Initialize();
86 input->GetCellPoints(i,cellPoints);
87 outputCellPoints->Initialize();
88 switch (cellType)
89 {
90 case VTK_TRIANGLE:
91 case VTK_QUADRATIC_TRIANGLE:
92 for (j=0; j<3; j++)
93 {
94 pointId = cellPoints->GetId(j);
95 outputCellPoints->InsertNextId(pointId);
96 pointUsedArray->SetValue(pointId,1);
97 }
98 outputCellId = outputCellTypes->InsertNextId(VTK_TRIANGLE);
99 outputCellArray->InsertNextCell(outputCellPoints);
100 outputCellData->CopyData(inputCellData,i,outputCellId);
101 break;
102 case VTK_QUAD:
103 case VTK_QUADRATIC_QUAD:
104 case VTK_QUADRATIC_LINEAR_QUAD:
105 case VTK_BIQUADRATIC_QUAD:
106 for (j=0; j<4; j++)
107 {
108 pointId = cellPoints->GetId(j);
109 outputCellPoints->InsertNextId(pointId);
110 pointUsedArray->SetValue(pointId,1);
111 }
112 outputCellId = outputCellTypes->InsertNextId(VTK_QUAD);
113 outputCellArray->InsertNextCell(outputCellPoints);
114 outputCellData->CopyData(inputCellData,i,outputCellId);
115 break;
116 case VTK_TETRA:
117 case VTK_QUADRATIC_TETRA:
118 for (j=0; j<4; j++)
119 {
120 pointId = cellPoints->GetId(j);
121 outputCellPoints->InsertNextId(pointId);
122 pointUsedArray->SetValue(pointId,1);
123 }
124 outputCellId = outputCellTypes->InsertNextId(VTK_TETRA);
125 outputCellArray->InsertNextCell(outputCellPoints);
126 outputCellData->CopyData(inputCellData,i,outputCellId);
127 break;
128 case VTK_HEXAHEDRON:
129 case VTK_QUADRATIC_HEXAHEDRON:
130 case VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON:
131 case VTK_TRIQUADRATIC_HEXAHEDRON:
132 for (j=0; j<8; j++)
133 {
134 pointId = cellPoints->GetId(j);
135 outputCellPoints->InsertNextId(pointId);
136 pointUsedArray->SetValue(pointId,1);
137 }
138 outputCellId = outputCellTypes->InsertNextId(VTK_HEXAHEDRON);
139 outputCellArray->InsertNextCell(outputCellPoints);
140 outputCellData->CopyData(inputCellData,i,outputCellId);
141 break;
142 case VTK_WEDGE:
143 case VTK_QUADRATIC_WEDGE:
144 case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
145 for (j=0; j<6; j++)
146 {
147 pointId = cellPoints->GetId(j);
148 outputCellPoints->InsertNextId(pointId);
149 pointUsedArray->SetValue(pointId,1);
150 }
151 outputCellId = outputCellTypes->InsertNextId(VTK_WEDGE);
152 outputCellArray->InsertNextCell(outputCellPoints);
153 outputCellData->CopyData(inputCellData,i,outputCellId);
154 break;
155 default:
156 vtkWarningMacro(<<"Unsupported element to linearize. Skipping element.");
157 break;
158 }
159 }
160
161 vtkIdTypeArray* pointIdMapArray = vtkIdTypeArray::New();
162 pointIdMapArray->SetNumberOfTuples(numberOfPoints);
163 for (i=0; i<numberOfPoints; i++)
164 {
165 if (this->CleanOutput)
166 {
167 if (!pointUsedArray->GetValue(i))
168 {
169 continue;
170 }
171 }
172 pointId = outputPoints->InsertNextPoint(input->GetPoint(i));
173 outputPointData->CopyData(inputPointData,i,pointId);
174 pointIdMapArray->SetValue(i,pointId);
175 }
176
177 vtkCellArray* remappedOutputCellArray = vtkCellArray::New();
178 int numberOfOutputCells = outputCellArray->GetNumberOfCells();
179 outputCellArray->InitTraversal();
180 vtkIdType npts = 0;
181 const vtkIdType *pts = NULL;
182 for (i=0; i<numberOfOutputCells; i++)
183 {
184 outputCellArray->GetNextCell(npts,pts);
185 outputCellPoints->Initialize();
186 for (j=0; j<npts; j++)
187 {
188 outputCellPoints->InsertNextId(pointIdMapArray->GetValue(pts[j]));
189 }
190 remappedOutputCellArray->InsertNextCell(outputCellPoints);
191 }
192
193 output->GetPointData()->Squeeze();
194 output->GetCellData()->Squeeze();
195
196 output->SetPoints(outputPoints);
197
198 int* outputCellTypesInt = new int[outputCellTypes->GetNumberOfIds()];
199 for (i=0; i<outputCellTypes->GetNumberOfIds(); i++)
200 {
201 outputCellTypesInt[i] = outputCellTypes->GetId(i);
202 }
203
204 output->SetCells(outputCellTypesInt,remappedOutputCellArray);
205
206 delete[] outputCellTypesInt;
207
208 outputPoints->Delete();
209 outputCellArray->Delete();
210 remappedOutputCellArray->Delete();
211 outputCellTypes->Delete();
212 pointUsedArray->Delete();
213 pointIdMapArray->Delete();
214 cellPoints->Delete();
215 outputCellPoints->Delete();
216
217 return 1;
218}

Member Data Documentation

◆ CleanOutput

int vtkvmtkLinearizeMeshFilter::CleanOutput
protected

Definition at line 69 of file vtkvmtkLinearizeMeshFilter.h.


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