Commit 1582c8e8773c9dedd401df6acf4df4cc1c36661e
1 parent
38ee57c1
Exists in
master
and in
6 other branches
ADD: Method to extract all regions
Showing
1 changed file
with
21 additions
and
1 deletions
Show diff stats
invesalius/data/polydata_utils.py
| ... | ... | @@ -150,5 +150,25 @@ def SelectLargestPart(polydata): |
| 150 | 150 | def SplitDisconectedParts(polydata): |
| 151 | 151 | """ |
| 152 | 152 | """ |
| 153 | - return [polydata] | |
| 153 | + conn = vtk.vtkPolyDataConnectivityFilter() | |
| 154 | + conn.SetInput(polydata) | |
| 155 | + conn.SetExtractionModeToAllRegions() | |
| 156 | + conn.Update() | |
| 157 | + | |
| 158 | + nregions = conn.GetNumberOfExtractedRegions() | |
| 159 | + | |
| 160 | + polydata_collection = [] | |
| 161 | + | |
| 162 | + for region in nregions: | |
| 163 | + conn.InitializeSpecifiedRegionList() | |
| 164 | + conn.AddSpecifiedRegion(region) | |
| 165 | + conn.Update() | |
| 166 | + | |
| 167 | + p = vtk.vtkPolyData() | |
| 168 | + p.DeepCopy(conn.GetOutput()) | |
| 169 | + p.Update() | |
| 170 | + | |
| 171 | + polydata_collection.append(p) | |
| 172 | + | |
| 173 | + return polydata_collection | |
| 154 | 174 | ... | ... |