#Documentation # @brief Set the spacing. # #The spacing is also changed in the IndexToWorldTransform.
| 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 |
no test coverage detected