namespace clitk {
- //--------------------------------------------------------------------
- class DicomRT_Contour {
-
- public:
- DicomRT_Contour();
- ~DicomRT_Contour();
-
- void Print(std::ostream & os = std::cout) const;
- bool Read(gdcm::SQItem * item);
- vtkPolyData * GetMesh();
- vtkPoints * GetPoints() {return mData;}
- double GetZ() const {return mZ;}
-
- protected:
- void ComputeMesh();
- unsigned int mNbOfPoints;
- std::string mType;
- vtkPoints * mData;
- vtkPolyData * mMesh;
- bool mMeshIsUpToDate;
- ///Z location of the contour
- double mZ;
-
- };
- //--------------------------------------------------------------------
+//--------------------------------------------------------------------
+class DicomRT_Contour : public itk::LightObject{
+
+public:
+ typedef DicomRT_Contour Self;
+ typedef itk::SmartPointer<Self> Pointer;
+ itkNewMacro(Self);
+
+ void Print(std::ostream & os = std::cout) const;
+ bool Read(gdcm::SQItem * item);
+ vtkPolyData * GetMesh();
+ vtkPoints * GetPoints() {return mData;}
+ double GetZ() const {return mZ;}
+
+protected:
+ void ComputeMesh();
+ unsigned int mNbOfPoints;
+ std::string mType;
+ vtkPoints * mData;
+ vtkPolyData * mMesh;
+ bool mMeshIsUpToDate;
+ ///Z location of the contour
+ double mZ;
+
+private:
+ DicomRT_Contour();
+ ~DicomRT_Contour();
+};
+//--------------------------------------------------------------------
//--------------------------------------------------------------------
clitk::DicomRT_ROI::~DicomRT_ROI()
{
- mImage->Delete();
}
//--------------------------------------------------------------------
bool delta_computed=false;
double last_z=0;
for(gdcm::SQItem* j=contours->GetFirstSQItem(); j!=0; j=contours->GetNextSQItem()) {
- DicomRT_Contour * c = new DicomRT_Contour;
+ DicomRT_Contour::Pointer c = DicomRT_Contour::New();
bool b = c->Read(j);
if (b) {
mListOfContours.push_back(c);
namespace clitk {
- //--------------------------------------------------------------------
- class DicomRT_ROI {
-
- public:
- DicomRT_ROI();
- ~DicomRT_ROI();
+//--------------------------------------------------------------------
+class DicomRT_ROI : public itk::LightObject
+{
+
+public:
+ typedef DicomRT_ROI Self;
+ typedef itk::SmartPointer<Self> Pointer;
+ itkNewMacro(Self);
- void Print(std::ostream & os = std::cout) const;
- void Read(std::map<int, std::string> & rois, gdcm::SQItem * item);
- void SetFromBinaryImage(vvImage * image, int n,
- std::string name,
- std::vector<double> color,
- std::string filename);
+ void Print(std::ostream & os = std::cout) const;
+ void Read(std::map<int, std::string> & rois, gdcm::SQItem * item);
+ void SetFromBinaryImage(vvImage * image, int n,
+ std::string name,
+ std::vector<double> color,
+ std::string filename);
- int GetROINumber() const;
- const std::string & GetName() const;
- const std::string & GetFilename() const;
- const std::vector<double> & GetDisplayColor() const;
- vtkPolyData * GetMesh();
- vvImage * GetImage() const;
+ int GetROINumber() const;
+ const std::string & GetName() const;
+ const std::string & GetFilename() const;
+ const std::vector<double> & GetDisplayColor() const;
+ vtkPolyData * GetMesh();
+ vvImage * GetImage() const;
- void SetDisplayColor(double r, double v, double b);
- std::vector<double> & GetDisplayColor() { return mColor; }
-
- double GetBackgroundValueLabelImage() const;
- void SetBackgroundValueLabelImage(double bg);
-
- double GetForegroundValueLabelImage() const;
- void SetForegroundValueLabelImage(double bg);
-
- void SetImage(vvImage * im);
- DicomRT_Contour* GetContour(int n);
+ void SetDisplayColor(double r, double v, double b);
+ std::vector<double> & GetDisplayColor() { return mColor; }
+
+ double GetBackgroundValueLabelImage() const;
+ void SetBackgroundValueLabelImage(double bg);
+
+ double GetForegroundValueLabelImage() const;
+ void SetForegroundValueLabelImage(double bg);
+
+ void SetImage(vvImage * im);
+ DicomRT_Contour* GetContour(int n);
- double GetContourSpacing() const {return mZDelta;}
-
- protected:
- void ComputeMesh();
- std::string mName;
- std::string mFilename;
- int mNumber;
- std::vector<double> mColor;
- std::vector<DicomRT_Contour*> mListOfContours;
- vtkPolyData * mMesh;
- bool mMeshIsUpToDate;
- vvImage * mImage;
- double mBackgroundValue;
- double mForegroundValue;
- ///Spacing between two contours
- double mZDelta;
- };
- //--------------------------------------------------------------------
+ double GetContourSpacing() const {return mZDelta;}
+
+protected:
+ void ComputeMesh();
+ std::string mName;
+ std::string mFilename;
+ int mNumber;
+ std::vector<double> mColor;
+ std::vector<DicomRT_Contour::Pointer> mListOfContours;
+ vtkPolyData * mMesh;
+ bool mMeshIsUpToDate;
+ vvImage::Pointer mImage;
+ double mBackgroundValue;
+ double mForegroundValue;
+ ///Spacing between two contours
+ double mZDelta;
+
+private:
+ DicomRT_ROI();
+ ~DicomRT_ROI();
+};
+//--------------------------------------------------------------------
} // end namespace clitk
#endif // CLITKDICOMRT_ROI_H
//--------------------------------------------------------------------
clitk::DicomRT_StructureSet::~DicomRT_StructureSet()
{
- for(uint i=0; i<mListOfROI.size(); i++) {
- delete mListOfROI[i];
- }
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
-const std::vector<clitk::DicomRT_ROI*> & clitk::DicomRT_StructureSet::GetListOfROI() const
+const std::vector<clitk::DicomRT_ROI::Pointer> & clitk::DicomRT_StructureSet::GetListOfROI() const
{
return mListOfROI;
}
assert(roi_contour_seq); // TODO error message
int n=0;
for (gdcm::SQItem* r=roi_contour_seq->GetFirstSQItem(); r!=0; r=roi_contour_seq->GetNextSQItem()) {
- DicomRT_ROI * roi = new DicomRT_ROI;
+ DicomRT_ROI::Pointer roi = DicomRT_ROI::New();
roi->Read(mMapOfROIName, r);
mListOfROI.push_back(roi);
mMapOfROIIndex[roi->GetROINumber()] = n;
color.push_back(0);
// Create ROI
- DicomRT_ROI * roi = new DicomRT_ROI;
+ DicomRT_ROI::Pointer roi = DicomRT_ROI::New();
roi->SetFromBinaryImage(im, max, oss.str(), color, n);
mListOfROI.push_back(roi);
mMapOfROIIndex[mListOfROI.size()-1] = max;
namespace clitk {
- //--------------------------------------------------------------------
- class DicomRT_StructureSet {
-
- public:
- DicomRT_StructureSet();
- ~DicomRT_StructureSet();
+//--------------------------------------------------------------------
+class DicomRT_StructureSet : public itk::LightObject{
+
+public:
+ typedef DicomRT_StructureSet Self;
+ typedef itk::SmartPointer<Self> Pointer;
+ itkNewMacro(Self);
- void Print(std::ostream & os = std::cout) const;
- void Read(const std::string & filename);
+ void Print(std::ostream & os = std::cout) const;
+ void Read(const std::string & filename);
- const std::vector<clitk::DicomRT_ROI*> & GetListOfROI() const;
- clitk::DicomRT_ROI * GetROI(int n);
- const std::string & GetStudyID() const;
- const std::string & GetStudyTime() const;
- const std::string & GetStudyDate() const;
- const std::string & GetLabel() const;
- const std::string & GetName() const;
- const std::string & GetDate() const;
- const std::string & GetTime() const;
+ const std::vector<DicomRT_ROI::Pointer> & GetListOfROI() const;
+ clitk::DicomRT_ROI * GetROI(int n);
+ const std::string & GetStudyID() const;
+ const std::string & GetStudyTime() const;
+ const std::string & GetStudyDate() const;
+ const std::string & GetLabel() const;
+ const std::string & GetName() const;
+ const std::string & GetDate() const;
+ const std::string & GetTime() const;
- int AddBinaryImageAsNewROI(vvImage * i, std::string name);
-
- protected:
- std::string mStudyID;
- std::string mStudyTime;
- std::string mStudyDate;
- std::string mLabel;
- std::string mName;
- std::string mDate;
- std::string mTime;
- std::map<int, std::string> mMapOfROIName;
- std::map<int, int> mMapOfROIIndex;
- std::vector<clitk::DicomRT_ROI*> mListOfROI;
+ int AddBinaryImageAsNewROI(vvImage * i, std::string name);
+
+protected:
+ std::string mStudyID;
+ std::string mStudyTime;
+ std::string mStudyDate;
+ std::string mLabel;
+ std::string mName;
+ std::string mDate;
+ std::string mTime;
+ std::map<int, std::string> mMapOfROIName;
+ std::map<int, int> mMapOfROIIndex;
+ std::vector<clitk::DicomRT_ROI::Pointer> mListOfROI;
- };
- //--------------------------------------------------------------------
+private:
+ DicomRT_StructureSet();
+ ~DicomRT_StructureSet();
+};
+//--------------------------------------------------------------------
} // end namespace clitk
#endif // CLITKDICOMRT_STRUCTURESET_H
GGO(clitkDicomRTStruct2BinaryImage, args_info);
// Read and display information
- clitk::DicomRT_StructureSet s;
- s.Read(args_info.input_arg);
- // s.Print(std::cout);
+ clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New();
+ s->Read(args_info.input_arg);
+ // s->Print(std::cout);
// New filter to convert to binary image
clitk::DicomRT_ROI_ConvertToImageFilter filter;
filter.SetCropMaskEnabled(args_info.crop_flag);
filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
if (args_info.roi_arg != -1) {
- filter.SetROI(s.GetROI(args_info.roi_arg));
+ filter.SetROI(s->GetROI(args_info.roi_arg));
filter.SetOutputImageFilename(args_info.output_arg);
filter.Update();
}
else {
- for(unsigned int i=0; i<s.GetListOfROI().size(); i++) {
+ for(unsigned int i=0; i<s->GetListOfROI().size(); i++) {
clitk::DicomRT_ROI_ConvertToImageFilter filter;
filter.SetCropMaskEnabled(args_info.crop_flag);
filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
- std::string name = s.GetListOfROI()[i]->GetName();
- int num = s.GetListOfROI()[i]->GetROINumber();
- filter.SetROI(s.GetListOfROI()[i]);
+ std::string name = s->GetListOfROI()[i]->GetName();
+ int num = s->GetListOfROI()[i]->GetROINumber();
+ filter.SetROI(s->GetListOfROI()[i]);
name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
std::string n = std::string(args_info.output_arg).append
(clitk::toString(num)).append
(name).append
(".mhd");
if (args_info.verbose_flag) {
- std::cout << i << " " << s.GetListOfROI()[i]->GetName() << " num=" << num << " : " << n << std::endl;
+ std::cout << i << " " << s->GetListOfROI()[i]->GetName() << " num=" << num << " : " << n << std::endl;
}
filter.SetOutputImageFilename(n);
filter.Update();
void UpdateImage();
protected:
- clitk::DicomRT_ROI * mROI;
+ clitk::DicomRT_ROI::Pointer mROI;
vvSlicerManager * mSlicerManager;
std::vector<vvImageContour *> mImageContour;
std::vector<vvBinaryImageOverlayActor *> mOverlayActors;
vvToolStructureSetManager::~vvToolStructureSetManager()
{
m_NumberOfTool--;
- mStructureSetActorsList.clear();
- mMapROIToTreeWidget.clear();
-
- /*
- for(uint i=0; i<mStructureSetsList[0]->GetListOfROI().size();i++) {
- DD(i);
- DD(mStructureSetsList[0]->GetROI(i)->GetImage()->GetReferenceCount());
- // mStructureSetsList[0]->GetROI(i)->GetImage()->Delete();
- }
- */
- mStructureSetsList.clear();
- mOpenedBinaryImage.clear();
+ for(unsigned int i=0; i< mStructureSetActorsList.size(); i++)
+ delete mStructureSetActorsList[i];
+
+ for (std::map<clitk::DicomRT_ROI::Pointer, QTreeWidgetItem *>::iterator it = mMapROIToTreeWidget.begin();
+ it!=mMapROIToTreeWidget.end(); it++)
+ delete it->second;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvToolStructureSetManager::UpdateStructureSetInTreeWidget(int index, clitk::DicomRT_StructureSet * s) {
// Insert ROI
- const std::vector<clitk::DicomRT_ROI*> & rois = s->GetListOfROI();
+ const std::vector<clitk::DicomRT_ROI::Pointer> & rois = s->GetListOfROI();
for(unsigned int i=0; i<rois.size(); i++) {
if (mMapROIToTreeWidget.find(rois[i]) == mMapROIToTreeWidget.end())
AddRoiInTreeWidget(rois[i], mTree); // replace mTree with ss if several SS
int index;
if (mCurrentStructureSet == NULL) {
if (mStructureSetsList.size() == 0) { // Create a default SS
- clitk::DicomRT_StructureSet * mStructureSet = new clitk::DicomRT_StructureSet;
+ clitk::DicomRT_StructureSet::Pointer mStructureSet = clitk::DicomRT_StructureSet::New();
index = AddStructureSet(mStructureSet);
}
else { // Get first SS
for(int i=0; i<filename.size(); i++) {
// Open Image
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- vvImageReader * mReader = new vvImageReader;
+ vvImageReader mReader;
std::vector<std::string> filenames;
filenames.push_back(filename[i].toStdString());
- mReader->SetInputFilenames(filenames);
- mReader->Update(IMAGE);
+ mReader.SetInputFilenames(filenames);
+ mReader.Update(IMAGE);
QApplication::restoreOverrideCursor();
- if (mReader->GetLastError().size() != 0) {
+ if (mReader.GetLastError().size() != 0) {
std::cerr << "Error while reading " << filename[i].toStdString() << std::endl;
QString error = "Cannot open file \n";
- error += mReader->GetLastError().c_str();
+ error += mReader.GetLastError().c_str();
QMessageBox::information(this,tr("Reading problem"),error);
- delete mReader;
return;
}
- vvImage::Pointer binaryImage = mReader->GetOutput();
+ vvImage::Pointer binaryImage = mReader.GetOutput();
AddImage(binaryImage, filename[i].toStdString(), mBackgroundValueSpinBox->value());
mOpenedBinaryImage.push_back(binaryImage);
- delete mReader;
}
UpdateImage();
}
int index;
if (mCurrentStructureSet == NULL) {
if (mStructureSetsList.size() == 0) { // Create a default SS
- clitk::DicomRT_StructureSet * mStructureSet = new clitk::DicomRT_StructureSet;
+ clitk::DicomRT_StructureSet::Pointer mStructureSet = clitk::DicomRT_StructureSet::New();
index = AddStructureSet(mStructureSet);
}
else { // Get first SS
//------------------------------------------------------------------------------
void vvToolStructureSetManager::ReloadCurrentROI() {
// Reload image
- vvImageReader * mReader = new vvImageReader;
- mReader->SetInputFilename(mCurrentROI->GetFilename());
- mReader->Update(IMAGE);
- if (mReader->GetLastError() != "") {
- QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), mReader->GetLastError().c_str());
+ vvImageReader mReader;
+ mReader.SetInputFilename(mCurrentROI->GetFilename());
+ mReader.Update(IMAGE);
+ if (mReader.GetLastError() != "") {
+ QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), mReader.GetLastError().c_str());
return;
}
mCurrentROI->GetImage()->GetFirstVTKImageData()->ReleaseData();
- mCurrentROI->SetImage(mReader->GetOutput());
+ mCurrentROI->SetImage(mReader.GetOutput());
// Update visu"
mCurrentROIActor->UpdateImage();
protected:
Ui::vvToolStructureSetManager ui;
- clitk::DicomRT_StructureSet * mCurrentStructureSet;
+ clitk::DicomRT_StructureSet* mCurrentStructureSet;
vvStructureSetActor * mCurrentStructureSetActor;
int mCurrentStructureSetIndex;
- clitk::DicomRT_ROI * mCurrentROI;
+ clitk::DicomRT_ROI::Pointer mCurrentROI;
vvROIActor * mCurrentROIActor;
vtkSmartPointer<vtkLookupTable> mDefaultLUTColor;
bool mIsAllVisibleEnabled;
int mNumberOfVisibleROI;
int mNumberOfVisibleContourROI;
- std::vector<clitk::DicomRT_StructureSet* > mStructureSetsList;
+ std::vector<clitk::DicomRT_StructureSet::Pointer > mStructureSetsList;
std::vector<vvStructureSetActor *> mStructureSetActorsList;
std::map<int, QTreeWidgetItem *> mMapStructureSetIndexToTreeWidget;
- std::map<clitk::DicomRT_ROI*, QTreeWidgetItem *> mMapROIToTreeWidget;
- std::map<QTreeWidgetItem *, clitk::DicomRT_ROI*> mMapTreeWidgetToROI;
+ std::map<clitk::DicomRT_ROI::Pointer, QTreeWidgetItem *> mMapROIToTreeWidget;
+ std::map<QTreeWidgetItem *, clitk::DicomRT_ROI::Pointer> mMapTreeWidgetToROI;
std::vector<int> mLoadedROIIndex;
std::vector<vvImage::Pointer> mOpenedBinaryImage;