32 #include "vtkAppendPolyData.h"
33 #include "vtkPolyData.h"
34 #include "vtkProperty.h"
35 #include "vtkSmartPointer.h"
37 #include <itkCommand.h>
40 : m_MinSpacing(1.0), m_MaxSpacing(1.0), m_WorkingImage(NULL), m_ActiveLabel(0)
47 ContourListMap::iterator it = m_MapOfContourLists.begin();
48 for (; it != m_MapOfContourLists.end(); it++)
50 for (
unsigned int j = 0; j < m_MapOfContourLists[(*it).first].size(); ++j)
52 delete (m_MapOfContourLists[(*it).first].at(j).second);
54 m_MapOfContourLists.erase(it);
61 m_InterpolateSurfaceFilter->SetUseProgressBar(
false);
65 m_InterpolationResult = NULL;
83 if (m_ActiveLabel == 0)
92 for (
unsigned int i = 0; i < m_MapOfContourLists[m_ActiveLabel].size(); i++)
94 itk::Matrix<ScalarType> diffM =
95 transform->GetMatrix() - m_MapOfContourLists[m_ActiveLabel].at(i).second->GetTransform()->GetMatrix();
96 bool isSameMatrix(
true);
97 for (
unsigned int j = 0; j < 3; j++)
99 if (fabs(diffM[j][0]) > 0.0001 && fabs(diffM[j][1]) > 0.0001 && fabs(diffM[j][2]) > 0.0001)
101 isSameMatrix =
false;
105 itk::Vector<float> diffV =
106 m_MapOfContourLists[m_ActiveLabel].at(i).second->GetTransform()->GetOffset() - transform->GetOffset();
107 if (isSameMatrix && m_MapOfContourLists[m_ActiveLabel].at(i).second->GetPos() == op->
GetPos() &&
108 (fabs(diffV[0]) < 0.0001 && fabs(diffV[1]) < 0.0001 && fabs(diffV[2]) < 0.0001))
115 if (pos == -1 && newContour->GetNumberOfVertices() > 0)
119 ContourPositionPair newData = std::make_pair(newContour, newOp);
120 m_MapOfContourLists[m_ActiveLabel].push_back(newData);
124 m_MapOfContourLists[m_ActiveLabel].at(pos).first = newContour;
132 if (m_MapOfContourLists[m_ActiveLabel].size() < 2)
135 m_InterpolationResult = NULL;
139 m_InterpolateSurfaceFilter->Reset();
148 for (
unsigned int i = 0; i < m_MapOfContourLists[m_ActiveLabel].size(); i++)
151 converter->SetInput(m_MapOfContourLists[m_ActiveLabel].at(i).first);
155 surface->DisconnectPipeline();
158 reduceFilter->SetUseProgressBar(
false);
159 reduceFilter->SetInput(surface);
160 reduceFilter->SetMinSpacing(m_MinSpacing);
161 reduceFilter->SetMaxSpacing(m_MaxSpacing);
162 reduceFilter->Update();
165 normalsFilter->SetUseProgressBar(
false);
166 normalsFilter->SetInput(reduceFilter->GetOutput());
167 normalsFilter->SetMaxSpacing(m_MaxSpacing);
172 m_InterpolateSurfaceFilter->SetInput(i, normalsFilter->GetOutput());
174 polyDataAppender->AddInputData(reduceFilter->GetOutput()->GetVtkPolyData());
177 polyDataAppender->Update();
178 m_Contours->SetVtkPolyData(polyDataAppender->GetOutput());
181 m_InterpolateSurfaceFilter->Update();
182 Image::Pointer distanceImage = m_InterpolateSurfaceFilter->GetOutput();
183 if (distanceImage.IsNull())
186 m_InterpolationResult = NULL;
192 imageToSurfaceFilter->SetInput(distanceImage);
193 imageToSurfaceFilter->SetThreshold(0);
194 imageToSurfaceFilter->SetSmooth(
true);
195 imageToSurfaceFilter->SetSmoothIteration(20);
196 imageToSurfaceFilter->Update();
197 m_InterpolationResult = imageToSurfaceFilter->GetOutput();
199 m_InterpolationResult->DisconnectPipeline();
204 return m_InterpolationResult;
214 m_MinSpacing = minSpacing;
219 m_MaxSpacing = maxSpacing;
224 m_DistanceImageVolume = value;
229 m_WorkingImage = workingImage;
234 return m_InterpolateSurfaceFilter->GetOutput();
239 double numberOfPoints = 0.0;
240 for (
unsigned int i = 0; i < m_MapOfContourLists[m_ActiveLabel].size(); i++)
242 numberOfPoints += m_MapOfContourLists[m_ActiveLabel].at(i).first->GetNumberOfVertices() * 3;
245 double sizeOfPoints = pow(numberOfPoints, 2) *
sizeof(double);
247 double percentage = sizeOfPoints / totalMem;
253 if (m_ActiveLabel == activeLabel)
256 if (activeLabel == 0)
259 m_ActiveLabel = activeLabel;
261 ContourListMap::iterator it = m_MapOfContourLists.find(m_ActiveLabel);
263 if (it == m_MapOfContourLists.end())
265 ContourPositionPairList newList;
266 m_MapOfContourLists.insert(std::pair<unsigned int, ContourPositionPairList>(m_ActiveLabel, newList));
267 m_InterpolationResult = NULL;
static vcl_size_t GetTotalSizeOfPhysicalRam()
Class for storing surfaces (vtkPolyData).
itk::SmartPointer< Self > Pointer
static SurfaceBasedInterpolationController * GetInstance()
Surface * GetContoursAsSurface()
Constants for most interaction classes, due to the generic StateMachines.
SurfaceBasedInterpolationController()
void SetMaxSpacing(double maxSpacing)
void AddNewContour(ContourModel::Pointer newContour, RestorePlanePositionOperation *op)
mitk::Surface::Pointer GetInterpolationResult()
void SetActiveLabel(int activeLabel)
void SetDistanceImageVolume(unsigned int value)
Image class for storing images.
void SetWorkingImage(Image *workingImage)
~SurfaceBasedInterpolationController()
Vector3D GetDirectionVector()
double EstimatePortionOfNeededMemory()
AffineTransform3D::Pointer GetTransform()
void SetMinSpacing(double minSpacing)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.