| 45 | } |
| 46 | |
| 47 | ::mitk::PointSet::Pointer |
| 48 | mitk::PointSetMappingHelper::map(const ::mitk::PointSet* input, const mitk::PointSetMappingHelper::RegistrationType* registration, int timeStep, |
| 49 | bool throwOnMappingError, const ::mitk::PointSet::PointDataType& errorPointValue) |
| 50 | { |
| 51 | if (!registration) |
| 52 | { |
| 53 | mitkThrow() << "Cannot map point set. Passed registration wrapper pointer is nullptr."; |
| 54 | } |
| 55 | if (!input) |
| 56 | { |
| 57 | mitkThrow() << "Cannot map point set. Passed point set pointer is nullptr."; |
| 58 | } |
| 59 | if (static_cast<int>(input->GetTimeSteps())<=timeStep && timeStep>=0) |
| 60 | { |
| 61 | mitkThrow() << "Cannot set point set. Selected time step is larger then mitk point set. MITK time step count: "<<input->GetTimeSteps()<<"; selected time step: "<<timeStep; |
| 62 | } |
| 63 | |
| 64 | ::mitk::PointSet::Pointer result = input->Clone(); |
| 65 | |
| 66 | typedef ::map::core::continuous::Elements<3>::InternalPointSetType MAPPointSetType; |
| 67 | typedef ::map::core::Registration<3,3> ConcreteRegistrationType; |
| 68 | const ConcreteRegistrationType* castedReg = dynamic_cast<const ConcreteRegistrationType*>(registration); |
| 69 | if (!castedReg) |
| 70 | { |
| 71 | mitkThrow() <<"Moving and/or fixed dimension of the registration is not 3. Cannot map point 3D set."; |
| 72 | } |
| 73 | |
| 74 | typedef ::map::core::PointSetMappingTask<ConcreteRegistrationType, MAPPointSetType, MAPPointSetType> MappingTaskType; |
| 75 | MappingTaskType::ErrorPointValueType internalErrorValue = itk::NumericTraits<MappingTaskType::ErrorPointValueType>::NonpositiveMin(); |
| 76 | MappingTaskType::Pointer spTask = MappingTaskType::New(); |
| 77 | spTask->setRegistration(castedReg); |
| 78 | spTask->setThrowOnMappingError(throwOnMappingError); |
| 79 | spTask->setErrorPointValue(internalErrorValue); |
| 80 | |
| 81 | unsigned int timePos = timeStep; |
| 82 | unsigned int timeEndPos = timeStep+1; |
| 83 | if (timeStep < 0) |
| 84 | { |
| 85 | timePos = 0; |
| 86 | timeEndPos = input->GetTimeSteps(); |
| 87 | } |
| 88 | |
| 89 | while (timePos<timeEndPos) |
| 90 | { |
| 91 | MAPPointSetType::Pointer inputTempSet = ConvertPointSetMITKtoMAP(input->GetPointSet(timePos)); |
| 92 | spTask->setInputPointSet(inputTempSet); |
| 93 | spTask->execute(); |
| 94 | |
| 95 | MAPPointSetType::Pointer mappedSet = spTask->getResultPointSet(); |
| 96 | |
| 97 | unsigned int pointCount = input->GetSize(timePos); |
| 98 | |
| 99 | for (unsigned int pointId = 0; pointId < pointCount; ++pointId) |
| 100 | { |
| 101 | result->SetPoint(pointId, mappedSet->GetPoint(pointId), timePos); |
| 102 | bool invalid = true; |
| 103 | MAPPointSetType::PixelType mappedData; |
| 104 | if (mappedSet->GetPointData(pointId,&mappedData)) |
nothing calls this directly
no test coverage detected