[vtkusers] How to extract area of (triangle) Cells?

Bryn Lloyd blloyd at vision.ee.ethz.ch
Sat Dec 19 05:54:49 EST 2009


David,

> 
> Bryn, 
> 
> Hmm, I tried it with a sphere source run through vtkTriangleFilter. This 
> should produce good triangles, right?
> 
>   vtkSmartPointer<vtkSphereSource> sphereSource = 
> vtkSmartPointer<vtkSphereSource>::New();
>   sphereSource->Update();
>   
>   vtkSmartPointer<vtkTriangleFilter> triangleFilter = 
> vtkSmartPointer<vtkTriangleFilter>::New();
>   triangleFilter->SetInputConnection(sphereSource->GetOutputPort());
>   triangleFilter->Update();
>   
>   //vtkPolyData* mesh = sphereSource->GetOutput();
>   vtkPolyData* mesh = triangleFilter->GetOutput();
>   cout << "There are " << mesh->GetNumberOfCells() << " cells." << endl;
>   
>   vtkSmartPointer<vtkMeshQuality> qualityFilter = 
> vtkSmartPointer<vtkMeshQuality>::New();
>   qualityFilter->SetInput(mesh);
>   qualityFilter->SetTriangleQualityMeasureToArea();
>   qualityFilter->Update();
>   
>   vtkDataSet* qualityMesh = qualityFilter->GetOutput();
>   vtkSmartPointer<vtkDoubleArray> qualityArray = 
> vtkDoubleArray::SafeDownCast(qualityMesh->GetCellData()->GetArray("Quality"));
>   
>   cout << "There are " << qualityArray->GetNumberOfTuples() << " 
> values." << endl;
>   
>   for(unsigned int i = 0; i < qualityArray->GetNumberOfTuples(); i++)
>     {
>     double val;
>     qualityArray->GetValue(i);
>     cout << "value " << i << " : " << val << endl;
>     }
> 
> The output is still 
> 
> ...
> value 90 : 5.77804e-269
> value 91 : 5.77804e-269
> value 92 : 5.77804e-269
> ...
> 
> Any thoughts?
> 
> Thanks,
> 
> David 


My advice: This kind of thing is most easily tested in paraview. If the 
same error/behavior occurs, then it might be a bug in VTK code. Else, 
the bug is likely to be in yours (as Bill uncovered). (-:

Best regards,
Bryn








More information about the vtkusers mailing list