diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp index 56bb690974..30a01e6604 100644 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp @@ -1,429 +1,518 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ -// Blueberry +// Blueberry application and interaction service #include #include - - // Qmitk #include "QmitkFiberBundleDeveloperView.h" -#include +#include + // MITK -#include +#include //for fiberStructure +//===needed when timeSlicedGeometry is null to invoke rendering mechansims ==== +#include +#include -// VTK -#include -#include -#include +// VTK +#include //for randomized FiberStructure +#include //for fiberStructure +#include //for fiberStructure +#include //for geometry const std::string QmitkFiberBundleDeveloperView::VIEW_ID = "org.mitk.views.fiberbundledeveloper"; const std::string id_DataManager = "org.mitk.views.datamanager"; using namespace berry; QmitkFiberBundleDeveloperView::QmitkFiberBundleDeveloperView() : QmitkFunctionality() , m_Controls( 0 ) , m_MultiWidget( NULL ) { } // Destructor QmitkFiberBundleDeveloperView::~QmitkFiberBundleDeveloperView() { } void QmitkFiberBundleDeveloperView::CreateQtPartControl( QWidget *parent ) { // build up qt view, unless already done in QtDesigner, etc. if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkFiberBundleDeveloperViewControls; m_Controls->setupUi( parent ); connect( m_Controls->buttonGenerateFibers, SIGNAL(clicked()), this, SLOT(DoGenerateFibers()) ); connect( m_Controls->radioButton_directionRandom, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); connect( m_Controls->radioButton_directionX, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); connect( m_Controls->radioButton_directionY, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); connect( m_Controls->radioButton_directionZ, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); } // Checkpoint for fiber ORIENTATION if ( m_DirectionRadios.empty() ) { m_DirectionRadios.insert(0, m_Controls->radioButton_directionRandom); m_DirectionRadios.insert(1, m_Controls->radioButton_directionX); m_DirectionRadios.insert(2, m_Controls->radioButton_directionY); m_DirectionRadios.insert(3, m_Controls->radioButton_directionZ); } // set GUI elements of FiberGenerator to according configuration DoUpdateGenerateFibersWidget(); } void QmitkFiberBundleDeveloperView::DoUpdateGenerateFibersWidget() { //get selected radioButton QString fibDirection; //stores the object_name of selected radiobutton QVector::const_iterator i; for (i = m_DirectionRadios.begin(); i != m_DirectionRadios.end(); ++i) { QRadioButton* rdbtn = *i; if (rdbtn->isChecked()) fibDirection = rdbtn->objectName(); } if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_RANDOM ) { // disable radiobuttons if (m_Controls->boxFiberMinLength->isEnabled()) m_Controls->boxFiberMinLength->setEnabled(false); if (m_Controls->labelFiberMinLength->isEnabled()) m_Controls->labelFiberMinLength->setEnabled(false); if (m_Controls->boxFiberMaxLength->isEnabled()) m_Controls->boxFiberMaxLength->setEnabled(false); if (m_Controls->labelFiberMaxLength->isEnabled()) m_Controls->labelFiberMaxLength->setEnabled(false); //enable radiobuttons if (!m_Controls->labelFibersTotal->isEnabled()) m_Controls->labelFibersTotal->setEnabled(true); if (!m_Controls->boxFiberNumbers->isEnabled()) m_Controls->boxFiberNumbers->setEnabled(true); if (!m_Controls->labelDistrRadius->isEnabled()) m_Controls->labelDistrRadius->setEnabled(true); if (!m_Controls->boxDistributionRadius->isEnabled()) m_Controls->boxDistributionRadius->setEnabled(true); } else { // disable radiobuttons if (m_Controls->labelDistrRadius->isEnabled()) m_Controls->labelDistrRadius->setEnabled(false); if (m_Controls->boxDistributionRadius->isEnabled()) m_Controls->boxDistributionRadius->setEnabled(false); //enable radiobuttons if (!m_Controls->labelFibersTotal->isEnabled()) m_Controls->labelFibersTotal->setEnabled(true); if (!m_Controls->boxFiberNumbers->isEnabled()) m_Controls->boxFiberNumbers->setEnabled(true); if (!m_Controls->boxFiberMinLength->isEnabled()) m_Controls->boxFiberMinLength->setEnabled(true); if (!m_Controls->labelFiberMinLength->isEnabled()) m_Controls->labelFiberMinLength->setEnabled(true); if (!m_Controls->boxFiberMaxLength->isEnabled()) m_Controls->boxFiberMaxLength->setEnabled(true); if (!m_Controls->labelFiberMaxLength->isEnabled()) m_Controls->labelFiberMaxLength->setEnabled(true); } } void QmitkFiberBundleDeveloperView::DoGenerateFibers() { // GET SELECTED FIBER DIRECTION QString fibDirection; //stores the object_name of selected radiobutton QVector::const_iterator i; for (i = m_DirectionRadios.begin(); i != m_DirectionRadios.end(); ++i) { QRadioButton* rdbtn = *i; if (rdbtn->isChecked()) fibDirection = rdbtn->objectName(); } vtkSmartPointer output; // FiberPD stores the generated PolyData if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_RANDOM ) { // build polydata with random lines and fibers output = GenerateVtkFibersRandom(); } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_X ) { // build polydata with XDirection fibers output = GenerateVtkFibersDirectionX(); } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_Y ) { // build polydata with YDirection fibers output = GenerateVtkFibersDirectionY(); } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_Z ) { // build polydata with ZDirection fibers output = GenerateVtkFibersDirectionZ(); } mitk::FiberBundleX::Pointer FB = mitk::FiberBundleX::New(); FB->SetFibers(output); - MITK_INFO << output->GetNumberOfPoints(); - MITK_INFO << output->GetNumberOfLines(); - vtkPolyData* retFibers = FB->GetFibers(); - MITK_INFO << retFibers->GetNumberOfPoints(); - MITK_INFO << retFibers->GetNumberOfLines(); + FB->SetGeometry(this->GenerateStandardGeometryForMITK()); + mitk::DataNode::Pointer FBNode; FBNode = mitk::DataNode::New(); FBNode->SetName("FiberBundleX"); FBNode->SetData(FB); FBNode->SetVisibility(true); GetDataStorage()->Add(FBNode); - GetDataStorage()->Modified(); - m_MultiWidget->RequestUpdate(); - + const mitk::PlaneGeometry * tsgeo = m_MultiWidget->GetTimeNavigationController()->GetCurrentPlaneGeometry(); + if (tsgeo == NULL) { + /* GetDataStorage()->Modified etc. have no effect, therefore proceed as followed below */ + // get all nodes that have not set "includeInBoundingBox" to false + mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" + , mitk::BoolProperty::New(false))); + + mitk::DataStorage::SetOfObjects::ConstPointer rs = GetDataStorage()->GetSubset(pred); + // calculate bounding geometry of these nodes + mitk::TimeSlicedGeometry::Pointer bounds = GetDataStorage()->ComputeBoundingGeometry3D(rs); + // initialize the views to the bounding geometry + mitk::RenderingManager::GetInstance()->InitializeViews(bounds); + } else { + + GetDataStorage()->Modified(); //necessary?? + m_MultiWidget->RequestUpdate(); //necessary?? + } } /* * Generate polydata of random fibers */ vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersRandom() { int numOfFibers = m_Controls->boxFiberNumbers->value(); int distrRadius = m_Controls->boxDistributionRadius->value(); int numOfPoints = numOfFibers * distrRadius; std::vector< std::vector > fiberStorage; for (int i=0; i a; fiberStorage.push_back( a ); } //get number of items in fiberStorage MITK_INFO << "Fibers in fiberstorage: " << fiberStorage.size(); /* Generate Point Cloud */ vtkSmartPointer randomPoints = vtkSmartPointer::New(); randomPoints->SetCenter(0.0, 0.0, 0.0); randomPoints->SetNumberOfPoints(numOfPoints); randomPoints->SetRadius(distrRadius); randomPoints->Update(); vtkPoints* pnts = randomPoints->GetOutput()->GetPoints(); /*====== checkpoint: compare initialized and required points =============================*/ if (numOfPoints != pnts->GetNumberOfPoints()) { MITK_INFO << "VTK POINT ERROR, WRONG AMOUNT OF GENRERATED POINTS... COULD BE VTK BUG OR BITFLIP DUE TO COSMIC RADIATION!"; return NULL; }/* ================================= */ /* ASSIGN EACH POINT TO A RANDOM FIBER */ srand((unsigned)time(0)); // init randomizer for (int i=0; iGetNumberOfPoints(); ++i) { //generate random number between 0 and numOfFibers-1 int random_integer; random_integer = (rand()%numOfFibers); //add current point to random fiber fiberStorage.at(random_integer).push_back(i); - MITK_INFO << "point" << i << "into fiber" << random_integer; + MITK_INFO << "point" << i << " |" << pnts->GetPoint(random_integer)[0] << "|" << pnts->GetPoint(random_integer)[1]<< "|" << pnts->GetPoint(random_integer)[2] << "| into fiber" << random_integer; } /* GENERATE VTK POLYLINES OUT OF FIBERSTORAGE */ vtkSmartPointer linesCell = vtkSmartPointer::New(); // Host vtkPolyLines linesCell->Allocate(pnts->GetNumberOfPoints()*2); //allocate for each cellindex also space for the pointId, e.g. [idx | pntID] for (unsigned long i=0; i singleFiber = fiberStorage.at(i); vtkSmartPointer fiber = vtkSmartPointer::New(); fiber->GetPointIds()->SetNumberOfIds((int)singleFiber.size()); for (unsigned long si=0; siGetPointIds()->SetId( si, singleFiber.at(si) ); } linesCell->InsertNextCell(fiber); } /* =======checkpoint for cellarray allocation ==========*/ if ( (linesCell->GetSize()/pnts->GetNumberOfPoints()) != 2 ) { MITK_INFO << "RANDOM FIBER ALLOCATION CAN NOT BE TRUSTED ANYMORE! Correct leak or remove command: linesCell->Allocate(pnts->GetNumberOfPoints()*2) but be aware of possible loss in performance."; }/* ====================================================*/ // MITK_INFO << "CellSize: " << linesCell->GetSize() << " NumberOfCells: " << linesCell->GetNumberOfCells(); /* HOSTING POLYDATA FOR RANDOM FIBERSTRUCTURE */ vtkSmartPointer PDRandom = vtkSmartPointer::New(); PDRandom->SetPoints(pnts); PDRandom->SetLines(linesCell); - MITK_INFO << PDRandom->GetNumberOfPoints(); - MITK_INFO << PDRandom->GetNumberOfLines(); + return PDRandom; } vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersDirectionX() { int numOfFibers = m_Controls->boxFiberNumbers->value(); vtkSmartPointer linesCell = vtkSmartPointer::New(); vtkSmartPointer points = vtkSmartPointer::New(); //insert Origin point, this point has index 0 in point array double originX = 0.0; double originY = 0.0; double originZ = 0.0; //after each iteration the origin of the new fiber increases //here you set which direction is affected. double increaseX = 0.0; double increaseY = 1.0; double increaseZ = 0.0; //walk along X axis //length of fibers increases in each iteration for (int i=0; i newFiber = vtkSmartPointer::New(); newFiber->GetPointIds()->SetNumberOfIds(i+2); //create starting point and add it to pointset points->InsertNextPoint(originX + (double)i * increaseX , originY + (double)i * increaseY, originZ + (double)i * increaseZ); //add starting point to fiber newFiber->GetPointIds()->SetId(0,points->GetNumberOfPoints()-1); //insert remaining points for fiber for (int pj=0; pj<=i ; ++pj) { //generate next point on X axis points->InsertNextPoint( originX + (double)pj+1 , originY + (double)i * increaseY, originZ + (double)i * increaseZ ); newFiber->GetPointIds()->SetId(pj+1,points->GetNumberOfPoints()-1); } linesCell->InsertNextCell(newFiber); } vtkSmartPointer PDX = vtkSmartPointer::New(); PDX->SetPoints(points); PDX->SetLines(linesCell); return PDX; } vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersDirectionY() { vtkSmartPointer PDY = vtkSmartPointer::New(); //todo return PDY; } vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersDirectionZ() { vtkSmartPointer PDZ = vtkSmartPointer::New(); //todo return PDZ; } +/* === THIS METHOD GENERATES ESSENTIAL GEOMETRY PARAMETERS FOR THE MITK FRAMEWORK === + * WITHOUT, the rendering mechanism will ignore objects without valid Geometry + * for each object, MITK requires: ORIGIN, SPACING, TRANSFORM MATRIX, BOUNDING-BOX */ +mitk::Geometry3D::Pointer QmitkFiberBundleDeveloperView::GenerateStandardGeometryForMITK() +{ + mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); + + // generate origin + mitk::Point3D origin; + origin[0] = 0; + origin[1] = 0; + origin[2] = 0; + geometry->SetOrigin(origin); + + // generate spacing + float spacing[3] = {1,1,1}; + geometry->SetSpacing(spacing); + + + // generate identity transform-matrix + vtkMatrix4x4* m = vtkMatrix4x4::New(); + geometry->SetIndexToWorldTransformByVtkMatrix(m); + + // generate boundingbox + // for an usable bounding-box use gui parameters to estimate the boundingbox + float bounds[] = {500, 500, 500, -500, -500, -500}; + + // GET SELECTED FIBER DIRECTION + QString fibDirection; //stores the object_name of selected radiobutton + QVector::const_iterator i; + for (i = m_DirectionRadios.begin(); i != m_DirectionRadios.end(); ++i) + { + QRadioButton* rdbtn = *i; + if (rdbtn->isChecked()) + fibDirection = rdbtn->objectName(); + } + + if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_RANDOM ) { + // use information about distribution parameter to calculate bounding box + int distrRadius = m_Controls->boxDistributionRadius->value(); + bounds[0] = distrRadius; + bounds[1] = distrRadius; + bounds[2] = distrRadius; + bounds[3] = -distrRadius; + bounds[4] = -distrRadius; + bounds[5] = -distrRadius; + + } else { + // so far only X,Y,Z directions are available + MITK_INFO << "_______GEOMETRY ISSUE_____\n***BoundingBox for X, Y, Z fiber directions are not optimized yet!***"; + + int maxFibLength = m_Controls->boxFiberMaxLength->value(); + bounds[0] = maxFibLength; + bounds[1] = maxFibLength; + bounds[2] = maxFibLength; + bounds[3] = -maxFibLength; + bounds[4] = -maxFibLength; + bounds[5] = -maxFibLength; + } + + geometry->SetFloatBounds(bounds); + geometry->SetImageGeometry(true); //?? + + return geometry; + + +} void QmitkFiberBundleDeveloperView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkFiberBundleDeveloperView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } /* OnSelectionChanged is registered to SelectionService, therefore no need to implement SelectionService Listener explicitly */ void QmitkFiberBundleDeveloperView::OnSelectionChanged( std::vector nodes ) { for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) { //flags needed for algorithm execution logic mitk::DataNode::Pointer node = *it; if( node.IsNotNull() && dynamic_cast(node->GetData()) ) { + MITK_INFO << node->GetData()->GetNameOfClass(); + MITK_INFO << "FBX"; mitk::FiberBundleX::Pointer serwas = dynamic_cast(node->GetData()); - vtkPolyData* pdfb = serwas->GetFibers(); - MITK_INFO << pdfb->GetNumberOfPoints(); - MITK_INFO << pdfb->GetNumberOfLines(); - + if (serwas.GetPointer() != NULL){ + vtkSmartPointer pdfb = serwas->GetFibers(); + + MITK_INFO << pdfb->GetNumberOfLines(); + MITK_INFO << pdfb->GetNumberOfPoints(); + }else{ + MITK_INFO << "what happend in datastorage?"; + MITK_INFO << node->GetData()->GetNameOfClass(); + } + + } else { MITK_INFO << node->GetData()->GetNameOfClass(); } } } void QmitkFiberBundleDeveloperView::Activated() { MITK_INFO << "FB DevelopersV ACTIVATED()"; } diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h index af5487c418..158258cbb2 100644 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h +++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h @@ -1,113 +1,117 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef QmitkFiberBundleDeveloperView_h #define QmitkFiberBundleDeveloperView_h #include #include #include #include "ui_QmitkFiberBundleDeveloperViewControls.h" #include #include // Qt #include #include #include // VTK #include #include const QString FIB_RADIOBUTTON_DIRECTION_RANDOM = "radioButton_directionRandom"; const QString FIB_RADIOBUTTON_DIRECTION_X = "radioButton_directionX"; const QString FIB_RADIOBUTTON_DIRECTION_Y = "radioButton_directionY"; const QString FIB_RADIOBUTTON_DIRECTION_Z = "radioButton_directionZ"; /*! \brief QmitkFiberBundleView \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup Functionalities */ class QmitkFiberBundleDeveloperView : public QmitkFunctionality { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; QmitkFiberBundleDeveloperView(); virtual ~QmitkFiberBundleDeveloperView(); virtual void CreateQtPartControl(QWidget *parent); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); virtual void Activated(); protected slots: void DoGenerateFibers(); void DoUpdateGenerateFibersWidget(); protected: /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( std::vector nodes ); Ui::QmitkFiberBundleDeveloperViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; private: + /* METHODS GENERATING FIBERSTRUCTURES */ vtkSmartPointer GenerateVtkFibersRandom(); vtkSmartPointer GenerateVtkFibersDirectionX(); vtkSmartPointer GenerateVtkFibersDirectionY(); vtkSmartPointer GenerateVtkFibersDirectionZ(); + /* MITK RELEVANT HELPERMETHODS */ + mitk::Geometry3D::Pointer GenerateStandardGeometryForMITK(); + //contains the selected FiberBundle mitk::DataNode::Pointer m_FiberBundleNode; // radiobutton groups QVector< QRadioButton* > m_DirectionRadios; QVector< QRadioButton* > m_FARadios; QVector< QRadioButton* > m_GARadios; }; #endif // _QMITKFIBERTRACKINGVIEW_H_INCLUDED diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp index 659188f8d8..40fec9e9b6 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp @@ -1,259 +1,283 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkFiberBundleX.h" +/* musthave */ +#include // without geometry, fibers are not rendered + #include #include #include #include // baptize array names const char* mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED = "Color_Orient"; const char* mitk::FiberBundleX::COLORCODING_FA_BASED = "Color_FA"; mitk::FiberBundleX::FiberBundleX() { + /* ====== GEOMETRY IS ESSENTIAL ======= + * by default set a standard geometry, usually geometry is + * set by the user on initializing a mitkFiberBundle Object */ - +// mitk::Geometry3D::Pointer fbgeometry = mitk::Geometry3D::New(); +// fbgeometry->SetIdentity(); +// this->SetGeometry(fbgeometry); + /* ==================================== */ } mitk::FiberBundleX::~FiberBundleX() { } /* === main input method ==== * set computed fibers from tractography algorithms */ void mitk::FiberBundleX::SetFibers(vtkSmartPointer fiberPD) { if (fiberPD.GetPointer() == NULL){ MITK_INFO << "passed FiberBundleX is NULL, exit!"; return; } m_FiberStructureData = fiberPD; } /* === main output method === * return fiberbundle as vtkPolyData * Depending on processing of input fibers, this method returns * the latest processed fibers. */ -vtkPolyData* mitk::FiberBundleX::GetFibers() + vtkSmartPointer mitk::FiberBundleX::GetFibers() { return m_FiberStructureData; } /*============================================== *++++ PROCESSING WITH FIBER INFORMATION +++++++ =============================================*/ void mitk::FiberBundleX::DoColorCodingOrientationbased() { //===== FOR WRITING A TEST ======================== // colorT size == tupelComponents * tupelElements // compare color results // to cover this code 100% also polydata needed, where colorarray already exists // + one fiber with exactly 1 point // + one fiber with 0 points //================================================= /* make sure that processing colorcoding is only called when necessary */ if ( m_FiberStructureData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED) && m_FiberStructureData->GetNumberOfPoints() == m_FiberStructureData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)->GetNumberOfTuples() ) { // fiberstructure is already colorcoded MITK_INFO << " NO NEED TO REGENERATE COLORCODING!"; return; } /* Finally, execute color calculation */ vtkPoints* extrPoints = m_FiberStructureData->GetPoints(); int numOfPoints = extrPoints->GetNumberOfPoints(); //colors and alpha value for each single point, RGBA = 4 components unsigned char rgba[4] = {0,0,0,0}; int componentSize = sizeof(rgba); vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); colorsT->Allocate(numOfPoints * componentSize); colorsT->SetNumberOfComponents(componentSize); colorsT->SetName(COLORCODING_ORIENTATION_BASED); /* checkpoint: does polydata contain any fibers */ int numOfFibers = m_FiberStructureData->GetNumberOfLines(); if (numOfFibers < 1) { MITK_INFO << "\n ========= Number of Fibers is below 1 ========= \n"; return; } /* extract single fibers of fiberBundle */ vtkCellArray* fiberList = m_FiberStructureData->GetLines(); for (int fi=0; fiGetNextCell(numOfPoints, idList); /* single fiber checkpoints: is number of points valid */ if (numOfPoints > 1) { /* operate on points of single fiber */ for (int i=0; i 0) { /* The color value of the current point is influenced by the previous point and next point. */ vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = currentPntvtk - nextPntvtk; diff1.normalize(); vnl_vector_fixed< double, 3 > diff2; diff2 = currentPntvtk - prevPntvtk; diff2.normalize(); vnl_vector_fixed< double, 3 > diff; diff = (diff1 - diff2) / 2.0; rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); rgba[3] = (unsigned char) (255.0); } else if (i==0) { /* First point has no previous point, therefore only diff1 is taken */ vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = currentPntvtk - nextPntvtk; diff1.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff1[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff1[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff1[2])); rgba[3] = (unsigned char) (255.0); } else if (i==numOfPoints-1) { /* Last point has no next point, therefore only diff2 is taken */ vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); vnl_vector_fixed< double, 3 > diff2; diff2 = currentPntvtk - prevPntvtk; diff2.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff2[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff2[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff2[2])); rgba[3] = (unsigned char) (255.0); } colorsT->InsertTupleValue(idList[i], rgba); } //end for loop } else if (numOfPoints == 1) { /* a single point does not define a fiber (use vertex mechanisms instead */ continue; // colorsT->InsertTupleValue(0, rgba); } else { MITK_INFO << "Fiber with 0 points detected... please check your tractography algorithm!" ; continue; } }//end for loop m_FiberStructureData->GetPointData()->AddArray(colorsT); //mini test, shall be ported to MITK TESTINGS! if (colorsT->GetSize() != numOfPoints*componentSize) { MITK_INFO << "ALLOCATION ERROR IN INITIATING COLOR ARRAY"; } //===== clean memory ===== colorsT->Delete(); //======================== } + +double* mitk::FiberBundleX::DoComputeFiberStructureBoundingBox(vtkSmartPointer fiberStructure) +{ + fiberStructure->ComputeBounds(); + double* bounds = fiberStructure->GetBounds(); + return bounds; +} + ////private repairMechanism for orientationbased colorcoding //bool mitk::FiberBundleX::doSelfHealingColorOrient(vtkPolyData* healMe) //{ // bool hasHealingSucceeded = false; // MITK_INFO << "FiberBundleX self repair mechanism is called, but not yet implemented"; //// check type of healMe // if (healMe == m_ImportedFiberData) // { // //todo // } // // return hasHealingSucceeded; //} + + + + + + + /* ESSENTIAL IMPLEMENTATION OF SUPERCLASS METHODS */ void mitk::FiberBundleX::UpdateOutputInformation() { } void mitk::FiberBundleX::SetRequestedRegionToLargestPossibleRegion() { } bool mitk::FiberBundleX::RequestedRegionIsOutsideOfTheBufferedRegion() { return false; } bool mitk::FiberBundleX::VerifyRequestedRegion() { return true; } void mitk::FiberBundleX::SetRequestedRegion( itk::DataObject *data ) { } \ No newline at end of file diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h index 8e042185f7..21a59fe45a 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h @@ -1,105 +1,113 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision: 11989 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_FiberBundleX_H #define _MITK_FiberBundleX_H //includes for MITK datastructure #include "mitkBaseData.h" #include "MitkDiffusionImagingExports.h" //includes storing fiberdata #include //may be replaced by class precompile argument #include // may be replaced by class #include // my be replaced by class namespace mitk { /** * \brief Base Class for Fiber Bundles; */ class MitkDiffusionImaging_EXPORT FiberBundleX : public BaseData { public: // names of certain arrays (e.g colorcodings, etc.) static const char* COLORCODING_ORIENTATION_BASED; static const char* COLORCODING_FA_BASED; /* friend classes wanna access typedefs ContainerPointType, ContainerTractType, ContainerType */ friend class FiberBundleXWriter; friend class FiberBundleXReader; // ======virtual methods must have====== virtual void UpdateOutputInformation(); virtual void SetRequestedRegionToLargestPossibleRegion(); virtual bool RequestedRegionIsOutsideOfTheBufferedRegion(); virtual bool VerifyRequestedRegion(); virtual void SetRequestedRegion( itk::DataObject *data ); //======================================= mitkClassMacro( FiberBundleX, BaseData ); itkNewMacro( Self ); - // import fiber result from tractography algorithms - void SetFibers(vtkSmartPointer); + + - // return processed fibers - vtkPolyData* GetFibers(); + /*====FIBERBUNDLE I/O METHODS====*/ + void SetFibers(vtkSmartPointer); //set result of tractography algorithm in vtkPolyData format using vtkPolyLines + vtkSmartPointer GetFibers(); + vtkSmartPointer GetVertices(); - // return vertex polydata - vtkPolyData* GetVertices(); + /*===FIBERBUNDLE PROCESSING METHODS====*/ void DoColorCodingOrientationbased(); + + /*===FIBERBUNDLE ASSESSMENT METHODS====*/ + // Compute Bounding Box for FiberStructure; needed for MITK Geometry + double* DoComputeFiberStructureBoundingBox(vtkSmartPointer); + + protected: FiberBundleX(); virtual ~FiberBundleX(); private: + //// ====TODO==================================== // bool doSelfHealingColorOrient( vtkPolyData* ); //// ============================================ // The following polydata variables are used for fiber- and pointbased representation of the tractography results. As VTK suggests, one vtkPolyData is used to manage vertices and the other for polylines. // FiberPolyData stores all brain fibers using polylines (in world coordinates) // this variable hosts the smoothed fiber data, this data we generate, therefore a smartpointer structure is recommended // vtkSmartPointer m_FiberPolyData; is depricated // // this variable hosts the original fiber data, no smartpointer needed because who or whatever passes this data to FiberBundleX should use vtkSmartPointer structure - vtkPolyData* m_FiberStructureData; + vtkSmartPointer m_FiberStructureData; // VertexPolyData stores all original points as vertices computed by tracking algorithms vtkSmartPointer m_VertexPolyData; }; } // namespace mitk #endif /* _MITK_FiberBundleX_H */ diff --git a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp index 60cd378e58..2e73a53149 100644 --- a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp +++ b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp @@ -1,308 +1,305 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-06-18 15:59:04 +0200 (Do, 18 Jun 2009) $ Version: $Revision: 16916 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkDiffusionImagingObjectFactory.h" #include "mitkProperties.h" #include "mitkBaseRenderer.h" #include "mitkDataNode.h" #include "mitkNrrdDiffusionImageIOFactory.h" #include "mitkNrrdDiffusionImageWriterFactory.h" #include "mitkNrrdDiffusionImageWriter.h" #include "mitkDiffusionImage.h" #include "mitkNrrdQBallImageIOFactory.h" #include "mitkNrrdQBallImageWriterFactory.h" #include "mitkNrrdQBallImageWriter.h" #include "mitkNrrdTensorImageIOFactory.h" #include "mitkNrrdTensorImageWriterFactory.h" #include "mitkNrrdTensorImageWriter.h" #include "mitkCompositeMapper.h" #include "mitkDiffusionImageMapper.h" #include "mitkGPUVolumeMapper3D.h" #include "mitkVolumeDataVtkMapper3D.h" //====depricated fiberstructure===== #include "mitkFiberBundle.h" #include "mitkFiberBundleMapper3D.h" #include "mitkFiberBundleIOFactory.h" #include "mitkFiberBundleWriterFactory.h" #include "mitkFiberBundleWriter.h" //================================== //modernized fiberbundle datastrucutre #include "mitkFiberBundleX.h" #include "mitkFiberBundleXIOFactory.h" #include "mitkFiberBundleXWriterFactory.h" #include "mitkFiberBundleXWriter.h" #include "mitkFiberBundleXMapper3D.h" #include "mitkNrrdTbssImageIOFactory.h" #include "mitkNrrdTbssImageWriterFactory.h" #include "mitkNrrdTbssImageWriter.h" typedef short DiffusionPixelType; typedef char TbssRoiPixelType; typedef mitk::DiffusionImage DiffusionImageShort; typedef std::multimap MultimapType; mitk::DiffusionImagingObjectFactory::DiffusionImagingObjectFactory(bool /*registerSelf*/) :CoreObjectFactoryBase() { static bool alreadyDone = false; if (!alreadyDone) { MITK_INFO << "DiffusionImagingObjectFactory c'tor" << std::endl; RegisterIOFactories(); mitk::NrrdDiffusionImageIOFactory::RegisterOneFactory(); mitk::NrrdQBallImageIOFactory::RegisterOneFactory(); mitk::NrrdTensorImageIOFactory::RegisterOneFactory(); mitk::FiberBundleIOFactory::RegisterOneFactory(); mitk::NrrdTbssImageIOFactory::RegisterOneFactory(); mitk::FiberBundleXIOFactory::RegisterOneFactory(); //modernized mitk::NrrdDiffusionImageWriterFactory::RegisterOneFactory(); mitk::NrrdQBallImageWriterFactory::RegisterOneFactory(); mitk::NrrdTensorImageWriterFactory::RegisterOneFactory(); mitk::FiberBundleWriterFactory::RegisterOneFactory(); mitk::NrrdTbssImageWriterFactory::RegisterOneFactory(); mitk::FiberBundleXWriterFactory::RegisterOneFactory();//modernized m_FileWriters.push_back( NrrdDiffusionImageWriter::New().GetPointer() ); m_FileWriters.push_back( NrrdQBallImageWriter::New().GetPointer() ); m_FileWriters.push_back( NrrdTensorImageWriter::New().GetPointer() ); m_FileWriters.push_back( mitk::FiberBundleWriter::New().GetPointer() ); m_FileWriters.push_back( NrrdTbssImageWriter::New().GetPointer() ); m_FileWriters.push_back( mitk::FiberBundleXWriter::New().GetPointer() );//modernized mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(this); CreateFileExtensionsMap(); alreadyDone = true; } } mitk::Mapper::Pointer mitk::DiffusionImagingObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper=NULL; if ( id == mitk::BaseRenderer::Standard2D ) { std::string classname("QBallImage"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::CompositeMapper::New(); newMapper->SetDataNode(node); node->SetMapper(3, ((CompositeMapper*)newMapper.GetPointer())->GetImageMapper()); } classname = "TensorImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::CompositeMapper::New(); newMapper->SetDataNode(node); node->SetMapper(3, ((CompositeMapper*)newMapper.GetPointer())->GetImageMapper()); } classname = "DiffusionImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::DiffusionImageMapper::New(); newMapper->SetDataNode(node); } mitk::Mapper::Pointer newMapper=NULL; classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::ImageMapperGL2D::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { - if(node->GetData()){ - MITK_INFO << node->GetData()->GetNameOfClass(); - } - std::string classname("QBallImage"); + std::string classname("QBallImage"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::GPUVolumeMapper3D::New(); newMapper->SetDataNode(node); } classname = "TensorImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::GPUVolumeMapper3D::New(); newMapper->SetDataNode(node); } classname = "DiffusionImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::GPUVolumeMapper3D::New(); newMapper->SetDataNode(node); } classname = "FiberBundle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleMapper3D::New(); newMapper->SetDataNode(node); } classname = "FiberBundleX"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleXMapper3D::New(); newMapper->SetDataNode(node); } classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::VolumeDataVtkMapper3D::New(); newMapper->SetDataNode(node); } } return newMapper; } void mitk::DiffusionImagingObjectFactory::SetDefaultProperties(mitk::DataNode* node) { std::string classname = "QBallImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::CompositeMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "TensorImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::CompositeMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "DiffusionImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::DiffusionImageMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "FiberBundle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::FiberBundleMapper3D::SetDefaultProperties(node); } classname = "FiberBundleX"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { - mitk::FiberBundleMapper3D::SetDefaultProperties(node); + mitk::FiberBundleXMapper3D::SetDefaultProperties(node); } classname = "TbssImage"; std::string n = node->GetData()->GetNameOfClass(); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::ImageMapperGL2D::SetDefaultProperties(node); mitk::VolumeDataVtkMapper3D::SetDefaultProperties(node); } } const char* mitk::DiffusionImagingObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::DiffusionImagingObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } const char* mitk::DiffusionImagingObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::DiffusionImagingObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::DiffusionImagingObjectFactory::CreateFileExtensionsMap() { m_FileExtensionsMap.insert(std::pair("*.dwi", "Diffusion Weighted Images")); m_FileExtensionsMap.insert(std::pair("*.hdwi", "Diffusion Weighted Images")); m_FileExtensionsMap.insert(std::pair("*.nii", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.fsl", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.fslgz", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.qbi", "Q-Ball Images")); m_FileExtensionsMap.insert(std::pair("*.hqbi", "Q-Ball Images")); m_FileExtensionsMap.insert(std::pair("*.dti", "Tensor Images")); m_FileExtensionsMap.insert(std::pair("*.hdti", "Tensor Images")); m_FileExtensionsMap.insert(std::pair("*.fib", "Fiber Bundle")); m_FileExtensionsMap.insert(std::pair("*.vfib", "Fiber Bundle Polydata")); m_FileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle Polydata")); m_FileExtensionsMap.insert(std::pair("*.tbss", "TBSS data")); m_SaveFileExtensionsMap.insert(std::pair("*.dwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hdwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.nii", "Diffusion Weighted Images for FSL")); m_SaveFileExtensionsMap.insert(std::pair("*.fsl", "Diffusion Weighted Images for FSL")); m_SaveFileExtensionsMap.insert(std::pair("*.fslgz", "Diffusion Weighted Images for FSL")); m_SaveFileExtensionsMap.insert(std::pair("*.qbi", "Q-Ball Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hqbi", "Q-Ball Images")); m_SaveFileExtensionsMap.insert(std::pair("*.dti", "Tensor Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hdti", "Tensor Images")); m_SaveFileExtensionsMap.insert(std::pair("*.fib", "Fiber Bundle")); m_SaveFileExtensionsMap.insert(std::pair("*.vfib", "Fiber Bundle Polydata")); m_SaveFileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle Polydata")); m_SaveFileExtensionsMap.insert(std::pair("*.tbss", "TBSS data")); } void mitk::DiffusionImagingObjectFactory::RegisterIOFactories() { } void RegisterDiffusionImagingObjectFactory() { static bool oneDiffusionImagingObjectFactoryRegistered = false; if ( ! oneDiffusionImagingObjectFactoryRegistered ) { MITK_INFO << "Registering DiffusionImagingObjectFactory..." << std::endl; mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(mitk::DiffusionImagingObjectFactory::New()); oneDiffusionImagingObjectFactoryRegistered = true; } } diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp index 6f1a12fa0d..773ea3d4e1 100644 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp +++ b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp @@ -1,1140 +1,1140 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkProperties.h" #include "mitkFiberBundleMapper3D.h" #include #include #include #include #include #include #include #include #include #include #include #include "vtkVertex.h" #include #include #include #include #include #include "mitkFiberBundleInteractor.h" #include "mitkGlobalInteraction.h" //template mitk::FiberBundleMapper3D::FiberBundleMapper3D() : m_vtkFiberList(NULL), -m_VtkFiberDataMapperGL(NULL), +//m_VtkFiberDataMapperGL(NULL), + m_VtkFiberDataMapperGL(vtkOpenGLPolyDataMapper::New()), m_vtkTubeMapper(NULL) { //MITK_INFO << "FiberBundleMapper3D()"; m_FiberAssembly = vtkPropAssembly::New(); m_FiberActor = vtkOpenGLActor::New(); m_TubeActor = vtkOpenGLActor::New(); /* vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); colorsT->SetName("Colors"); colorsT->SetNumberOfComponents(4); unsigned char red1[4] = {255, 0, 0 , 10}; colorsT->InsertNextTupleValue(red1); unsigned char red2[4] = {255,0, 0 , 255}; colorsT->InsertNextTupleValue(red2); colorsT->SetValue(3, (unsigned char)(255)); colorsT->SetValue(7, (unsigned char)(255)); //Create points for polyline1. double origin[3] = {100.0, 400.0, 0.0}; double p0[3] = {300.0, 400.0, 0.0}; double p1[3] = {300.0, 200.0, 0.0}; double p2[3] = {100.0, 300.0, 0.0}; double p3[3] = {130.0, 250.0, 0.0}; //create points for polyline2 //double p01[3] = {50.0, 50.0, 13.0}; //double p11[3] = {200.0, 100.0, 13.0}; //insert points to vtkPointarray vtkPoints *pnts = vtkPoints::New(); pnts->InsertPoint(0,origin); pnts->InsertPoint(1,p0); pnts->InsertPoint(2,p1); pnts->InsertPoint(3,p2); //pnts->InsertPoint(4,p01); //pnts->InsertPoint(5,p11); pnts->InsertPoint(4,p3); //generate and define polyline1 vtkPolyLine *polyLine = vtkPolyLine::New(); polyLine->GetPointIds()->SetNumberOfIds(4); polyLine->GetPointIds()->SetId(0,0); polyLine->GetPointIds()->SetId(1,1); polyLine->GetPointIds()->SetId(2,2); polyLine->GetPointIds()->SetId(3,3); /*generate and define polyline2 vtkPolyLine *polyLine2 = vtkPolyLine::New(); polyLine2->GetPointIds()->SetNumberOfIds(2); polyLine2->GetPointIds()->SetId(0,4); polyLine2->GetPointIds()->SetId(1,5); */ /* vtkVertex *vtx = vtkVertex::New(); vtx->GetPointIds()->SetNumberOfIds(1); vtx->GetPointIds()->SetId(0,4); vtkCellArray *lines = vtkCellArray::New(); lines->InsertNextCell(polyLine); //lines->InsertNextCell(vtx); //lines->InsertNextCell(polyLine2); vtkCellArray *vertx = vtkCellArray::New(); vertx->InsertNextCell(vtx); vtkPolyData *polyDataT = vtkPolyData::New(); polyDataT->SetPoints(pnts); polyDataT->SetLines(lines); polyDataT->SetVerts(vertx); //color and opacity handling vtkUnsignedCharArray *colorT = vtkUnsignedCharArray::New(); colorT->SetName("Colors"); colorT->SetNumberOfComponents(4); //4 components cuz of RGBA unsigned char rgba[4] = {255,0,0,255}; unsigned char rgba2[4] = {0,255,0,255}; //if just 1 point in there colorT->InsertNextTupleValue(rgba); colorT->InsertNextTupleValue(rgba2); colorT->InsertNextTupleValue(rgba); colorT->InsertNextTupleValue(rgba2); colorT->InsertNextTupleValue(rgba); /*for(int i=0; i<6; i++) { double vtkPntTmp[3]; pnts->GetPoint(i, vtkPntTmp); double vtkPntTmpNxt[3]; pnts->GetPoint(i+1, vtkPntTmpNxt); vnl_vector_fixed< double, 3 > tmpPntvtk( vtkPntTmp[0], vtkPntTmp[1],vtkPntTmp[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(vtkPntTmpNxt[0], vtkPntTmpNxt[1], vtkPntTmpNxt[2]); vnl_vector_fixed< double, 3 > diff; diff = tmpPntvtk - nxttmpPntvtk; diff.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); rgba[3] = (unsigned char) (255.0); if(i==3) { colorT->InsertNextTupleValue(rgba); colorT->InsertNextTupleValue(rgba); }else if(i==4) { //do nothing }else{ colorT->InsertNextTupleValue(rgba); } } /* unsigned char red[4] = {255, 0, 0 , 20}; unsigned char green[4] = {0, 255, 0 , 190}; unsigned char blue[4] = {0, 0, 255, 255}; unsigned char white[4] = {255, 255, 255, 255}; colorT->InsertNextTupleValue(red); //color for point0 colorT->InsertNextTupleValue(green); //color for point1 colorT->InsertNextTupleValue(blue); colorT->InsertNextTupleValue(white); colorT->InsertNextTupleValue(white); colorT->InsertNextTupleValue(white); //color for point5 polyDataT->GetPointData()->AddArray(colorT); vtkTubeFilter *tube = vtkTubeFilter::New(); tube->SetInput(polyDataT); tube->SetNumberOfSides(8); tube->SetRadius(5); vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInput(polyDataT); //mapper->SetInputConnection(tube->GetOutputPort()); mapper->ScalarVisibilityOn(); mapper->SetScalarModeToUsePointFieldData(); //mapper->SetColorModeToMapScalars(); mapper->SelectColorArray("Colors"); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); actor->GetProperty()->SetOpacity(1.0); //actor->GetProperty()->SetLineWidth(20); actor->GetProperty()->SetPointSize(5.0); vtkSmartPointer renderer = vtkSmartPointer::New(); renderer->AddActor(actor); //renderer->SetBackground(.2, .3, .4); // Make an oblique view renderer->GetActiveCamera()->Azimuth(30); renderer->GetActiveCamera()->Elevation(30); renderer->ResetCamera(); vtkSmartPointer renWin = vtkSmartPointer::New(); vtkSmartPointer iren = vtkSmartPointer::New(); iren->SetRenderWindow(renWin); renWin->AddRenderer(renderer); //renWin->LineSmoothingOff(); renWin->SetSize(500, 500); renWin->Render(); vtkSmartPointer style = vtkSmartPointer::New(); iren->SetInteractorStyle(style); iren->Start(); MITK_INFO << "swerwas"; /* // Spiral tube double vX, vY, vZ; unsigned int nV = 256; // No. of vertices unsigned int nCyc = 5; // No. of spiral cycles double rT1 = 0.1, rT2 = 0.5;// Start/end tube radii double rS = 2; // Spiral radius double h = 10; // Height unsigned int nTv = 8; // No. of surface elements for each tube vertex unsigned int i; // Create points and cells for the spiral vtkSmartPointer points = vtkSmartPointer::New(); for(i = 0; i < nV; i++) { // Spiral coordinates vX = rS * cos(2 * 3 * nCyc * i / (nV - 1)); vY = rS * sin(2 * 3 * nCyc * i / (nV - 1)); vZ = h * i / nV; points->InsertPoint(i, vX, vY, vZ); } vtkSmartPointer lines = vtkSmartPointer::New(); lines->InsertNextCell(nV); for (i = 0; i < nV; i++) { lines->InsertCellPoint(i); } vtkSmartPointer polyData = vtkSmartPointer::New(); polyData->SetPoints(points); polyData->SetLines(lines); // RBG array (could add Alpha channel too I guess...) // Varying from blue to red vtkSmartPointer colors = vtkSmartPointer::New(); colors->SetName("Colors"); colors->SetNumberOfComponents(3); colors->SetNumberOfTuples(nV); for (i = 0; i < nV ;i++) { unsigned char red[3] = {char(255 * i/ (nV - 1)),0,char(255 * (nV - 1 - i)/(nV - 1))}; colors->InsertNextTupleValue( red); } polyData->GetPointData()->AddArray(colors); vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInput(polyData); mapper->ScalarVisibilityOn(); mapper->SetScalarModeToUsePointFieldData(); mapper->SelectColorArray("Colors"); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); vtkSmartPointer renderer = vtkSmartPointer::New(); renderer->AddActor(actor); renderer->SetBackground(.2, .3, .4); // Make an oblique view renderer->GetActiveCamera()->Azimuth(30); renderer->GetActiveCamera()->Elevation(30); renderer->ResetCamera(); vtkSmartPointer renWin = vtkSmartPointer::New(); vtkSmartPointer iren = vtkSmartPointer::New(); iren->SetRenderWindow(renWin); renWin->AddRenderer(renderer); renWin->SetSize(500, 500); renWin->Render(); vtkSmartPointer style = vtkSmartPointer::New(); iren->SetInteractorStyle(style); iren->Start(); /* double origin[3] = {0.0, 0.0, 0.0}; double p0[3] = {10.0, 0.0, 0.0}; double p1[3] = {10.0, 10.0, 0.0}; double p2[3] = {0.0, 10.0, 0.0}; double p3[3] = {10.0, 10.0, 0.0}; double p4[3] = {10.0, 20.0, 0.0}; double p5[3] = {0.0, 20.0, 0.0}; //create a vtkPoints object and store the points in it vtkSmartPointer points = vtkSmartPointer::New(); points->InsertNextPoint(origin); points->InsertNextPoint(p0); points->InsertNextPoint(p1); points->InsertNextPoint(p2); points->InsertNextPoint(p3); points->InsertNextPoint(p4); points->InsertNextPoint(p5); vtkSmartPointer polyLine = vtkSmartPointer::New(); polyLine->GetPointIds()->SetNumberOfIds(7); for(unsigned int i = 0; i < 7; i++) { polyLine->GetPointIds()->SetId(i,i); } double origin2[3] = {30.0, 0.0, 0.0}; double p02[3] = {40.0, 0.0, 0.0}; double p12[3] = {40.0, 20.0, 0.0}; double p22[3] = {30.0, 20.0, 0.0}; double p23[3] = {30.0, 0.0, 0.0}; points->InsertNextPoint(origin2); points->InsertNextPoint(p02); points->InsertNextPoint(p12); points->InsertNextPoint(p22); points->InsertNextPoint(p23); vtkSmartPointer polyLine2 = vtkSmartPointer::New(); polyLine2->GetPointIds()->SetNumberOfIds(5); for(unsigned int i = 0; i < 5; i++) { polyLine2->GetPointIds()->SetId(i,i+7); } //Create a cell array to store the lines in and add the lines to it vtkSmartPointer cells = vtkSmartPointer::New(); cells->InsertNextCell(polyLine); cells->InsertNextCell(polyLine2); //Create a polydata to store everything in vtkSmartPointer polyData = vtkSmartPointer::New(); //add the points to the dataset polyData->SetPoints(points); //add the lines to the dataset polyData->SetLines(cells); //setup actor and mapper vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInput(polyData); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); m_FiberAssembly->AddPart(actor); */ } //template mitk::FiberBundleMapper3D::~FiberBundleMapper3D() { //MITK_INFO << "FiberBundleMapper3D(destructor)"; m_FiberActor->Delete(); m_FiberAssembly->Delete(); //m_vtkFiberList->Delete(); //m_VtkFiberDataMapperGL->Delete(); //m_VtkFiberDataMapper->Delete(); } const mitk::FiberBundle* mitk::FiberBundleMapper3D::GetInput() { //MITK_INFO << "FiberBundleMapper3D GetInput()" ; return static_cast ( GetData() ); } /* This method is called once the mapper gets new input, for UI rotation or changes in colorcoding this method is NOT called */ void mitk::FiberBundleMapper3D::GenerateData() { /* ######## FIBER PREPARATION START ######### */ //get fiberbundle mitk::FiberBundle::Pointer PFiberBundle = dynamic_cast< mitk::FiberBundle* > (this->GetData()); //get groupFiberBundle, which is a datastructure containing single fibers mitk::FiberBundle::FiberGroupType::Pointer groupFiberBundle = PFiberBundle->GetGroupFiberBundle(); //extractn single fibers //in the groupFiberBundle all smartPointers to single fibers are stored in in a ChildrenList mitk::FiberBundle::ChildrenListType * FiberList; FiberList = groupFiberBundle->GetChildren(); /* ######## FIBER PREPARATION END ######### */ /* ######## VTK FIBER REPRESENTATION ######## */ //create a vtkPoints object and store the all the brainFiber points in it vtkPoints* vtkSmoothPoints = vtkPoints::New(); //in smoothpoints the interpolated points representing a fiber are stored. //in vtkcells all polylines are stored, actually all id's of them are stored vtkCellArray *vtkSmoothCells = vtkCellArray::New(); //cellcontainer for smoothed lines //in some cases a fiber includes just 1 point, so put it in here vtkCellArray *vtkVrtxs = vtkCellArray::New(); //colors and alpha value for each single point, RGBA = 4 components vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); colorsT->SetNumberOfComponents(4); colorsT->SetName("ColorValues"); vtkDoubleArray *faColors = vtkDoubleArray::New(); faColors->SetName("FaColors"); vtkDoubleArray *tubeRadius = vtkDoubleArray::New(); tubeRadius->SetName("TubeRadius"); // iterate through FiberList for(mitk::FiberBundle::ChildrenListType::iterator itLst = FiberList->begin(); itLst != FiberList->end(); ++itLst) { //all points are stored in one vtkpoints list, soooooooo that the lines find their point id to start and end we need some kind of helper index who monitors the current ids for a polyline //unsigned long pntIdxHelper = vtkpointsDTI->GetNumberOfPoints(); // lists output is SpatialObject, we know we have DTITubeSpacialObjects // dynamic cast only likes pointers, no smartpointers, so each dsmartpointer has membermethod .GetPointer() itk::SpatialObject<3>::Pointer tmp_fbr; tmp_fbr = *itLst; mitk::FiberBundle::DTITubeType::Pointer dtiTract = dynamic_cast< mitk::FiberBundle::DTITubeType * > (tmp_fbr.GetPointer()); if (dtiTract.IsNull()) { return; } //get list of points int fibrNrPnts = dtiTract->GetNumberOfPoints(); mitk::FiberBundle::DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); //MITK_INFO << "REAL AMOUNT OF FIBERS: " << fibrNrPnts; vtkPoints *vtkpointsDTI = vtkPoints::New(); if (fibrNrPnts <= 0) { //this should never occour! but who knows MITK_INFO << "HyperERROR in fiberBundleMapper3D.cpp ...no point in fiberBundle!!! .. check ur trackingAlgorithm"; continue; } ///////PROCESS ON FIBERS//////// for (int i=0; i1 PFiberBundle->GetGeometry()->IndexToWorld(indexPnt, worldPnt); double worldFbrPnt[3] = {worldPnt[0], worldPnt[1], worldPnt[2]}; vtkpointsDTI->InsertNextPoint(worldFbrPnt); } //MITK_INFO << "REDUCED AMOUNT OF FIBERS: " << vtkpointsDTI->GetNumberOfPoints(); ////POINTS OF DTI ARE READY FOR FUTHER VTK PROCESSING//// } /////PROCESS POLYLINE SMOOTHING///// vtkKochanekSpline* xSpline = vtkKochanekSpline::New(); vtkKochanekSpline* ySpline = vtkKochanekSpline::New(); vtkKochanekSpline* zSpline = vtkKochanekSpline::New(); vtkParametricSpline* spline = vtkParametricSpline::New(); spline->SetXSpline(xSpline); spline->SetYSpline(ySpline); spline->SetZSpline(zSpline); spline->SetPoints(vtkpointsDTI); vtkParametricFunctionSource* functionSource = vtkParametricFunctionSource::New(); functionSource->SetParametricFunction(spline); functionSource->SetUResolution(200); functionSource->SetVResolution(200); functionSource->SetWResolution(200); functionSource->Update(); vtkPolyData* outputFunction = functionSource->GetOutput(); vtkPoints* tmpSmoothPnts = outputFunction->GetPoints(); //smoothPoints of current fiber vtkPolyLine* smoothLine = vtkPolyLine::New(); smoothLine->GetPointIds()->SetNumberOfIds(tmpSmoothPnts->GetNumberOfPoints()); // MITK_INFO << "SMOOTHED AMOUNT OF POINTS:" << tmpSmoothPnts->GetNumberOfPoints(); /////CREATE SMOOTH POLYLINE OBJECT//// /////MANAGE LINE AND CORRELATED POINTS///// int pointHelperCnt = vtkSmoothPoints->GetNumberOfPoints(); //also put current points into global smooth pointcontainer int nrSmPnts = tmpSmoothPnts->GetNumberOfPoints(); tubeRadius->SetNumberOfTuples(nrSmPnts); double tbradius = 1;//default value for radius for(int ism=0; ismGetPointIds()->SetId(ism, ism+pointHelperCnt); vtkSmoothPoints->InsertNextPoint(tmpSmoothPnts->GetPoint(ism)); // MITK_INFO << "LinePntID: " << ism << " linked to: " << ism+pointHelperCnt << " val: " << tmpSmoothPnts->GetPoint(ism)[0] << " " << tmpSmoothPnts->GetPoint(ism)[1] << " " << tmpSmoothPnts->GetPoint(ism)[2]; tubeRadius->SetTuple1(ism,tbradius); //tuple with 1 argument //colorcoding orientation based unsigned char rgba[4] = {0,0,0,0}; if (ism < nrSmPnts-1 && ism>0) { // MITK_INFO << "inbetween fiber, at position:" << ism; // //nimm nur diff1 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(tmpSmoothPnts->GetPoint(ism+1)[0], tmpSmoothPnts->GetPoint(ism+1)[1], tmpSmoothPnts->GetPoint(ism+1)[2]); vnl_vector_fixed< double, 3 > prevtmpPntvtk(tmpSmoothPnts->GetPoint(ism-1)[0], tmpSmoothPnts->GetPoint(ism-1)[1], tmpSmoothPnts->GetPoint(ism-1)[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = tmpPntvtk - nxttmpPntvtk; diff1.normalize(); vnl_vector_fixed< double, 3 > diff2; diff2 = tmpPntvtk - prevtmpPntvtk; diff2.normalize(); vnl_vector_fixed< double, 3 > diff; diff = (diff1 - diff2)/2.0; rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); rgba[3] = (unsigned char) (255.0); } else if(ism==0) { //explicit handling of startpoint of line //nimm nur diff1 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(tmpSmoothPnts->GetPoint(ism+1)[0], tmpSmoothPnts->GetPoint(ism+1)[1], tmpSmoothPnts->GetPoint(ism+1)[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = tmpPntvtk - nxttmpPntvtk; diff1.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff1[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff1[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff1[2])); rgba[3] = (unsigned char) (255.0); // MITK_INFO << "first point color: " << rgba[0] << " " << rgba[1] << " " << rgba[2]; } else if(ism==nrSmPnts-1) { // last point in fiber // nimm nur diff2 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > prevtmpPntvtk(tmpSmoothPnts->GetPoint(ism-1)[0], tmpSmoothPnts->GetPoint(ism-1)[1], tmpSmoothPnts->GetPoint(ism-1)[2]); vnl_vector_fixed< double, 3 > diff2; diff2 = tmpPntvtk - prevtmpPntvtk; diff2.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff2[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff2[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff2[2])); rgba[3] = (unsigned char) (255.0); // // MITK_INFO << "last point color: " << rgba[0] << " " << rgba[1] << " " << rgba[2]; } //end colorcoding // colorsT->InsertNextTupleValue(rgba); }//end of smoothline ///////smooth Fiber ready//////// vtkSmoothCells->InsertNextCell(smoothLine); } //vtkpointsDTI->Delete();//points are not needed anymore TODO uncomment! /* //get FA value ... for that FA has to be interpolated as well as DTItracktLine float faVal = tmpFiberPntLst.GetField(mitk::FiberBundle::DTITubePointType::FA); //use insertNextValue cuz FA Values are reperesented as a single number (1 Tuple containing 1 parameter) faColors->InsertNextValue((double) faVal); */ //vtkcells->InitTraversal(); // Put points and lines together in one polyData structure vtkPolyData *polyData = vtkPolyData::New(); polyData->SetPoints(vtkSmoothPoints); polyData->SetLines(vtkSmoothCells); if (vtkVrtxs->GetSize() > 0) { polyData->SetVerts(vtkVrtxs); } polyData->GetPointData()->AddArray(colorsT); //polyData->GetPointData()->AddArray(faColors); //polyData->GetPointData()->AddArray(tubeRadius); vtkLookupTable *lut = vtkLookupTable::New(); lut->Build(); - m_VtkFiberDataMapperGL = vtkOpenGLPolyDataMapper::New(); + // m_VtkFiberDataMapperGL = vtkOpenGLPolyDataMapper::New(); m_VtkFiberDataMapperGL->SetInput(polyData); m_VtkFiberDataMapperGL->ScalarVisibilityOn(); m_VtkFiberDataMapperGL->SetScalarModeToUsePointFieldData(); //m_VtkFiberDataMapperGL->SelectColorArray("FaColors"); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); m_VtkFiberDataMapperGL->SetLookupTable(lut); m_vtkTubeMapper = vtkOpenGLPolyDataMapper::New(); //m_FiberActor = vtkOpenGLActor::New(); m_FiberActor->SetMapper(m_VtkFiberDataMapperGL); m_FiberActor->GetProperty()->SetOpacity(1.0); m_FiberActor->GetProperty()->SetPointSize(4.0f); // m_FiberActor->GetProperty()->SetColor(255.0, 0.0, 0.0); m_FiberAssembly->AddPart(m_FiberActor); //setting color and opacity in the fiberActor itself is not recommended //here cuz color and opacity of dataNode will be considered in GetData(baserenderer*) anyway this->GetDataNode()->SetColor(255.0,0,0); this->GetDataNode()->SetOpacity(1.0); } //template void mitk::FiberBundleMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { - //MITK_INFO << "FiberBundleMapper3D GenerateData(BaseRenderer)" ; // nodeCC = 1 ... ROI colorcoding // 2 ... orientation colorcoding // 3 ... FA colorcoding int nodeCC; bool isCCd = this->GetDataNode()->GetPropertyValue("ColorCoding", nodeCC); if ( isCCd && nodeCC == 1 ) { //get color and opacity from DataNode int tmpline; bool isLineProp = this->GetDataNode()->GetPropertyValue("LineWidth",tmpline); bool isPointRep; bool successPointProp = this->GetDataNode()->GetPropertyValue("RepPoints", isPointRep); float pointSize; bool successPointSize = this->GetDataNode()->GetPropertyValue("pointSize", pointSize); if (isLineProp) { m_FiberActor->GetProperty()->SetLineWidth(tmpline); } if(isPointRep) { m_FiberActor->GetProperty()->SetRepresentationToPoints(); m_FiberActor->GetProperty()->SetPointSize(pointSize); } } else if (isCCd && nodeCC == 2) { float tmpopa; this->GetDataNode()->GetOpacity(tmpopa, NULL); m_FiberActor->GetProperty()->SetOpacity((double) tmpopa); } else if (isCCd && nodeCC == 3) { float temprgb[3]; this->GetDataNode()->GetColor( temprgb, NULL ); double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; m_FiberActor->GetProperty()->SetColor(trgb); if(m_VtkFiberDataMapperGL->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_VtkFiberDataMapperGL->ScalarVisibilityOff(); } } else if (isCCd && nodeCC == 4) { if(!m_VtkFiberDataMapperGL->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_VtkFiberDataMapperGL->ScalarVisibilityOn(); } m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 5){ if(!m_VtkFiberDataMapperGL->GetScalarVisibility()) //if visibility is off, switch it on { m_VtkFiberDataMapperGL->ScalarVisibilityOn(); } m_VtkFiberDataMapperGL->SelectColorArray("FaColors"); } else if (isCCd && nodeCC == 6){ //orientationbased colorcoding + FA as opacity //get FA out of polydata, which is saved in faColor vtkDoubleArray vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPointData *tmpPointData = tmpPolyData->GetPointData(); int hasAr = tmpPointData->HasArray("FaColors"); if(!hasAr) return; vtkDoubleArray *tmpFAarray = (vtkDoubleArray*)(tmpPointData->GetArray("FaColors")) ; /*for(int i=0; iGetNumberOfTuples(); i++) { double *tmpTuple; tmpFAarray->GetTuple(i, tmpTuple); for(int j=0; jGetNumberOfComponents(); j++) { MITK_INFO << "FA Value: at index " << i << ": " << tmpTuple[j]; } } */ //since we have our FA values, lets replace the alpha values in colorT //we know each 4th entry is a A value of RGBA int hasArCV = tmpPointData->HasArray("ColorValues"); if(!hasArCV) return; vtkUnsignedCharArray *colorsTtmp = dynamic_cast (tmpPointData->GetArray("ColorValues")); for(int i=0; iGetNumberOfTuples(); i++) { //double *tmpTupleCV = colorsTtmp->GetTuple4(i); double tmpTupleFA = tmpFAarray->GetTuple1(i); tmpTupleFA = tmpTupleFA * 255.0; colorsTtmp->SetComponent(i,3, tmpTupleFA ); // MITK_INFO << "----" << i; //MITK_INFO << tmpTupleCV[0]; //MITK_INFO << tmpTupleCV[1]; //MITK_INFO << tmpTupleCV[2]; //MITK_INFO << tmpTupleCV[3]; //double *test = m_VtkFiberDataMapperGL->GetInput()->GetPointData()->GetArray("ColorValues")->GetTuple4(i); //MITK_INFO << test[0]; //MITK_INFO << test[1]; //MITK_INFO << test[2]; //MITK_INFO << test[3]; } m_VtkFiberDataMapperGL->SelectColorArray(""); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 7){ vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPointData *tmpPointData = tmpPolyData->GetPointData(); int hasArCV = tmpPointData->HasArray("ColorValues"); if(!hasArCV) return; vtkUnsignedCharArray *colorsTtmp = dynamic_cast (tmpPointData->GetArray("ColorValues")); for(int i=0; iGetNumberOfTuples(); i++) { double tmpTupleFA = 255.0; colorsTtmp->SetComponent(i,3, tmpTupleFA ); } m_VtkFiberDataMapperGL->SelectColorArray(""); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 8) { /* something is still missing to activate smoothing or make it work.... */ if (!renderer->GetRenderWindow()->GetLineSmoothing()) { renderer->GetRenderWindow()->SetLineSmoothing(1); renderer->GetRenderWindow()->Modified(); } if (!renderer->GetRenderWindow()->GetPointSmoothing()) { renderer->GetRenderWindow()->SetPointSmoothing(1); renderer->GetRenderWindow()->Modified(); } if (!renderer->GetRenderWindow()->GetPolygonSmoothing()) { renderer->GetRenderWindow()->SetPolygonSmoothing(1); renderer->GetRenderWindow()->Modified(); } } else if (isCCd && nodeCC == 9) { if (renderer->GetRenderWindow()->GetLineSmoothing()) { renderer->GetRenderWindow()->SetLineSmoothing(0); renderer->GetRenderWindow()->Modified(); } if (renderer->GetRenderWindow()->GetPointSmoothing()) { renderer->GetRenderWindow()->SetPointSmoothing(0); renderer->GetRenderWindow()->Modified(); } if (renderer->GetRenderWindow()->GetPolygonSmoothing()) { renderer->GetRenderWindow()->SetPolygonSmoothing(0); renderer->GetRenderWindow()->Modified(); } } else if (isCCd && nodeCC == 10) { // manipulate X Coordinates of selected FiberBundle int tmpXmove; bool isXmove = this->GetDataNode()->GetPropertyValue("Xmove",tmpXmove); if (!isXmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[0] = PtmpPntVal[0] + (double) tmpXmove; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 11) { // manipulate Y Coordinates of selected FiberBundle int tmpYmove; bool isYmove = this->GetDataNode()->GetPropertyValue("Ymove",tmpYmove); if (!isYmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[1] = PtmpPntVal[1] + (double) tmpYmove; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 12) { // manipulate Z Coordinates of selected FiberBundle int tmpZmove; bool isZmove = this->GetDataNode()->GetPropertyValue("Zmove",tmpZmove); if (!isZmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[2] = PtmpPntVal[2] + (double) tmpZmove; //PtmpPntVal[2] = PtmpPntVal[2] + 1; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 13) { int tmpTubeSides; bool isTubeSides = this->GetDataNode()->GetPropertyValue("TubeSides",tmpTubeSides); float tmpRadius; bool isRadius = this->GetDataNode()->GetPropertyValue("TubeRadius",tmpRadius); if (!isTubeSides) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); m_tubes = vtkTubeFilter::New(); m_tubes->SetInput(tmpPolyData); m_tubes->SidesShareVerticesOn(); m_tubes->SetRadius((double)(tmpRadius)); m_tubes->SetNumberOfSides(tmpTubeSides); m_tubes->Modified(); // m_tubes->Update(); m_vtkTubeMapper->SetInputConnection(m_tubes->GetOutputPort()); m_vtkTubeMapper->ScalarVisibilityOn(); m_vtkTubeMapper->SetScalarModeToUsePointFieldData(); m_vtkTubeMapper->SelectColorArray(""); m_vtkTubeMapper->SelectColorArray("ColorValues"); m_TubeActor->SetMapper(m_vtkTubeMapper); m_TubeActor->GetProperty()->SetOpacity(1); m_TubeActor->GetProperty()->BackfaceCullingOn(); m_FiberAssembly->AddPart(m_TubeActor); m_FiberAssembly->Modified(); } else if (isCCd && nodeCC == 14) { float temprgb[3]; this->GetDataNode()->GetColor( temprgb, NULL ); double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; m_TubeActor->GetProperty()->SetColor(trgb); if(m_vtkTubeMapper->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_vtkTubeMapper->ScalarVisibilityOff(); } } else if (isCCd && nodeCC == 15) { m_TubeActor->GetProperty()->SetOpacity(0); m_FiberAssembly->RemovePart(m_TubeActor); m_FiberAssembly->Modified(); }else if (isCCd && nodeCC == 16) { float tmpTubeOpacity; bool isTubeOpacity = this->GetDataNode()->GetPropertyValue("TubeOpacity",tmpTubeOpacity); m_TubeActor->GetProperty()->SetOpacity((double) tmpTubeOpacity); m_TubeActor->Modified(); } else if (isCCd && nodeCC == 17) { m_FiberActor->GetProperty()->SetOpacity(0); m_FiberAssembly->RemovePart(m_FiberActor); m_FiberAssembly->Modified(); }else if (isCCd && nodeCC == 18) { m_FiberActor->GetProperty()->SetOpacity(0); m_FiberAssembly->AddPart(m_FiberActor); m_FiberAssembly->Modified(); } //MITK_INFO << m_VtkFiberDataMapperGL->GetArrayName(); /* int displayIndex(0); this->GetDataNode()->GetIntProperty( "DisplayChannel", displayIndex, renderer ); InputImageType *input = const_cast< InputImageType* >( this->GetInput() ); mitk::DiffusionImage *input2 = dynamic_cast< mitk::DiffusionImage* >( input ); input2->SetDisplayIndexForRendering(displayIndex); Superclass::GenerateDataForRenderer(renderer); */ } //template void mitk::FiberBundleMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { - //MITK_INFO << "FiberBundleMapper3D SetDefault Properties(...)"; +// MITK_INFO << "FiberBundleMapper3D SetDefault Properties(...)"; node->AddProperty( "DisplayChannel", mitk::IntProperty::New( true ), renderer, overwrite ); node->AddProperty( "LineWidth", mitk::IntProperty::New( true ), renderer, overwrite ); node->AddProperty( "ColorCoding", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "VertexOpacity_1", mitk::BoolProperty::New( false ), renderer, overwrite); node->AddProperty( "Set_FA_VertexAlpha", mitk::BoolProperty::New( false ), renderer, overwrite); node->AddProperty( "pointSize", mitk::FloatProperty::New(0.5), renderer, overwrite); node->AddProperty( "setShading", mitk::IntProperty::New(1), renderer, overwrite); node->AddProperty( "Xmove", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "Ymove", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "Zmove", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "RepPoints", mitk::BoolProperty::New( false ), renderer, overwrite); node->AddProperty( "TubeSides", mitk::IntProperty::New( 8 ), renderer, overwrite); node->AddProperty( "TubeRadius", mitk::FloatProperty::New( 0.15 ), renderer, overwrite); node->AddProperty( "TubeOpacity", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); node->AddProperty( "pickable", mitk::BoolProperty::New( true ), renderer, overwrite); Superclass::SetDefaultProperties(node, renderer, overwrite); } vtkProp* mitk::FiberBundleMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) { //MITK_INFO << "FiberBundleMapper3D GetVtkProp(renderer)"; return m_FiberAssembly; } void mitk::FiberBundleMapper3D::ApplyProperties(mitk::BaseRenderer* renderer) { // MITK_INFO << "FiberBundleMapper3D ApplyProperties(renderer)"; } void mitk::FiberBundleMapper3D::UpdateVtkObjects() { // MITK_INFO << "FiberBundleMapper3D UpdateVtkObjects()"; } void mitk::FiberBundleMapper3D::SetVtkMapperImmediateModeRendering(vtkMapper *) { } diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.h b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.h index bc5be955c5..be68501d9d 100644 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.h +++ b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.h @@ -1,103 +1,103 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef FiberBundleMapper3D_H_HEADER_INCLUDED #define FiberBundleMapper3D_H_HEADER_INCLUDED //#include "mitkCommon.h" //#include "mitkBaseRenderer.h" #include "mitkFiberBundle.h" #include #include "mitkVtkMapper3D.h" #include "MitkDiffusionImagingExports.h" -#include "mitkBaseData.h" +//#include "mitkBaseData.h" #include "vtkAppendPolyData.h" #include "vtkOpenGLPolyDataMapper.h" #include "vtkOpenGLActor.h" #include "vtkPropAssembly.h" #include "vtkProperty.h" #include "vtkUnsignedCharArray.h" #include "vtkTubeFilter.h" namespace mitk { //##Documentation //## @brief Mapper for FiberBundles //## @ingroup Mapper // template class MitkDiffusionImaging_EXPORT FiberBundleMapper3D : public VtkMapper3D { public: mitkClassMacro(FiberBundleMapper3D, VtkMapper3D); itkNewMacro(Self); const mitk::FiberBundle* GetInput(); virtual vtkProp *GetVtkProp(mitk::BaseRenderer *renderer); //looks like depricated.. should be replaced bz GetViewProp() static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false ); virtual void ApplyProperties(mitk::BaseRenderer* renderer); static void SetVtkMapperImmediateModeRendering(vtkMapper *mapper); virtual void GenerateDataForRenderer(mitk::BaseRenderer* renderer); virtual void GenerateData(); protected: FiberBundleMapper3D(); virtual ~FiberBundleMapper3D(); void UpdateVtkObjects(); vtkAppendPolyData *m_vtkFiberList; //vtkSmartPointer m_vtkFiberList; vtkOpenGLPolyDataMapper *m_VtkFiberDataMapperGL; //vtkPainterPolyDataMapper *m_VtkFiberDataMapperGL; //vtkSmartPointer m_VtkFiberDataMapperGL; //vtkOpenGLPolyDataMapper *m_VtkFiberDataMapper; //vtkSmartPointer m_VtkFiberDataMapper; vtkOpenGLActor *m_FiberActor; //vtkSmartPointer m_FiberActor; vtkTubeFilter *m_tubes; vtkOpenGLActor *m_TubeActor; vtkOpenGLPolyDataMapper *m_vtkTubeMapper; vtkPropAssembly *m_FiberAssembly; }; } // namespace mitk #endif /* FiberBundleMapper3D_H_HEADER_INCLUDED */ diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.cpp b/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.cpp index 107d1e391b..181322cc1a 100644 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.cpp +++ b/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.cpp @@ -1,182 +1,187 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkFiberBundleXMapper3D.h" #include -#include -#include +//#include +//#include #include #include #include //not essential for mapper #include mitk::FiberBundleXMapper3D::FiberBundleXMapper3D() -: m_FiberMapperGLSP(vtkSmartPointer::New()), - m_FiberMapperGLWP(vtkOpenGLPolyDataMapper::New()), - m_FiberActorSP(vtkSmartPointer::New()), - m_FiberActorWP(vtkActor::New()), - m_FiberAssembly(vtkPropAssembly::New()) +:m_FiberMapperGLSP(vtkSmartPointer::New()), + m_FiberMapperGLWP(vtkOpenGLPolyDataMapper::New()), + m_FiberActorSP(vtkSmartPointer::New()), + m_FiberActorWP(vtkOpenGLActor::New()), + m_FiberAssembly(vtkPropAssembly::New()) { - MITK_INFO << "FiberBundleXxXXMapper3D()"; + } mitk::FiberBundleXMapper3D::~FiberBundleXMapper3D() { m_FiberAssembly->Delete(); } const mitk::FiberBundleX* mitk::FiberBundleXMapper3D::GetInput() { MITK_INFO << "FiberBundleXxXXMapper3D() GetInput()"; return static_cast ( GetData() ); } /* This method is called once the mapper gets new input, for UI rotation or changes in colorcoding this method is NOT called */ void mitk::FiberBundleXMapper3D::GenerateData() { MITK_INFO << "GENERATE DATA FOR FBX :)"; //=====timer measurement==== QTime myTimer; myTimer.start(); //========================== - mitk::FiberBundleX::Pointer FBX = dynamic_cast< mitk::FiberBundleX* > (this->GetData()); - vtkPolyData* FiberData = FBX->GetFibers(); -MITK_INFO << "NumOfFibs: " << FiberData->GetNumberOfLines(); +// mitk::FiberBundleX::Pointer FBX = dynamic_cast< mitk::FiberBundleX* > (this->GetData()); + + mitk::FiberBundleX::Pointer FBX = dynamic_cast (this->GetData()); + if (FBX.GetPointer() == NULL) { + MITK_INFO << "FBX==NULL"; + } + vtkSmartPointer FiberData = FBX->GetFibers(); + MITK_INFO << "NumOfFibs: " << FiberData->GetNumberOfLines(); MITK_INFO << "NumOfPoints: " << FiberData->GetNumberOfPoints(); m_FiberMapperGLSP->SetInput(FiberData); -// m_FiberMapperGLWP->SetInput(FiberData); + // m_FiberMapperGLWP->SetInput(FiberData); if ( FiberData->GetPointData()->GetNumberOfArrays() > 0 ) { if ( FiberData->GetPointData()->HasArray(FiberBundleX::COLORCODING_ORIENTATION_BASED) ) { m_FiberMapperGLSP->SelectColorArray(FiberBundleX::COLORCODING_ORIENTATION_BASED); -// m_FiberMapperGLWP->SelectColorArray(FiberBundleX::COLORCODING_ORIENTATION_BASED); + // m_FiberMapperGLWP->SelectColorArray(FiberBundleX::COLORCODING_ORIENTATION_BASED); } else { -// iterate through polydata array and take the first best -but valid- array + // iterate through polydata array and take the first best -but valid- array //===ToDo=== //check of componentsize as well, if it is not RGB or RGBA (ie. size 3 or 4), then check if it is a scalar // if scalar then create lookuptable for that. } m_FiberMapperGLSP->ScalarVisibilityOn(); -// m_FiberMapperGLWP->ScalarVisibilityOn(); + // m_FiberMapperGLWP->ScalarVisibilityOn(); m_FiberMapperGLSP->SetScalarModeToUsePointFieldData(); -// m_FiberMapperGLWP->SetScalarModeToUsePointFieldData(); + // m_FiberMapperGLWP->SetScalarModeToUsePointFieldData(); } - + m_FiberActorSP->SetMapper(m_FiberMapperGLSP); -// m_FiberActorWP->SetMapper(m_FiberMapperGLWP); + // m_FiberActorWP->SetMapper(m_FiberMapperGLWP); m_FiberActorSP->GetProperty()->SetOpacity(1.0); -// m_FiberActorWP->GetProperty()->SetOpacity(1.0); - + // m_FiberActorWP->GetProperty()->SetOpacity(1.0); + m_FiberAssembly->AddPart(m_FiberActorSP); //====timer measurement======== MITK_INFO << "Execution Time GenerateData() (nmiliseconds): " << myTimer.elapsed(); //============================= } void mitk::FiberBundleXMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { MITK_INFO << "FiberBundleXxXXMapper3D()DataForRenderer"; //ToDo do update checks } void mitk::FiberBundleXMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { - MITK_INFO << "FiberBundleXxXXMapper3D()SetDefaultProperties"; - - - //MITK_INFO << "FiberBundleMapper3D SetDefault Properties(...)"; -// node->AddProperty( "DisplayChannel", mitk::IntProperty::New( true ), renderer, overwrite ); -// node->AddProperty( "LineWidth", mitk::IntProperty::New( true ), renderer, overwrite ); -// node->AddProperty( "ColorCoding", mitk::IntProperty::New( 0 ), renderer, overwrite); -// node->AddProperty( "VertexOpacity_1", mitk::BoolProperty::New( false ), renderer, overwrite); -// node->AddProperty( "Set_FA_VertexAlpha", mitk::BoolProperty::New( false ), renderer, overwrite); -// node->AddProperty( "pointSize", mitk::FloatProperty::New(0.5), renderer, overwrite); -// node->AddProperty( "setShading", mitk::IntProperty::New(1), renderer, overwrite); -// node->AddProperty( "Xmove", mitk::IntProperty::New( 0 ), renderer, overwrite); -// node->AddProperty( "Ymove", mitk::IntProperty::New( 0 ), renderer, overwrite); -// node->AddProperty( "Zmove", mitk::IntProperty::New( 0 ), renderer, overwrite); -// node->AddProperty( "RepPoints", mitk::BoolProperty::New( false ), renderer, overwrite); -// node->AddProperty( "TubeSides", mitk::IntProperty::New( 8 ), renderer, overwrite); -// node->AddProperty( "TubeRadius", mitk::FloatProperty::New( 0.15 ), renderer, overwrite); -// node->AddProperty( "TubeOpacity", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); +// MITK_INFO << "FiberBundleXxXXMapper3D()SetDefaultProperties"; + + + //MITK_INFO << "FiberBundleMapperX3D SetDefault Properties(...)"; + // node->AddProperty( "DisplayChannel", mitk::IntProperty::New( true ), renderer, overwrite ); + // node->AddProperty( "LineWidth", mitk::IntProperty::New( true ), renderer, overwrite ); + // node->AddProperty( "ColorCoding", mitk::IntProperty::New( 0 ), renderer, overwrite); + // node->AddProperty( "VertexOpacity_1", mitk::BoolProperty::New( false ), renderer, overwrite); + // node->AddProperty( "Set_FA_VertexAlpha", mitk::BoolProperty::New( false ), renderer, overwrite); + // node->AddProperty( "pointSize", mitk::FloatProperty::New(0.5), renderer, overwrite); + // node->AddProperty( "setShading", mitk::IntProperty::New(1), renderer, overwrite); + // node->AddProperty( "Xmove", mitk::IntProperty::New( 0 ), renderer, overwrite); + // node->AddProperty( "Ymove", mitk::IntProperty::New( 0 ), renderer, overwrite); + // node->AddProperty( "Zmove", mitk::IntProperty::New( 0 ), renderer, overwrite); + // node->AddProperty( "RepPoints", mitk::BoolProperty::New( false ), renderer, overwrite); + // node->AddProperty( "TubeSides", mitk::IntProperty::New( 8 ), renderer, overwrite); + // node->AddProperty( "TubeRadius", mitk::FloatProperty::New( 0.15 ), renderer, overwrite); + // node->AddProperty( "TubeOpacity", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); node->AddProperty( "pickable", mitk::BoolProperty::New( true ), renderer, overwrite); - + Superclass::SetDefaultProperties(node, renderer, overwrite); } vtkProp* mitk::FiberBundleXMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) { -//MITK_INFO << "FiberBundleXxXXMapper3D()GetVTKProp"; + //MITK_INFO << "FiberBundleXxXXMapper3D()GetVTKProp"; //this->GenerateData(); return m_FiberAssembly; } void mitk::FiberBundleXMapper3D::ApplyProperties(mitk::BaseRenderer* renderer) { - MITK_INFO << "FiberBundleXXXXMapper3D ApplyProperties(renderer)"; +// MITK_INFO << "FiberBundleXXXXMapper3D ApplyProperties(renderer)"; } void mitk::FiberBundleXMapper3D::UpdateVtkObjects() { - MITK_INFO << "FiberBundleXxxXMapper3D UpdateVtkObjects()"; +// MITK_INFO << "FiberBundleXxxXMapper3D UpdateVtkObjects()"; } void mitk::FiberBundleXMapper3D::SetVtkMapperImmediateModeRendering(vtkMapper *) { } diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.h b/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.h index 19103ea0f1..370ee0d7a5 100644 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.h +++ b/Modules/DiffusionImaging/Rendering/mitkFiberBundleXMapper3D.h @@ -1,85 +1,85 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef FiberBundleXMapper3D_H_HEADER_INCLUDED #define FiberBundleXMapper3D_H_HEADER_INCLUDED -#include //?? necessary +//#include //?? necessary #include #include #include #include #include -#include +#include class vtkPropAssembly; namespace mitk { //##Documentation //## @brief Mapper for FiberBundleX //## @ingroup Mapper class MitkDiffusionImaging_EXPORT FiberBundleXMapper3D : public VtkMapper3D { public: mitkClassMacro(FiberBundleXMapper3D, VtkMapper3D); itkNewMacro(Self); //========== essential implementation for 3D mapper ======== const FiberBundleX* GetInput(); virtual vtkProp *GetVtkProp(mitk::BaseRenderer *renderer); //looks like depricated.. should be replaced bz GetViewProp() static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false ); virtual void ApplyProperties(mitk::BaseRenderer* renderer); static void SetVtkMapperImmediateModeRendering(vtkMapper *mapper); virtual void GenerateDataForRenderer(mitk::BaseRenderer* renderer); virtual void GenerateData(); //========================================================= protected: FiberBundleXMapper3D(); virtual ~FiberBundleXMapper3D(); void UpdateVtkObjects(); //?? vtkSmartPointer m_FiberMapperGLSP; vtkOpenGLPolyDataMapper* m_FiberMapperGLWP; vtkSmartPointer m_FiberActorSP; - vtkActor* m_FiberActorWP; + vtkOpenGLActor* m_FiberActorWP; vtkPropAssembly* m_FiberAssembly; }; } // end namespace mitk #endif /* FiberBundleXMapper3D_H_HEADER_INCLUDED */