Calculation sum of scalar field

Feel free to ask any question here
Post Reply
fblue
Posts: 37
Joined: Thu Oct 25, 2018 9:00 am

Calculation sum of scalar field

Post by fblue »

Hi,
To compute the sum of a scalar field of a cloud point, I use the conventional way like this:

int density = Cloud->getScalarFieldIndexByName("Density");
CCLib::ScalarField* sf_density = Cloud->getScalarField(density);
double sum = 0.;
for (int num = 0; num < Cloud->size(); num++)
sum = sum + sf_density->getValue(num);

It seems to work for me. Are there another way more simple to do that?
Thanks
daniel
Site Admin
Posts: 7711
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Calculation sum of scalar field

Post by daniel »

That's correct. And nope, there's no shortcut to do that operation ;)
Daniel, CloudCompare admin
Post Reply