<div dir="ltr">Hi, Cory<div><br></div><div>thank you for the reply</div><div><br></div><div>> <span style="font-size:12.8000001907349px">You must be using VTK 5-something?</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">yes, it is 5.10</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">> </span><span style="font-size:12.8000001907349px">Otherwise your example is pretty nice and compact in my opinion.</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">thank you. General question, before I start implementing your suggestions, is it a right approach? Basically, we draw contour on top of the image. Now we want contour to have semi-transparent fill, and keep it up with, say, moved point or added point. Is it a good idea to do it with triangle strip? Maybe it is already done, and I'm reinventing the wheel, or there is an obvious and simpler way to do so</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">thank you</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Oleg</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 16, 2015 at 10:41 AM, Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Oleg,<div><br></div><div>Welcome to VTK!<br><div><br></div><div>Thanks for providing the code sample. You must be using VTK 5-something? In 6 and above, your SetInput() calls need to be changed to SetInputData(). Also, as a general note about using VTK, you can use</div><div><br></div><div>algorithm2.SetInputConnection(algorithm1.GetOutputPort())</div><div><br></div><div>to create pipelines rather than pass vtkPolyData objects around. This is usually preferable as any changes to your upstream algorithms will propagate down to the renderer automatically. That might save you some code.</div><div><br></div><div>Otherwise your example is pretty nice and compact in my opinion.</div><div><br></div><div>To update the surface triangles, you need to set up an observer on the contourWidget's InteractionEvent. You can do this with</div><div><br></div><div>contourWidget.AddObserver('InteractionEvent', my_callback)<br></div><div><br></div><div>where my_callback is defined with</div><div><br></div><div>def my_callback(contourWidget, unused):</div><div> global contourWidget, mapper<br></div><div><div><br></div><div> cd = contourWidget.GetRepresentation().GetContourRepresentationAsPolyData() </div><div><br></div><div> td = gen_triangles(cd) </div><div> mapper.SetInputData(td)</div></div><div><br></div><div>Note that I've made the mapper global so you can access it in the callback. The first argument is the contour widget and the second is just the event type, which you don't need in this callback.</div><div><br></div><div>By the way, you will likely get better results for the surface if you use the following definition of gen_triangles:</div><div><br></div><div><div>def gen_triangles(cd):</div><div> clsdPoly = vtk.vtkPolyData()</div><div> clsdPoly.Allocate()</div><div> clsdPoly.SetPoints(cd.GetPoints())</div><div><br></div><div> numPts = cd.GetNumberOfPoints()</div><div> idList = vtk.vtkIdList()</div><div> idList.SetNumberOfIds(numPts)</div><div> [idList.SetId(i, i) for i in xrange(numPts)]</div><div><br></div><div> clsdPoly.InsertNextCell(vtk.VTK_POLYGON, idList)</div><div><br></div><div> triangles = vtk.vtkTriangleFilter()</div><div> triangles.SetInputData(clsdPoly)</div><div> triangles.Update()</div><div> </div><div> return triangles.GetOutput()</div></div><div><br></div><div>This creates a VTK polygon cell which works better with the vtkTriangleFilter than the line cells from the contour widget representation.</div><div><br></div><div>Hope that helps,</div><div>Cory</div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Jul 15, 2015 at 1:01 AM, Oleg Krivosheev <span dir="ltr"><<a href="mailto:oleg.krivosheev@xcision.com" target="_blank">oleg.krivosheev@xcision.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi, All<div><br></div><div>what I'm trying to do is to have editable contour in vtkContourWidget, with internal</div><div>area filled with somewhat transparent color. What I managed to do is to make contour,</div><div>put it into a widget, generate triangles strip from the contour via vtkTriangleFilter and</div><div>draw it all together, Python code at the link</div><div><br></div><div><a href="http://codepad.org/VPOa13St" target="_blank">http://codepad.org/VPOa13St</a><br></div><div><br></div><div>Now questions. Is it a good way to proceed? Looks very cumbersome to me,</div><div>but I'm new to VTK. </div><div><br></div><div>Another big question is how to connect contour edit action (say, moving or adding point)</div><div>with triangle strip update. Right now as soon as I move point, contour is updated</div><div>but triangles filler is not</div><div><br></div><div>Any help is greatly appreciated</div><div><br></div><div>regards</div><span><font color="#888888"><div><br></div><div>OK</div><div><br></div></font></span></div>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</font></span></div>
</blockquote></div><br></div>