[vtk-developers] Proposed CenterOfMass function for vtkPoints

Bill Lorensen bill.lorensen at gmail.com
Thu Apr 1 13:43:11 EDT 2010


And of course, optimization is compiler dependent.

On Thu, Apr 1, 2010 at 1:12 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> 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
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>



More information about the vtk-developers mailing list