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

Function vtkOpenGLImageMapperRenderShort

Rendering/OpenGL2/vtkOpenGLImageMapper.cxx:254–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252
253template <class T>
254void vtkOpenGLImageMapperRenderShort(vtkOpenGLImageMapper* self, vtkImageData* data, T* dataPtr,
255 double shift, double scale, vtkViewport* viewport)
256{
257 vtkOpenGLClearErrorMacro();
258
259 int inMin0 = self->DisplayExtent[0];
260 int inMax0 = self->DisplayExtent[1];
261 int inMin1 = self->DisplayExtent[2];
262 int inMax1 = self->DisplayExtent[3];
263
264 int width = inMax0 - inMin0 + 1;
265 int height = inMax1 - inMin1 + 1;
266
267 vtkIdType tempIncs[3];
268 data->GetIncrements(tempIncs);
269 vtkIdType inInc1 = tempIncs[1];
270
271 int bpp = data->GetNumberOfScalarComponents();
272
273 double range[2];
274 data->GetPointData()->GetScalars()->GetDataTypeRange(range);
275
276 auto ostate = static_cast<vtkOpenGLRenderWindow*>(viewport->GetVTKWindow())->GetState();
277 ostate->vtkglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
278
279 // Find the number of bits to use for the fraction:
280 // continue increasing the bits until there is an overflow
281 // in the worst case, then decrease by 1.
282 // The "*2.0" and "*1.0" ensure that the comparison is done
283 // with double-precision math.
284 int bitShift = 0;
285 double absScale = std::abs(scale);
286
287 while ((static_cast<long>(1 << bitShift) * absScale) * 2.0 * USHRT_MAX < INT_MAX * 1.0)
288 {
289 bitShift++;
290 }
291 bitShift--;
292 bitShift = std::max(bitShift, 0);
293
294 long sscale = static_cast<long>(scale * (1 << bitShift));
295 long sshift = static_cast<long>(sscale * shift);
296 /* should do proper rounding, as follows:
297 long sscale = (long) floor(scale*(1 << bitShift) + 0.5);
298 long sshift = (long) floor((scale*shift + 0.5)*(1 << bitShift));
299 */
300 long val;
301 unsigned char tmp;
302
303 T* inPtr = dataPtr;
304 T* inPtr1 = inPtr;
305
306 int i;
307 int j = height;
308
309 unsigned char* newPtr;
310 if (bpp < 4)
311 {

Callers 1

Calls 12

vtkPadToFourFunction · 0.85
GetIncrementsMethod · 0.80
GetDataTypeRangeMethod · 0.80
GetVTKWindowMethod · 0.80
vtkglPixelStoreiMethod · 0.80
absFunction · 0.50
maxFunction · 0.50
GetScalarsMethod · 0.45
GetPointDataMethod · 0.45
GetStateMethod · 0.45
DrawPixelsMethod · 0.45

Tested by

no test coverage detected