| 72 | } |
| 73 | |
| 74 | vtkSmartPointer<vtkPolyData> mitk::MultiLabelSurfaceNetsExtractor::Extract( |
| 75 | vtkImageData* groupImage, |
| 76 | const std::vector<LabelValueType>& labelValues) |
| 77 | { |
| 78 | auto output = vtkSmartPointer<vtkPolyData>::New(); |
| 79 | |
| 80 | if (groupImage == nullptr || labelValues.empty()) |
| 81 | { |
| 82 | return output; |
| 83 | } |
| 84 | |
| 85 | PrepareInput(groupImage); |
| 86 | |
| 87 | m_SurfaceNets->SetInputData(groupImage); |
| 88 | this->ConfigureLabels(labelValues); |
| 89 | m_SurfaceNets->InitializeSelectedLabelsList(); |
| 90 | m_SurfaceNets->SetOutputStyleToDefault(); |
| 91 | // TODO(VTK 9.5.2): force re-extraction. vtkSurfaceNets3D::RequestData reuses its |
| 92 | // cache based on Superclass::GetMTime(), which SetLabel/SetInputData do not always |
| 93 | // bump; the cached path then leaves newScalars null and TransformMeshType crashes. |
| 94 | // Drop this Modified() when VTK is upgraded past 9.5.2. |
| 95 | m_SurfaceNets->Modified(); |
| 96 | |
| 97 | m_NormalsFilter->Update(); |
| 98 | output->DeepCopy(m_NormalsFilter->GetOutput()); |
| 99 | |
| 100 | return output; |
| 101 | } |
| 102 | |
| 103 | std::map<mitk::MultiLabelSurfaceNetsExtractor::LabelValueType, vtkSmartPointer<vtkPolyData>> |
| 104 | mitk::MultiLabelSurfaceNetsExtractor::ExtractPerLabel( |