VMTK
Loading...
Searching...
No Matches
vtkvmtkLinearToQuadraticSurfaceMeshFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3Program: VMTK
4Module: $RCSfile: vtkvmtkLinearToQuadraticSurfaceMeshFilter.cxx,v $
5Language: C++
6Date: $Date: 2005/03/31 15:49:05 $
7Version: $Revision: 1.3 $
8
9 Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 See LICENSE file for details.
11
12 Portions of this code are covered under the VTK copyright.
13 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
14 for details.
15
16 This software is distributed WITHOUT ANY WARRANTY; without even
17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE. See the above copyright notices for more information.
19
20=========================================================================*/
21
23#include "vtkGeometryFilter.h"
24#include "vtkInterpolatingSubdivisionFilter.h"
25#include "vtkLinearSubdivisionFilter.h"
26#include "vtkButterflySubdivisionFilter.h"
27#include "vtkPolyData.h"
28#include "vtkUnstructuredGrid.h"
29#include "vtkPointData.h"
30#include "vtkCellData.h"
31#include "vtkCellArray.h"
32#include "vtkInformation.h"
33#include "vtkInformationVector.h"
34#include "vtkObjectFactory.h"
35#include "vtkVersion.h"
36
37
39
43
47
49 vtkInformation *vtkNotUsed(request),
50 vtkInformationVector **inputVector,
51 vtkInformationVector *outputVector)
52{
53 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
54 vtkInformation *outInfo = outputVector->GetInformationObject(0);
55
56 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
57 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
58
59 vtkIdType nqpts, *qpts, npts0, npts1;
60 const vtkIdType *pts0, *pts1;
61 vtkIdType numberOfInputCells;
62 vtkPolyData* subdividedSurface;
63 vtkCellArray* quadraticTriangles;
64 vtkIdList* quadraticTriangleCellTypes;
65
66 vtkGeometryFilter* geometryFilter;
67 vtkInterpolatingSubdivisionFilter* subdivisionFilter;
68
69 geometryFilter = vtkGeometryFilter::New();
70 geometryFilter->SetInputData(input);
71 geometryFilter->MergingOff();
72
73 switch (this->SubdivisionMethod)
74 {
76 subdivisionFilter = vtkLinearSubdivisionFilter::New();
77 break;
79 subdivisionFilter = vtkButterflySubdivisionFilter::New();
80 break;
81 default:
82 vtkErrorMacro(<<"Unsupported subdivision method.");
83 return 1;
84 }
85
86 subdivisionFilter->SetInputConnection(geometryFilter->GetOutputPort());
87 subdivisionFilter->SetNumberOfSubdivisions(1);
88 subdivisionFilter->Update();
89
90 subdividedSurface = subdivisionFilter->GetOutput();
91
92 output->SetPoints(subdividedSurface->GetPoints());
93 output->GetPointData()->PassData(subdividedSurface->GetPointData());
94 output->GetCellData()->PassData(subdividedSurface->GetCellData());
95
96 // input->BuildCells();
97 subdividedSurface->BuildCells();
98
99 numberOfInputCells = input->GetNumberOfCells();
100
101 quadraticTriangles = vtkCellArray::New();
102 quadraticTriangleCellTypes = vtkIdList::New();
103
104 nqpts = 6;
105 qpts = new vtkIdType[nqpts];
106
107 // strongly based on the way output cells are built in vtkInterpolatingSubdivisionFilter !!!
108 for (int i=0; i<numberOfInputCells; i++)
109 {
110 input->GetCellPoints(i,npts0,pts0);
111 subdividedSurface->GetCellPoints(4*i+3,npts1,pts1);
112
113 qpts[0] = pts0[0];
114 qpts[1] = pts0[1];
115 qpts[2] = pts0[2];
116 qpts[3] = pts1[0];
117 qpts[4] = pts1[1];
118 qpts[5] = pts1[2];
119
120 // old PolyDataToPolyData version
121// qpts[0] = pts0[0];
122// qpts[1] = pts1[0];
123// qpts[2] = pts0[1];
124// qpts[3] = pts1[1];
125// qpts[4] = pts0[2];
126// qpts[5] = pts1[2];
127
128 quadraticTriangles->InsertNextCell(nqpts,qpts);
129 quadraticTriangleCellTypes->InsertNextId(VTK_QUADRATIC_TRIANGLE);
130 }
131
132 delete[] qpts;
133
134 int* quadraticTriangleCellTypesInt = new int[quadraticTriangleCellTypes->GetNumberOfIds()];
135 for (int i=0; i<quadraticTriangleCellTypes->GetNumberOfIds(); i++)
136 {
137 quadraticTriangleCellTypesInt[i] = quadraticTriangleCellTypes->GetId(i);
138 }
139
140 output->SetCells(quadraticTriangleCellTypesInt,quadraticTriangles);
141
142 delete[] quadraticTriangleCellTypesInt;
143
144 geometryFilter->Delete();
145 subdivisionFilter->Delete();
146 quadraticTriangles->Delete();
147 quadraticTriangleCellTypes->Delete();
148
149 return 1;
150}
151
152void vtkvmtkLinearToQuadraticSurfaceMeshFilter::PrintSelf(std::ostream& os, vtkIndent indent)
153{
154 this->Superclass::PrintSelf(os,indent);
155}
Converts linear surface elements to quadratic surface elements via either linear subdivision of lapla...
void PrintSelf(std::ostream &os, vtkIndent indent) override
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkStandardNewMacro(vtkvmtkLinearToQuadraticSurfaceMeshFilter)