<div class="gmail_quote">On Fri, Mar 12, 2010 at 7:08 AM, Liam Kurmos <span dir="ltr"><<a href="mailto:quantum.leaf@googlemail.com">quantum.leaf@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I have some triangle data i need to visualise to make sure it's correct.<br>
<br>
I looked at <a href="http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Display/Triangle" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Display/Triangle</a><br>
which adds a single vtkSmartPointer<vtkTriangle> triangle<br>
to vtkSmartPointer<vtkCellArray> triangles.<br>
<br>
I thought it would be straight forward to extend this to adding<br>
multiple cells. I added all my points and then did:<br>
<br>
for (int i=0;i<rsphere->n_faces;i++){<br>
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();<br>
triangle->GetPointIds()->SetId ( i, rsphere->faces[i]);<br>
triangle->GetPointIds()->SetId ( i+1, rsphere->faces[i+1] );<br>
triangle->GetPointIds()->SetId ( i+2, rsphere->faces[i+2]);<br>
triangles->InsertNextCell ( triangle );<br>
}<br>
<br>
however this segfaults on the second itteration. (a triangle is<br>
produced if i only loop once).<br>
<br>
Is this the correct approach? if so it must be my data that is causing<br>
the segfault.<br>
<br>
i think my point/index array data is correct. I changed the index from<br>
rsphere->faces[...] to constants 0,1,2 but it still segfaults on the<br>
second itteration.<br>
<br>
please let me know if i am missing something. I couldn't find an<br>
example for multiple triangles, but i can write want if desired.<br>
I have the books at home so if this is covered there please let me<br>
know and i'll look it up.<br>
<br>
regards,<br>
<br>
Liam<br>
<br>
<br>
ps: small point but<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Triangle_GeometryPolygon" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Triangle_GeometryPolygon</a><br>
and<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/TriangleOnData" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/TriangleOnData</a><br>
seem to be almost identical to each other, the former has better<br>
comments and the latter has defines an unused vtktriangle t.<br><br></blockquote><div><br></div><div class="gmail_quote">Shoudn't you have to use i+=3 instead of i++ to increment the loop counter?</div><div class="gmail_quote">
<br></div><div class="gmail_quote">Now you are getting</div><div class="gmail_quote"><br></div><div class="gmail_quote">0, 1, 2</div><div class="gmail_quote">1, 2, 3</div><div class="gmail_quote"><br></div><div class="gmail_quote">
where you want</div><div class="gmail_quote"><br></div><div class="gmail_quote">0, 1, 2</div><div class="gmail_quote">3, 4, 5</div><div class="gmail_quote"><br></div><div class="gmail_quote">right?</div><div class="gmail_quote">
<br></div><div class="gmail_quote"><br></div>Good point with the two examples. I removed the unused vtkTriangle t. I also created this page:</div><div class="gmail_quote"><br></div><div class="gmail_quote"><a href="http://www.vtk.org/Wiki/VTK/Tutorials/GeometryTopology">http://www.vtk.org/Wiki/VTK/Tutorials/GeometryTopology</a></div>
<div class="gmail_quote"><br></div><div class="gmail_quote">that is linked to from the Tutorials page. This way there are not links to two similar examples from the Examples page. I also renamed those pages to be in the Tutorials "directory".</div>
<div class="gmail_quote"><br clear="all">Thanks,<br><br>David</div>