OK, these 'd be the example:<div><br></div><div><div>#include <vtkSmartPointer.h></div><div>#include <vtkProperty.h></div><div>#include <vtkContourWidget.h></div><div>#include <vtkOrientedGlyphContourRepresentation.h></div>
<div>#include <vtkRenderer.h></div><div>#include <vtkRenderWindow.h></div><div>#include <vtkRenderWindowInteractor.h></div><div>#include <vtkCommand.h></div><div>#include <vtkDebugLeaks.h></div>
<div>#include <vtkCamera.h></div><div>#include <vtkPlane.h></div><div>#include <vtkPolyData.h></div><div>#include <vtkCellArray.h></div><div>#include <vtkPoints.h></div><div>#include <vtkMath.h></div>
<div>#include <vtkWidgetEvent.h></div><div>#include <vtkWidgetEventTranslator.h></div><div>#include <vtkTriangleFilter.h></div><div>#include <vtkMassProperties.h></div><div> </div><div>int main( int argc, char *argv[] )</div>
<div>{</div><div> // Create the RenderWindow, Renderer and both Actors</div><div> //</div><div> vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();</div><div> vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();</div>
<div> renderWindow->AddRenderer(renderer);</div><div> </div><div> vtkSmartPointer<vtkRenderWindowInteractor> interactor = </div><div> vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div> interactor->SetRenderWindow(renderWindow);</div>
<div> </div><div> renderer->SetBackground(0.1, 0.2, 0.4);</div><div> renderWindow->SetSize(600, 600);</div><div> </div><div> vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep = </div><div> vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();</div>
<div> contourRep->GetLinesProperty()->SetColor(1, 0, 0); //set color to red</div><div> </div><div> vtkSmartPointer<vtkContourWidget> contourWidget = </div><div> vtkSmartPointer<vtkContourWidget>::New();</div>
<div> contourWidget->SetInteractor(interactor);</div><div> contourWidget->SetRepresentation(contourRep);</div><div> contourWidget->On();</div><div> </div><div> for (int i = 0; i < argc; i++)</div><div> {</div>
<div> if (strcmp("-Shift", argv[i]) == 0)</div><div> {</div><div> contourWidget->GetEventTranslator()->RemoveTranslation( </div><div> vtkCommand::LeftButtonPressEvent );</div>
<div> contourWidget->GetEventTranslator()->SetTranslation( </div><div> vtkCommand::LeftButtonPressEvent,</div><div> vtkWidgetEvent::Translate );</div>
<div> }</div><div> else if (strcmp("-Scale", argv[i]) == 0)</div><div> {</div><div> contourWidget->GetEventTranslator()->RemoveTranslation( </div><div> vtkCommand::LeftButtonPressEvent );</div>
<div> contourWidget->GetEventTranslator()->SetTranslation( </div><div> vtkCommand::LeftButtonPressEvent,</div><div> vtkWidgetEvent::Scale );</div>
<div> }</div><div> }</div><div> </div><div> </div><div> vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::New();</div><div> </div><div> vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();</div>
<div> vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();</div><div> vtkIdType* lineIndices = new vtkIdType[21];</div><div> for (int i = 0; i< 20; i++)</div><div> {</div><div> const double angle = 2.0*vtkMath::Pi()*i/20.0;</div>
<div> points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle),</div><div> 0.1*sin(angle), 0.0 );</div><div> lineIndices[i] = static_cast<vtkIdType>(i);</div><div> }</div>
<div> </div><div> lineIndices[20] = 0;</div><div> lines->InsertNextCell(21,lineIndices);</div><div> delete [] lineIndices;</div><div> pd->SetPoints(points);</div><div> pd->SetLines(lines);</div><div> </div><div>
contourWidget->Initialize(pd);</div><div> contourWidget->Render();</div><div> renderer->ResetCamera();</div><div> renderWindow->Render();</div><div> </div><div> interactor->Initialize();</div><div> interactor->Start();</div>
<div><br></div><div> vtkSmartPointer< vtkTriangleFilter > triangles =</div><div><span class="" style="white-space:pre">        </span> vtkSmartPointer< vtkTriangleFilter >::New();</div><div> triangles->SetInput(contourRep->GetContourRepresentationAsPolyData());</div>
<div> vtkSmartPointer< vtkMassProperties > massProp =</div><div><span class="" style="white-space:pre">        </span> vtkSmartPointer< vtkMassProperties >::New();</div><div> massProp->SetInput(triangles->GetOutput());</div>
<div> double algo = massProp->GetSurfaceArea();</div><div><br></div><div> std::cout<< algo;</div><div><br></div><div> contourWidget->Off();</div><div><br></div><div> return EXIT_SUCCESS;</div><div>}</div></div>
<div><br></div><div>There's is the contourwidget example but i'm adding the pipe I think 'd be necessary to compute the area.</div><div><br></div><div>It still gives me same error as before at closing the renderwindow for some reason:</div>
<div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">Warning: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK 5.10\VTK\Graphics\vtkMassProperties.cxx, line 120</div><div style="font-family:arial,sans-serif;font-size:13px">
vtkMassProperties (04C64588): Input data type must be VTK_TRIANGLE not 3</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Hope you can help me get throught these or maybe give some other advice on how to get the value of the area contained by a contourwidget created at will.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Regards,</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Rodrigo Lovera</div><div><br></div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2012/12/3 David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><div class="h5">On Mon, Dec 3, 2012 at 2:00 PM, Rodrigo Lovera <span dir="ltr"><<a href="mailto:lobo.theslayer@gmail.com" target="_blank">lobo.theslayer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello everyone,<div><br></div><div>I've applied the vtkContourWidget in the same way the distancewidget is applied in the QT VTK FOUR PANE VIEW EXAMPLE</div><div><br></div><div>so far everything is fine, but I'm trying now to compute the area so I connect the following code to an pushButton which 'll be activated after finishing drawing the contour.</div>
<div><br></div><div><div><span style="white-space:pre-wrap">        </span>vtkSmartPointer< vtkTriangleFilter > triangleTrans =</div><div><span style="white-space:pre-wrap">                </span>vtkSmartPointer< vtkTriangleFilter >::New();</div>
<div><span style="white-space:pre-wrap">        </span>triangleTrans->SetInput(contourRepresentation->GetContourRepresentationAsPolyData());</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span></div>
<div><span style="white-space:pre-wrap">        </span>vtkSmartPointer< vtkMassProperties > massProp =</div><div><span style="white-space:pre-wrap">                </span>vtkSmartPointer< vtkMassProperties >::New();</div><div>
<span style="white-space:pre-wrap">        </span>massProp->SetInput(triangleTrans->GetOutput());</div><div><span style="white-space:pre-wrap">        </span>massProp->GetSurfaceArea();</div><div><span style="white-space:pre-wrap">        </span></div>
<div><span style="white-space:pre-wrap">        </span>this->ui->surfaceAreaLabel->setNum(massProp->GetSurfaceArea());</div></div><div><br></div><div>What I'm trying to do is convert the contour in a triangle mesh so then I can apply vtkMassProperties and get the surface area which is my goal.</div>
<div><br></div><div>Everythings build ok, but once in the gui when pushing the button... it gives me the following error:</div><div><br></div><div><div>Warning: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK 5.10\VTK\Graphics\vtkMassProperties.cxx, line 120</div>
<div>vtkMassProperties (04C64588): Input data type must be VTK_TRIANGLE not 3</div></div><div><br></div><div>What I use to draw the contours is the following code:</div></blockquote><div><br></div></div></div>As usual, I suggest you create a compilable example. It doesn't sound like this has anything to do with Qt, so it should be a single, self contained file (generate data similar to the data you are reading in your real code).<span class="HOEnZb"><font color="#888888"><br clear="all">
<br><div>David </div></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><b><font face="'comic sans ms', sans-serif" color="#000066">Rodrigo aka WarHearT</font></b><br>
</div>