#include <vtkImageStencil.h>
#include <vtkLinearExtrusionFilter.h>
#include <vtkMetaImageWriter.h>
+#include <vtkXMLPolyDataWriter.h>
//--------------------------------------------------------------------
{
mROI = NULL;
mWriteOutput = false;
+ mWriteMesh = false;
mCropMask = true;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::DicomRTStruct2ImageFilter::SetWriteMesh(bool b)
+{
+ mWriteMesh = b;
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRTStruct2ImageFilter::SetOutputImageFilename(std::string s)
{
mOrigin.resize(3);
mSize.resize(3);
mDirection.resize(3);
+ mTransformMatrix = image->GetTransform()[0]->GetMatrix();
for(unsigned int i=0; i<3; i++) {
mSpacing[i] = image->GetSpacing()[i];
mOrigin[i] = image->GetOrigin()[i];
}
// Get Mesh
- vtkPolyData * mesh = mROI->GetMesh();
+ 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();
extend[0] = ceil((bounds[1]-origin[0])/mSpacing[0]+4);
extend[1] = ceil((bounds[3]-origin[1])/mSpacing[1]+4);
extend[2] = ceil((bounds[5]-origin[2])/mSpacing[2]+4);
-
// If no crop, set initial image size/origin
if (!mCropMask) {
for(int i=0; i<3; i++) {