MCPcopy Create free account
hub / github.com/Kitware/VTK / ThreadedRequestData

Method ThreadedRequestData

Imaging/OpenGL2/vtkOpenGLImageGradient.cxx:86–164  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This method contains the first switch statement that calls the correct templated function for the input and output region types.

Source from the content-addressed store, hash-verified

84// This method contains the first switch statement that calls the correct
85// templated function for the input and output region types.
86void vtkOpenGLImageGradient::ThreadedRequestData(vtkInformation* vtkNotUsed(request),
87 vtkInformationVector** inputVector, vtkInformationVector* vtkNotUsed(outputVector),
88 vtkImageData*** inData, vtkImageData** outData, int outExt[6], int vtkNotUsed(id))
89{
90 vtkDataArray* inArray = this->GetInputArrayToProcess(0, inputVector);
91 outData[0]->GetPointData()->GetScalars()->SetName(inArray->GetName());
92
93 // The output scalar type must be double to store proper gradients.
94 if (outData[0]->GetScalarType() != VTK_DOUBLE)
95 {
96 vtkErrorMacro(
97 "Execute: output ScalarType is " << outData[0]->GetScalarType() << "but must be double.");
98 return;
99 }
100
101 // Gradient makes sense only with one input component. This is not
102 // a Jacobian filter.
103 if (inArray->GetNumberOfComponents() != 1)
104 {
105 vtkErrorMacro("Execute: input has more than one component. "
106 "The input to gradient should be a single component image. "
107 "Think about it. If you insist on using a color image then "
108 "run it though RGBToHSV then ExtractComponents to get the V "
109 "components. That's probably what you want anyhow.");
110 return;
111 }
112
113 vtkOpenGLGradientCB cb;
114 cb.Spacing = inData[0][0]->GetSpacing();
115
116 // build the fragment shader for 2D or 3D gradient
117 std::string fragShader =
118 "//VTK::System::Dec\n"
119 "varying vec2 tcoordVSOutput;\n"
120 "uniform sampler3D inputTex1;\n"
121 "uniform float zPos;\n"
122 "uniform vec3 spacing;\n"
123 "uniform float inputScale;\n"
124 "uniform float inputShift;\n"
125 "//VTK::Output::Dec\n"
126 "void main(void) {\n"
127 " float dx = textureOffset(inputTex1, vec3(tcoordVSOutput, zPos), ivec3(1,0,0)).r\n"
128 " - textureOffset(inputTex1, vec3(tcoordVSOutput, zPos), ivec3(-1,0,0)).r;\n"
129 " dx = inputScale*0.5*dx/spacing.x;\n"
130 " float dy = textureOffset(inputTex1, vec3(tcoordVSOutput, zPos), ivec3(0,1,0)).r\n"
131 " - textureOffset(inputTex1, vec3(tcoordVSOutput, zPos), ivec3(0,-1,0)).r;\n"
132 " dy = inputScale*0.5*dy/spacing.y;\n";
133
134 if (this->Dimensionality == 3)
135 {
136 fragShader +=
137 " float dz = textureOffset(inputTex1, vec3(tcoordVSOutput, zPos), ivec3(0,0,1)).r\n"
138 " - textureOffset(inputTex1, vec3(tcoordVSOutput, zPos), ivec3(0,0,-1)).r;\n"
139 " dz = inputScale*0.5*dz/spacing.z;\n"
140 " gl_FragData[0] = vec4(dx, dy, dz, 1.0);\n"
141 "}\n";
142 }
143 else

Callers

nothing calls this directly

Calls 10

SetNameMethod · 0.45
GetScalarsMethod · 0.45
GetPointDataMethod · 0.45
GetNameMethod · 0.45
GetScalarTypeMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetSpacingMethod · 0.45
ExecuteMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected