Hi! I'm a newbie on VTK and I'm using vtkContourWidget to manually draw a contour on a polydata surface.<div><br></div><div>I've managed to draw the contour and also, via callbacks, to print (std::cout) the polydata contour info (using the syntax polyData->GetNumberOfPoints(), where "polyData" is the contour obtained as vtkPolyData *polyData = rep->GetContourRepresentationAsPolyData();).</div>
<div><br></div><div>The problem: up to know I only have access to this polydata from within the class implementation and not from the calling function (in my case the main function).</div><div><br></div><div>What I'd like to do: to return the polydata pointer (from the callback) to the main function, in order to have access to the contour. Does any of you know how to do that?</div>
<div><br></div><div>Here's part of my code:</div><div><br></div><div>//</div><div>// Callback class</div><div>//</div><div><div>class callbackContourWidget : public vtkCommand</div><div>{</div><div> public:</div><div>
static callbackContourWidget *New()</div><div> {</div><div> return new callbackContourWidget;</div><div> }</div><div> callbackContourWidget(){}</div><div> </div><div> virtual void Execute(vtkObject *caller, unsigned long, void*)</div>
<div> {</div><div> vtkContourWidget *contourWidget = reinterpret_cast<vtkContourWidget*>(caller);</div><div> vtkContourRepresentation* rep = static_cast<vtkContourRepresentation *>(contourWidget->GetRepresentation());</div>
<div> </div><div> vtkPolyData *polyData = rep->GetContourRepresentationAsPolyData();</div><div> std::cout<< "The contour has " << polyData->GetNumberOfPoints() << "points." << std::endl;</div>
<div> }</div><div> </div><div> void SetMeshSource(vtkSmartPointer<vtkTriangleFilter> triangleMesh) {this->MeshSource = triangleMesh;}</div><div><br></div><div> // Metodo para obtener el polydata</div><div> void GetPolydataContour(<vtkContourRepresentation> rep) {}</div>
<div> </div><div> private:</div><div> vtkSmartPointer<vtkTriangleFilter> MeshSource;</div><div>};</div></div><div><br></div><div>//</div><div>// Calling the callback from the main function</div><div>//</div><div>
<br></div><div>int main(int argc, char *argv[]){</div><div>...</div><div>...</div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<callbackContourWidget> callback = vtkSmartPointer<callbackContourWidget>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>callback->SetMeshSource(triangleFilter);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>contourWidget->AddObserver(vtkCommand::InteractionEvent,callback);</div>
</div><div>...</div><div>...</div><div>}</div><div><br></div><div>Thanks!</div><div>Miguel</div>