MCPcopy Create free account
hub / github.com/MITK/MITK / SetSpacing

Method SetSpacing

Modules/Core/src/DataManagement/mitkGeometryTransformHolder.cpp:142–175  ·  view source on GitHub ↗

#Documentation # @brief Set the spacing. # #The spacing is also changed in the IndexToWorldTransform.

Source from the content-addressed store, hash-verified

140 //##
141 //##The spacing is also changed in the IndexToWorldTransform.
142 void GeometryTransformHolder::SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing)
143 {
144 if (mitk::Equal(this->GetSpacing(), aSpacing) == false || enforceSetSpacing)
145 {
146 assert(aSpacing[0] > 0 && aSpacing[1] > 0 && aSpacing[2] > 0);
147
148 AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
149
150 vnlmatrix = m_IndexToWorldTransform->GetMatrix().GetVnlMatrix();
151
152 mitk::VnlVector col;
153 col = vnlmatrix.get_column(0).as_ref();
154 col.normalize();
155 col *= aSpacing[0];
156 vnlmatrix.set_column(0, col);
157 col = vnlmatrix.get_column(1).as_ref();
158 col.normalize();
159 col *= aSpacing[1];
160 vnlmatrix.set_column(1, col);
161 col = vnlmatrix.get_column(2).as_ref();
162 col.normalize();
163 col *= aSpacing[2];
164 vnlmatrix.set_column(2, col);
165
166 Matrix3D matrix;
167 matrix = vnlmatrix;
168
169 AffineTransform3D::Pointer transform = AffineTransform3D::New();
170 transform->SetMatrix(matrix);
171 transform->SetOffset(m_IndexToWorldTransform->GetOffset());
172
173 SetIndexToWorldTransform(transform.GetPointer());
174 }
175 }
176
177 //##Documentation
178 //## @brief Get the transformation used to convert from index

Calls 8

GetSpacingMethod · 0.95
GetVnlMatrixMethod · 0.80
GetMatrixMethod · 0.80
SetMatrixMethod · 0.80
GetOffsetMethod · 0.80
GetPointerMethod · 0.80
EqualFunction · 0.50
NewFunction · 0.50

Tested by

no test coverage detected