- [Linux 64bits](https://www.creatis.insa-lyon.fr/rio/vv?action=AttachFile&do=get&target=vv-1.4Qt4-linux64)
- [Windows 32bits](https://www.creatis.insa-lyon.fr/rio/vv?action=AttachFile&do=get&target=vv-1.4Qt4-win32.zip)
- [Windows 64bits](https://www.creatis.insa-lyon.fr/rio/vv?action=AttachFile&do=get&target=vv-1.4Qt4-win64.zip)
-
-### Installation
-To install vv with Linux (e.g.: OpenSuse 42.2), follow the instructions:
-
-#### Qt
-Install Qt5-devel and widget development library (Designer, Xml, Tools, Gui, Network, OpenGL, ...) with your package manager (e.g.: Yast)
-
-#### VTK
-mkdir vtk
-cd vtk
-mkdir src
-git clone https://github.com/Kitware/VTK.git src
-cd src
-git checkout tags/v7.0.0
-cd ..
-mkdir bin
-cd bin
-ccmake ../src (use t to toggle, c to configure and g to generate)
-Be sure to set (in toogle mode):
- - Module_vtkGUISuppotQt to ON
- - Module_vtkGUISuppotQtOpenGL to ON
- - Module_vtkRenderingQt to ON
- - Module_vtkViewQt to ON
- - VTK_QT_VERSION to 5
- - VTK_RENDERING_BACKEND to OpenGL
- - All Qt5... DIR to /usr/local/Qt-5.../lib/cmake/QT5...
-make
-cd ../..
-
-#### ITK
-mkdir itk
-cd itk
-mkdir src
-git clone https://github.com/InsightSoftwareConsortium/ITK.git src
-mkdir bin
-ccmake ../src
-Be sure to set (in toogle mode):
- - Module_ITKReview to ON
- - Module_ITKVtkGlue to ON
- - BUILD_SHARED_LIBS to ON
-make
-cd ../..
-
-#### vv
-mkdir vv
-cd vv
-mkdir src
-git clone https://github.com/open-vv/vv.git src
-mkdir bin
-ccmake ../src
-Be sure to set (the correct paths to Qt5 and ITK)
-make
-cd ../..
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();
// 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++) {
}
}
+std::cout << "origin " << origin[0] << " " << origin[1] << " " << origin[2] << std::endl;
+std::cout << "extend " << extend[0] << " " << extend[1] << " " << extend[2] << std::endl;
// Create new output image
mBinaryImage = vtkSmartPointer<vtkImageData>::New();
#if VTK_MAJOR_VERSION <= 5
#include "clitkDicomRT_ROI.h"
#include "clitkImageCommon.h"
#include <vtkImageData.h>
+#include <vtkMatrix4x4.h>
#include <itkImage.h>
#include <itkVTKImageToImageFilter.h>
std::vector<double> mOrigin;
std::vector<unsigned long> mSize;
std::vector< std::vector< double> > mDirection;
+ vtkSmartPointer<vtkMatrix4x4> mTransformMatrix;
clitk::DicomRT_ROI * mROI;
vtkSmartPointer<vtkImageData> mBinaryImage;
};
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::DicomRT_Contour::SetTransformMatrix(vtkMatrix4x4* matrix)
+{
+ mTransformMatrix = matrix;
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRT_Contour::ComputeMeshFromDataPoints()
{
mMesh->SetPoints(mPoints);
vtkIdType ids[2];
for (unsigned int idx=0 ; idx<mNbOfPoints ; idx++) {
+ double pointIn[4], pointOut[4];
+ for (unsigned int j=0 ; j<3; ++j)
+ pointIn[j] = mData->GetPoint(idx)[j];
+ pointIn[4] = 1.0;
+ /*mTransformMatrix->MultiplyPoint(pointIn, pointOut);
+ std::cout << pointOut[0] << " " << pointOut[1] << " " << pointOut[2] << " " << pointOut[3] << std::endl;
+ mMesh->GetPoints()->InsertNextPoint(pointOut[0],
+ pointOut[1],
+ pointOut[2]);*/
mMesh->GetPoints()->InsertNextPoint(mData->GetPoint(idx)[0],
mData->GetPoint(idx)[1],
mData->GetPoint(idx)[2]);
+ //std::cout << mData->GetPoint(idx)[0] << " " << mData->GetPoint(idx)[1] << " " << mData->GetPoint(idx)[2] << std::endl;
ids[0]=idx;
ids[1]=(ids[0]+1) % mNbOfPoints; //0-1,1-2,...,n-1-0
mMesh->GetLines()->InsertNextCell(2,ids);
}
+ //std::cout << std::endl;
mMeshIsUpToDate = true;
}
//--------------------------------------------------------------------
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkSmartPointer.h>
+#include <vtkMatrix4x4.h>
namespace clitk {
void SetMesh(vtkPolyData * mesh);
vtkPoints * GetPoints() {return mData;}
double GetZ() const {return mZ;}
+ void SetTransformMatrix(vtkMatrix4x4* matrix);
protected:
vtkSmartPointer<vtkPoints> mData;
vtkSmartPointer<vtkPolyData> mMesh;
vtkSmartPointer<vtkPoints> mPoints;
+ vtkSmartPointer<vtkMatrix4x4> mTransformMatrix;
bool mMeshIsUpToDate;
///Z location of the contour
double mZ;
{
gdcm::Item & j = sqi2->GetItem(i+1); // Item start at #1
DicomRT_Contour::Pointer c = DicomRT_Contour::New();
+ c->SetTransformMatrix(mTransformMatrix);
bool b = c->Read(&j);
if (b) {
mListOfContours.push_back(c);
int i=0;
for(gdcm::SQItem* j=contours->GetFirstSQItem(); j!=0; j=contours->GetNextSQItem()) {
DicomRT_Contour::Pointer c = DicomRT_Contour::New();
+ c->SetTransformMatrix(mTransformMatrix);
bool b = c->Read(j);
if (b) {
mListOfContours.push_back(c);
std::vector<double> color,
std::string filename)
{
-
// ROI number [Referenced ROI Number]
mNumber = n;
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::DicomRT_ROI::SetTransformMatrix(vtkMatrix4x4* matrix)
+{
+ mTransformMatrix = matrix;
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
void clitk::DicomRT_ROI::ComputeContoursFromImage()
{
// Get the contour
mMesh = reader->GetOutput(roiindex);
DicomRT_Contour::Pointer c = DicomRT_Contour::New();
+ c->SetTransformMatrix(mTransformMatrix);
c->SetMesh(mMesh); // FIXME no GetZ, not GetPoints
mMeshIsUpToDate = true;
mListOfContours.push_back(c);
#include "clitkDicomRT_Contour.h"
#include "vvImage.h"
+#include <vtkMatrix4x4.h>
#include "clitkConfiguration.h"
#if CLITK_USE_SYSTEM_GDCM == 1
#include <vtkGDCMPolyDataReader.h>
void SetImage(vvImage::Pointer im);
DicomRT_Contour* GetContour(int n);
+ void SetTransformMatrix(vtkMatrix4x4* matrix);
+
// Compute a vtk mesh from the dicom contours
void ComputeMeshFromContour();
void ComputeContoursFromImage();
std::vector<double> mColor;
std::vector<DicomRT_Contour::Pointer> mListOfContours;
vtkSmartPointer<vtkPolyData> mMesh;
+ vtkSmartPointer<vtkMatrix4x4> mTransformMatrix;
bool mMeshIsUpToDate;
vvImage::Pointer mImage;
double mBackgroundValue;
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::DicomRT_StructureSet::SetTransformMatrix(vtkMatrix4x4* matrix)
+{
+ mTransformMatrix = matrix;
+}
+//--------------------------------------------------------------------
+
+
//--------------------------------------------------------------------
const std::string & clitk::DicomRT_StructureSet::GetTime() const
{
int nb = i->first;//ReadROINumber(i);//mROIIndex[i];
// Create the roi
mROIs[nb] = DicomRT_ROI::New();
+ mROIs[nb]->SetTransformMatrix(mTransformMatrix);
mROIs[nb]->Read(mMapOfROIInfo[nb], mMapOfROIContours[nb]);
}
#include "clitkCommon.h"
#include "clitkDicomRT_ROI.h"
+//vtk
+#include "vtkMatrix4x4.h"
+
// vv
#include "vvImage.h"
void Print(std::ostream & os = std::cout) const;
void Read(const std::string & filename);
+ void SetTransformMatrix(vtkMatrix4x4* matrix);
bool IsDicomRTStruct(const std::string & filename);
void Write(const std::string & filename);
std::string mName;
std::string mDate;
std::string mTime;
+ vtkSmartPointer<vtkMatrix4x4> mTransformMatrix;
std::map<int, clitk::DicomRT_ROI::Pointer> mROIs;
std::map<int, std::string> mMapOfROIName;
// Create an actor for each time slice
for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
// how many intensity ?
- vtkSmartPointer<vtkImageMapToRGBA> mOverlayMapper = vtkSmartPointer<vtkImageMapToRGBA>::New();
- if (mImage->IsTimeSequence())
- {
- #if VTK_MAJOR_VERSION <= 5
- mOverlayMapper->SetInput(mImage->GetVTKImages()[numImage]);
+
+
+
+ if (!mFusionReslice) {
+ mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
+ mFusionReslice->SetInterpolationModeToLinear();
+ mFusionReslice->AutoCropOutputOn();
+ mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
+ }
+
+ mConcatenatedFusionTransform->Identity();
+ mConcatenatedFusionTransform->Concatenate(mImage->GetTransform()[0]);
+ mConcatenatedFusionTransform->Concatenate(mSlicer->GetSlicingTransform());
+ mFusionReslice->SetResliceAxes(mConcatenatedFusionTransform->GetMatrix());
+ if (mImage->IsTimeSequence()) {
+#if VTK_MAJOR_VERSION <= 5
+ mFusionReslice->SetInput(0, mImage->GetVTKImages()[numImage]);
+ mFusionReslice->UpdateInformation();
#else
- mOverlayMapper->SetInputData(mImage->GetVTKImages()[numImage]);
+ mFusionReslice->SetInputData(0, mImage->GetVTKImages()[numImage]);
#endif
- }
- else {
+ } else {
#if VTK_MAJOR_VERSION <= 5
- mOverlayMapper->SetInput(mImage->GetVTKImages()[0]);
+ mFusionReslice->SetInput(0, mImage->GetVTKImages()[0]);
+ mFusionReslice->UpdateInformation();
#else
- mOverlayMapper->SetInputData(mImage->GetVTKImages()[0]);
+ mFusionReslice->SetInputData(0, mImage->GetVTKImages()[0]);
#endif
}
+ mFusionReslice->Update();
+
+
+
+ vtkSmartPointer<vtkImageMapToRGBA> mOverlayMapper = vtkSmartPointer<vtkImageMapToRGBA>::New();
+#if VTK_MAJOR_VERSION <= 5
+ mOverlayMapper->SetInput(mFusionReslice->GetOutput());
+#else
+ mOverlayMapper->SetInputConnection(mFusionReslice->GetOutputPort(0));
+#endif
double range[2];
if (mImage->IsTimeSequence())
class vvImage;
class vtkImageMapToRGBA;
class vtkImageActor;
+class vtkImageReslice;
+class vtkTransform;
//------------------------------------------------------------------------------
class vvBinaryImageOverlayActor : public itk::LightObject
std::vector<vtkSmartPointer<vtkImageMapToRGBA> > mMapperList;
std::vector<vtkSmartPointer<vtkImageActor> > mImageActorList;
+ vtkSmartPointer<vtkImageReslice> mFusionReslice;
+ vtkSmartPointer<vtkTransform> mConcatenatedFusionTransform;
void ComputeExtent(int orientation,
int slice,
mOverlayActors.push_back(vvBinaryImageOverlayActor::New());
// BG or FG
- if (m_modeBG) {
- mOverlayActors[i]->SetImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage());
- }
- else {
- mOverlayActors[i]->SetImage(mROI->GetImage(), mROI->GetForegroundValueLabelImage(), false);
- }
+ if (m_modeBG)
+ mOverlayActors[i]->SetImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage());
+ else
+ mOverlayActors[i]->SetImage(mROI->GetImage(), mROI->GetForegroundValueLabelImage(), false);
+
mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0],
//------------------------------------------------------------------------------
void vvROIActor::UpdateSlice(int slicer, int slices, int force)
-{
+{
if (!mROI->GetImage()) return;
if ((!mIsVisible) && (!mIsContourVisible)) return;
if (!mSlicerManager) {
vvSlicerManager * mSlicerManager;
std::vector<vvImageContour::Pointer> mImageContour;
std::vector< vvBinaryImageOverlayActor::Pointer > mOverlayActors;
-
+
bool mIsVisible;
bool mIsContourVisible;
double mOpacity;
QWidget(parent->GetTab()),
vvToolBase<vvToolROIManager>(parent),
Ui::vvToolROIManager()
-{
+{
// Store parent
mMainWindow = parent;
//------------------------------------------------------------------------------
vvToolROIManager::~vvToolROIManager()
-{
+{
mROIActorsList.clear();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// STATIC
void vvToolROIManager::Initialize()
-{
+{
SetToolName("ROIManager");
SetToolMenuName("Open ROI (binary image or RT-STRUCT)");
SetToolIconFilename(":/common/icons/tool-roi.png");
//------------------------------------------------------------------------------
void vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
-{
+{
// Check if we need to start a new tool or read in the state file to load
if (ReadStateFlag == false) {
// Select the current image as the target
//------------------------------------------------------------------------------
void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
-{
+{
// Initialization
mCurrentSlicerManager = m;
mCurrentImage = mCurrentSlicerManager->GetImage();
//------------------------------------------------------------------------------
void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
-{
+{
if (m == mCurrentSlicerManager) {
close();
return;
//------------------------------------------------------------------------------
void vvToolROIManager::RemoveROI()
-{
+{
// Search the indice of the selected ROI
QList<QTreeWidgetItem *> l = mTree->selectedItems();
//------------------------------------------------------------------------------
void vvToolROIManager::close()
-{
+{
disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
//------------------------------------------------------------------------------
void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m)
-{
+{
if (mCurrentSlicerManager == NULL) return;
if (m == NULL) return;
if (m != mCurrentSlicerManager) hide();
//------------------------------------------------------------------------------
void vvToolROIManager::Open()
-{
+{
// Open images
QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)";
Extensions += ";;All Files (*)";
//------------------------------------------------------------------------------
void vvToolROIManager::OpenBinaryImage(QStringList & filename)
-{
+{
if (filename.size() == 0) return;
vvProgressDialog p("Reading ROI ...", true);
//------------------------------------------------------------------------------
void vvToolROIManager::OpenDicomImage(std::string filename)
-{
+{
// GUI selector of roi
vvMeshReader reader;
reader.SetFilename(filename);
// Read information
clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New();
+ vtkSmartPointer<vtkMatrix4x4> transformMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
+ transformMatrix = mCurrentImage->GetTransform()[0]->GetMatrix();
+ s->SetTransformMatrix(transformMatrix);
s->Read(filename);
// Loop on selected struct
std::string name,
std::string filename,
double BG, bool modeBG)
-{
+{
// Check Dimension
int dim = mCurrentImage->GetNumberOfDimensions();
int bin_dim = binaryImage->GetNumberOfDimensions();
//------------------------------------------------------------------------------
void vvToolROIManager::UpdateAllContours()
-{
+{
if (mCurrentSlicerManager == NULL) return;
// Render loaded ROIs (the first is sufficient)
for(unsigned int i=0; i<mROIList.size(); i++) {
//------------------------------------------------------------------------------
void vvToolROIManager::UpdateAllROIStatus()
-{
+{
int nbVisible = 0;
int nbContourVisible = 0;
int nb = mROIList.size();
//------------------------------------------------------------------------------
void vvToolROIManager::SelectedItemChangedInTree()
-{
+{
// Search which roi is selected
QList<QTreeWidgetItem *> l = mTree->selectedItems();
if (l.size() == 0) {
//------------------------------------------------------------------------------
void vvToolROIManager::VisibleROIToggled(bool b)
-{
+{
if (mCurrentROIActor == NULL) return;
if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
mCurrentROIActor->SetVisible(b);
//------------------------------------------------------------------------------
void vvToolROIManager::VisibleContourROIToggled(bool b)
-{
+{
if (mCurrentROIActor == NULL) return;
if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
mCurrentROIActor->SetContourVisible(b);
//------------------------------------------------------------------------------
void vvToolROIManager::OpacityChanged(int v)
-{
+{
if (mCurrentROIActor == NULL) return;
mCurrentROIActor->SetOpacity((double)v/100.0);
mCurrentROIActor->UpdateColor();
//------------------------------------------------------------------------------
void vvToolROIManager::AllVisibleROIToggled(int b)
-{
+{
disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
bool status = false;
if ((mCheckBoxShowAll->checkState() == Qt::Checked) ||
//------------------------------------------------------------------------------
void vvToolROIManager::AllVisibleContourROIToggled(int b)
-{
+{
disconnect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int)));
bool status = false;
if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
//------------------------------------------------------------------------------
void vvToolROIManager::ChangeColor()
-{
+{
if (mCurrentROIActor == NULL) return;
QColor color;
color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0],
//------------------------------------------------------------------------------
void vvToolROIManager::ChangeContourColor()
-{
+{
if (mCurrentROIActor == NULL) return;
QColor color;
color.setRgbF(mCurrentROIActor->GetContourColor()[0],
//------------------------------------------------------------------------------
void vvToolROIManager::ChangeContourWidth(int n)
-{
+{
if (mCurrentROIActor == NULL) return;
mCurrentROIActor->SetContourWidth(n);
mCurrentROIActor->UpdateColor();
//------------------------------------------------------------------------------
void vvToolROIManager::ChangeDepth(int n)
-{
+{
if (mCurrentROIActor == NULL) return;
mCurrentROIActor->SetDepth(n);
// mCurrentROIActor->UpdateImage(); // FIXME
//------------------------------------------------------------------------------
void vvToolROIManager::ReloadCurrentROI()
-{
+{
if (mCurrentROI->GetFilename() == "") {
return; // do nothing (contour from rt struct do not reload)
}
#else
void vvToolROIManager::SaveState(std::auto_ptr<QXmlStreamWriter> & m_XmlWriter)
#endif
-{
+{
// Get index of the image
int n = mMainWindow->GetSlicerManagers().size();
int index=-1;
//------------------------------------------------------------------------------
void vvToolROIManager::ReadXMLInformation()
-{
+{
std::string value="";
mInitialImageIndex = -1;
while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) {
//------------------------------------------------------------------------------
void vvToolROIManager::ReadXMLInformation_ROI()
-{
+{
QString s;
std::string value="";
QSharedPointer<vvROIActor> param = QSharedPointer<vvROIActor>(new vvROIActor);