typedef typename clitk::DicomRT_StructureSet::Pointer DicomRTStructPointer;
// Set inputs
- itkSetMacro(Input, ImagePointer);
- itkGetConstMacro(Input, ImagePointer);
+ itkSetMacro(InputFilenames, std::vector<std::string> );
itkSetMacro(StructureSetFilename, std::string);
itkSetMacro(DicomFolder, std::string);
itkSetMacro(OutputFilename, std::string);
- void SetROIName(std::string name, std::string type);
+ void SetROIType(std::string type);
itkSetMacro(ThresholdValue, PixelType);
// Run filter
void Update();
protected:
- ImagePointer m_Input;
std::string m_StructureSetFilename;
std::string m_DicomFolder;
std::string m_OutputFilename;
- std::string m_ROIName;
std::string m_ROIType;
PixelType m_ThresholdValue;
+ std::vector<std::string> m_InputFilenames;
};
//--------------------------------------------------------------------
#include "vtkCamera.h"
#include "vtkProperty.h"
#include "vtkProperty2D.h"
+#include <vtksys/SystemTools.hxx>
// itk
#include <itkImage.h>
//--------------------------------------------------------------------
template<class PixelType>
void
-clitk::Image2DicomRTStructFilter<PixelType>::SetROIName(std::string name, std::string type)
+clitk::Image2DicomRTStructFilter<PixelType>::SetROIType(std::string type)
{
- m_ROIName = name;
m_ROIType = type;
}
//--------------------------------------------------------------------
<< p->GetNumberOfStructureSetROIs() << std::endl;
}
+
+ // number of additional contours
+ int m = m_InputFilenames.size();
+
// Init writer
vtkGDCMPolyDataWriter * writer = vtkGDCMPolyDataWriter::New();
- int numMasks = reader->GetNumberOfOutputPorts() + 1;//add one more
+ int numMasks = reader->GetNumberOfOutputPorts() + m;
writer->SetNumberOfInputPorts(numMasks);
writer->SetFileName(m_OutputFilename.c_str());
writer->SetMedicalImageProperties(reader->GetMedicalImageProperties());
roiTypes->SetNumberOfValues(numMasks);
// Convert the image into a mesh
- typedef clitk::BinaryImageToMeshFilter<ImageType> BinaryImageToMeshFilterType;
- typename BinaryImageToMeshFilterType::Pointer convert = BinaryImageToMeshFilterType::New();
- convert->SetThresholdValue(m_ThresholdValue);
- convert->SetInput(m_Input);
- convert->Update();
- vtkPolyData* mesh = convert->GetOutputMesh();
- if (GetVerboseFlag()) {
- std::cout << "Mesh has " << mesh->GetNumberOfLines() << " lines." << std::endl;
+ std::vector<vtkSmartPointer<vtkPolyData> > meshes;
+ std::vector<std::string> m_ROINames;
+ meshes.resize(m);
+ m_ROINames.resize(m);
+ for(unsigned int i=0; i<m; i++) {
+
+ // read image
+ // typedef float PixelType;
+ //typedef itk::Image<PixelType, 3> ImageType;
+ ImagePointer input = clitk::readImage<ImageType>(m_InputFilenames[i], false);
+
+ std::ostringstream oss;
+ oss << vtksys::SystemTools::
+ GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(m_InputFilenames[i]));
+ std::string name = oss.str();
+ m_ROINames[i] = name;
+
+ // convert to mesh
+ typedef clitk::BinaryImageToMeshFilter<ImageType> BinaryImageToMeshFilterType;
+ typename BinaryImageToMeshFilterType::Pointer convert = BinaryImageToMeshFilterType::New();
+ convert->SetThresholdValue(m_ThresholdValue);
+ convert->SetInput(input);
+ convert->Update();
+ meshes[i] = convert->GetOutputMesh();
+ if (GetVerboseFlag()) {
+ std::cout << "Mesh has " << meshes[i]->GetNumberOfLines() << " lines." << std::endl;
+ }
+
+ /*
+ // debug mesh write FIXME
+ vtkSmartPointer<vtkPolyDataWriter> wr = vtkSmartPointer<vtkPolyDataWriter>::New();
+ wr->SetInputConnection(convert->GetOutputPort()); //psurface->GetOutputPort()
+ wr->SetFileName("bidon.obj");
+ wr->Update();
+ wr->Write();
+ */
}
-
+
// Copy previous contours
- for (unsigned int i = 0; i < numMasks-1; ++i) {
+ for (unsigned int i = 0; i < numMasks-m; ++i) {
writer->SetInput(i, reader->GetOutput(i));
std::string theString = reader->GetRTStructSetProperties()->GetStructureSetROIName(i);
roiNames->InsertValue(i, theString);
roiTypes->InsertValue(i, theString);
}
- // Add new one
- int last = numMasks-1;
- writer->SetInput(last, mesh);
- roiNames->InsertValue(last, m_ROIName);
- roiAlgorithms->InsertValue(last, "CLITK_CREATED");
- roiTypes->InsertValue(last, m_ROIType);
-
+ // Add new ones
+ for (unsigned int i = numMasks-m; i < numMasks; ++i) {
+ writer->SetInput(i, meshes[i-numMasks+m]);
+ roiNames->InsertValue(i, m_ROINames[i-numMasks+m]);
+ roiAlgorithms->InsertValue(i, "CLITK_CREATED");
+ roiTypes->InsertValue(i, m_ROIType);
+ }
+
/*
// Visu DEBUG
vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();
// Init command line
GGO(clitkImage2DicomRTStruct, args_info);
- // Read initial 3D image
- typedef float PixelType;
- typedef itk::Image<PixelType, 3> ImageType;
- ImageType::Pointer input = clitk::readImage<ImageType>(args_info.input_arg, args_info.verbose_flag);
+ // Set initial 3D image filenames
+ std::vector<std::string> filenames;
+ for(unsigned int i=0; i< args_info.input_given; i++)
+ filenames.push_back(args_info.input_arg[i]);
// Create a filter to convert image into dicomRTStruct and write to disk
+ typedef float PixelType;
clitk::Image2DicomRTStructFilter<PixelType> filter;
filter.SetVerboseFlag(args_info.verbose_flag);
- filter.SetInput(input);
+ filter.SetInputFilenames(filenames);
filter.SetDicomFolder(args_info.dicom_arg);
filter.SetStructureSetFilename(args_info.rtstruct_arg);
filter.SetOutputFilename(args_info.output_arg);
- filter.SetROIName(args_info.roiname_arg, args_info.roitype_arg);
+ filter.SetROIType(args_info.roitype_arg);
filter.SetThresholdValue(args_info.threshold_arg);
filter.Update();