Hi Hugo,<div><br></div><div>Go with my method. Remove the vtkTriangleStrip class from your code, it isn't needed and it just makes the code less efficient (and IMHO more confusing). The vtkCellArray has many InsertNextCell methods, and the one that takes a vtkCell object is the least efficient of all of them. For you, I think the best way to add cells is this:</div>
<div><br></div><div>cells.InsertNextCell(number_of_ids_in_strip)</div><div>cells.InsertCellPoint(first_id_in_strip)</div><div>cells.InsertCellPoint(second_id_in_srip)</div><div>(repeat InsertCellPoint for all IDs)</div><div>
<br></div><div>Repeat all of the above for each strip that you want to add, then call SetStrips() to add the whole cell array to the polydata. Look at the example code that I linked to in my previous email for more info.</div>
<div><br></div><div> David</div><div><br></div><div><br><div class="gmail_quote">On Tue, Nov 23, 2010 at 4:30 AM, Hugo Valdebenito <span dir="ltr"><<a href="mailto:hugo@maptek.cl">hugo@maptek.cl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi David.<br><br>Thanks for you help, I'm trying to undestand, I have some doubts yet, Which is the difference between both methods? Wich is better?. <br>
<div><div></div><div class="h5"><br>Hugo. <br><br><br><div class="gmail_quote">2010/11/22 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">Hi Hugo,<div><br></div><div>Your code is a mix of the method that I suggested and the method that David Doria suggested. The SetStrips() method is a low-level method for building a vtkPolyData (as per my suggestion). The InsertNextCell() method is a high-level method for building a vtkDataSet (as per David Doria's suggestion). You have to use one method or the other, not both. I apologize for the confusion.</div>
<div><br></div><font color="#888888"><div> David</div></font><div><div></div><div><div><br><div class="gmail_quote">On Mon, Nov 22, 2010 at 11:10 AM, Hugo Valdebenito <span dir="ltr"><<a href="mailto:hugo@maptek.cl" target="_blank">hugo@maptek.cl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Hi David.<br>
<br>
It works with one strip, but that doesn't work with 2 o more strips. that is my implementation (sorry, is C#, I translated the c++ example)<br>
<br>
public void GenerateSurface(int nx, int ny)<br>
{<br>
<br>
vtkPoints points = vtkPoints.New();<br>
vtkCellArray cells = new vtkCellArray();<br>
vtkTriangleStrip triangleStrip;<br>
<br>
<br>
double z,zmax = 50.0;<br>
points.SetNumberOfPoints(nx * ny);<br> //se points<br> int index = 0;<br>
for (int j = 0; j < ny; j++)<br>
{<br>
for (int i = 0; i < nx; i++)<br>
{<br>
z = zmax * Math.Sin(4 * 3.1 * i / (float)nx) + 4 * j / (float)(ny);<br>
//insert point and increment index<br>
<b>points.SetPoint(index++,(double)i, (double)j, (double)z);</b><br>
<br>
<br>
}<br>
}<br>
//set ids<br>
for (int i = 0; i < nx - 1; i++)<br>
{<br>
index = 0;<br>
triangleStrip = new vtkTriangleStrip();<br>
triangleStrip.GetPointIds().SetNumberOfIds(ny*2);<br>
<br>
for (int j = 0; j < ny; j++)<br>
{<br>
triangleStrip.GetPointIds().SetId(index++, i + j * nx);<br>
triangleStrip.GetPointIds().SetId(index++, i + j * nx + 1);<br>
}<br>
<b>cells.InsertNextCell(triangleStrip);</b><br>
}<br>
vtkPolyData polydata = new vtkPolyData();<br>
polydata.SetPoints(points);<br>
<b>polydata.SetStrips(cells);</b><br>
<br>
// Create an actor and mapper<br>
vtkDataSetMapper mapper = new vtkDataSetMapper();<br>
mapper.SetInput(polydata);<br>
vtkActor Actor = new vtkActor();<br>
<br>
Actor.SetMapper(mapper);<br>
Actor.GetProperty().SetRepresentationToWireframe();<br>
//Add the actors to the scene<br>
_renderer.AddActor(Actor);<br>
}<br>
<br><br>Hugo<br><br><br><br><div class="gmail_quote">2010/11/22 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span><div><div></div><div><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Hi Hugo,<br>
<br>
The vtkPolyData stores the strips in an array called "Strips", that is<br>
how it knows what cells are strips. And all vtkDataSet objects have a<br>
GetCellType(i) method that VTK can use to check the type of cell "i".<br>
I have some code here that generates several shapes with triangle<br>
strips:<br>
<a href="https://github.com/dgobbi/ToolCursor/blob/master/vtkGeometricCursorShapes.cxx" target="_blank">https://github.com/dgobbi/ToolCursor/blob/master/vtkGeometricCursorShapes.cxx</a><br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div><br>
<br>
On Mon, Nov 22, 2010 at 5:55 AM, Hugo Valdebenito <<a href="mailto:hugo@maptek.cl" target="_blank">hugo@maptek.cl</a>> wrote:<br>
><br>
> You should to see the triangles, maybe it's wrong. with 4 ids you define 2<br>
> triagles, with 5 --> 3 and so on (that structure saves memory). How does you<br>
> said to vtk that you are using Strips? I don't know how to define that on<br>
> VTK.<br>
><br>
><br>
> Thanks!<br>
><br>
><br>
><br>
> 2010/11/19 David Doria <<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>><br>
>><br>
>> On Fri, Nov 19, 2010 at 3:22 PM, Hugo Valdebenito <<a href="mailto:hugo@maptek.cl" target="_blank">hugo@maptek.cl</a>> wrote:<br>
>> > Thanks david!!<br>
>> ><br>
>> > vtkCellArray object is defined, but never used....<br>
>> ><br>
>> > Anyone can suggest a fix?, I'm beginner on VTK<br>
>> > Hugo<br>
>><br>
>> Try it now. It doesn't show the line through the middle of the square<br>
>> (the center edge of the triangles), but maybe that is expected with a<br>
>> triangle strip?<br>
>><br>
>><br>
>> <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Broken/GeometricObjects/TriangleStrip" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Broken/GeometricObjects/TriangleStrip</a><br>
>><br>
>> David<br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br></div>