MCPcopy Create free account
hub / github.com/MITK/MITK / CreateSurface

Method CreateSurface

Modules/AlgorithmsExt/src/mitkLabeledImageToSurfaceFilter.cpp:158–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void mitk::LabeledImageToSurfaceFilter::CreateSurface(int time,
159 vtkImageData *vtkimage,
160 mitk::Surface *surface,
161 mitk::LabeledImageToSurfaceFilter::LabelType label)
162{
163 vtkImageChangeInformation *indexCoordinatesImageFilter = vtkImageChangeInformation::New();
164 indexCoordinatesImageFilter->SetInputData(vtkimage);
165 indexCoordinatesImageFilter->SetOutputOrigin(0.0, 0.0, 0.0);
166
167 vtkImageThreshold *threshold = vtkImageThreshold::New();
168 threshold->SetInputConnection(indexCoordinatesImageFilter->GetOutputPort());
169 // indexCoordinatesImageFilter->Delete();
170 threshold->SetInValue(100);
171 threshold->SetOutValue(0);
172 threshold->ThresholdBetween(label, label);
173 threshold->SetOutputScalarTypeToUnsignedChar();
174 threshold->ReleaseDataFlagOn();
175
176 vtkImageGaussianSmooth *gaussian = vtkImageGaussianSmooth::New();
177 gaussian->SetInputConnection(threshold->GetOutputPort());
178 // threshold->Delete();
179 gaussian->SetDimensionality(3);
180 gaussian->SetRadiusFactor(0.49);
181 gaussian->SetStandardDeviation(GetGaussianStandardDeviation());
182 gaussian->ReleaseDataFlagOn();
183 gaussian->UpdateInformation();
184 gaussian->Update();
185
186 // MarchingCube -->create Surface
187 vtkMarchingCubes *skinExtractor = vtkMarchingCubes::New();
188 skinExtractor->ReleaseDataFlagOn();
189 skinExtractor->SetInputConnection(gaussian->GetOutputPort()); // RC++
190 indexCoordinatesImageFilter->Delete();
191 skinExtractor->SetValue(0, 50);
192
193 vtkPolyData *polydata;
194 skinExtractor->Update();
195 polydata = skinExtractor->GetOutput();
196 polydata->Register(nullptr); // RC++
197 skinExtractor->Delete();
198
199 if (m_Smooth)
200 {
201 vtkSmoothPolyDataFilter *smoother = vtkSmoothPolyDataFilter::New();
202 // read poly1 (poly1 can be the original polygon, or the decimated polygon)
203 smoother->SetInputData(polydata); // RC++
204 smoother->SetNumberOfIterations(m_SmoothIteration);
205 smoother->SetRelaxationFactor(m_SmoothRelaxation);
206 smoother->SetFeatureAngle(60);
207 smoother->FeatureEdgeSmoothingOff();
208 smoother->BoundarySmoothingOff();
209 smoother->SetConvergence(0);
210
211 polydata->Delete(); // RC--
212 smoother->Update();
213 polydata = smoother->GetOutput();
214 polydata->Register(nullptr); // RC++
215 smoother->Delete();

Callers

nothing calls this directly

Calls 15

SetInputConnectionMethod · 0.80
GetNumberOfPointsMethod · 0.80
GetGeometryMethod · 0.80
GetMatrixMethod · 0.80
SetVtkPolyDataMethod · 0.80
NewFunction · 0.50
UpdateMethod · 0.45
DeleteMethod · 0.45
SetValueMethod · 0.45
GetOutputMethod · 0.45
RegisterMethod · 0.45

Tested by

no test coverage detected