forked from Kitware/ParaView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtkShearedWaveletSource.cxx
123 lines (103 loc) · 4.29 KB
/
vtkShearedWaveletSource.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*=========================================================================
Program: ParaView
Module: vtkShearedWaveletSource.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkShearedWaveletSource.h"
#include "vtkDataSetTriangleFilter.h"
#include "vtkDoubleArray.h"
#include "vtkFieldData.h"
#include "vtkMatrix4x4.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPVChangeOfBasisHelper.h"
#include "vtkRTAnalyticSource.h"
#include "vtkStringArray.h"
#include "vtkTransform.h"
#include "vtkTransformFilter.h"
#include "vtkUnstructuredGrid.h"
#include <algorithm>
vtkStandardNewMacro(vtkShearedWaveletSource);
//----------------------------------------------------------------------------
vtkShearedWaveletSource::vtkShearedWaveletSource()
{
this->EnableAxisTitles = false;
this->EnableTimeLabel = false;
this->TimeLabel = NULL;
this->AxisUTitle = NULL;
this->AxisVTitle = NULL;
this->AxisWTitle = NULL;
this->ModelBoundingBox[0] = this->ModelBoundingBox[2] = this->ModelBoundingBox[4] = 0.0;
this->ModelBoundingBox[1] = this->ModelBoundingBox[3] = this->ModelBoundingBox[5] = 1.0;
this->BasisU[0] = 1;
this->BasisU[1] = 0;
this->BasisU[2] = 0;
this->BasisV[0] = 0;
this->BasisV[1] = 1;
this->BasisV[2] = 0;
this->BasisW[0] = 0;
this->BasisW[1] = 0;
this->BasisW[2] = 1;
this->SetNumberOfInputPorts(0);
}
//----------------------------------------------------------------------------
vtkShearedWaveletSource::~vtkShearedWaveletSource()
{
this->SetTimeLabel(NULL);
this->SetAxisUTitle(NULL);
this->SetAxisVTitle(NULL);
this->SetAxisWTitle(NULL);
}
//----------------------------------------------------------------------------
int vtkShearedWaveletSource::RequestData(
vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
{
vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector, 0);
vtkNew<vtkRTAnalyticSource> analyticSource;
vtkNew<vtkDataSetTriangleFilter> tetrahedralize;
tetrahedralize->SetInputConnection(analyticSource->GetOutputPort());
// This produces an image in bounds (-10, 10, -10, 10, -10, 10).
// We will transform this to the bounds defined by ModelBoundingBox.
// That will be our original input model.
vtkNew<vtkTransformFilter> transformFilter;
vtkNew<vtkTransform> transform;
transform->Identity();
transform->PostMultiply();
transform->Translate(10, 10, 10);
transform->Scale(0.05, 0.05, 0.05);
// at this point, we have a unit box at origin. Now, scale/translate it
// based on ModelBoundingBox.
transform->Scale(this->ModelBoundingBox[1] - this->ModelBoundingBox[0],
this->ModelBoundingBox[3] - this->ModelBoundingBox[2],
this->ModelBoundingBox[5] - this->ModelBoundingBox[4]);
transform->Translate(
this->ModelBoundingBox[0], this->ModelBoundingBox[2], this->ModelBoundingBox[4]);
transformFilter->SetTransform(transform.GetPointer());
transformFilter->SetInputConnection(tetrahedralize->GetOutputPort());
transformFilter->Update();
output->ShallowCopy(transformFilter->GetOutputDataObject(0));
vtkSmartPointer<vtkMatrix4x4> cobMatrix = vtkPVChangeOfBasisHelper::GetChangeOfBasisMatrix(
vtkVector3d(this->BasisU), vtkVector3d(this->BasisV), vtkVector3d(this->BasisW));
transform->SetMatrix(cobMatrix.GetPointer());
transformFilter->SetInputDataObject(output);
transformFilter->Update();
output->ShallowCopy(transformFilter->GetOutputDataObject(0));
vtkPVChangeOfBasisHelper::AddChangeOfBasisMatrixToFieldData(output, cobMatrix);
vtkPVChangeOfBasisHelper::AddBoundingBoxInBasis(output, this->ModelBoundingBox);
if (this->EnableAxisTitles)
{
vtkPVChangeOfBasisHelper::AddBasisNames(
output, this->AxisUTitle, this->AxisVTitle, this->AxisWTitle);
}
return 1;
}
//----------------------------------------------------------------------------
void vtkShearedWaveletSource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}