Skip to content

Commit

Permalink
ENH: Pull request #124 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Colonel committed Jan 13, 2020
1 parent 2faa5b4 commit 70da8e0
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 44 deletions.
7 changes: 7 additions & 0 deletions Beams/MRML/vtkMRMLRTBeamNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,13 @@ void vtkMRMLRTBeamNode::CreateBeamPolyData(vtkPolyData* beamModelPolyData/*=null
}
}

//---------------------------------------------------------------------------
vtkPolyData* vtkMRMLRTBeamNode::CreateMultiLeafCollimatorPolyData()
{
//TODO: Create beam limiting device poly data here
return nullptr;
}

//---------------------------------------------------------------------------
void vtkMRMLRTBeamNode::RequestCloning()
{
Expand Down
3 changes: 3 additions & 0 deletions Beams/MRML/vtkMRMLRTBeamNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class VTK_SLICER_BEAMS_MODULE_MRML_EXPORT vtkMRMLRTBeamNode : public vtkMRMLMode
/// Only creates it if missing
virtual void CreateDefaultTransformNode();

/// Create beam limiting device (MLC and jaws) polydata for model node
virtual vtkPolyData* CreateMultiLeafCollimatorPolyData();

/// Create transform node that places the beam poly data in the right position based on geometry.
/// Always creates a new transform node.
virtual void CreateNewBeamTransformNode();
Expand Down
7 changes: 7 additions & 0 deletions Beams/MRML/vtkMRMLRTIonBeamNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ void vtkMRMLRTIonBeamNode::CreateNewBeamTransformNode()
Superclass::CreateNewBeamTransformNode();
}

//---------------------------------------------------------------------------
vtkPolyData* vtkMRMLRTIonBeamNode::CreateMultiLeafCollimatorPolyData()
{
//TODO: Create beam limiting device poly data here
return nullptr;
}

//----------------------------------------------------------------------------
void vtkMRMLRTIonBeamNode::SetVSAD( double xComponent, double yComponent)
{
Expand Down
3 changes: 3 additions & 0 deletions Beams/MRML/vtkMRMLRTIonBeamNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class VTK_SLICER_BEAMS_MODULE_MRML_EXPORT vtkMRMLRTIonBeamNode : public vtkMRMLR
/// Only creates it if missing
void CreateDefaultTransformNode() override;

/// Create beam limiting device (MLC and jaws) polydata for model node
vtkPolyData* CreateMultiLeafCollimatorPolyData() override;

/// Create transform node that places the beam poly data in the right position based on geometry.
/// Always creates a new transform node.
void CreateNewBeamTransformNode() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ bool vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::LoadExternalBeamPlan(
{
unsigned int dicomBeamNumber = rtReader->GetBeamNumberForIndex(beamIndex);
const char* beamName = rtReader->GetBeamName(dicomBeamNumber);
unsigned int nofCointrolPoints = rtReader->GetNumberOfControlPoints(dicomBeamNumber);
unsigned int nofCointrolPoints = rtReader->GetBeamNumberOfControlPoints(dicomBeamNumber);

for ( unsigned int cointrolPointIndex = 0; cointrolPointIndex < nofCointrolPoints; ++cointrolPointIndex)
{
Expand Down Expand Up @@ -863,17 +863,17 @@ bool vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::LoadExternalBeamPlan(

// Set beam geometry parameters from DICOM
double jawPositions[2][2] = {{0.0, 0.0},{0.0, 0.0}};
if (rtReader->GetControlPointJawPositions( dicomBeamNumber, cointrolPointIndex, jawPositions))
if (rtReader->GetBeamControlPointJawPositions( dicomBeamNumber, cointrolPointIndex, jawPositions))
{
beamNode->SetX1Jaw(jawPositions[0][0]);
beamNode->SetX2Jaw(jawPositions[0][1]);
beamNode->SetY1Jaw(jawPositions[1][0]);
beamNode->SetY2Jaw(jawPositions[1][1]);
}

beamNode->SetGantryAngle(rtReader->GetControlPointGantryAngle( dicomBeamNumber, cointrolPointIndex));
beamNode->SetCollimatorAngle(rtReader->GetControlPointBeamLimitingDeviceAngle( dicomBeamNumber, cointrolPointIndex));
beamNode->SetCouchAngle(rtReader->GetControlPointPatientSupportAngle( dicomBeamNumber, cointrolPointIndex));
beamNode->SetGantryAngle(rtReader->GetBeamControlPointGantryAngle( dicomBeamNumber, cointrolPointIndex));
beamNode->SetCollimatorAngle(rtReader->GetBeamControlPointBeamLimitingDeviceAngle( dicomBeamNumber, cointrolPointIndex));
beamNode->SetCouchAngle(rtReader->GetBeamControlPointPatientSupportAngle( dicomBeamNumber, cointrolPointIndex));

// SAD for RTPlan, source to beam limiting devices (Jaws, MLC)
if (beamNode && !ionBeamNode)
Expand All @@ -892,7 +892,7 @@ bool vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::LoadExternalBeamPlan(
ionBeamNode->SetIsocenterToJawsDistanceX(rtReader->GetBeamIsocenterToJawsDistanceX(dicomBeamNumber));
ionBeamNode->SetIsocenterToJawsDistanceY(rtReader->GetBeamIsocenterToJawsDistanceY(dicomBeamNumber));
ionBeamNode->SetIsocenterToMultiLeafCollimatorDistance(rtReader->GetBeamIsocenterToMultiLeafCollimatorDistance(dicomBeamNumber));
bool res = rtReader->GetControlPointScanningSpotSize( dicomBeamNumber,
bool res = rtReader->GetBeamControlPointScanningSpotSize( dicomBeamNumber,
cointrolPointIndex, ScanSpotSize);
if (res)
{
Expand All @@ -901,7 +901,7 @@ bool vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::LoadExternalBeamPlan(
}

// Set isocenter to parent plan
double* isocenter = rtReader->GetControlPointIsocenterPositionRas( dicomBeamNumber,
double* isocenter = rtReader->GetBeamControlPointIsocenterPositionRas( dicomBeamNumber,
cointrolPointIndex);
planNode->SetIsocenterSpecification(vtkMRMLRTPlanNode::ArbitraryPoint);
if (beamIndex == 0)
Expand Down Expand Up @@ -934,7 +934,7 @@ bool vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::LoadExternalBeamPlan(
vtkMRMLTableNode* mlcTableNode = nullptr;
vtkMRMLDoubleArrayNode* mlcArrayNode = nullptr;
// Check MLC
const char* mlcName = rtReader->GetControlPointMultiLeafCollimatorPositions( dicomBeamNumber,
const char* mlcName = rtReader->GetBeamControlPointMultiLeafCollimatorPositions( dicomBeamNumber,
cointrolPointIndex, boundaries, positions);
if (mlcName)
{
Expand All @@ -957,7 +957,7 @@ bool vtkSlicerDicomRtImportExportModuleLogic::vtkInternal::LoadExternalBeamPlan(
if (ionBeamNode)
{
std::vector<float> positions, weights;
bool result = rtReader->GetControlPointScanSpotParameters( dicomBeamNumber,
bool result = rtReader->GetBeamControlPointScanSpotParameters( dicomBeamNumber,
cointrolPointIndex, positions, weights);
if (result)
{
Expand Down
49 changes: 24 additions & 25 deletions DicomRtImportExport/Logic/vtkSlicerDicomRtReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ void vtkSlicerDicomRtReader::vtkInternal::LoadRTIonPlan(DcmDataset* dataset)
controlPoint.CumulativeMetersetWeight = cumulativeMetersetWeight;
}

if (beamEntry.ScanMode == "MODULATED")
if (!beamEntry.ScanMode.compare("MODULATED") || !beamEntry.ScanMode.compare("MODULATED_SPEC"))
{
OFString scanSpotTuneId("");
dataCondition = controlPointItem.getScanSpotTuneID(scanSpotTuneId);
Expand Down Expand Up @@ -1751,7 +1751,7 @@ void vtkSlicerDicomRtReader::vtkInternal::LoadRTIonPlan(DcmDataset* dataset)
dataCondition = controlPointItem.getScanSpotPositionMap( y, 2 * i + 1);
if (dataCondition.good())
{
controlPoint.ScanSpotPositionMap.at(2 * i + 1) = float(x);
controlPoint.ScanSpotPositionMap.at(2 * i + 1) = float(y);
}

dataCondition = controlPointItem.getScanSpotMetersetWeights( w, i);
Expand Down Expand Up @@ -2627,10 +2627,9 @@ int vtkSlicerDicomRtReader::GetNumberOfBeams()
}

//----------------------------------------------------------------------------
unsigned int vtkSlicerDicomRtReader::GetNumberOfControlPoints(unsigned int beamNumber)
unsigned int vtkSlicerDicomRtReader::GetBeamNumberOfControlPoints(unsigned int beamNumber)
{
vtkInternal::BeamEntry* beam = this->Internal->FindBeamByNumber(beamNumber);

if (beam)
{
return (beam->ControlPointSequenceVector.size() > 1) ? beam->ControlPointSequenceVector.size() : 0;
Expand All @@ -2655,10 +2654,10 @@ const char* vtkSlicerDicomRtReader::GetBeamName(unsigned int beamNumber)
return (beam->Name.empty() ? vtkSlicerRtCommon::DICOMRTIMPORT_NO_NAME : beam->Name).c_str();
}

//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- DEPRICATED
double* vtkSlicerDicomRtReader::GetBeamIsocenterPositionRas(unsigned int beamNumber)
{
return GetControlPointIsocenterPositionRas( beamNumber, 0);
return GetBeamControlPointIsocenterPositionRas( beamNumber, 0);
}

//----------------------------------------------------------------------------
Expand All @@ -2684,7 +2683,7 @@ const char* vtkSlicerDicomRtReader::GetBeamRadiationType(unsigned int beamNumber
}

//----------------------------------------------------------------------------
double vtkSlicerDicomRtReader::GetControlPointNominalBeamEnergy( unsigned int beamNumber,
double vtkSlicerDicomRtReader::GetBeamControlPointNominalBeamEnergy( unsigned int beamNumber,
unsigned int controlPointIndex)
{
vtkInternal::BeamEntry* beam=this->Internal->FindBeamByNumber(beamNumber);
Expand All @@ -2697,7 +2696,7 @@ double vtkSlicerDicomRtReader::GetControlPointNominalBeamEnergy( unsigned int be
}

//----------------------------------------------------------------------------
double* vtkSlicerDicomRtReader::GetControlPointIsocenterPositionRas( unsigned int beamNumber,
double* vtkSlicerDicomRtReader::GetBeamControlPointIsocenterPositionRas( unsigned int beamNumber,
unsigned int controlPointIndex)
{
vtkInternal::BeamEntry* beam = this->Internal->FindBeamByNumber(beamNumber);
Expand Down Expand Up @@ -2733,14 +2732,14 @@ double* vtkSlicerDicomRtReader::GetBeamVirtualSourceAxisDistance(unsigned int be
return beam->SourceAxisDistance.data();
}

//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- DEPRICATED
double vtkSlicerDicomRtReader::GetBeamGantryAngle(unsigned int beamNumber)
{
return GetControlPointGantryAngle( beamNumber, 0);
return GetBeamControlPointGantryAngle( beamNumber, 0);
}

//----------------------------------------------------------------------------
double vtkSlicerDicomRtReader::GetControlPointGantryAngle( unsigned int beamNumber,
double vtkSlicerDicomRtReader::GetBeamControlPointGantryAngle( unsigned int beamNumber,
unsigned int controlPointIndex)
{
vtkInternal::BeamEntry* beam = this->Internal->FindBeamByNumber(beamNumber);
Expand All @@ -2762,14 +2761,14 @@ double vtkSlicerDicomRtReader::GetControlPointGantryAngle( unsigned int beamNumb
return 0.0;
}

//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- DEPRICATED
double vtkSlicerDicomRtReader::GetBeamPatientSupportAngle(unsigned int beamNumber)
{
return GetControlPointPatientSupportAngle( beamNumber, 0);
return GetBeamControlPointPatientSupportAngle( beamNumber, 0);
}

//----------------------------------------------------------------------------
double vtkSlicerDicomRtReader::GetControlPointPatientSupportAngle( unsigned int beamNumber,
double vtkSlicerDicomRtReader::GetBeamControlPointPatientSupportAngle( unsigned int beamNumber,
unsigned int controlPointIndex)
{
vtkInternal::BeamEntry* beam = this->Internal->FindBeamByNumber(beamNumber);
Expand All @@ -2791,14 +2790,14 @@ double vtkSlicerDicomRtReader::GetControlPointPatientSupportAngle( unsigned int
return 0.0;
}

//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- DEPRICATED
double vtkSlicerDicomRtReader::GetBeamBeamLimitingDeviceAngle(unsigned int beamNumber)
{
return GetControlPointBeamLimitingDeviceAngle( beamNumber, 0);
return GetBeamControlPointBeamLimitingDeviceAngle( beamNumber, 0);
}

//----------------------------------------------------------------------------
double vtkSlicerDicomRtReader::GetControlPointBeamLimitingDeviceAngle( unsigned int beamNumber,
double vtkSlicerDicomRtReader::GetBeamControlPointBeamLimitingDeviceAngle( unsigned int beamNumber,
unsigned int controlPointIndex)
{
vtkInternal::BeamEntry* beam = this->Internal->FindBeamByNumber(beamNumber);
Expand All @@ -2820,14 +2819,14 @@ double vtkSlicerDicomRtReader::GetControlPointBeamLimitingDeviceAngle( unsigned
return 0.0;
}

//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- DEPRICATED
void vtkSlicerDicomRtReader::GetBeamLeafJawPositions(unsigned int beamNumber, double jawPositions[2][2])
{
GetControlPointJawPositions( beamNumber, 0, jawPositions);
GetBeamControlPointJawPositions( beamNumber, 0, jawPositions);
}

//----------------------------------------------------------------------------
bool vtkSlicerDicomRtReader::GetControlPointJawPositions( unsigned int beamNumber,
bool vtkSlicerDicomRtReader::GetBeamControlPointJawPositions( unsigned int beamNumber,
unsigned int controlPointIndex, double jawPositions[2][2])
{
vtkInternal::BeamEntry* beam = this->Internal->FindBeamByNumber(beamNumber);
Expand All @@ -2853,16 +2852,16 @@ bool vtkSlicerDicomRtReader::GetControlPointJawPositions( unsigned int beamNumbe
return false;
}

//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- DEPRICATED
const char* vtkSlicerDicomRtReader::GetBeamMultiLeafCollimatorPositions( unsigned int beamNumber,
std::vector<double>& pairBoundaries, std::vector<double>& leafPositions)
{
return GetControlPointMultiLeafCollimatorPositions( beamNumber, 0,
return GetBeamControlPointMultiLeafCollimatorPositions( beamNumber, 0,
pairBoundaries, leafPositions);
}

//----------------------------------------------------------------------------
const char* vtkSlicerDicomRtReader::GetControlPointMultiLeafCollimatorPositions( unsigned int beamNumber,
const char* vtkSlicerDicomRtReader::GetBeamControlPointMultiLeafCollimatorPositions( unsigned int beamNumber,
unsigned int controlPointIndex, std::vector<double>& pairBoundaries,
std::vector<double>& leafPositions)
{
Expand Down Expand Up @@ -2912,7 +2911,7 @@ const char* vtkSlicerDicomRtReader::GetControlPointMultiLeafCollimatorPositions(
}

//----------------------------------------------------------------------------
bool vtkSlicerDicomRtReader::GetControlPointScanSpotParameters( unsigned int beamNumber,
bool vtkSlicerDicomRtReader::GetBeamControlPointScanSpotParameters( unsigned int beamNumber,
unsigned int controlPointIndex, std::vector<float>& positionMap,
std::vector<float>& metersetWeights)
{
Expand Down Expand Up @@ -2958,7 +2957,7 @@ bool vtkSlicerDicomRtReader::GetControlPointScanSpotParameters( unsigned int bea
}

//----------------------------------------------------------------------------
bool vtkSlicerDicomRtReader::GetControlPointScanningSpotSize( unsigned int beamNumber,
bool vtkSlicerDicomRtReader::GetBeamControlPointScanningSpotSize( unsigned int beamNumber,
unsigned int controlPointIndex, std::array< float, 2 >& ScanSpotSize)
{
vtkInternal::BeamEntry* beam = this->Internal->FindBeamByNumber(beamNumber);
Expand Down
20 changes: 10 additions & 10 deletions DicomRtImportExport/Logic/vtkSlicerDicomRtReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class VTK_SLICER_DICOMRTIMPORTEXPORT_LOGIC_EXPORT vtkSlicerDicomRtReader : publi

/// Get number of control points for a given beams
/// \result >= 2 if number of control points are valid, 0 otherwise
unsigned int GetNumberOfControlPoints(unsigned int beamNumber);
unsigned int GetBeamNumberOfControlPoints(unsigned int beamNumber);

/// Get beam number (as defined in DICOM) for a beam index (that is between 0 and numberOfBeams-1)
unsigned int GetBeamNumberForIndex(unsigned int index);
Expand All @@ -98,11 +98,11 @@ class VTK_SLICER_DICOMRTIMPORTEXPORT_LOGIC_EXPORT vtkSlicerDicomRtReader : publi
const char* GetBeamRadiationType(unsigned int beamNumber);

/// Get isocenter for a given control point of a beam
double* GetControlPointIsocenterPositionRas( unsigned int beamNumber,
double* GetBeamControlPointIsocenterPositionRas( unsigned int beamNumber,
unsigned int controlPointIndex);

/// Get nominal beam energy for a given control point of a beam
double GetControlPointNominalBeamEnergy( unsigned int beamNumber,
double GetBeamControlPointNominalBeamEnergy( unsigned int beamNumber,
unsigned int controlPoint);

/// Get source axis distance for a given beam
Expand All @@ -116,21 +116,21 @@ class VTK_SLICER_DICOMRTIMPORTEXPORT_LOGIC_EXPORT vtkSlicerDicomRtReader : publi
double GetBeamGantryAngle(unsigned int beamNumber); // DEPRICATED

/// Get gantry angle for a given control point of a beam
double GetControlPointGantryAngle( unsigned int beamNumber,
double GetBeamControlPointGantryAngle( unsigned int beamNumber,
unsigned int controlPoint);

/// Get beam patient support (couch) angle for a given beam
double GetBeamPatientSupportAngle(unsigned int beamNumber); // DEPRICATED

/// Get patient support (couch) angle for a given control point of a beam
double GetControlPointPatientSupportAngle( unsigned int beamNumber,
double GetBeamControlPointPatientSupportAngle( unsigned int beamNumber,
unsigned int controlPoint);

/// Get beam beam limiting device (collimator) angle for a given beam
double GetBeamBeamLimitingDeviceAngle(unsigned int beamNumber); // DEPRICATED

/// Get beam limiting device (collimator) angle for a given control point of a beam
double GetControlPointBeamLimitingDeviceAngle( unsigned int beamNumber,
double GetBeamControlPointBeamLimitingDeviceAngle( unsigned int beamNumber,
unsigned int controlPoint);

/// Get beam leaf jaw positions for a given beam
Expand All @@ -140,7 +140,7 @@ class VTK_SLICER_DICOMRTIMPORTEXPORT_LOGIC_EXPORT vtkSlicerDicomRtReader : publi
/// Get jaw positions for a given control point of a beam
/// \param jawPositions Array in which the jaw positions are copied
/// \return true if jaw positions are valid, false otherwise
bool GetControlPointJawPositions( unsigned int beamNumber,
bool GetBeamControlPointJawPositions( unsigned int beamNumber,
unsigned int controlPoint, double jawPositions[2][2]);

/// Get MLC leaves boundaries & leaves positions opening for a given beam
Expand All @@ -155,14 +155,14 @@ class VTK_SLICER_DICOMRTIMPORTEXPORT_LOGIC_EXPORT vtkSlicerDicomRtReader : publi
/// \param positionMap Array in which the raw position map are copied
/// \param metersetWeights Array in which the raw meterset weights are copied
/// \return true if data is valid, false otherwise
bool GetControlPointScanSpotParameters( unsigned int beamNumber,
bool GetBeamControlPointScanSpotParameters( unsigned int beamNumber,
unsigned int controlPointIndex, std::vector<float>& positionMap,
std::vector<float>& metersetWeights);

/// Get Scan spot size for a given control point of a modulated ion beam
/// \param ScanSpotSize Array in which the raw scanning spot size is copied
/// \return true if data is valid, false otherwise
bool GetControlPointScanningSpotSize( unsigned int beamNumber,
bool GetBeamControlPointScanningSpotSize( unsigned int beamNumber,
unsigned int controlPointIndex, std::array< float, 2 >& ScanSpotSize);

/// Get source to beam limiting device distance (MLC) for a given beam of RTPlan
Expand Down Expand Up @@ -190,7 +190,7 @@ class VTK_SLICER_DICOMRTIMPORTEXPORT_LOGIC_EXPORT vtkSlicerDicomRtReader : publi
/// \param pairBoundaries Array in which the raw leaves boundaries are copied
/// \param leafPositions Array in which the raw leaf positions are copied
/// \return "MLCX" or "MLCY" if data is valid, nullptr otherwise
const char* GetControlPointMultiLeafCollimatorPositions( unsigned int beamNumber,
const char* GetBeamControlPointMultiLeafCollimatorPositions( unsigned int beamNumber,
unsigned int controlPoint, std::vector<double>& pairBoundaries,
std::vector<double>& leafPositions);

Expand Down

0 comments on commit 70da8e0

Please sign in to comment.