Page 1 of 1

Calculation sum of scalar field

Posted: Wed Dec 05, 2018 9:32 am
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

Re: Calculation sum of scalar field

Posted: Wed Dec 05, 2018 9:24 pm
by daniel
That's correct. And nope, there's no shortcut to do that operation ;)