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

Method ImageContour

Filters/General/vtkMarchingContourFilter.cxx:224–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void vtkMarchingContourFilter::ImageContour(int dim, vtkDataSet* input, vtkPolyData* output)
225{
226 vtkIdType numContours = this->ContourValues->GetNumberOfContours();
227 double* values = this->ContourValues->GetValues();
228 vtkPolyData* contourOutput;
229
230 vtkNew<vtkTrivialProducer> producer;
231 producer->SetOutput(input);
232 producer->SetContainerAlgorithm(this);
233 // Explicitly update the update extent in the trivial producer to prevent
234 // an error when downstream algorithms request a different extent.
235 producer->UpdateWholeExtent();
236
237 if (dim == 2) // marching squares
238 {
239 vtkMarchingSquares* msquares;
240 int i;
241
242 msquares = vtkMarchingSquares::New();
243 msquares->SetInputConnection(producer->GetOutputPort());
244 msquares->SetDebug(this->Debug);
245 msquares->SetNumberOfContours(numContours);
246 for (i = 0; i < numContours; i++)
247 {
248 msquares->SetValue(i, values[i]);
249 }
250
251 contourOutput = msquares->GetOutput();
252 msquares->SetContainerAlgorithm(this);
253 msquares->Update();
254 output->ShallowCopy(contourOutput);
255 msquares->Delete();
256 }
257
258 else // image marching cubes
259 {
260 vtkImageMarchingCubes* mcubes;
261 int i;
262
263 mcubes = vtkImageMarchingCubes::New();
264
265 mcubes->SetInputConnection(producer->GetOutputPort());
266 mcubes->SetComputeNormals(this->ComputeNormals);
267 mcubes->SetComputeGradients(this->ComputeGradients);
268 mcubes->SetComputeScalars(this->ComputeScalars);
269 mcubes->SetDebug(this->Debug);
270 mcubes->SetNumberOfContours(numContours);
271 for (i = 0; i < numContours; i++)
272 {
273 mcubes->SetValue(i, values[i]);
274 }
275
276 contourOutput = mcubes->GetOutput();
277 mcubes->SetContainerAlgorithm(this);
278 mcubes->Update();
279 output->ShallowCopy(contourOutput);
280 mcubes->Delete();
281 }

Callers 1

RequestDataMethod · 0.95

Calls 14

DeleteMethod · 0.65
NewFunction · 0.50
GetNumberOfContoursMethod · 0.45
GetValuesMethod · 0.45
SetOutputMethod · 0.45
UpdateWholeExtentMethod · 0.45
SetInputConnectionMethod · 0.45
GetOutputPortMethod · 0.45
SetDebugMethod · 0.45
SetNumberOfContoursMethod · 0.45
SetValueMethod · 0.45
GetOutputMethod · 0.45

Tested by

no test coverage detected