[vtkusers] Disconnected 3D lines segments

Eric E. Monson emonson at cs.duke.edu
Wed Aug 24 08:53:59 EDT 2011


Hello,

For me it works to explicitly set the Ids of the lines using SetId rather than using InsertNextId. My guess is that vtkLine is initialized with two points with both of their IDs set to 0, and then you're adding two new IDs on to the end of that vtkIdList. (Sorry if my syntax is wrong, I don't know VB and used C# to test...)

   line = vtkLine.New()
   line.GetPointIds().SetId 0 id1
   line.GetPointIds().SetId 1 id2
   lines.InsertNextCell line

   line = vtkLine.New()
   line.GetPointIds().SetId 0 id3
   line.GetPointIds().SetId 1 id4
   lines.InsertNextCell line

Good luck,
-Eric

· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Eric E Monson
Duke Visualization Technology Group


On Aug 24, 2011, at 5:22 AM, Oldrich Svec wrote:

> Hi,
> 
> I try to save an array of disconnected 3D line segments using Activiz
> .NET. I use the following sample code:
> 
>    points = vtkPoints.New()
>    lines = vtkCellArray.New()
> 
>    id1 = points.InsertNextPoint(0.,0.,0.)
>    id2 = points.InsertNextPoint(1.,0.,0.)
>    id3 = points.InsertNextPoint(0.,1.,0.)
>    id4 = points.InsertNextPoint(0.,0.,1.)
> 
>    line = vtkLine.New()
>    line.GetPointIds().InsertNextId id1
>    line.GetPointIds().InsertNextId id2
>    lines.InsertNextCell line
> 
>    line = vtkLine.New()
>    line.GetPointIds().InsertNextId id3
>    line.GetPointIds().InsertNextId id4
>    lines.InsertNextCell line
> 
>    poly = vtkPolyData.New()
>    poly.SetPoints points
>    poly.SetLines lines
> 
>    vtp = vtkPolyDataWriter.New()
>    vtp.SetFileName @"D:\\test.vtk"
>    vtp.SetFileTypeToASCII()
>    vtp.SetInput poly
>    vtp.Write()
> 
> Those lines are however connected. How to make the two lines disconnected?
> 
> PS: I obtain this vtk:
> 
> # vtk DataFile Version 3.0
> vtk output
> ASCII
> DATASET POLYDATA
> POINTS 4 float
> 0 0 0 1 0 0 0 1 0
> 0 0 1
> LINES 2 10
> 4 0 0 0 1
> 4 0 0 2 3
> 
> and I want to obtain this vtk:
> 
> # vtk DataFile Version 3.0
> vtk output
> ASCII
> DATASET POLYDATA
> POINTS 4 float
> 0 0 0 1 0 0 0 1 0
> 0 0 1
> LINES 2 6
> 2 0 1
> 2 2 3
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list