forked from Slicer/Slicer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: WIP: Issue Slicer#7179 Curved Planar Reformation
This code is WIP and does not compile! Create vtkMRMLScalarVectorDWIVolumeResampler, a subclass of vtkMRMLAbstractVolumeResampler, so that vtkMRMLApplicationLogic->ResampleVolume() can be used. The compile problems include that vtkMRMLCommandLineModuleNode.h, vtkSlicerCLIModuleLogic.h, and vtkSlicerModuleLogic.h cannot be found from Libs/MRML/Logic. Also, windowed sinc functions do not appear to be accessible from Libs/MRML/Logic, and have been commented out.
- Loading branch information
Showing
3 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
Libs/MRML/Logic/vtkMRMLScalarVectorDWIVolumeResampler.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/*============================================================================== | ||
Program: 3D Slicer | ||
Copyright(c) Kitware Inc. | ||
See COPYRIGHT.txt | ||
or http://www.slicer.org/copyright/copyright.txt for details. | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
|
||
#include "vtkMRMLAbstractVolumeResampler.h" | ||
#include "vtkMRMLScalarVectorDWIVolumeResampler.h" | ||
#include "vtkMRMLTransformNode.h" | ||
#include "vtkMRMLVolumeNode.h" | ||
|
||
// TODO: Replace these with include files | ||
class vtkMRMLCommandLineModuleNode; | ||
class vtkSlicerCLIModuleLogic; | ||
class vtkSlicerModuleLogic; | ||
|
||
//---------------------------------------------------------------------------- | ||
void vtkMRMLScalarVectorDWIVolumeResampler::PrintSelf(ostream & os, vtkIndent indent) | ||
{ | ||
this->Superclass::PrintSelf(os, indent); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
bool vtkMRMLScalarVectorDWIVolumeResampler::Resample(vtkMRMLVolumeNode * inputVolume, | ||
vtkMRMLVolumeNode * outputVolume, | ||
vtkMRMLTransformNode * resamplingTransform, | ||
vtkMRMLVolumeNode * referenceVolume, | ||
int interpolationType, | ||
int windowedSincFunction, | ||
const ResamplingParameters & resamplingParameter) | ||
{ | ||
vtkSlicerCLIModuleLogic* resampleLogic = | ||
vtkSlicerCLIModuleLogic::SafeDownCast(vtkSlicerModuleLogic::GetModuleLogic("ResampleScalarVectorDWIVolume")); | ||
if (!resampleLogic) | ||
{ | ||
vtkErrorMacro("vtkMRMLScalarVectorDWIVolumeResampler: resample logic is not set"); | ||
return false; | ||
} | ||
|
||
// TODO: Which of these? | ||
# if 0 | ||
vtkSmartPointer<vtkMRMLCommandLineModuleNode> cmdNode = vtkSmartPointer<vtkMRMLCommandLineModuleNode>::New(); | ||
resampleLogic->GetMRMLScene()->AddNode(cmdNode); | ||
#else | ||
vtkMRMLCommandLineModuleNode* cmdNode = resampleLogic->CreateNodeInScene(); | ||
if (cmdNode == nullptr) | ||
{ | ||
vtkErrorMacro("vtkMRMLScalarVectorDWIVolumeResampler: failed to create command line module node"); | ||
return false; | ||
} | ||
#endif | ||
|
||
// Also look at Modules/Loadable/CropVolume/Logic/vtkSlicerCropVolumeLogic.cxx | ||
cmdNode->SetParameterAsString("inputVolume", inputVolume->GetID()); | ||
cmdNode->SetParameterAsString("outputVolume", outputVolume->GetID()); | ||
cmdNode->SetParameterAsString("transformationFile", resamplingTransform->GetID()); | ||
cmdNode->SetParameterAsString("referenceVolume", referenceVolume->GetID()); | ||
switch (interpolationType) | ||
{ | ||
case vtkMRMLAbstractVolumeResampler::InterpolationTypeNearestNeighbor: | ||
cmdNode->SetParameterAsString("interpolationType", "nn"); | ||
break; | ||
case vtkMRMLAbstractVolumeResampler::InterpolationTypeLinear: | ||
cmdNode->SetParameterAsString("interpolationType", "linear"); | ||
break; | ||
case vtkMRMLAbstractVolumeResampler::InterpolationTypeWindowedSinc: | ||
cmdNode->SetParameterAsString("interpolationType", "ws"); | ||
break; | ||
case vtkMRMLAbstractVolumeResampler::InterpolationTypeBSpline: | ||
cmdNode->SetParameterAsString("interpolationType", "bs"); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
#if 0 | ||
// TODO: How do we fix this so that it compiles? | ||
static const int RADIUS = 3; | ||
typedef itk::WindowedSincInterpolateImageFunction<InputImageType, RADIUS, itk::Function::HammingWindowFunction<RADIUS> > HammingInterpolatorType; | ||
typedef itk::WindowedSincInterpolateImageFunction<InputImageType, RADIUS, itk::Function::CosineWindowFunction<RADIUS> > CosineInterpolatorType; | ||
typedef itk::WindowedSincInterpolateImageFunction<InputImageType, RADIUS, itk::Function::WelchWindowFunction<RADIUS> > WelchInterpolatorType; | ||
typedef itk::WindowedSincInterpolateImageFunction<InputImageType, RADIUS, itk::Function::LanczosWindowFunction<RADIUS> > LanczosInterpolatorType; | ||
typedef itk::WindowedSincInterpolateImageFunction<InputImageType, RADIUS, itk::Function::BlackmanWindowFunction<RADIUS> > BlackmanInterpolatorType; | ||
|
||
switch (windowedSincFunction) | ||
{ | ||
case WindowedSincFunctionHamming: | ||
resampleLogic->SetInterpolator(HammingInterpolatorType::New()) | ||
break; | ||
case WindowedSincFunctionCosine: | ||
resampleLogic->SetInterpolator(CosineInterpolatorType::New()) | ||
break; | ||
case WindowedSincFunctionWelch: | ||
resampleLogic->SetInterpolator(WelchInterpolatorType::New()) | ||
break; | ||
case WindowedSincFunctionLanczos: | ||
resampleLogic->SetInterpolator(LanczosInterpolatorType::New()) | ||
break; | ||
case WindowedSincFunctionBlackman: | ||
resampleLogic->SetInterpolator(BlackmanInterpolatorType::New()) | ||
break; | ||
default: | ||
break; | ||
} | ||
#endif | ||
|
||
// TODO: What should we do with resamplingParameter? | ||
|
||
resampleLogic->ApplyAndWait(cmdNode, false); | ||
resampleLogic->GetMRMLScene()->RemoveNode(cmdNode); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*============================================================================== | ||
Program: 3D Slicer | ||
Copyright(c) Kitware Inc. | ||
See COPYRIGHT.txt | ||
or http://www.slicer.org/copyright/copyright.txt for details. | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
|
||
#ifndef __vtkMRMLScalarVectorDWIVolumeResampler_h | ||
#define __vtkMRMLScalarVectorDWIVolumeResampler_h | ||
|
||
// MRMLLogic includes | ||
// TODO: If this file gets moved then choose the correct export here and below | ||
#include "vtkMRMLLogicExport.h" | ||
|
||
// MRML includes | ||
#include "vtkMRMLAbstractVolumeResampler.h" | ||
|
||
class VTK_MRML_LOGIC_EXPORT vtkMRMLScalarVectorDWIVolumeResampler : public vtkMRMLAbstractVolumeResampler | ||
{ | ||
public: | ||
vtkTypeMacro(vtkMRMLScalarVectorDWIVolumeResampler, vtkMRMLAbstractVolumeResampler); | ||
void PrintSelf(ostream & os, vtkIndent indent) override; | ||
|
||
virtual bool Resample(vtkMRMLVolumeNode * inputVolume, | ||
vtkMRMLVolumeNode * outputVolume, | ||
vtkMRMLTransformNode * resamplingTransform, | ||
vtkMRMLVolumeNode * referenceVolume, | ||
int interpolationType, | ||
int windowedSincFunction, | ||
const vtkMRMLAbstractVolumeResampler::ResamplingParameters & resamplingParameter); | ||
|
||
protected: | ||
vtkMRMLScalarVectorDWIVolumeResampler() = default; | ||
~vtkMRMLScalarVectorDWIVolumeResampler() override = default; | ||
vtkMRMLScalarVectorDWIVolumeResampler(const vtkMRMLScalarVectorDWIVolumeResampler &) = delete; | ||
void operator=(const vtkMRMLScalarVectorDWIVolumeResampler &) = delete; | ||
}; | ||
|
||
#endif |