Another question that I wanted to ask is why do we set the z offset? Clearly, this is needed as the output is completely different... But what does it actually do?<br><br>Thanks,<br>Anja<br><br><div><span class="gmail_quote">
On 25/10/06, <b class="gmail_sendername">Anja Ende</b> <<a href="mailto:anja.ende@googlemail.com">anja.ende@googlemail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Dean,<br><br>Thanks for the reply and code fragmant. This really helps!<br><br>Your suggestiosn were completely on the money (as usual!). It was the problem with not closing the loop and the extrusion vector just being copied and pasted from example code without bothering to understand what it meant!
<br><br>However, there seems to be a problem with the stencil output:<br><br>The points I have chosen are:<br><br>float pts[4][3] = {{-55.7812, 9.375, -0.5},<br> {-18.2812, 49.6875, -0.5},<br> {
21.0938, 14.0625, -0.5},<br> {-55.7812, 9.375, -0.5}};<br><br>which should form a triangle. <br><br>However, the output looks very weird. The triangle is too small and very jagged. Also, the dimensions of the triangle seem wrong. There is a screenshot attached with this message. Please mail me if you cannot see it on the website and I will send you the screenshot immediately.
<br><br>Also, here is the latest code now:<br><br>float pts[4][3] = {{-55.7812, 9.375, -0.5},<br> {-18.2812, 49.6875, -0.5},<br> {21.0938, 14.0625, -0.5},<br> {-55.7812, 9.375
, -
0.5}};<span class="q"><br><br>vtkFloatArray* pcoords = vtkFloatArray::New();<br>pcoords->SetNumberOfComponents(3);<br>pcoords->SetNumberOfTuples(4);<br>for (int i=0; i<4; i++)<br>{<br> pcoords->SetTuple(i, pts[i]);
<br>}<br>
// Create vtkPoints and assign pcoords as the internal data array.<br>vtkPoints* points = vtkPoints::New();<br>points->SetData(pcoords);<br>vtkPolyData* polydata = vtkPolyData::New();<br>polydata->SetPoints(points);
<br><br><br></span> vtkCellArray* strips = vtkCellArray::New();<br> strips->InsertNextCell(4);<span class="q"><br> strips->InsertCellPoint(0);<br> strips->InsertCellPoint(1);<br> strips->InsertCellPoint(2);<br>
</span> strips->InsertCellPoint(3); // same coordinates as the first one..
<span class="q"><br> <br>polydata->SetStrips(strips);<br><br>vtkLinearExtrusionFilter* extrude = vtkLinearExtrusionFilter::New();<br>extrude->SetInput(polydata);<br>extrude->SetScaleFactor(1);<br>extrude->SetExtrusionTypeToNormalExtrusion();
<br></span><span class="q">extrude->SetVector(0, 0, 1);<br><br>vtkPolyDataToImageStencil* dataToStencil = vtkPolyDataToImageStencil::New();<br>dataToStencil->SetInput(extrude->GetOutput());<br><br>vtkImageStencil* stencil = vtkImageStencil::New();
<br>stencil->SetInput(m_viewer->GetOutput());<br>stencil->SetStencil(dataToStencil->GetOutput());<br></span>stencil->ReverseStencilOn();<br>stencil->SetBackgroundValue(0);<br><br>stencil->Update();<br>
<br>Also, when I add more points, so instead of a triangle have a quadrilateral. I see a triangle shape being stencilled and the outside the loop some lines through the image... but they are completely outside the loop. However, I can see that the shape is completely closed....
<br><br>Thanks for all the help!<br><span class="sg"><br>Anja<br>
</span><br clear="all"></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br><br>Anja