58 vtkInformationVector **inputVector,
59 vtkInformationVector *outputVector) {
60 vtkDataSet *input = vtkDataSet::GetData(inputVector[0], 0);
61 vtkDataSet *output = vtkDataSet::GetData(outputVector, 0);
69 auto inputScalars1 = this->GetInputArrayToProcess(0, input);
70 auto inputScalars2 = this->GetInputArrayToProcess(1, input);
72#ifndef TTK_ENABLE_KAMIKAZE
74 if(!inputScalars1 || !inputScalars2) {
75 this->
printErr(
"wrong scalar fields.");
81 = ScatterplotResolution[0] * ScatterplotResolution[1];
82#ifndef TTK_ENABLE_KAMIKAZE
90 std::vector<std::vector<double>> density(ScatterplotResolution[0]);
91 std::vector<std::vector<char>> validPointMask(ScatterplotResolution[0]);
92 for(
SimplexId k = 0; k < ScatterplotResolution[0]; ++k) {
93 density[k].resize(ScatterplotResolution[1], 0.0);
94 validPointMask[k].resize(ScatterplotResolution[1], 0);
97 SimplexId const numberOfPoints = input->GetNumberOfPoints();
98#ifndef TTK_ENABLE_KAMIKAZE
100 if(numberOfPoints < 1) {
106 std::array<double, 2> scalarMin{0, 0};
107 std::array<double, 2> scalarMax{0, 0};
108 for(
SimplexId k = 0; k < numberOfPoints; ++k) {
109 double const d1 = inputScalars1->GetTuple1(k);
110 double const d2 = inputScalars2->GetTuple1(k);
112 if(!k or scalarMin[0] > d1)
114 if(!k or scalarMin[1] > d2)
116 if(!k or scalarMax[0] < d1)
118 if(!k or scalarMax[1] < d2)
121#ifndef TTK_ENABLE_KAMIKAZE
123 if(scalarMin[0] == scalarMax[0] or scalarMin[1] == scalarMax[1]) {
124 this->
printErr(
"scalar fields stats problem.");
132 this->
setResolutions(ScatterplotResolution[0], ScatterplotResolution[1]);
140 (status = this->dispatch<VTK_TT, TTK_TT>(
142 inputScalars2, (TTK_TT *)triangulation->
getData())));
146 std::stringstream msg;
147 msg <<
"ContinuousScatterPlot.execute() error " << status;
152 vtkNew<vtkCharArray> maskScalars;
153 maskScalars->SetNumberOfComponents(1);
154 maskScalars->SetNumberOfTuples(numberOfPixels);
155 maskScalars->SetName(
"ValidPointMask");
157 vtkNew<vtkDoubleArray> densityScalars;
158 densityScalars->SetNumberOfComponents(1);
159 densityScalars->SetNumberOfTuples(numberOfPixels);
160 densityScalars->SetName(
"Density");
162 vtkNew<vtkDoubleArray> scalars1;
163 scalars1->SetNumberOfComponents(1);
164 scalars1->SetNumberOfTuples(numberOfPixels);
165 scalars1->SetName(inputScalars1->GetName());
167 vtkNew<vtkDoubleArray> scalars2;
168 scalars2->SetNumberOfComponents(1);
169 scalars2->SetNumberOfTuples(numberOfPixels);
170 scalars2->SetName(inputScalars2->GetName());
173 delta[0] = (scalarMax[0] - scalarMin[0]) / (ScatterplotResolution[0] - 1);
174 delta[1] = (scalarMax[1] - scalarMin[1]) / (ScatterplotResolution[1] - 1);
176 double imageMin[2]{0.0, 0.0};
177 double imageMax[2]{1.0, 1.0};
178 if(ProjectImageSupport) {
179 imageMin[0] = scalarMin[0];
180 imageMin[1] = scalarMin[1];
181 imageMax[0] = scalarMax[0];
182 imageMax[1] = scalarMax[1];
184 double imageDelta[2];
185 imageDelta[0] = (imageMax[0] - imageMin[0]) / (ScatterplotResolution[0] - 1);
186 imageDelta[1] = (imageMax[1] - imageMin[1]) / (ScatterplotResolution[1] - 1);
188 vtkNew<vtkUnstructuredGrid> vtu;
189 vtkNew<vtkPoints> pts;
190 pts->SetNumberOfPoints(numberOfPixels);
194 for(
SimplexId i = 0; i < ScatterplotResolution[0]; i++) {
195 for(
SimplexId j = 0; j < ScatterplotResolution[1]; j++) {
197 double const x = imageMin[0] + i * imageDelta[0];
198 double const y = imageMin[1] + j * imageDelta[1];
199 pts->SetPoint(
id, x, y, 0);
203 maskScalars->SetTuple1(
id, validPointMask[i][j]);
205 densityScalars->SetTuple1(
id, density[i][j]);
207 double const d1 = scalarMin[0] + i * delta[0];
208 double const d2 = scalarMin[1] + j * delta[1];
209 scalars1->SetTuple1(
id, d1);
210 scalars2->SetTuple1(
id, d2);
211 if(i < ScatterplotResolution[0] - 1
212 and j < ScatterplotResolution[1] - 1) {
215 ids[2] =
id + ScatterplotResolution[1];
216 vtu->InsertNextCell(VTK_TRIANGLE, 3, ids);
219 ids[1] =
id + ScatterplotResolution[1];
220 ids[2] =
id + ScatterplotResolution[1] + 1;
221 vtu->InsertNextCell(VTK_TRIANGLE, 3, ids);
228 vtu->GetPointData()->AddArray(maskScalars);
229 vtu->GetPointData()->AddArray(densityScalars);
230 vtu->GetPointData()->AddArray(scalars1);
231 vtu->GetPointData()->AddArray(scalars2);
232 output->ShallowCopy(vtu);