64 std::clamp( i.x(), 0, size().x() - 1 ),
65 std::clamp( i.y(), 0, size().y() - 1 ),
66 std::clamp( i.z(), 0, size().z() - 1 ),
71void VolumeGrid::computeGradients() {
72 m_gradient.resize( m_data.size() );
75#pragma omp parallel for firstprivate( s )
76 for (
int k = 0; k < s.z(); ++k ) {
77 for (
int j = 0; j < s.y(); ++j ) {
78 for (
int i = 0; i < s.x(); ++i ) {
79 Eigen::Matrix<ValueType, 3, 1> s1;
80 Eigen::Matrix<ValueType, 3, 1> s2;
81 s1( 0 ) = sample( { i - 1, j, k } );
82 s2( 0 ) = sample( { i + 1, j, k } );
83 s1( 1 ) = sample( { i, j - 1, k } );
84 s2( 1 ) = sample( { i, j + 1, k } );
85 s1( 2 ) = sample( { i, j, k - 1 } );
86 s2( 2 ) = sample( { i, j, k + 1 } );
87 IndexType idx { i, j, k };
88 Eigen::Matrix<ValueType, 3, 1> gradient = s2 - s1;
89 m_gradient[*linearIndex( idx )] = {
90 gradient[0], gradient[1], gradient[2], sample( { i, j, k } ) };