| 210 | } |
| 211 | |
| 212 | void MAPAlgorithmHelper::SetData(const mitk::BaseData* moving, const mitk::BaseData* target) |
| 213 | { |
| 214 | if (! m_AlgorithmBase) |
| 215 | { |
| 216 | mapDefaultExceptionStaticMacro( << "Error, cannot check data. Helper has no algorithm defined."); |
| 217 | } |
| 218 | |
| 219 | if (! moving) |
| 220 | { |
| 221 | mapDefaultExceptionStaticMacro( << "Error, cannot check data. Moving data pointer is nullptr."); |
| 222 | } |
| 223 | |
| 224 | if (! target) |
| 225 | { |
| 226 | mapDefaultExceptionStaticMacro( << "Error, cannot check data. Target data pointer is nullptr."); |
| 227 | } |
| 228 | |
| 229 | unsigned int movingDim = m_AlgorithmBase->getMovingDimensions(); |
| 230 | unsigned int targetDim = m_AlgorithmBase->getTargetDimensions(); |
| 231 | |
| 232 | if (movingDim != targetDim) |
| 233 | { |
| 234 | mapDefaultExceptionStaticMacro( << |
| 235 | "Error, cannot set data. Current version of MAPAlgorithmHelper only supports images/point sets with same dimensionality."); |
| 236 | } |
| 237 | |
| 238 | if (GetDataAsPointSet(target) && GetDataAsPointSet(moving)) |
| 239 | { |
| 240 | typedef ::map::core::continuous::Elements<3>::InternalPointSetType InternalDefaultPointSetType; |
| 241 | typedef ::map::algorithm::facet::PointSetRegistrationAlgorithmInterface<InternalDefaultPointSetType, InternalDefaultPointSetType> |
| 242 | PointSetRegInterface; |
| 243 | |
| 244 | PointSetRegInterface* pPointSetInterface = dynamic_cast<PointSetRegInterface*> |
| 245 | (m_AlgorithmBase.GetPointer()); |
| 246 | |
| 247 | pPointSetInterface->setMovingPointSet(mitk::PointSetMappingHelper::ConvertPointSetMITKtoMAP( |
| 248 | GetDataAsPointSet(moving)->GetPointSet())); |
| 249 | pPointSetInterface->setTargetPointSet(mitk::PointSetMappingHelper::ConvertPointSetMITKtoMAP( |
| 250 | GetDataAsPointSet(target)->GetPointSet())); |
| 251 | } |
| 252 | else if (GetDataAsImage(moving) && GetDataAsImage(target)) |
| 253 | { |
| 254 | if (movingDim == 2) |
| 255 | { |
| 256 | AccessTwoImagesFixedDimensionByItk(GetDataAsImage(moving), GetDataAsImage(target), DoSetImages, 2); |
| 257 | } |
| 258 | else if (movingDim == 3) |
| 259 | { |
| 260 | AccessTwoImagesFixedDimensionByItk(GetDataAsImage(moving), GetDataAsImage(target), DoSetImages, 3); |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | template<typename TInImageType, typename TOutImageType> |
| 266 | typename TOutImageType::Pointer MAPAlgorithmHelper::CastImage(const TInImageType* input) const |