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

David Gobbi david.gobbi at gmail.com
Fri Dec 18 11:48:42 EST 2009


What overhead is there, as long as it isn't declared as a virtual method?

I think the addition is fine, myself.  My only objection would be the
usual: instantiating a vtk object to do a computation is inefficient.
It's probably too late to add lightweight stack-based math objects to
VTK, so in general, people should use the static methods even if it
does mean that they have to write a few more lines of code.  But for
the sake of the wrappers, these sort of convenience methods can be
useful.

   David


On Fri, Dec 18, 2009 at 9:29 AM, David E DeMarle
<dave.demarle at kitware.com> wrote:
> I suppose the reason it is not there in the first place is the design
> goal of not adding overhead. That class is pretty deep down in VTK.
> Adding a method to the class grows the class's function lookup table
> which makes vtkTriangle's infinitesimally slower to use. Since there
> are usually many Triangles, and they are used in many places that
> infinitesimal overhead can add up. Thus, adding that convenience
> method then was left to user's application which can do it externally
> to the class.
>
> That said I still don't have a problem with adding it. Others can say
> no if they think the added overhead is not worth the added
> convenience.
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 28 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-371-3971 x109
>
> On Fri, Dec 18, 2009 at 11:01 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> David,
>>
>> I looked at the source for vtkMeshQuality and I think you have
>> uncovered a bug. I see vtkDoubleArray named "Quality" added to the
>> cell data, but I do not see where any data is added to the array.
>>
>> I noticed that that Graphics/Texting/Cxx/MeshQuality does not access
>> the CellData.
>>
>> If it's not tested it's broken,
>>
>> Bill
>>
>> On Fri, Dec 18, 2009 at 8:10 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
>>> 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
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list