[vtkusers] Comput the area contained by a contour (VTK C++)
Rodrigo Lovera
lobo.theslayer at gmail.com
Mon Dec 3 14:07:40 EST 2012
Well, I applied what you said but I'm getting these error:
Warning: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
5.10\VTK\Graphics\vtkMassProperties.cxx, line 120
vtkMassProperties (04C64588): Input data type must be VTK_TRIANGLE not 3
I'm taking as a base the FOUR PANE VIEWER VTK QT EXAMPLE that comes with
the documentation.
I applied the vtkContourWidget in a similar way the distancewidget is
applied:
void mainwindow::AddContourToView(int i)
{
// Remover widgets existentes
if (this->ContourWidget[i])
{
this->ContourWidget[i]->SetEnabled(0);
this->ContourWidget[i] = NULL;
}
//Agregar un nuevo widget
this->ContourWidget[i] = vtkSmartPointer< vtkContourWidget >::New();
this->ContourWidget[i]->SetInteractor(
this->riw[i]->GetResliceCursorWidget()->GetInteractor());
//Crear la Representacion Geometrica para el ContourWidget
contourRepresentation =vtkSmartPointer<
vtkOrientedGlyphContourRepresentation >::New();
contourRepresentation->GetProperty()->SetColor(0.25, 1.0, 0.25);
vtkSmartPointer< vtkSphereSource > ss =
vtkSmartPointer< vtkSphereSource >::New();
ss->SetRadius(0.5);
contourRepresentation->SetActiveCursorShape(ss->GetOutput());
contourRepresentation->GetActiveProperty()->SetAmbient(0.1);
contourRepresentation->GetActiveProperty()->SetDiffuse(0.9);
contourRepresentation->GetActiveProperty()->SetSpecular(0.0);
//Configurar la prioridad mayor a la del reslice
this->ContourWidget[i]->SetPriority(
this->riw[i]->GetResliceCursorWidget()->GetPriority() + 0.01);
this->ContourWidget[i]->SetRepresentation(contourRepresentation);
this->ContourWidget[i]->EnabledOn();
//this->ContourWidget[i]->ProcessEventsOn();
this->riw[i]->GetMeasurements()->AddItem(this->ContourWidget[i]);
}
After that I got another button wich 'll be applied to compute the are with
the method you mentioned, I wrote sth like:
vtkSmartPointer< vtkTriangleFilter > triangleTrans =
vtkSmartPointer< vtkTriangleFilter >::New();
triangleTrans->SetInput(contourRepresentation->GetContourRepresentationAsPolyData());
vtkSmartPointer< vtkMassProperties > massProp =
vtkSmartPointer< vtkMassProperties >::New();
massProp->SetInput(triangleTrans->GetOutput());
massProp->GetSurfaceArea();
this->ui->surfaceAreaLabel->setNum(massProp->GetSurfaceArea());
But the problem is the one I mentioned at the start, hope you have a better
idea on what to do.
Thx in advance.
Regards
Rodrigo Lovera
2012/12/3 Rodrigo Lovera <lobo.theslayer at gmail.com>
> Hi Bouba,
>
> I was checking on the method you propose, but I don't get to set the input
> correctly for the triangle filter, considering i'm defining the 2D contour
> using the vtkContourWidget, so there is where im stucked atm.
>
> Checking vtkMassProperties I think surfacearea 'd suit well for computing
> area contained by the contour, hope you could give me an idea on how to
> connect the pipe between the contour widget and the triangle filter so I
> could test the rest.
>
> Thx in advance,
>
> Regards,
> Rodrigo
>
>
> 2012/11/29 Belaroussi, Boubakeur <Boubakeur.Belaroussi at bioclinica.com>
>
> Hi Rodrigo,****
>>
>> ** **
>>
>> For 2D contours, you can use the following pipeline:****
>>
>> ** **
>>
>> 1. Transform your contour points into triangles, using vtkTriangleFilter,
>> which creates triangle polygons from input polygons and triangle strips**
>> **
>>
>> 2. Then, to get the area of your contour, among other features, you can
>> use the vtkMassProperties filter, which estimates volume, area, shape index
>> of triangle mesh.****
>>
>> ** **
>>
>> Hope it helps****
>>
>> Regards,****
>>
>> Bouba****
>>
>> ** **
>>
>> *From:* vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] *On
>> Behalf Of *Rodrigo Lovera
>> *Sent:* jeudi 29 novembre 2012 18:01
>> *To:* VTK Users
>> *Subject:* [vtkusers] Comput the area contained by a contour (VTK C++)***
>> *
>>
>> ** **
>>
>> Hello everyone,
>>
>> I was wondering if any of you know a method to compute the area
>> cointained by a figure or maybe something like the contourwidget which
>> shape can be changed at will.
>>
>> What I need -d be some kind of implementation or code or guide on how to
>> perform that math operation, similar to the distance widget but what I need
>> to compute now is area.
>>
>> Id really appreciate any kind of help
>>
>> --
>> *Rodrigo*****
>> --
>> Confidentiality Notice: This e-mail transmission may contain confidential
>> or legally privileged information that is intended only for the individual
>> or entity named in the e-mail address. If you are not the intended
>> recipient, you are hereby notified that any disclosure, copying,
>> distribution, or reliance upon the contents of this e-mail is strictly
>> prohibited. If you have received this e-mail transmission in error, please
>> reply to the sender and then delete the message from your computer. Thank
>> you.
>> --
>>
>
>
>
> --
> *Rodrigo aka WarHearT*
>
--
*Rodrigo aka WarHearT*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121203/f5783aeb/attachment.htm>
More information about the vtkusers
mailing list