67 vtkRenderPassCollection *valuePassCollection,
68 std::vector<std::string> &valuePassNames)
const {
69 auto fd = fieldType == 0 ?
static_cast<vtkFieldData *
>(
object->GetPointData())
70 :
static_cast<vtkFieldData *
>(
object->GetCellData());
72 for(
size_t i = 0, j = fd->GetNumberOfArrays(); i < j; i++) {
73 auto array = fd->GetArray(i);
77 std::string
const name(array->GetName());
80 array->GetRange(minmax);
82 size_t const nComponents = array->GetNumberOfComponents();
83 for(
size_t c = 0; c < nComponents; c++) {
85 valuePass->SetInputArrayToProcess(fieldType == 0
86 ? VTK_SCALAR_MODE_USE_POINT_FIELD_DATA
87 : VTK_SCALAR_MODE_USE_CELL_FIELD_DATA,
89 valuePass->SetInputComponentToProcess(c);
91 valuePassCollection->AddItem(valuePass);
92 valuePassNames.push_back(
93 nComponents == 1 ? name : name +
"_" + std::to_string(c));
101 vtkMultiBlockDataSet *outputImages,
103 vtkPointSet *inputObject,
104 vtkPointSet *inputGrid)
const {
107 if(inputObject->IsA(
"vtkPolyData")) {
108 inputObjectAsPD->ShallowCopy(inputObject);
111 surfaceFilter->SetInputDataObject(inputObject);
112 surfaceFilter->Update();
113 inputObjectAsPD->ShallowCopy(surfaceFilter->GetOutput());
122 float *samplingPositions
124 int const nSamplingPositions = inputGrid->GetNumberOfPoints();
125 auto camParameters = inputGrid->GetPointData();
126 auto camUp =
static_cast<double *
>(
128 auto camFocalPoint =
static_cast<double *
>(
130 auto camHeight =
static_cast<double *
>(
132 auto camAngle =
static_cast<double *
>(
134 auto camNearFar =
static_cast<double *
>(
136 auto resolution =
static_cast<double *
>(
138 auto projectionMode =
static_cast<double *
>(
146 this->setupRenderer(rendererDepth, inputObjectAsPD, camera);
149 this->setupWindow(windowDepth, rendererDepth, resolution);
151 auto windowDepthToImageFilter
153 windowDepthToImageFilter->SetInput(windowDepth);
154 windowDepthToImageFilter->SetInputBufferTypeToZBuffer();
157 size_t nValuePasses = 0;
160 this->setupRenderer(rendererScalars, inputObjectAsPD, camera);
163 this->setupWindow(windowScalars, rendererScalars, resolution);
165 if(windowScalars->SupportsOpenGL() == 0) {
167 this->printErr(
"RenderWindow does not support OpenGL");
172 std::vector<std::string> valuePassNames;
173 size_t firstValuePassIndex = 0;
175 auto preventVTKBug = [](vtkPointSet *object) {
176 auto pd =
object->GetPointData();
177 auto cd =
object->GetCellData();
179 if(pd->GetNumberOfArrays() < 1 && cd->GetNumberOfArrays() > 0) {
180 size_t const nP =
object->GetNumberOfPoints();
183 fakeArray->SetName(
"Fake");
184 fakeArray->SetNumberOfComponents(1);
185 fakeArray->SetNumberOfTuples(nP);
186 auto fakeArrayData = (
signed char *)fakeArray->GetVoidPointer(0);
187 for(
size_t i = 0; i < nP; i++)
188 fakeArrayData[i] = 0;
189 pd->AddArray(fakeArray);
195 if(preventVTKBug(inputObjectAsPD)) {
196 firstValuePassIndex = 1;
199 this->addValuePass(inputObjectAsPD, 0, valuePassCollection, valuePassNames);
200 this->addValuePass(inputObjectAsPD, 1, valuePassCollection, valuePassNames);
201 nValuePasses = valuePassNames.size();
204 sequence->SetPasses(valuePassCollection);
207 cameraPass->SetDelegatePass(sequence);
209 auto glRenderer = vtkOpenGLRenderer::SafeDownCast(rendererScalars);
210 glRenderer->SetPass(cameraPass);
213 windowScalars->Render();
215 for(
int i = 0; i < nSamplingPositions; i++) {
217 int const resX = resolution[i * 2];
218 int const resY = resolution[i * 2 + 1];
221 + std::string(projectionMode[i] ?
"P" :
"O") +
"|"
222 + std::to_string(resX) +
"x" + std::to_string(resY) +
")",
225 double camPos[3]{samplingPositions[i * 3], samplingPositions[i * 3 + 1],
226 samplingPositions[i * 3 + 2]};
228 if(projectionMode[i] == 0) {
229 camera->SetParallelProjection(
true);
230 camera->SetParallelScale(
234 camera->SetParallelProjection(
false);
235 camera->SetViewAngle(camAngle[i] * resolution[i * 2 + 1]
236 / resolution[i * 2]);
239 camera->SetPosition(camPos);
240 camera->SetViewUp(&camUp[i * 3]);
241 camera->SetFocalPoint(&camFocalPoint[i * 3]);
242 camera->SetClippingRange(&camNearFar[i * 2]);
246 outputImage->SetDimensions(resolution[i * 2], resolution[i * 2 + 1], 1);
247 outputImage->SetSpacing(1, 1, 1);
248 outputImage->SetOrigin(0, 0, 0);
249 outputImage->AllocateScalars(VTK_FLOAT, 1);
251 auto outputImagePD = outputImage->GetPointData();
254 windowDepthToImageFilter->Modified();
255 windowDepthToImageFilter->Update();
256 outputImage->DeepCopy(windowDepthToImageFilter->GetOutput());
257 outputImagePD->GetAbstractArray(0)->SetName(
"Depth");
262 if(nValuePasses > firstValuePassIndex) {
263 windowScalars->Render();
265 for(
size_t j = firstValuePassIndex; j < nValuePasses; j++) {
267 = vtkValuePass::SafeDownCast(valuePassCollection->GetItemAsObject(j));
269 newValueArray->DeepCopy(
270 valuePass->GetFloatImageDataArray(rendererScalars));
271 newValueArray->SetName(valuePassNames[j].data());
272 outputImagePD->AddArray(newValueArray);
277 outputImages->SetBlock(i, outputImage);
280 + std::string(projectionMode[i] ?
"P" :
"O") +
"|"
281 + std::to_string(resX) +
"x" + std::to_string(resY) +
")",