[vtk-developers] Proposed CenterOfMass function for vtkPoints
David Doria
daviddoria+vtk at gmail.com
Thu Apr 1 13:12:38 EDT 2010
On Thu, Apr 1, 2010 at 11:46 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> On Thu, Apr 1, 2010 at 11:42 AM, Will Schroeder
> <will.schroeder at kitware.com> wrote:
>> My concern with the term centroid is to differentiate the centroid of
>> the points from the centroid of the dataset, which can be different.
>> Since the user generally asks a dataset for its points, it would be
>> easy to make the mistake of assuming that the centroid of a dataset
>> matches the centroid of the points. Maybe this is just a documentation
>> issue, but it needs to be clear.
>
> I agree that it should be made clear in documentation, but again since
> this is called on the vtkPoints of a dataset, it shouldn't introduce
> much confusion.
>
> polydata->GetPoints()->GetCentroid() should be clear that it is the
> centroid of the points.
>
> If it was just polydata->GetCentroid(), then it would be ambiguous.
>
> David
>
I ran a test to see if it was really worth our while to optimize this
(I've always been curious about this).
I generated 1e8 points with vtkPointSource and then computed the
centroid with the unoptimized version (GetPoint(), the optimized
version (manual pointer moving), and the optimized version inlined.
Below are the outputs of
time ./Test
The point generation alone took:
real 0m45.840s
user 0m38.502s
sys 0m1.172s
The unoptimized centroid centroid (including point generation) took:
real 0m59.522s
user 0m48.932s
sys 0m1.591s
The optimized centroid (not inlined, including point generation) took:
real 0m55.233s
user 0m43.368s
sys 0m1.392s
The optimized centroid (inlined, including point generation) took:
real 1m7.317s
user 0m52.937s
sys 0m1.536s
I don't know if we should look at 'real' or 'user'. Looking at 'real',
the inline seems to make it worse, but the optimization seems to bring
it from 15 seconds to 10 seconds, meaning it reduced the time by 33%?
Attached is the latest version.
Thanks,
David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkPoints.cxx
Type: text/x-c++src
Size: 6967 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100401/bff2e14f/attachment-0001.cxx>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkPoints.h
Type: text/x-chdr
Size: 8337 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100401/bff2e14f/attachment-0001.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.cpp
Type: text/x-c++src
Size: 516 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100401/bff2e14f/attachment-0001.cpp>
More information about the vtk-developers
mailing list