Thanks for the quick reply @lassoan,
I created the mesh that way and I directly used it as input for my extraction of the network :
def Addmesh( self, Matrixvertices :float, Matrixtriangle: float)->vars:
"""
Input :
Matrixvertices = [[x0,y0,z0],...,[xn,yn,zn]]
--> Contains the points (n points)
Matrixshape = [xid0,yid0,zid0,...,xidp,yidp,zidp]
--> Contains the triplet of ids giving a triangle (p triangles)
Ouput :
actor --> Actor which contains the mesh of our object
"""
# Define points, triangles and colors
points = vtk.vtkPoints()
triangles = vtk.vtkCellArray()
#Add the different points to the mesh
for i in range(len(Matrixvertices)):
points.InsertNextPoint(Matrixvertices[i][0], Matrixvertices[i][1], Matrixvertices[i][2])
#Add the Ids of the point to create the triangle cells.
cmpt=0
for i in range(int(len(Matrixtriangle)/3)):
triangle = vtk.vtkTriangle()
triangle.GetPointIds().SetId(0, Matrixtriangle.astype(int)[cmpt])
triangle.GetPointIds().SetId(1, Matrixtriangle.astype(int)[1+cmpt])
triangle.GetPointIds().SetId(2, Matrixtriangle.astype(int)[2+cmpt])
triangles.InsertNextCell(triangle)
cmpt+=3
#Creation of polydata object
trianglePolyData = vtk.vtkPolyData()
filler = vtk.vtkFillHolesFilter()
# Add the geometry and topology to the polydata
trianglePolyData.SetPoints(points)
trianglePolyData.SetPolys(triangles)
(I notice there could be an error because I am defining an open surface as mesh, but I also tried with a closed surface the same way as the examples of Slicer, and I still had the error)
And if I use print(surfacePolyData)
I get this :
vtkPolyData (000002827B4CCA80)
Debug: Off
Modified Time: 9882
Reference Count: 3
Registered Events: (none)
Information: 000002827B61F6F0
Data Released: False
Global Release Data: Off
UpdateTime: 10991
Field Data:
Debug: Off
Modified Time: 9864
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Number Of Points: 192
Number Of Cells: 95
Cell Data:
Debug: Off
Modified Time: 9867
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (000002827B591EA0)
Event: 33
EventName: ModifiedEvent
Command: 000002827B61ECF0
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Point Data:
Debug: Off
Modified Time: 9866
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (000002827B592530)
Event: 33
EventName: ModifiedEvent
Command: 000002827B61ECF0
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Bounds:
Xmin,Xmax: (-0.91, -0.69)
Ymin,Ymax: (-0.11, 0.11)
Zmin,Zmax: (-0.7, -0.6)
Compute Time: 11035
Number Of Points: 192
Point Coordinates: 000002827B619890
Locator: 0000000000000000
Number Of Vertices: 0
Number Of Lines: 0
Number Of Polygons: 95
Number Of Triangle Strips: 0
Number Of Pieces: 1
Piece: 0
Ghost Level: 0