[Paraview] Getting plate boundary data into Paraview

David E DeMarle dave.demarle at kitware.com
Mon Aug 30 18:55:45 EDT 2010


Pop this into a python programmable source and it should import your data.

import os
import string

def insertNextCell():
  nextpoly = vtk.vtkPolyLine()
  nextpoly.GetPointIds().DeepCopy(segments)
  cells.InsertNextCell(nextpoly)

filename = os.path.normcase("/location/of/your/data.txt")
f = open(filename)

pdo = self.GetPolyDataOutput()

pts = vtk.vtkPoints()

#an array for the fault information
segmentNames = vtk.vtkStringArray()
segmentNames.SetName("Fault Information")
segmentNames.SetNumberOfComponents(1)

cells = vtk.vtkCellArray()
segments = vtk.vtkIdList()

#traverse file
for line in f:
  if line.startswith(">"):
    #when you find a new fault
    #save the one you just finished
    if segments.GetNumberOfIds() != 0:
      insertNextCell()
      segments = vtk.vtkIdList()
    segmentNames.InsertNextValue(line)
  else:
    #otherwise just keep remembering coordinates
    x,y = [float(n) for n in line.strip().split()[:2]]
    id = pts.InsertNextPoint(x,y,0)
    segments.InsertNextId(id)
f.close()

if segments.GetNumberOfIds()>0:
  #don't forget the last fault in progress
  insertNextCell()

pdo.SetPoints(pts)
pdo.SetStrips(cells)
pdo.GetCellData().AddArray(segmentNames)


David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



On Wed, Aug 25, 2010 at 5:02 AM, Lester Anderson
<lester_anderson1963 at hotmail.com> wrote:
>> 2014 BOCONO TRANSFORM FAULT, N. SOUTH AMERICA
>  -58.9415   10.5593
>  -59.1817   10.5598
>  -59.4918   10.5899
>  -59.8086   10.6593
>  -60.1954   10.7256
>  -60.4489   10.7065
>  -60.8159   10.6678
>  -61.0594   10.6486
>  -61.4631   10.6068
>  -61.8535   10.5682
>  -62.2972   10.5395
>  -62.8876   10.4915
>  -63.7494   10.4103
>> 2014 BOCONO TRANSFORM FAULT, N. SOUTH AMERICA
>  -77.5807    0.4294
>  -77.8448    0.1430
>  -77.9752   -0.0068
>  -78.2026   -0.3332
>  -78.4367   -0.6463
>  -78.7342   -0.9592
>  -79.0453   -1.3955
>  -79.2994   -1.6951
>  -79.4901   -1.9814
>  -79.6407   -2.2444
>  -79.7878   -2.4208
>  -79.8400   -2.5000
>  -79.9182   -2.5805
>  -80.0386   -2.7369
>  -80.1589   -2.8732
>  -81.9900   -4.8900
>> 2014 SE CAYMAN TROUGH TRANSFORM FAULT
>  -78.4356   18.4315
>  -78.3248   18.4569
>  -78.1413   18.4710
>  -78.0147   18.4664
>  -77.9386   18.4565


More information about the ParaView mailing list