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

David Doria daviddoria+vtk at gmail.com
Fri Dec 18 08:10:15 EST 2009


On Thu, Dec 17, 2009 at 11:14 AM, Bryn Lloyd <blloyd at vision.ee.ethz.ch>wrote:

> David,
>
> Not sure, but it works in paraview doesn't it?
>
> 1. Maybe inverted triangles (there was an issue in the past with inverted
> tets).
>
> 2. Maybe you don't have triangles, but strips?
>
> /Bryn
>
>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091218/ca1b22d3/attachment.htm>


More information about the vtkusers mailing list