13 #include "mapRegistration.h" 19 #include "mapPointSetMappingTask.h" 23 if (! mitkSet) mapDefaultExceptionStaticMacro(<<
"Error, cannot convert point set. Passed mitk point set is null.");
25 ::map::core::continuous::Elements<3>::InternalPointSetType::Pointer mapSet = ::map::core::continuous::Elements<3>::InternalPointSetType::New();
26 ::map::core::continuous::Elements<3>::InternalPointSetType::PointsContainer::Pointer mapContainer = ::map::core::continuous::Elements<3>::InternalPointSetType::PointsContainer::New();
27 ::map::core::continuous::Elements<3>::InternalPointSetType::PointDataContainer::Pointer mapDataContainer = ::map::core::continuous::Elements<3>::InternalPointSetType::PointDataContainer::New();
28 mapSet->SetPoints(mapContainer);
29 mapSet->SetPointData(mapDataContainer);
31 unsigned int pointCount = mitkSet->GetNumberOfPoints();
33 for (
unsigned int pointId = 0; pointId < pointCount; ++pointId)
35 mapSet->SetPoint(pointId, mitkSet->GetPoint(pointId));
38 if (mitkSet->GetPointData(pointId,&data))
40 mapSet->SetPointData(pointId,data.
id);
49 bool throwOnMappingError, const ::mitk::PointSet::PointDataType& errorPointValue)
53 mitkThrow() <<
"Cannot map point set. Passed registration wrapper pointer is nullptr.";
57 mitkThrow() <<
"Cannot map point set. Passed point set pointer is nullptr.";
59 if (static_cast<int>(input->GetTimeSteps())<=timeStep && timeStep>=0)
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;
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);
71 mitkThrow() <<
"Moving and/or fixed dimension of the registration is not 3. Cannot map point 3D set.";
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);
81 unsigned int timePos = timeStep;
82 unsigned int timeEndPos = timeStep+1;
86 timeEndPos = input->GetTimeSteps();
89 while (timePos<timeEndPos)
92 spTask->setInputPointSet(inputTempSet);
95 MAPPointSetType::Pointer mappedSet = spTask->getResultPointSet();
97 unsigned int pointCount = input->GetSize(timePos);
99 for (
unsigned int pointId = 0; pointId < pointCount; ++pointId)
101 result->SetPoint(pointId, mappedSet->GetPoint(pointId), timePos);
103 MAPPointSetType::PixelType mappedData;
104 if (mappedSet->GetPointData(pointId,&mappedData))
106 invalid = mappedData == internalErrorValue;
111 result->GetPointSet(timePos)->GetPointData()->SetElement(pointId,errorPointValue);
115 result->GetPointSet(timePos)->GetPointData()->SetElement(pointId,input->GetPointSet(timePos)->GetPointData()->GetElement(pointId));
127 bool throwOnMappingError, const ::mitk::PointSet::PointDataType& errorPointValue)
131 mitkThrow() <<
"Cannot map point set. Passed registration wrapper pointer is nullptr.";
135 mitkThrow() <<
"Cannot map point set. Passed registration wrapper containes no registration.";
139 mitkThrow() <<
"Cannot map point set. Passed point set pointer is nullptr.";
struct for data of a point
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
MITKMATCHPOINTREGISTRATION_EXPORT ::mitk::PointSet::Pointer map(const ::mitk::PointSet *input, const RegistrationType *registration, int timeStep=-1, bool throwOnMappingError=true, const ::mitk::PointSet::PointDataType &errorPointValue=::mitk::PointSet::PointDataType())
::map::core::RegistrationBase * GetRegistration()
MITKMATCHPOINTREGISTRATION_EXPORT ::map::core::continuous::Elements< 3 >::InternalPointSetType::Pointer ConvertPointSetMITKtoMAP(const mitk::PointSet::DataType *mitkSet)
::map::core::RegistrationBase RegistrationType
MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType *input, const RegistrationType *registration, bool throwOnOutOfInputAreaError=false, const double &paddingValue=0, const ResultImageGeometryType *resultGeometry=nullptr, bool throwOnMappingError=true, const double &errorValue=0, mitk::ImageMappingInterpolator::Type interpolatorType=mitk::ImageMappingInterpolator::Linear)