#include <vtkImageStencil.h>
#include <vtkLinearExtrusionFilter.h>
#include <vtkMetaImageWriter.h>
+#include <vtkXMLPolyDataWriter.h>
//--------------------------------------------------------------------
{
mROI = NULL;
mWriteOutput = false;
+ mWriteMesh = true;
mCropMask = true;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::DicomRTStruct2ImageFilter::SetWriteMesh(bool b)
+{
+ mWriteMesh = b;
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::SetOutputImageFilename(std::string s)
{
// Get Mesh
vtkPolyData * mesh = mROI->GetMesh();
+ if (mWriteMesh) {
+ vtkSmartPointer<vtkXMLPolyDataWriter> meshWriter = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
+ std::string vtkName = mOutputFilename;
+ vtkName += ".vtk";
+ meshWriter->SetFileName(vtkName.c_str());
+#if VTK_MAJOR_VERSION <= 5
+ meshWriter->SetInput(mesh);
+#else
+ meshWriter->SetInputData(mesh);
+#endif
+ meshWriter->Write();
+ }
// Get bounds
double *bounds=mesh->GetBounds();
void SetOutputSpacing(const double* spacing);
void SetOutputSize(const unsigned long* size);
void SetOutputImageFilename(std::string s);
+ void SetWriteMesh(bool b);
void Update();
vtkImageData * GetOutput();
template <int Dimension> typename itk::Image<unsigned char,Dimension>::ConstPointer GetITKOutput();
protected:
bool ImageInfoIsSet() const;
bool mWriteOutput;
+ bool mWriteMesh;
bool mCropMask;
std::string mOutputFilename;
std::vector<double> mSpacing;
clitk::DicomRTStruct2ImageFilter filter;
filter.SetCropMaskEnabled(args_info.crop_flag);
filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
+ if (args_info.vtk_flag) {
+ filter.SetWriteMesh(true);
+ }
if (args_info.roiName_given) {
filter.SetROI(s->GetROIFromROIName(args_info.roiName_arg));
filter.SetOutputImageFilename(args_info.output_arg);
filter.SetROI(roi);
filter.SetCropMaskEnabled(args_info.crop_flag);
filter.SetImageFilename(args_info.image_arg); // Used to get spacing + origin
+ if (args_info.vtk_flag) {
+ filter.SetWriteMesh(true);
+ }
name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
std::string n;
if (args_info.mha_flag) {
option "crop" c "Crop binary mask" flag off
option "mha" - "Write the RTStruct as a mha image to avoid special character problems" flag off
+option "vtk" - "Write the vtk Mesh as a vtk file" flag off