Update CubeSample.cpp

- getDensity method modified