Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
vtkMitkVolumeTextureMapper3D.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkCommon.h"
19 
20 #define GPU_INFO MITK_INFO("mapper.vr")
21 #define GPU_WARN MITK_WARN("mapper.vr")
22 
23 #include "vtkCamera.h"
24 #include "vtkColorTransferFunction.h"
25 #include "vtkDataArray.h"
26 #include "vtkImageData.h"
27 #include "vtkMath.h"
28 #include "vtkMatrix4x4.h"
29 #include "vtkPiecewiseFunction.h"
30 #include "vtkPointData.h"
31 #include "vtkRenderer.h"
32 #include "vtkVolume.h"
33 #include "vtkVolumeProperty.h"
34 //#include "vtkVolumeRenderingFactory.h" //VTK6_TODO
35 
36 //----------------------------------------------------------------------------
37 // Needed when we don't use the vtkStandardNewMacro.
39 //----------------------------------------------------------------------------
40 
41 //-----------------------------------------------------------------------------
43 {
44  // GPU_INFO << "vtkMitkVolumeTextureMapper3D";
45 
46  this->PolygonBuffer = nullptr;
47  this->IntersectionBuffer = nullptr;
48  this->NumberOfPolygons = 0;
49  this->BufferSize = 0;
50 
51  // The input used when creating the textures
52  this->SavedTextureInput = nullptr;
53 
54  // The input used when creating the color tables
55  this->SavedParametersInput = nullptr;
56 
57  this->SavedRGBFunction = nullptr;
58  this->SavedGrayFunction = nullptr;
59  this->SavedScalarOpacityFunction = nullptr;
60  this->SavedGradientOpacityFunction = nullptr;
61  this->SavedColorChannels = 0;
62  this->SavedSampleDistance = 0;
64 
65  /*
66  this->Volume1 = NULL;
67  this->Volume2 = NULL;
68  this->Volume3 = NULL;
69  */
70  /*
71  this->VolumeSize = 0;
72  this->VolumeComponents = 0;
73  */
74 
75  this->VolumeSpacing[0] = this->VolumeSpacing[1] = this->VolumeSpacing[2] = 0;
76  this->VolumeDimensions[0] = 0;
77  this->VolumeDimensions[1] = 0;
78  this->VolumeDimensions[2] = 0;
79 
80  this->SampleDistance = 1.0;
81  this->ActualSampleDistance = 1.0;
82 
83  this->UseCompressedTexture = false;
84  this->SupportsNonPowerOfTwoTextures = false;
85 
86  // GPU_INFO << "np2: " << (this->SupportsNonPowerOfTwoTextures?1:0);
87 }
88 
89 //-----------------------------------------------------------------------------
91 {
92  // GPU_INFO << "~vtkMitkVolumeTextureMapper3D";
93 
94  delete[] this->PolygonBuffer;
95  delete[] this->IntersectionBuffer;
96  /*
97  delete [] this->Volume1;
98  delete [] this->Volume2;
99  delete [] this->Volume3;
100  */
101 }
102 
103 //-----------------------------------------------------------------------------
104 // vtkMitkVolumeTextureMapper3D *vtkMitkVolumeTextureMapper3D::New() //VTK6_TODO
105 //{
106 // //GPU_INFO << "New";
107 
108 // // First try to create the object from the vtkObjectFactory
109 // vtkObject* ret =
110 // vtkVolumeRenderingFactory::CreateInstance("vtkMitkVolumeTextureMapper3D");
111 // return static_cast<vtkMitkVolumeTextureMapper3D *>(ret);
112 //}
113 
114 //-----------------------------------------------------------------------------
115 void vtkMitkVolumeTextureMapper3D::ComputePolygons(vtkRenderer *ren, vtkVolume *vol, double inBounds[6])
116 {
117  // GPU_INFO << "ComputePolygons";
118 
119  // Get the camera position and focal point
120  double focalPoint[4], position[4];
121  double plane[4];
122  vtkCamera *camera = ren->GetActiveCamera();
123 
124  camera->GetPosition(position);
125  camera->GetFocalPoint(focalPoint);
126 
127  position[3] = 1.0;
128  focalPoint[3] = 1.0;
129 
130  // Pass the focal point and position through the inverse of the
131  // volume's matrix to map back into the data coordinates. We
132  // are going to compute these polygons in the coordinate system
133  // of the input data - this is easiest since this data must be
134  // axis aligned. Then we'll use OpenGL to transform these polygons
135  // into the world coordinate system through the use of the
136  // volume's matrix.
137  vtkMatrix4x4 *matrix = vtkMatrix4x4::New();
138  vol->GetMatrix(matrix);
139  matrix->Invert();
140  matrix->MultiplyPoint(position, position);
141  matrix->MultiplyPoint(focalPoint, focalPoint);
142  matrix->Delete();
143 
144  if (position[3])
145  {
146  position[0] /= position[3];
147  position[1] /= position[3];
148  position[2] /= position[3];
149  }
150 
151  if (focalPoint[3])
152  {
153  focalPoint[0] /= focalPoint[3];
154  focalPoint[1] /= focalPoint[3];
155  focalPoint[2] /= focalPoint[3];
156  }
157 
158  // Create a plane equation using the direction and position of the camera
159  plane[0] = focalPoint[0] - position[0];
160  plane[1] = focalPoint[1] - position[1];
161  plane[2] = focalPoint[2] - position[2];
162 
163  vtkMath::Normalize(plane);
164 
165  plane[3] = -(plane[0] * position[0] + plane[1] * position[1] + plane[2] * position[2]);
166 
167  // Find the min and max distances of the boundary points of the volume
168  double minDistance = VTK_DOUBLE_MAX;
169  double maxDistance = VTK_DOUBLE_MIN;
170 
171  // The inBounds parameter is the bounds we are using for clipping the
172  // texture planes against. First we need to clip these against the bounds
173  // of the volume to make sure they don't exceed it.
174  double volBounds[6];
175  this->GetInput()->GetBounds(volBounds);
176 
177  double bounds[6];
178  bounds[0] = (inBounds[0] > volBounds[0]) ? (inBounds[0]) : (volBounds[0]);
179  bounds[1] = (inBounds[1] < volBounds[1]) ? (inBounds[1]) : (volBounds[1]);
180  bounds[2] = (inBounds[2] > volBounds[2]) ? (inBounds[2]) : (volBounds[2]);
181  bounds[3] = (inBounds[3] < volBounds[3]) ? (inBounds[3]) : (volBounds[3]);
182  bounds[4] = (inBounds[4] > volBounds[4]) ? (inBounds[4]) : (volBounds[4]);
183  bounds[5] = (inBounds[5] < volBounds[5]) ? (inBounds[5]) : (volBounds[5]);
184 
185  // Create 8 vertices for the bounding box we are rendering
186  int i, j, k;
187  double vertices[8][3];
188 
189  int idx = 0;
190 
191  for (k = 0; k < 2; k++)
192  {
193  for (j = 0; j < 2; j++)
194  {
195  for (i = 0; i < 2; i++)
196  {
197  vertices[idx][2] = bounds[4 + k];
198  vertices[idx][1] = bounds[2 + j];
199  vertices[idx][0] = bounds[i];
200 
201  double d = plane[0] * vertices[idx][0] + plane[1] * vertices[idx][1] + plane[2] * vertices[idx][2] + plane[3];
202 
203  idx++;
204 
205  // Keep track of closest and farthest point
206  minDistance = (d < minDistance) ? (d) : (minDistance);
207  maxDistance = (d > maxDistance) ? (d) : (maxDistance);
208  }
209  }
210  }
211 
212  int dim[6];
213  this->GetVolumeDimensions(dim);
214 
215  float tCoordOffset[3], tCoordScale[3];
216 
217  tCoordOffset[0] = 0.5 / dim[0];
218  tCoordOffset[1] = 0.5 / dim[1];
219  tCoordOffset[2] = 0.5 / dim[2];
220 
221  tCoordScale[0] = (dim[0] - 1) / static_cast<float>(dim[0]);
222  tCoordScale[1] = (dim[1] - 1) / static_cast<float>(dim[1]);
223  tCoordScale[2] = (dim[2] - 1) / static_cast<float>(dim[2]);
224 
225  float spacing[3];
226  this->GetVolumeSpacing(spacing);
227 
228  double offset = 0.333 * 0.5 * (spacing[0] + spacing[1] + spacing[2]);
229 
230  minDistance += 0.1 * offset;
231  maxDistance -= 0.1 * offset;
232 
233  minDistance = (minDistance < offset) ? (offset) : (minDistance);
234 
235  double stepSize = this->ActualSampleDistance;
236 
237  // Determine the number of polygons
238  int numPolys = static_cast<int>((maxDistance - minDistance) / static_cast<double>(stepSize));
239 
240  // Check if we have space, free old space only if it is too small
241  if (this->BufferSize < numPolys)
242  {
243  delete[] this->PolygonBuffer;
244  delete[] this->IntersectionBuffer;
245 
246  this->BufferSize = numPolys;
247 
248  this->PolygonBuffer = new float[36 * this->BufferSize];
249  this->IntersectionBuffer = new float[12 * this->BufferSize];
250  }
251 
252  this->NumberOfPolygons = numPolys;
253 
254  // Compute the intersection points for each edge of the volume
255  int lines[12][2] = {{0, 1}, {1, 3}, {2, 3}, {0, 2}, {4, 5}, {5, 7}, {6, 7}, {4, 6}, {0, 4}, {1, 5}, {3, 7}, {2, 6}};
256 
257  float *iptr, *pptr;
258 
259  for (i = 0; i < 12; i++)
260  {
261  double line[3];
262 
263  line[0] = vertices[lines[i][1]][0] - vertices[lines[i][0]][0];
264  line[1] = vertices[lines[i][1]][1] - vertices[lines[i][0]][1];
265  line[2] = vertices[lines[i][1]][2] - vertices[lines[i][0]][2];
266 
267  double d = maxDistance;
268 
269  iptr = this->IntersectionBuffer + i;
270 
271  double planeDotLineOrigin = vtkMath::Dot(plane, vertices[lines[i][0]]);
272  double planeDotLine = vtkMath::Dot(plane, line);
273 
274  double t, increment;
275 
276  if (planeDotLine != 0.0)
277  {
278  t = (d - planeDotLineOrigin - plane[3]) / planeDotLine;
279  increment = -stepSize / planeDotLine;
280  }
281  else
282  {
283  t = -1.0;
284  increment = 0.0;
285  }
286 
287  for (j = 0; j < numPolys; j++)
288  {
289  *iptr = (t > 0.0 && t < 1.0) ? (t) : (-1.0);
290 
291  t += increment;
292  iptr += 12;
293  }
294  }
295 
296  // Compute the polygons by determining which edges were intersected
297  int neighborLines[12][6] = {{1, 2, 3, 4, 8, 9},
298  {0, 2, 3, 5, 9, 10},
299  {0, 1, 3, 6, 10, 11},
300  {0, 1, 2, 7, 8, 11},
301  {0, 5, 6, 7, 8, 9},
302  {1, 4, 6, 7, 9, 10},
303  {2, 4, 5, 7, 10, 11},
304  {3, 4, 5, 6, 8, 11},
305  {0, 3, 4, 7, 9, 11},
306  {0, 1, 4, 5, 8, 10},
307  {1, 2, 5, 6, 9, 11},
308  {2, 3, 6, 7, 8, 10}};
309 
310  float tCoord[12][4] = {{0, 0, 0, 0},
311  {1, 0, 0, 1},
312  {0, 1, 0, 0},
313  {0, 0, 0, 1},
314  {0, 0, 1, 0},
315  {1, 0, 1, 1},
316  {0, 1, 1, 0},
317  {0, 0, 1, 1},
318  {0, 0, 0, 2},
319  {1, 0, 0, 2},
320  {1, 1, 0, 2},
321  {0, 1, 0, 2}};
322 
323  double low[3];
324  double high[3];
325 
326  low[0] = (bounds[0] - volBounds[0]) / (volBounds[1] - volBounds[0]);
327  high[0] = (bounds[1] - volBounds[0]) / (volBounds[1] - volBounds[0]);
328  low[1] = (bounds[2] - volBounds[2]) / (volBounds[3] - volBounds[2]);
329  high[1] = (bounds[3] - volBounds[2]) / (volBounds[3] - volBounds[2]);
330  low[2] = (bounds[4] - volBounds[4]) / (volBounds[5] - volBounds[4]);
331  high[2] = (bounds[5] - volBounds[4]) / (volBounds[5] - volBounds[4]);
332 
333  for (i = 0; i < 12; i++)
334  {
335  tCoord[i][0] = (tCoord[i][0]) ? (high[0]) : (low[0]);
336  tCoord[i][1] = (tCoord[i][1]) ? (high[1]) : (low[1]);
337  tCoord[i][2] = (tCoord[i][2]) ? (high[2]) : (low[2]);
338  }
339 
340  iptr = this->IntersectionBuffer;
341  pptr = this->PolygonBuffer;
342 
343  for (i = 0; i < numPolys; i++)
344  {
345  // Look for a starting point
346  int start = 0;
347 
348  while (start < 12 && iptr[start] == -1.0)
349  {
350  start++;
351  }
352 
353  if (start == 12)
354  {
355  pptr[0] = -1.0;
356  }
357  else
358  {
359  int current = start;
360  int previous = -1;
361  int errFlag = 0;
362 
363  idx = 0;
364 
365  while (idx < 6 && !errFlag && (idx == 0 || current != start))
366  {
367  double t = iptr[current];
368 
369  *(pptr + idx * 6) = tCoord[current][0] * tCoordScale[0] + tCoordOffset[0];
370  *(pptr + idx * 6 + 1) = tCoord[current][1] * tCoordScale[1] + tCoordOffset[1];
371  *(pptr + idx * 6 + 2) = tCoord[current][2] * tCoordScale[2] + tCoordOffset[2];
372 
373  int coord = static_cast<int>(tCoord[current][3]);
374  *(pptr + idx * 6 + coord) =
375  (low[coord] + t * (high[coord] - low[coord])) * tCoordScale[coord] + tCoordOffset[coord];
376 
377  *(pptr + idx * 6 + 3) = static_cast<float>(
378  vertices[lines[current][0]][0] + t * (vertices[lines[current][1]][0] - vertices[lines[current][0]][0]));
379 
380  *(pptr + idx * 6 + 4) = static_cast<float>(
381  vertices[lines[current][0]][1] + t * (vertices[lines[current][1]][1] - vertices[lines[current][0]][1]));
382 
383  *(pptr + idx * 6 + 5) = static_cast<float>(
384  vertices[lines[current][0]][2] + t * (vertices[lines[current][1]][2] - vertices[lines[current][0]][2]));
385 
386  idx++;
387 
388  j = 0;
389 
390  while (j < 6 && (*(this->IntersectionBuffer + i * 12 + neighborLines[current][j]) < 0 ||
391  neighborLines[current][j] == previous))
392  {
393  j++;
394  }
395 
396  if (j >= 6)
397  {
398  errFlag = 1;
399  }
400  else
401  {
402  previous = current;
403  current = neighborLines[current][j];
404  }
405  }
406 
407  if (idx < 6)
408  {
409  *(pptr + idx * 6) = -1;
410  }
411  }
412 
413  iptr += 12;
414  pptr += 36;
415  }
416 }
417 
419 {
420  this->SavedTextureMTime.Modified();
421 }
422 
423 //-----------------------------------------------------------------------------
425 {
426  // GPU_INFO << "UpdateColorLookup";
427 
428  int needToUpdate = 0;
429 
430  // Get the image data
431  vtkImageData *input = this->GetInput();
432  Update();
433 
434  // Has the volume changed in some way?
435  if (this->SavedParametersInput != input || this->SavedParametersMTime.GetMTime() < input->GetMTime())
436  {
437  needToUpdate = 1;
438  }
439 
440  // What sample distance are we going to use for rendering? If we
441  // have to render quickly according to our allocated render time,
442  // don't necessary obey the sample distance requested by the user.
443  // Instead set the sample distance to the average spacing.
444  this->ActualSampleDistance = this->SampleDistance;
445  if (vol->GetAllocatedRenderTime() < 1.0)
446  {
447  float spacing[3];
448  this->GetVolumeSpacing(spacing);
449  this->ActualSampleDistance =
450  0.333 * (static_cast<double>(spacing[0]) + static_cast<double>(spacing[1]) + static_cast<double>(spacing[2]));
451  }
452 
453  // How many components?
454  int components = input->GetNumberOfScalarComponents();
455 
456  // Has the sample distance changed?
457  if (this->SavedSampleDistance != this->ActualSampleDistance)
458  {
459  needToUpdate = 1;
460  }
461 
462  vtkColorTransferFunction *rgbFunc = nullptr;
463  vtkPiecewiseFunction *grayFunc = nullptr;
464 
465  // How many color channels for this component?
466  int colorChannels = vol->GetProperty()->GetColorChannels(0);
467 
468  if (components < 3)
469  {
470  // Has the number of color channels changed?
471  if (this->SavedColorChannels != colorChannels)
472  {
473  needToUpdate = 1;
474  }
475 
476  // Has the color transfer function changed in some way,
477  // and we are using it?
478  if (colorChannels == 3)
479  {
480  rgbFunc = vol->GetProperty()->GetRGBTransferFunction(0);
481  if (this->SavedRGBFunction != rgbFunc || this->SavedParametersMTime.GetMTime() < rgbFunc->GetMTime())
482  {
483  needToUpdate = 1;
484  }
485  }
486 
487  // Has the gray transfer function changed in some way,
488  // and we are using it?
489  if (colorChannels == 1)
490  {
491  grayFunc = vol->GetProperty()->GetGrayTransferFunction(0);
492  if (this->SavedGrayFunction != grayFunc || this->SavedParametersMTime.GetMTime() < grayFunc->GetMTime())
493  {
494  needToUpdate = 1;
495  }
496  }
497  }
498 
499  // Has the scalar opacity transfer function changed in some way?
500  vtkPiecewiseFunction *scalarOpacityFunc = vol->GetProperty()->GetScalarOpacity(0);
501  if (this->SavedScalarOpacityFunction != scalarOpacityFunc ||
502  this->SavedParametersMTime.GetMTime() < scalarOpacityFunc->GetMTime())
503  {
504  needToUpdate = 1;
505  }
506 
507  // Has the gradient opacity transfer function changed in some way?
508  vtkPiecewiseFunction *gradientOpacityFunc = vol->GetProperty()->GetGradientOpacity(0);
509  if (this->SavedGradientOpacityFunction != gradientOpacityFunc ||
510  this->SavedParametersMTime.GetMTime() < gradientOpacityFunc->GetMTime())
511  {
512  needToUpdate = 1;
513  }
514 
515  double scalarOpacityDistance = vol->GetProperty()->GetScalarOpacityUnitDistance(0);
516  if (this->SavedScalarOpacityDistance != scalarOpacityDistance)
517  {
518  needToUpdate = 1;
519  }
520 
521  // If we have not found any need to update, return now
522  if (!needToUpdate)
523  {
524  return 0;
525  }
526 
527  this->SavedRGBFunction = rgbFunc;
528  this->SavedGrayFunction = grayFunc;
529  this->SavedScalarOpacityFunction = scalarOpacityFunc;
530  this->SavedGradientOpacityFunction = gradientOpacityFunc;
531  this->SavedColorChannels = colorChannels;
533  this->SavedScalarOpacityDistance = scalarOpacityDistance;
534  this->SavedParametersInput = input;
535 
536  this->SavedParametersMTime.Modified();
537 
538  // Find the scalar range
539  double scalarRange[2];
540  input->GetPointData()->GetScalars()->GetRange(scalarRange, components - 1);
541 
542  int arraySizeNeeded = this->ColorTableSize;
543 
544  if (components < 3)
545  {
546  // Sample the transfer functions between the min and max.
547  if (colorChannels == 1)
548  {
549  grayFunc->GetTable(scalarRange[0], scalarRange[1], arraySizeNeeded, this->TempArray1);
550  }
551  else
552  {
553  rgbFunc->GetTable(scalarRange[0], scalarRange[1], arraySizeNeeded, this->TempArray1);
554  }
555  }
556 
557  scalarOpacityFunc->GetTable(scalarRange[0], scalarRange[1], arraySizeNeeded, this->TempArray2);
558 
559  float goArray[256];
560  gradientOpacityFunc->GetTable(0, (scalarRange[1] - scalarRange[0]) * 0.25, 256, goArray);
561 
562  // Correct the opacity array for the spacing between the planes.
563  int i;
564 
565  float *fptr2 = this->TempArray2;
566  double factor = this->ActualSampleDistance / scalarOpacityDistance;
567  for (i = 0; i < arraySizeNeeded; i++)
568  {
569  if (*fptr2 > 0.0001)
570  {
571  *fptr2 = 1.0 - pow(static_cast<double>(1.0 - (*fptr2)), factor);
572  }
573  fptr2++;
574  }
575 
576  int goLoop;
577  unsigned char *ptr, *rgbptr, *aptr;
578  float *fptr1;
579 
580  switch (components)
581  {
582  case 1:
583  // Move the two temp float arrays into one RGBA unsigned char array
584  ptr = this->ColorLookup;
585  for (goLoop = 0; goLoop < 256; goLoop++)
586  {
587  fptr1 = this->TempArray1;
588  fptr2 = this->TempArray2;
589  if (colorChannels == 1)
590  {
591  for (i = 0; i < arraySizeNeeded; i++)
592  {
593  *(ptr++) = static_cast<unsigned char>(*(fptr1)*255.0 + 0.5);
594  *(ptr++) = static_cast<unsigned char>(*(fptr1)*255.0 + 0.5);
595  *(ptr++) = static_cast<unsigned char>(*(fptr1++) * 255.0 + 0.5);
596  *(ptr++) = static_cast<unsigned char>(*(fptr2++) * goArray[goLoop] * 255.0 + 0.5);
597  }
598  }
599  else
600  {
601  for (i = 0; i < arraySizeNeeded; i++)
602  {
603  *(ptr++) = static_cast<unsigned char>(*(fptr1++) * 255.0 + 0.5);
604  *(ptr++) = static_cast<unsigned char>(*(fptr1++) * 255.0 + 0.5);
605  *(ptr++) = static_cast<unsigned char>(*(fptr1++) * 255.0 + 0.5);
606  *(ptr++) = static_cast<unsigned char>(*(fptr2++) * goArray[goLoop] * 255.0 + 0.5);
607  }
608  }
609 
610  for (; i < 256; i++)
611  {
612  *(ptr++) = 0;
613  *(ptr++) = 0;
614  *(ptr++) = 0;
615  *(ptr++) = 0;
616  }
617  }
618  break;
619 
620  case 2:
621  // Move the two temp float arrays into one RGB unsigned char array and
622  // one alpha array.
623  rgbptr = this->ColorLookup;
624  aptr = this->AlphaLookup;
625 
626  if (colorChannels == 1)
627  {
628  for (i = 0; i < arraySizeNeeded; i++)
629  {
630  fptr1 = this->TempArray1;
631  fptr2 = this->TempArray2;
632  for (goLoop = 0; goLoop < 256; goLoop++)
633  {
634  *(rgbptr++) = static_cast<unsigned char>(*(fptr1)*255.0 + 0.5);
635  *(rgbptr++) = static_cast<unsigned char>(*(fptr1)*255.0 + 0.5);
636  *(rgbptr++) = static_cast<unsigned char>(*(fptr1++) * 255.0 + 0.5);
637  *(aptr++) = static_cast<unsigned char>(*(fptr2++) * goArray[goLoop] * 255.0 + 0.5);
638  }
639  }
640  }
641  else
642  {
643  fptr1 = this->TempArray1;
644  fptr2 = this->TempArray2;
645  for (i = 0; i < arraySizeNeeded; i++)
646  {
647  for (goLoop = 0; goLoop < 256; goLoop++)
648  {
649  *(rgbptr++) = static_cast<unsigned char>(*(fptr1)*255.0 + 0.5);
650  *(rgbptr++) = static_cast<unsigned char>(*(fptr1 + 1) * 255.0 + 0.5);
651  *(rgbptr++) = static_cast<unsigned char>(*(fptr1 + 2) * 255.0 + 0.5);
652  *(aptr++) = static_cast<unsigned char>(*(fptr2)*goArray[goLoop] * 255.0 + 0.5);
653  }
654  fptr1 += 3;
655  fptr2++;
656  }
657  }
658 
659  for (; i < 256; i++)
660  {
661  for (goLoop = 0; goLoop < 256; goLoop++)
662  {
663  *(rgbptr++) = 0;
664  *(rgbptr++) = 0;
665  *(rgbptr++) = 0;
666  *(aptr++) = 0;
667  }
668  }
669  break;
670 
671  case 3:
672  case 4:
673  // Move the two temp float arrays into one alpha array
674  aptr = this->AlphaLookup;
675 
676  for (goLoop = 0; goLoop < 256; goLoop++)
677  {
678  fptr2 = this->TempArray2;
679  for (i = 0; i < arraySizeNeeded; i++)
680  {
681  *(aptr++) = static_cast<unsigned char>(*(fptr2++) * goArray[goLoop] * 255.0 + 0.5);
682  }
683  for (; i < 256; i++)
684  {
685  *(aptr++) = 0;
686  }
687  }
688 
689  break;
690  }
691  return 1;
692 }
693 
694 //-----------------------------------------------------------------------------
695 // Print the vtkMitkVolumeTextureMapper3D
696 void vtkMitkVolumeTextureMapper3D::PrintSelf(ostream &os, vtkIndent indent)
697 {
698  this->Superclass::PrintSelf(os, indent);
699 
700  os << indent << "Sample Distance: " << this->SampleDistance << endl;
701  os << indent << "NumberOfPolygons: " << this->NumberOfPolygons << endl;
702  os << indent << "ActualSampleDistance: " << this->ActualSampleDistance << endl;
703  os << indent << "VolumeDimensions: " << this->VolumeDimensions[0] << " " << this->VolumeDimensions[1] << " "
704  << this->VolumeDimensions[2] << endl;
705  os << indent << "VolumeSpacing: " << this->VolumeSpacing[0] << " " << this->VolumeSpacing[1] << " "
706  << this->VolumeSpacing[2] << endl;
707 
708  os << indent << "UseCompressedTexture: " << this->UseCompressedTexture << endl;
709 }
static char * line
Definition: svm.cpp:2884
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
vtkColorTransferFunction * SavedRGBFunction
void ComputePolygons(vtkRenderer *ren, vtkVolume *vol, double bounds[6])
static Vector3D offset
vtkInstantiatorNewMacro(vtkMitkVolumeTextureMapper3D)
void Normalize(itk::Image< TPixel, VImageDimension > *itkImage, mitk::Image::Pointer im2, mitk::Image::Pointer mask1, std::string output)
Definition: CLBrainMask.cpp:40
vtkPiecewiseFunction * SavedGradientOpacityFunction
vtkPiecewiseFunction * SavedScalarOpacityFunction
void PrintSelf(ostream &os, vtkIndent indent) override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.