Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add detached vtkIECTransformLogic library to SlicerRT superbuild #254

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Beams/Logic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ set(${KIT}_INCLUDE_DIRECTORIES
${SlicerRtCommon_INCLUDE_DIRS}
${vtkSlicerBeamsModuleMRML_INCLUDE_DIRS}
${vtkSlicerSubjectHierarchyModuleLogic_INCLUDE_DIRS}
${vtkIECTransformLogic_INCLUDE_DIRS}
)

set(${KIT}_SRCS
vtkSlicer${MODULE_NAME}ModuleLogic.cxx
vtkSlicer${MODULE_NAME}ModuleLogic.h
vtkSlicerIECTransformLogic.cxx
vtkSlicerIECTransformLogic.h
vtkSlicerMLCPositionLogic.cxx
vtkSlicerMLCPositionLogic.h
)

SET (${KIT}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${vtkSlicerBeamsModuleMRML_INCLUDE_DIRS} CACHE INTERNAL "" FORCE)
SET (${KIT}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${vtkSlicerBeamsModuleMRML_INCLUDE_DIRS} ${vtkIECTransformLogic_INCLUDE_DIRS} CACHE INTERNAL "" FORCE)

find_package(vtkIECTransformLogic REQUIRED)

set(${KIT}_TARGET_LIBRARIES
vtkSlicer${MODULE_NAME}ModuleMRML
Expand All @@ -28,8 +29,10 @@ set(${KIT}_TARGET_LIBRARIES
vtkSlicerSubjectHierarchyModuleLogic
${ITK_LIBRARIES}
${VTK_LIBRARIES}
vtkIECTransformLogic
)


#-----------------------------------------------------------------------------
SlicerMacroBuildModuleLogic(
NAME ${KIT}
Expand All @@ -38,4 +41,4 @@ SlicerMacroBuildModuleLogic(
SRCS ${${KIT}_SRCS}
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
)

19 changes: 9 additions & 10 deletions Beams/Logic/vtkSlicerBeamsModuleLogic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

// Beams includes
#include "vtkSlicerBeamsModuleLogic.h"
#include "vtkSlicerIECTransformLogic.h"
#include "vtkSlicerMLCPositionLogic.h"

// SlicerRT includes
Expand All @@ -46,7 +45,7 @@ vtkStandardNewMacro(vtkSlicerBeamsModuleLogic);
//----------------------------------------------------------------------------
vtkSlicerBeamsModuleLogic::vtkSlicerBeamsModuleLogic()
: MLCPositionLogic(vtkSlicerMLCPositionLogic::New())
, IECLogic(vtkSlicerIECTransformLogic::New())
, IECLogic(vtkIECTransformLogic::New())
{
}

Expand Down Expand Up @@ -172,7 +171,7 @@ void vtkSlicerBeamsModuleLogic::OnMRMLSceneEndImport()
}

//---------------------------------------------------------------------------
void vtkSlicerBeamsModuleLogic::SetIECLogic(vtkSlicerIECTransformLogic* iecLogic)
void vtkSlicerBeamsModuleLogic::SetIECLogic(vtkIECTransformLogic* iecLogic)
{
if (iecLogic == nullptr)
{
Expand All @@ -183,7 +182,7 @@ void vtkSlicerBeamsModuleLogic::SetIECLogic(vtkSlicerIECTransformLogic* iecLogic
this->IECLogic->Delete();
this->IECLogic = nullptr;

vtkSetObjectBodyMacro(IECLogic, vtkSlicerIECTransformLogic, iecLogic);
vtkSetObjectBodyMacro(IECLogic, vtkIECTransformLogic, iecLogic);
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -361,7 +360,7 @@ void vtkSlicerBeamsModuleLogic::UpdateBeamTransform(vtkMRMLRTBeamNode* beamNode,
this->UpdateIECTransformsFromBeam(beamNode, isocenter);

vtkNew<vtkGeneralTransform> beamGeneralTransform;
this->IECLogic->GetTransformBetween(vtkSlicerIECTransformLogic::Collimator, vtkSlicerIECTransformLogic::RAS, beamGeneralTransform, true);
this->IECLogic->GetTransformBetween(vtkIECTransformLogic::Collimator, vtkIECTransformLogic::RAS, beamGeneralTransform, true);

// Convert general transform to linear
// This call also makes hard copy of the transform so that it doesn't change when other beam transforms change
Expand Down Expand Up @@ -406,7 +405,7 @@ void vtkSlicerBeamsModuleLogic::UpdateIECTransformsFromBeam(vtkMRMLRTBeamNode* b

//-----------------------------------------------------------------------------
void vtkSlicerBeamsModuleLogic::UpdateRASRelatedTransforms(
vtkSlicerIECTransformLogic* iecLogic/*=nullptr*/, vtkMRMLRTPlanNode* planNode/*=nullptr*/, double* isocenter/*=nullptr*/, bool transformForBeam/*=false*/)
vtkIECTransformLogic* iecLogic/*=nullptr*/, vtkMRMLRTPlanNode* planNode/*=nullptr*/, double* isocenter/*=nullptr*/, bool transformForBeam/*=false*/)
{
if (!this->GetMRMLScene())
{
Expand All @@ -422,7 +421,7 @@ void vtkSlicerBeamsModuleLogic::UpdateRASRelatedTransforms(
// Do the same for the RAS to Patient transform as well.
vtkNew<vtkTransform> fixedReferenceToRASTransformBeamComponent;
vtkTransform* rasToPatientReferenceTransform = iecLogic->GetElementaryTransformBetween(
vtkSlicerIECTransformLogic::RAS, vtkSlicerIECTransformLogic::Patient);
vtkIECTransformLogic::RAS, vtkIECTransformLogic::Patient);
if (rasToPatientReferenceTransform == nullptr)
{
vtkErrorMacro("UpdateRASRelatedTransforms: Failed to find RAS related transforms in the IEC logic");
Expand Down Expand Up @@ -477,7 +476,7 @@ void vtkSlicerBeamsModuleLogic::UpdateRASRelatedTransforms(
// Set up concatenation for final fixed reference to RAS transform
vtkNew<vtkGeneralTransform> tableTopToTableTopEccentricRotationGeneralTransform;
iecLogic->GetTransformBetween(
vtkSlicerIECTransformLogic::TableTop, vtkSlicerIECTransformLogic::TableTopEccentricRotation, tableTopToTableTopEccentricRotationGeneralTransform, transformForBeam);
vtkIECTransformLogic::TableTop, vtkIECTransformLogic::TableTopEccentricRotation, tableTopToTableTopEccentricRotationGeneralTransform, transformForBeam);
vtkNew<vtkTransform> tableTopToTableTopEccentricRotationLinearTransform;
if (!vtkMRMLTransformNode::IsGeneralTransformLinear(tableTopToTableTopEccentricRotationGeneralTransform, tableTopToTableTopEccentricRotationLinearTransform))
{
Expand All @@ -487,7 +486,7 @@ void vtkSlicerBeamsModuleLogic::UpdateRASRelatedTransforms(

vtkNew<vtkGeneralTransform> patientSupportRotationToFixedReferenceGeneralTransform;
iecLogic->GetTransformBetween(
vtkSlicerIECTransformLogic::PatientSupportRotation, vtkSlicerIECTransformLogic::FixedReference, patientSupportRotationToFixedReferenceGeneralTransform, transformForBeam);
vtkIECTransformLogic::PatientSupportRotation, vtkIECTransformLogic::FixedReference, patientSupportRotationToFixedReferenceGeneralTransform, transformForBeam);
vtkNew<vtkTransform> patientSupportRotationToFixedReferenceLinearTransform;
if (!vtkMRMLTransformNode::IsGeneralTransformLinear(patientSupportRotationToFixedReferenceGeneralTransform, patientSupportRotationToFixedReferenceLinearTransform))
{
Expand All @@ -504,6 +503,6 @@ void vtkSlicerBeamsModuleLogic::UpdateRASRelatedTransforms(

// Update fixed reference to RAS transform in IEC logic
vtkTransform* fixedReferenceToRASTransform = iecLogic->GetElementaryTransformBetween(
vtkSlicerIECTransformLogic::FixedReference, vtkSlicerIECTransformLogic::RAS);
vtkIECTransformLogic::FixedReference, vtkIECTransformLogic::RAS);
fixedReferenceToRASTransform->DeepCopy(fixedReferenceToRASTransformNew);
}
12 changes: 7 additions & 5 deletions Beams/Logic/vtkSlicerBeamsModuleLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
// Slicer includes
#include "vtkSlicerModuleLogic.h"

// IEC Logic include
#include <vtkIECTransformLogic.h>

// Beams includes
#include "vtkSlicerBeamsModuleLogicExport.h"
#include "vtkMRMLRTBeamNode.h"
#include "vtkSlicerIECTransformLogic.h"

// VTK includes
#include <vtkNew.h>
Expand Down Expand Up @@ -77,14 +79,14 @@ class VTK_SLICER_BEAMS_LOGIC_EXPORT vtkSlicerBeamsModuleLogic : public vtkSlicer
/// \param planNode: Plan node to get the isocenter position from
/// \param isocenter: Option to set any isocenter for dynamic beams
/// \param transformForBeam: calculate dynamic transformation for beam model or other models. False by default.
void UpdateRASRelatedTransforms(vtkSlicerIECTransformLogic* iecLogic=nullptr, vtkMRMLRTPlanNode* planNode=nullptr, double* isocenter=nullptr, bool transformForBeam=false);
void UpdateRASRelatedTransforms(vtkIECTransformLogic* iecLogic=nullptr, vtkMRMLRTPlanNode* planNode=nullptr, double* isocenter=nullptr, bool transformForBeam=false);

public:
vtkGetObjectMacro(MLCPositionLogic, vtkSlicerMLCPositionLogic);
vtkGetObjectMacro(IECLogic, vtkSlicerIECTransformLogic);
vtkGetObjectMacro(IECLogic, vtkIECTransformLogic);

/// Possibility to use an external IEC logic. This is useful for testing.
void SetIECLogic(vtkSlicerIECTransformLogic* iecLogic);
void SetIECLogic(vtkIECTransformLogic* iecLogic);

protected:
vtkSlicerBeamsModuleLogic();
Expand All @@ -108,7 +110,7 @@ class VTK_SLICER_BEAMS_LOGIC_EXPORT vtkSlicerBeamsModuleLogic : public vtkSlicer
vtkSlicerMLCPositionLogic* MLCPositionLogic;

private:
vtkSlicerIECTransformLogic* IECLogic;
vtkIECTransformLogic* IECLogic;
};

#endif
Loading