make a vtkPolyData from Points and Cells

having a surface as a vtkPolyData like the one bellow, would it be possible to extract points and cells, and then again assemble them to a vtkPolyData like the surface we had first?

vtkPolyData (0000022DAA05F6D0)
  Debug: Off
  Modified Time: 14667
  Reference Count: 2
  Registered Events: (none)
  Information: 0000022DA9DADEC0
  Data Released: False
  Global Release Data: Off
  UpdateTime: 14668
  Field Data:
    Debug: Off
    Modified Time: 14611
    Reference Count: 1
    Registered Events: (none)
    Number Of Arrays: 0
    Number Of Components: 0
    Number Of Tuples: 0
  Number Of Points: 3208
  Number Of Cells: 6151
  Cell Data:
    Debug: Off
    Modified Time: 14619
    Reference Count: 1
    Registered Events:
      Registered Observers:
        vtkObserver (0000022DA9C719D0)
          Event: 33
          EventName: ModifiedEvent
          Command: 0000022DA9DAE1E0
          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 1 1 1 )
    Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 )
    Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )
    Scalars: (none)
    Vectors: (none)
    Normals: (none)
    TCoords: (none)
    Tensors: (none)
    GlobalIds: (none)
    PedigreeIds: (none)
    EdgeFlag: (none)
    Tangents: (none)
    RationalWeights: (none)
    HigherOrderDegrees: (none)
  Point Data:
    Debug: Off
    Modified Time: 14667
    Reference Count: 1
    Registered Events:
      Registered Observers:
        vtkObserver (0000022DA9C71C40)
          Event: 33
          EventName: ModifiedEvent
          Command: 0000022DA9DAE1E0
          Priority: 0
          Tag: 1
    Number Of Arrays: 2
    Array 0 name = ImageScalars
    Array 1 name = Normals
    Number Of Components: 4
    Number Of Tuples: 3208
    Copy Tuple Flags: ( 0 1 1 1 1 1 1 1 1 1 1 )
    Interpolate Flags: ( 0 1 1 1 1 1 1 1 1 1 1 )
    Pass Through Flags: ( 0 1 1 1 1 1 1 1 1 1 1 )
    Scalars:
      Debug: Off
      Modified Time: 14661
      Reference Count: 1
      Registered Events: (none)
      Name: ImageScalars
      Data type: float
      Size: 3208
      MaxId: 3207
      NumberOfComponents: 1
      Information: 0000000000000000
      Name: ImageScalars
      Number Of Components: 1
      Number Of Tuples: 3208
      Size: 3208
      MaxId: 3207
      LookupTable: (none)
    Vectors: (none)
    Normals:
      Debug: Off
      Modified Time: 14657
      Reference Count: 1
      Registered Events: (none)
      Name: Normals
      Data type: float
      Size: 9624
      MaxId: 9623
      NumberOfComponents: 3
      Information: 0000000000000000
      Name: Normals
      Number Of Components: 3
      Number Of Tuples: 3208
      Size: 9624
      MaxId: 9623
      LookupTable: (none)
    TCoords: (none)
    Tensors: (none)
    GlobalIds: (none)
    PedigreeIds: (none)
    EdgeFlag: (none)
    Tangents: (none)
    RationalWeights: (none)
    HigherOrderDegrees: (none)
  Bounds:
    Xmin,Xmax: (-8.56965, 75.1953)
    Ymin,Ymax: (-7.09702, 61.4379)
    Zmin,Zmax: (-4.387, 52.7254)
  Compute Time: 15186
  Editable: false
  Number Of Points: 3208
  Point Coordinates: 0000022DAA116720
  PointLocator: 0000000000000000
  CellLocator: 0000000000000000
  Number Of Vertices: 0
  Number Of Lines: 0
  Number Of Polygons: 6151
  Number Of Triangle Strips: 0
  Number Of Pieces: 1
  Piece: 0
  Ghost Level: 0

I suppose it should be doable? What do you mean by assembling them into a new vtkPolyData? Do you want to reorder the cells / points?

This is an online example to show how to extract point, cell and field array, then transfer it and reconstruct it at the receiver.

the function to extract cell and point array:

the function to load arrays and reconstruct the polyData:

Basically you need to go through every cell to extract the point coordinates manually based on point id

1 Like

Perfect @1116 Zhezhe , exactly what I meant.
One point: are the two pieces of code you shared pointing to the same place and line of code?

oh, it is a typo and I have updated previous links @SArbabi

1 Like

perfect, I’ll implement the idea in python and javascript (as the rest of my pipeline is in that) and let you know.

Thanks!

1 Like

That worked perfectly fine. Thank you so much for straightforward and clear answer, @1116 .