-
Notifications
You must be signed in to change notification settings - Fork 0
/
trial2.py
49 lines (36 loc) · 1.37 KB
/
trial2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
- Deepa 6/6/2020
"""
import vtk
import vtk.numpy_interface.dataset_adapter as dsa
import networkx as nx
from vmtk import pypes
from vmtk import vmtkscripts
from vtk.util.numpy_support import vtk_to_numpy
reader = vmtkscripts.vmtkSurfaceReader()
reader.InputFileName = 'vesseltree.stl'
reader.Execute()
# network extraction
networkExtraction = vmtkscripts.vmtkNetworkExtraction()
networkExtraction.Surface = reader.Surface
networkExtraction.Execute()
network = networkExtraction.Network
graph = networkExtraction.GraphLayout
network_dsa = dsa.WrapDataObject(network)
pprint(network_dsa.GetNumberOfCells())
cleaner = vtk.vtkCleanPolyData()
cleaner.SetInputData(graph) # set the data to processed
cleaner.Update() # execute the algorithm
cleanedGraph = cleaner.GetOutput()
cleanedGraph_dsa = dsa.WrapDataObject(graph)
pprint(cleanedGraph_dsa.GetNumberOfCells())
tail = []
head = []
radius = []
for edgeId in range(cleanedGraph.GetNumberOfCells()):
edge = cleanedGraph.GetCell(edgeId) # this will be a vtkLine, which only has two points
edgeNode0 = edge.GetPointId(0)
edgeNode1 = edge.GetPointId(1)
tail.append(edgeNode0)
head.append(edgeNode1)
radius.append((cleanedGraph_dsa.CellData['Radius'][edgeId]))