Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
mitkSurfaceInterpolationController.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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include "mitkImageAccessByItk.h"
15 #include "mitkImageCast.h"
16 #include "mitkMemoryUtilities.h"
17 
19 //#include "vtkXMLPolyDataWriter.h"
20 #include "vtkPolyDataWriter.h"
21 
22 // Check whether the given contours are coplanar
25 {
26  // Here we check two things:
27  // 1. Whether the normals of both contours are at least parallel
28  // 2. Whether both contours lie in the same plane
29 
30  // Check for coplanarity:
31  // a. Span a vector between two points one from each contour
32  // b. Calculate dot product for the vector and one of the normals
33  // c. If the dot is zero the two vectors are orthogonal and the contours are coplanar
34 
35  double vec[3];
36  vec[0] = leftHandSide.contourPoint[0] - rightHandSide.contourPoint[0];
37  vec[1] = leftHandSide.contourPoint[1] - rightHandSide.contourPoint[1];
38  vec[2] = leftHandSide.contourPoint[2] - rightHandSide.contourPoint[2];
39  double n[3];
40  n[0] = rightHandSide.contourNormal[0];
41  n[1] = rightHandSide.contourNormal[1];
42  n[2] = rightHandSide.contourNormal[2];
43  double dot = vtkMath::Dot(n, vec);
44 
45  double n2[3];
46  n2[0] = leftHandSide.contourNormal[0];
47  n2[1] = leftHandSide.contourNormal[1];
48  n2[2] = leftHandSide.contourNormal[2];
49 
50  // The normals of both contours have to be parallel but not of the same orientation
51  double lengthLHS = leftHandSide.contourNormal.GetNorm();
52  double lengthRHS = rightHandSide.contourNormal.GetNorm();
53  double dot2 = vtkMath::Dot(n, n2);
54  bool contoursParallel = mitk::Equal(fabs(lengthLHS * lengthRHS), fabs(dot2), 0.001);
55 
56  if (mitk::Equal(dot, 0.0, 0.001) && contoursParallel)
57  return true;
58  else
59  return false;
60 }
61 
63  mitk::Surface::Pointer contour)
64 {
66  contourInfo.contour = contour;
67  double n[3];
68  double p[3];
69  contour->GetVtkPolyData()->GetPoints()->GetPoint(0, p);
70  vtkPolygon::ComputeNormal(contour->GetVtkPolyData()->GetPoints(), n);
71  contourInfo.contourNormal = n;
72  contourInfo.contourPoint = p;
73  return contourInfo;
74 }
75 
77  : m_SelectedSegmentation(nullptr), m_CurrentTimeStep(0)
78 {
79  m_DistanceImageSpacing = 0.0;
80  m_ReduceFilter = ReduceContourSetFilter::New();
81  m_NormalsFilter = ComputeContourSetNormalsFilter::New();
82  m_InterpolateSurfaceFilter = CreateDistanceImageFromSurfaceFilter::New();
83  // m_TimeSelector = ImageTimeSelector::New();
84 
85  m_ReduceFilter->SetUseProgressBar(false);
86  // m_ReduceFilter->SetProgressStepSize(1);
87  m_NormalsFilter->SetUseProgressBar(true);
88  m_NormalsFilter->SetProgressStepSize(1);
89  m_InterpolateSurfaceFilter->SetUseProgressBar(true);
90  m_InterpolateSurfaceFilter->SetProgressStepSize(7);
91 
92  m_Contours = Surface::New();
93 
94  m_PolyData = vtkSmartPointer<vtkPolyData>::New();
95  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
96  m_PolyData->SetPoints(points);
97 
98  m_InterpolationResult = nullptr;
99  m_CurrentNumberOfReducedContours = 0;
100 }
101 
103 {
104  // Removing all observers
105  auto dataIter = m_SegmentationObserverTags.begin();
106  for (; dataIter != m_SegmentationObserverTags.end(); ++dataIter)
107  {
108  (*dataIter).first->RemoveObserver((*dataIter).second);
109  }
110  m_SegmentationObserverTags.clear();
111 }
112 
114 {
115  static mitk::SurfaceInterpolationController::Pointer m_Instance;
116 
117  if (m_Instance.IsNull())
118  {
120  }
121  return m_Instance;
122 }
123 
125 {
126  if (newContour->GetVtkPolyData()->GetNumberOfPoints() > 0)
127  {
129  this->AddToInterpolationPipeline(contourInfo);
130 
131  this->Modified();
132  }
133 }
134 
135 void mitk::SurfaceInterpolationController::AddNewContours(std::vector<mitk::Surface::Pointer> newContours)
136 {
137  for (unsigned int i = 0; i < newContours.size(); ++i)
138  {
139  if (newContours.at(i)->GetVtkPolyData()->GetNumberOfPoints() > 0)
140  {
141  ContourPositionInformation contourInfo = CreateContourPositionInformation(newContours.at(i));
142  this->AddToInterpolationPipeline(contourInfo);
143  }
144  }
145  this->Modified();
146 }
147 
148 void mitk::SurfaceInterpolationController::AddToInterpolationPipeline(ContourPositionInformation contourInfo)
149 {
150  if (!m_SelectedSegmentation)
151  {
152  return;
153  }
154 
155  int pos(-1);
156  unsigned int numTimeSteps = m_SelectedSegmentation->GetTimeSteps();
157  if (m_CurrentTimeStep >= numTimeSteps)
158  {
159  MITK_ERROR << "Invalid time step requested for interpolation pipeline.";
160  return;
161  }
162 
163  ContourPositionInformationVec2D currentContours = m_ListOfInterpolationSessions[m_SelectedSegmentation];
164  ContourPositionInformationList currentContourList = currentContours[m_CurrentTimeStep];
165 
166  mitk::Surface *newContour = contourInfo.contour;
167  for (unsigned int i = 0; i < currentContourList.size(); i++)
168  {
169  ContourPositionInformation contourFromList = currentContourList.at(i);
170  if (ContoursCoplanar(contourInfo, contourFromList))
171  {
172  pos = i;
173  break;
174  }
175  }
176 
177  // Don't save a new empty contour
178  if (pos == -1 && newContour->GetVtkPolyData()->GetNumberOfPoints() > 0)
179  {
180  m_ReduceFilter->SetInput(m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].size(),
181  newContour);
182  m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].push_back(contourInfo);
183  }
184  else if (pos != -1 && newContour->GetVtkPolyData()->GetNumberOfPoints() > 0)
185  {
186  m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].at(pos) = contourInfo;
187  m_ReduceFilter->SetInput(pos, newContour);
188  }
189  else if (newContour->GetVtkPolyData()->GetNumberOfPoints() == 0)
190  {
191  this->RemoveContour(contourInfo);
192  }
193 }
194 
196 {
197  if (!m_SelectedSegmentation)
198  {
199  return false;
200  }
201 
202  unsigned int numTimeSteps = m_SelectedSegmentation->GetTimeSteps();
203  if (m_CurrentTimeStep >= numTimeSteps)
204  {
205  return false;
206  }
207 
208  auto it = m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].begin();
209  while (it != m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].end())
210  {
211  ContourPositionInformation currentContour = (*it);
212  if (ContoursCoplanar(currentContour, contourInfo))
213  {
214  m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].erase(it);
216  return true;
217  }
218  ++it;
219  }
220  return false;
221 }
222 
224 {
225  if (!m_SelectedSegmentation)
226  {
227  return nullptr;
228  }
229 
230  unsigned int numTimeSteps = m_SelectedSegmentation->GetTimeSteps();
231  if (m_CurrentTimeStep >= numTimeSteps)
232  {
233  return nullptr;
234  }
235 
236  ContourPositionInformationList contourList = m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep];
237  for (unsigned int i = 0; i < contourList.size(); ++i)
238  {
239  ContourPositionInformation currentContour = contourList.at(i);
240  if (ContoursCoplanar(contourInfo, currentContour))
241  return currentContour.contour;
242  }
243  return nullptr;
244 }
245 
247 {
248  if (!m_SelectedSegmentation)
249  {
250  return -1;
251  }
252 
253  unsigned int numTimeSteps = m_SelectedSegmentation->GetTimeSteps();
254  if (m_CurrentTimeStep >= numTimeSteps)
255  {
256  return -1;
257  }
258 
259  return m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].size();
260 }
261 
263 {
264  m_ReduceFilter->Update();
265 
266  m_CurrentNumberOfReducedContours = m_ReduceFilter->GetNumberOfOutputs();
267  if (m_CurrentNumberOfReducedContours == 1)
268  {
269  vtkPolyData *tmp = m_ReduceFilter->GetOutput(0)->GetVtkPolyData();
270  if (tmp == nullptr)
271  {
272  m_CurrentNumberOfReducedContours = 0;
273  }
274  }
275 
277  timeSelector->SetInput(m_SelectedSegmentation);
278  timeSelector->SetTimeNr(m_CurrentTimeStep);
279  timeSelector->SetChannelNr(0);
280  timeSelector->Update();
281  mitk::Image::Pointer refSegImage = timeSelector->GetOutput();
282 
283  m_NormalsFilter->SetSegmentationBinaryImage(refSegImage);
284  for (unsigned int i = 0; i < m_CurrentNumberOfReducedContours; i++)
285  {
286  mitk::Surface::Pointer reducedContour = m_ReduceFilter->GetOutput(i);
287  reducedContour->DisconnectPipeline();
288  m_NormalsFilter->SetInput(i, reducedContour);
289  m_InterpolateSurfaceFilter->SetInput(i, m_NormalsFilter->GetOutput(i));
290  }
291 
292  if (m_CurrentNumberOfReducedContours < 2)
293  {
294  // If no interpolation is possible reset the interpolation result
295  m_InterpolationResult = nullptr;
296  return;
297  }
298 
299  // Setting up progress bar
301 
302  // create a surface from the distance-image
304  imageToSurfaceFilter->SetInput(m_InterpolateSurfaceFilter->GetOutput());
305  imageToSurfaceFilter->SetThreshold(0);
306  imageToSurfaceFilter->SetSmooth(true);
307  imageToSurfaceFilter->SetSmoothIteration(20);
308  imageToSurfaceFilter->Update();
309 
310  mitk::Surface::Pointer interpolationResult = mitk::Surface::New();
311  interpolationResult->SetVtkPolyData(imageToSurfaceFilter->GetOutput()->GetVtkPolyData(), m_CurrentTimeStep);
312  m_InterpolationResult = interpolationResult;
313 
314  m_DistanceImageSpacing = m_InterpolateSurfaceFilter->GetDistanceImageSpacing();
315 
316  vtkSmartPointer<vtkAppendPolyData> polyDataAppender = vtkSmartPointer<vtkAppendPolyData>::New();
317  for (unsigned int i = 0; i < m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].size(); i++)
318  {
319  polyDataAppender->AddInputData(
320  m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].at(i).contour->GetVtkPolyData());
321  }
322  polyDataAppender->Update();
323  m_Contours->SetVtkPolyData(polyDataAppender->GetOutput());
324 
325  // Last progress step
327 
328  m_InterpolationResult->DisconnectPipeline();
329 }
330 
332 {
333  return m_InterpolationResult;
334 }
335 
337 {
338  return m_Contours;
339 }
340 
342 {
343  m_DataStorage = ds;
344 }
345 
347 {
348  m_ReduceFilter->SetMinSpacing(minSpacing);
349 }
350 
352 {
353  m_ReduceFilter->SetMaxSpacing(maxSpacing);
354  m_NormalsFilter->SetMaxSpacing(maxSpacing);
355 }
356 
358 {
359  m_InterpolateSurfaceFilter->SetDistanceImageVolume(distImgVolume);
360 }
361 
363 {
364  return m_SelectedSegmentation;
365 }
366 
368 {
369  return m_InterpolateSurfaceFilter->GetOutput();
370 }
371 
373 {
374  double numberOfPointsAfterReduction = m_ReduceFilter->GetNumberOfPointsAfterReduction() * 3;
375  double sizeOfPoints = pow(numberOfPointsAfterReduction, 2) * sizeof(double);
377  double percentage = sizeOfPoints / totalMem;
378  return percentage;
379 }
380 
382 {
383  return m_ListOfInterpolationSessions.size();
384 }
385 
386 template <typename TPixel, unsigned int VImageDimension>
387 void mitk::SurfaceInterpolationController::GetImageBase(itk::Image<TPixel, VImageDimension> *input,
388  itk::ImageBase<3>::Pointer &result)
389 {
390  result->Graft(input);
391 }
392 
394 {
395  this->SetCurrentInterpolationSession(segmentation);
396 }
397 
399 {
400  if (currentSegmentationImage.GetPointer() == m_SelectedSegmentation)
401  return;
402 
403  if (currentSegmentationImage.IsNull())
404  {
405  m_SelectedSegmentation = nullptr;
406  return;
407  }
408 
409  m_SelectedSegmentation = currentSegmentationImage.GetPointer();
410 
411  auto it = m_ListOfInterpolationSessions.find(currentSegmentationImage.GetPointer());
412  // If the session does not exist yet create a new ContourPositionPairList otherwise reinitialize the interpolation
413  // pipeline
414  if (it == m_ListOfInterpolationSessions.end())
415  {
417  m_ListOfInterpolationSessions.insert(
418  std::pair<mitk::Image *, ContourPositionInformationVec2D>(m_SelectedSegmentation, newList));
419  m_InterpolationResult = nullptr;
420  m_CurrentNumberOfReducedContours = 0;
421 
422  itk::MemberCommand<SurfaceInterpolationController>::Pointer command =
423  itk::MemberCommand<SurfaceInterpolationController>::New();
424  command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted);
425  m_SegmentationObserverTags.insert(std::pair<mitk::Image *, unsigned long>(
426  m_SelectedSegmentation, m_SelectedSegmentation->AddObserver(itk::DeleteEvent(), command)));
427  }
428 
430 }
431 
433  mitk::Image::Pointer newSession)
434 {
435  if (oldSession.IsNull() || newSession.IsNull())
436  return false;
437 
438  if (oldSession.GetPointer() == newSession.GetPointer())
439  return false;
440 
441  if (!mitk::Equal(*(oldSession->GetGeometry()), *(newSession->GetGeometry()), mitk::eps, false))
442  return false;
443 
444  auto it = m_ListOfInterpolationSessions.find(oldSession.GetPointer());
445 
446  if (it == m_ListOfInterpolationSessions.end())
447  return false;
448 
449  ContourPositionInformationVec2D oldList = (*it).second;
450  m_ListOfInterpolationSessions.insert(
451  std::pair<mitk::Image *, ContourPositionInformationVec2D>(newSession.GetPointer(), oldList));
452  itk::MemberCommand<SurfaceInterpolationController>::Pointer command =
453  itk::MemberCommand<SurfaceInterpolationController>::New();
454  command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted);
455  m_SegmentationObserverTags.insert(
456  std::pair<mitk::Image *, unsigned long>(newSession, newSession->AddObserver(itk::DeleteEvent(), command)));
457 
458  if (m_SelectedSegmentation == oldSession)
459  m_SelectedSegmentation = newSession;
460 
462  timeSelector->SetInput(m_SelectedSegmentation);
463  timeSelector->SetTimeNr(m_CurrentTimeStep);
464  timeSelector->SetChannelNr(0);
465  timeSelector->Update();
466  mitk::Image::Pointer refSegImage = timeSelector->GetOutput();
467  m_NormalsFilter->SetSegmentationBinaryImage(refSegImage);
468 
469  this->RemoveInterpolationSession(oldSession);
470  return true;
471 }
472 
474 {
475  this->RemoveInterpolationSession(segmentation);
476 }
477 
479 {
480  if (segmentationImage)
481  {
482  if (m_SelectedSegmentation == segmentationImage)
483  {
484  m_NormalsFilter->SetSegmentationBinaryImage(nullptr);
485  m_SelectedSegmentation = nullptr;
486  }
487  m_ListOfInterpolationSessions.erase(segmentationImage);
488  // Remove observer
489  auto pos = m_SegmentationObserverTags.find(segmentationImage);
490  if (pos != m_SegmentationObserverTags.end())
491  {
492  segmentationImage->RemoveObserver((*pos).second);
493  m_SegmentationObserverTags.erase(pos);
494  }
495  }
496 }
497 
499 {
500  // Removing all observers
501  auto dataIter = m_SegmentationObserverTags.begin();
502  while (dataIter != m_SegmentationObserverTags.end())
503  {
504  mitk::Image *image = (*dataIter).first;
505  image->RemoveObserver((*dataIter).second);
506  ++dataIter;
507  }
508 
509  m_SegmentationObserverTags.clear();
510  m_SelectedSegmentation = nullptr;
511  m_ListOfInterpolationSessions.clear();
512 }
513 
515 {
516  // 1. detect coplanar contours
517  // 2. merge coplanar contours into a single surface
518  // 4. add contour to pipeline
519 
520  // Split the surface into separate polygons
521  vtkSmartPointer<vtkCellArray> existingPolys;
522  vtkSmartPointer<vtkPoints> existingPoints;
523  existingPolys = contours->GetVtkPolyData()->GetPolys();
524  existingPoints = contours->GetVtkPolyData()->GetPoints();
525  existingPolys->InitTraversal();
526 
527  vtkSmartPointer<vtkIdList> ids = vtkSmartPointer<vtkIdList>::New();
528 
529  typedef std::pair<mitk::Vector3D, mitk::Point3D> PointNormalPair;
530  std::vector<ContourPositionInformation> list;
531  std::vector<vtkSmartPointer<vtkPoints>> pointsList;
532  int count(0);
533  for (existingPolys->InitTraversal(); existingPolys->GetNextCell(ids);)
534  {
535  // Get the points
536  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
537  existingPoints->GetPoints(ids, points);
538  ++count;
539  pointsList.push_back(points);
540 
541  PointNormalPair p_n;
542  double n[3];
543  vtkPolygon::ComputeNormal(points, n);
544  p_n.first = n;
545  double p[3];
546 
547  existingPoints->GetPoint(ids->GetId(0), p);
548  p_n.second = p;
549 
551  p_info.contourNormal = n;
552  p_info.contourPoint = p;
553  list.push_back(p_info);
554  continue;
555  }
556 
557  // Detect and sort coplanar polygons
558  auto outer = list.begin();
559  std::vector<std::vector<vtkSmartPointer<vtkPoints>>> relatedPoints;
560  while (outer != list.end())
561  {
562  auto inner = outer;
563  ++inner;
564  std::vector<vtkSmartPointer<vtkPoints>> rel;
565  auto pointsIter = pointsList.begin();
566  rel.push_back((*pointsIter));
567  pointsIter = pointsList.erase(pointsIter);
568 
569  while (inner != list.end())
570  {
571  if (ContoursCoplanar((*outer), (*inner)))
572  {
573  inner = list.erase(inner);
574  rel.push_back((*pointsIter));
575  pointsIter = pointsList.erase(pointsIter);
576  }
577  else
578  {
579  ++inner;
580  ++pointsIter;
581  }
582  }
583  relatedPoints.push_back(rel);
584  ++outer;
585  }
586 
587  // Build the separate surfaces again
588  std::vector<mitk::Surface::Pointer> finalSurfaces;
589  for (unsigned int i = 0; i < relatedPoints.size(); ++i)
590  {
591  vtkSmartPointer<vtkPolyData> contourSurface = vtkSmartPointer<vtkPolyData>::New();
592  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
593  vtkSmartPointer<vtkCellArray> polygons = vtkSmartPointer<vtkCellArray>::New();
594  unsigned int pointId(0);
595  for (unsigned int j = 0; j < relatedPoints.at(i).size(); ++j)
596  {
597  unsigned int numPoints = relatedPoints.at(i).at(j)->GetNumberOfPoints();
598  vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
599  polygon->GetPointIds()->SetNumberOfIds(numPoints);
600  polygon->GetPoints()->SetNumberOfPoints(numPoints);
601  vtkSmartPointer<vtkPoints> currentPoints = relatedPoints.at(i).at(j);
602  for (unsigned k = 0; k < numPoints; ++k)
603  {
604  points->InsertPoint(pointId, currentPoints->GetPoint(k));
605  polygon->GetPointIds()->SetId(k, pointId);
606  ++pointId;
607  }
608  polygons->InsertNextCell(polygon);
609  }
610  contourSurface->SetPoints(points);
611  contourSurface->SetPolys(polygons);
612  contourSurface->BuildLinks();
614  surface->SetVtkPolyData(contourSurface);
615  finalSurfaces.push_back(surface);
616  }
617 
618  // Add detected contours to interpolation pipeline
619  this->AddNewContours(finalSurfaces);
620 }
621 
622 void mitk::SurfaceInterpolationController::OnSegmentationDeleted(const itk::Object *caller,
623  const itk::EventObject & /*event*/)
624 {
625  auto *tempImage = dynamic_cast<mitk::Image *>(const_cast<itk::Object *>(caller));
626  if (tempImage)
627  {
628  if (m_SelectedSegmentation == tempImage)
629  {
630  m_NormalsFilter->SetSegmentationBinaryImage(nullptr);
631  m_SelectedSegmentation = nullptr;
632  }
633  m_SegmentationObserverTags.erase(tempImage);
634  m_ListOfInterpolationSessions.erase(tempImage);
635  }
636 }
637 
639 {
640  // If session has changed reset the pipeline
641  m_ReduceFilter->Reset();
642  m_NormalsFilter->Reset();
643  m_InterpolateSurfaceFilter->Reset();
644 
645  itk::ImageBase<3>::Pointer itkImage = itk::ImageBase<3>::New();
646 
647  if (m_SelectedSegmentation)
648  {
650  timeSelector->SetInput(m_SelectedSegmentation);
651  timeSelector->SetTimeNr(m_CurrentTimeStep);
652  timeSelector->SetChannelNr(0);
653  timeSelector->Update();
654  mitk::Image::Pointer refSegImage = timeSelector->GetOutput();
655  AccessFixedDimensionByItk_1(refSegImage, GetImageBase, 3, itkImage);
656  m_InterpolateSurfaceFilter->SetReferenceImage(itkImage.GetPointer());
657 
658  unsigned int numTimeSteps = m_SelectedSegmentation->GetTimeSteps();
659  unsigned int size = m_ListOfInterpolationSessions[m_SelectedSegmentation].size();
660  if (size != numTimeSteps)
661  {
662  m_ListOfInterpolationSessions[m_SelectedSegmentation].resize(numTimeSteps);
663  }
664 
665  if (m_CurrentTimeStep < numTimeSteps)
666  {
667  unsigned int numContours = m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep].size();
668  for (unsigned int c = 0; c < numContours; ++c)
669  {
670  m_ReduceFilter->SetInput(c,
671  m_ListOfInterpolationSessions[m_SelectedSegmentation][m_CurrentTimeStep][c].contour);
672  }
673 
674  m_ReduceFilter->Update();
675 
676  m_CurrentNumberOfReducedContours = m_ReduceFilter->GetNumberOfOutputs();
677  if (m_CurrentNumberOfReducedContours == 1)
678  {
679  vtkPolyData *tmp = m_ReduceFilter->GetOutput(0)->GetVtkPolyData();
680  if (tmp == nullptr)
681  {
682  m_CurrentNumberOfReducedContours = 0;
683  }
684  }
685 
686  for (unsigned int i = 0; i < m_CurrentNumberOfReducedContours; i++)
687  {
688  m_NormalsFilter->SetInput(i, m_ReduceFilter->GetOutput(i));
689  m_InterpolateSurfaceFilter->SetInput(i, m_NormalsFilter->GetOutput(i));
690  }
691  }
692 
693  Modified();
694  }
695 }
static vcl_size_t GetTotalSizeOfPhysicalRam()
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
bool ReplaceInterpolationSession(mitk::Image::Pointer oldSession, mitk::Image::Pointer newSession)
void ReinitializeInterpolation(mitk::Surface::Pointer contours)
Reinitializes the interpolation using the provided contour data.
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
float k(1.0)
mitk::SurfaceInterpolationController::ContourPositionInformation CreateContourPositionInformation(mitk::Surface::Pointer contour)
virtual vtkPolyData * GetVtkPolyData(unsigned int t=0) const
const mitk::Surface * GetContour(ContourPositionInformation contourInfo)
Returns the contour for a given plane for the current selected segmenation.
std::vector< ContourPositionInformationList > ContourPositionInformationVec2D
#define MITK_ERROR
Definition: mitkLogMacros.h:20
unsigned int GetNumberOfContours()
Returns the number of available contours for the current selected segmentation.
void RemoveSegmentationFromContourList(mitk::Image *segmentation)
std::vector< ContourPositionInformation > ContourPositionInformationList
bool ContoursCoplanar(mitk::SurfaceInterpolationController::ContourPositionInformation leftHandSide, mitk::SurfaceInterpolationController::ContourPositionInformation rightHandSide)
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
void SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage)
void GetImageBase(itk::Image< TPixel, VImageDimension > *input, itk::ImageBase< 3 >::Pointer &result)
Image class for storing images.
Definition: mitkImage.h:72
mitk::Image::Pointer GetCurrentSegmentation()
Get the current selected segmentation for which the interpolation is performed.
void AddNewContours(std::vector< Surface::Pointer > newContours)
Adds new extracted contours to the list. If one or more contours at a given position already exist th...
mitk::Image::Pointer image
bool RemoveContour(ContourPositionInformation contourInfo)
Removes the contour for a given plane for the current selected segmenation.
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
#define AccessFixedDimensionByItk_1(mitkImage, itkImageTypeFunction, dimension, arg1)
static SurfaceInterpolationController * GetInstance()
MITKCORE_EXPORT const ScalarType eps
unsigned int GetTimeSteps() const
Get the number of time steps from the TimeGeometry As the base data has not a data vector given by it...
Definition: mitkBaseData.h:355
void AddNewContour(Surface::Pointer newContour)
Adds a new extracted contour to the list.
void SetDistanceImageVolume(unsigned int distImageVolume)
static Pointer New()
void RemoveInterpolationSession(mitk::Image::Pointer segmentationImage)
Remove interpolation session.
static Pointer New()
void SetCurrentSegmentationInterpolationList(mitk::Image::Pointer segmentation)