X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkDicomRTStruct2ImageFilter.cxx;h=2e11fdc42a6ccd2a3243d8f6598b74c52cddd534;hb=ed673c4df16c5541a1bd46413b4a67376b28008d;hp=bf515a423b460ec958a6dd624bea7587103212c2;hpb=a365564201d98b704f43e1f52124f55f5e110d2e;p=clitk.git diff --git a/common/clitkDicomRTStruct2ImageFilter.cxx b/common/clitkDicomRTStruct2ImageFilter.cxx index bf515a4..2e11fdc 100644 --- a/common/clitkDicomRTStruct2ImageFilter.cxx +++ b/common/clitkDicomRTStruct2ImageFilter.cxx @@ -31,6 +31,7 @@ #include #include #include +#include //-------------------------------------------------------------------- @@ -38,6 +39,7 @@ clitk::DicomRTStruct2ImageFilter::DicomRTStruct2ImageFilter() { mROI = NULL; mWriteOutput = false; + mWriteMesh = false; mCropMask = true; } //-------------------------------------------------------------------- @@ -83,6 +85,14 @@ void clitk::DicomRTStruct2ImageFilter::SetCropMaskEnabled(bool b) //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void clitk::DicomRTStruct2ImageFilter::SetWriteMesh(bool b) +{ + mWriteMesh = b; +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- void clitk::DicomRTStruct2ImageFilter::SetOutputImageFilename(std::string s) { @@ -103,6 +113,7 @@ void clitk::DicomRTStruct2ImageFilter::SetImage(vvImage::Pointer image) 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]; @@ -179,7 +190,19 @@ void clitk::DicomRTStruct2ImageFilter::Update() } // Get Mesh - vtkPolyData * mesh = mROI->GetMesh(); + vtkPolyData * mesh = mROI->GetMesh(); + if (mWriteMesh) { + vtkSmartPointer meshWriter = vtkSmartPointer::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(); @@ -229,7 +252,6 @@ void clitk::DicomRTStruct2ImageFilter::Update() 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++) {