[vtkusers] How to create triangle strips?
David Gobbi
david.gobbi at gmail.com
Fri Nov 19 15:40:14 EST 2010
Hi Hugo,
If you already have a mesh but it isn't made of strips, then you can
convert it to triangle strips with the vtkStripper filter. But if you
need to build your polydata from scratch, the typical way is to build
a vtkCellArray using the InsertNextCell method:
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
... insert all the points with InsertNextPoint(x, y, z);
vtkSmartPointer<vtkCellArray> strips = vtkSmartPointer<vtkCellArray>::New();
vtkIdType strip1[6] = { 0, 1, 3, 4, 6, 7 };
vtkIdType strip2[6] = { 1, 2, 4, 5, 7, 8 };
strips.InsertNextCell(6, strip1);
strips.InsertNextCell(6, strip2);
vtkSmartPointer<vtkPolyData> data = vtkSmartPointer<vtkPolyData>::New();
data->SetPoints(points);
data->SetStrips(strips);
The vtkCellArray is a generic array that can be used for any kind of
cell. The cell classes like vtkTriangleStrip are not meant to be used
in the creation of data, they are primarily analysis-type classes that
make it possible for VTK to implement generic operations like clipping
and contouring (and as a result, the vtkCell class and its descendants
are very heavy-weight, while vtkCellArray is just a lightweight
array).
- David
On Fri, Nov 19, 2010 at 1:28 PM, David Doria <daviddoria at gmail.com> wrote:
> On Fri, Nov 19, 2010 at 3:22 PM, Hugo Valdebenito <hugo at maptek.cl> wrote:
>> Thanks david!!
>>
>> vtkCellArray object is defined, but never used....
>>
>> Anyone can suggest a fix?, I'm beginner on VTK
>> Hugo
>
> Try it now. It doesn't show the line through the middle of the square
> (the center edge of the triangles), but maybe that is expected with a
> triangle strip?
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Broken/GeometricObjects/TriangleStrip
>
> David
> _______________________________________________
> 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