diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/itkSlowPolyLineParametricPath.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/itkSlowPolyLineParametricPath.h deleted file mode 100644 index e4b0f53d37..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/itkSlowPolyLineParametricPath.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef _itkSlowPolyLineParametricPathPath_h -#define _itkSlowPolyLineParametricPathPath_h - -#include "itkPolyLineParametricPath.h" -#include "itkVectorContainer.h" -#include "itkContinuousIndex.h" -#include "itkIndex.h" -#include "itkOffset.h" -#include "itkVector.h" - -namespace itk -{ - - -/** \class SlowPolyLineParametricPath - * \brief Represent a path of line segments through ND Space - * - * This class is intended to represent parametric paths through an image, where - * the paths are composed of line segments. Each line segment traverses one - * unit of input. A classic application of this class is the representation of - * contours in 2D images, especially when the contours only need to be - * approximately correct. Another use of a path is to guide the movement of an - * iterator through an image. - * - * \sa EllipseParametricPath - * \sa FourierSeriesPath - * \sa OrthogonallyCorrectedParametricPath - * \sa ParametricPath - * \sa ChainCodePath - * \sa Path - * \sa ContinuousIndex - * \sa Index - * \sa Offset - * \sa Vector - * - * \ingroup PathObjects - */ -template -class ITK_EXPORT SlowPolyLineParametricPath : public -PolyLineParametricPath< VDimension > -{ -public: - /** Standard class typedefs. */ - typedef SlowPolyLineParametricPath Self; - typedef PolyLineParametricPath Superclass; - typedef SmartPointer Pointer; - typedef SmartPointer ConstPointer; - - /** Run-time type information (and related methods). */ - itkTypeMacro(SlowPolyLineParametricPath, PolyLineParametricPath); - - /** Input type */ - typedef typename Superclass::InputType InputType; - - /** Output type */ - typedef typename Superclass::OutputType OutputType; - - - /** Basic data-structure types used */ - typedef typename Superclass::ContinuousIndexType ContinuousIndexType; - typedef typename Superclass::IndexType IndexType; - typedef typename Superclass::OffsetType OffsetType; - typedef typename Superclass::PointType PointType; - typedef typename Superclass::VectorType VectorType; - typedef typename Superclass::VertexType VertexType; - typedef typename Superclass::VertexListType VertexListType; - typedef typename Superclass::VertexListPointer VertexListPointer; - - /** Increment the input variable passed by reference such that the ND index of - * the path moves to its next vertex-connected (8-connected in 2D) neighbor. - * Return the Index-space offset of the path from its prior input to its new - * input. If the path is unable to increment, input is not changed and an - * offset of Zero is returned. Children are not required to implement bounds - * checking. - * - * This is a fairly slow, iterative algorithm that numerically converges to - * the next index along the path, in a vertex-connected (8-connected in 2D) - * fashion. When possible, children of this class should overload this - * function with something more efficient. - * - * WARNING: This default implementation REQUIRES that the ND endpoint of - * the path be either unique or coincident only with the startpoint, since it - * uses the endpoint as a stopping condition. */ - virtual OffsetType IncrementInput(InputType & input) const; - - - ///** Evaluate the first derivative of the ND output with respect to the 1D - // * input. This is an exact, algebraic function. */ - //virtual VectorType EvaluateDerivative(const InputType & input) const; - - - /** New() method for dynamic construction */ - itkNewMacro( Self ); - - -protected: - SlowPolyLineParametricPath(); - ~SlowPolyLineParametricPath(){} - void PrintSelf(std::ostream& os, Indent indent) const; - -private: - SlowPolyLineParametricPath(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented -}; - -} // namespace itk - -#ifndef ITK_MANUAL_INSTANTIATION -#include "itkSlowPolyLineParametricPath.txx" -#endif - -#endif diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/itkSlowPolyLineParametricPath.txx b/Modules/DiffusionImaging/IODataStructures/FiberBundle/itkSlowPolyLineParametricPath.txx deleted file mode 100644 index e0852d1614..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/itkSlowPolyLineParametricPath.txx +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef _itkSlowPolyLineParametricPath_txx -#define _itkSlowPolyLineParametricPath_txx - -#include "itkSlowPolyLineParametricPath.h" -#include - - - -namespace itk -{ - -//template -//typename SlowPolyLineParametricPath::VectorType -//SlowPolyLineParametricPath -//::EvaluateDerivative(const InputType & input) const -//{ -//} - - - -/** - * Constructor - */ -template -SlowPolyLineParametricPath -::SlowPolyLineParametricPath() -{ - this->SetDefaultInputStepSize( 0.3 ); -} - - -template -typename SlowPolyLineParametricPath::OffsetType -SlowPolyLineParametricPath -::IncrementInput(InputType & input) const -{ - int iterationCount; - bool tooSmall; - bool tooBig; - InputType inputStepSize; - InputType finalInputValue; - OffsetType offset; - IndexType currentImageIndex; - IndexType nextImageIndex; - IndexType finalImageIndex; - - iterationCount = 0; - inputStepSize = this->GetDefaultInputStepSize(); - - // Are we already at (or past) the end of the input? - finalInputValue = this->EndOfInput(); - currentImageIndex = this->EvaluateToIndex( input ); - finalImageIndex = this->EvaluateToIndex( finalInputValue ); - offset = finalImageIndex - currentImageIndex; - if( ( offset == this->GetZeroOffset() && input != this->StartOfInput() ) || - ( input >=finalInputValue ) ) - { - return this->GetZeroOffset(); - } - - do - { - if( iterationCount++ > 10000 ) {itkExceptionMacro(<<"Too many iterations");} - - nextImageIndex = this->EvaluateToIndex( input + inputStepSize ); - offset = nextImageIndex - currentImageIndex; - - tooBig = false; - tooSmall = ( offset == this->GetZeroOffset() ); - if( tooSmall ) - { - // increase the input step size, but don't go past the end of the input - inputStepSize *= 2; - if( (input + inputStepSize) >= finalInputValue ){ - //inputStepSize = finalInputValue - input; - inputStepSize += this->GetDefaultInputStepSize(); - } - } - else - { - // Search for an offset dimension that is too big - for( unsigned int i=0; i= 2 || offset[i] <= -2 ); - } - - if( tooBig ){ - //inputStepSize /= 1.5; - inputStepSize -= (this->GetDefaultInputStepSize()/0.5); - } - } - } - while( tooSmall || tooBig ); - - input += inputStepSize; - return offset; -} - - -/** - * Standard "PrintSelf" method - */ -template -void -SlowPolyLineParametricPath -::PrintSelf( std::ostream& os, Indent indent) const -{ - Superclass::PrintSelf( os, indent ); -} - - - -} // end namespaceitk - -#endif diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundle.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundle.cpp deleted file mode 100644 index dbbba8c28f..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundle.cpp +++ /dev/null @@ -1,1863 +0,0 @@ -/*========================================================================= - - 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 "mitkFiberBundle.h" -#include -#include -#include -#include - - -#include -#include -#include -#include - -#include -//#include - - -/* statics values to define the position of a fiberTractPoint - * related to the plane of a ROI - */ -const int mitk::FiberBundle::TRACTPOINT_BACKFACE = 0; -const int mitk::FiberBundle::TRACTPOINT_ON_PLANE = 1; -const int mitk::FiberBundle::TRACTPOINT_FRNTFACE = 2; - -// implementation of all essential methods from superclass - -mitk::FiberBundle::FiberBundle() -{ - m_GroupFiberBundle = FiberGroupType::New(); - - m_TractContainer = ContainerType::New(); - - //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); - - /* for debugging only */ - m_debugITKContainer = itkStochTractContainerType::New(); - - -} - -mitk::FiberBundle::~FiberBundle() -{ - -} - -void mitk::FiberBundle::SetBounds(float* b) -{ - m_boundsFB[0] = b[0]; - m_boundsFB[1] = b[1]; - m_boundsFB[2] = b[2]; -} - -void mitk::FiberBundle::SetBounds(double* b) -{ - m_boundsFB[0] = b[0]; - m_boundsFB[1] = b[1]; - m_boundsFB[2] = b[2]; -} - -float* mitk::FiberBundle::GetBounds() -{ - return m_boundsFB; -} - -void mitk::FiberBundle::PushPoint(int fiberIndex, ContainerPointType point) -{ - if( (unsigned)fiberIndex >= m_TractContainer->Size() ) - { - fiberIndex = m_TractContainer->Size(); - ContainerTractType::Pointer tract = ContainerTractType::New(); - tract->InsertElement(tract->Size(),point); - m_TractContainer->InsertElement(fiberIndex, tract); - } - else if(fiberIndex>=0) - { - m_TractContainer->ElementAt(fiberIndex)->InsertElement(m_TractContainer->ElementAt(fiberIndex)->Size(), point); - } -} - -void mitk::FiberBundle::PushTract(ContainerTractType::Pointer tract) -{ - m_TractContainer->InsertElement(m_TractContainer->Size(), tract); -} - -mitk::FiberBundle::Pointer mitk::FiberBundle::JoinBundle(mitk::FiberBundle::Pointer bundle) -{ - mitk::FiberBundle::Pointer retval = mitk::FiberBundle::New(); - retval->SetGeometry(this->GetGeometry()); - retval->SetBounds(this->m_boundsFB); - - retval->InsertBundle(this); - retval->InsertBundle(bundle); - return retval; -} - -void mitk::FiberBundle::InsertBundle(mitk::FiberBundle::Pointer bundle) -{ - - // INCOMPLETE, SHOULD CHECK FOR DIFFERENT GEOMETRIES IN THIS+BUNDLE - // DO INDEX1 -> WORLD -> INDEX2 TRANSFORMATION, IF THEY ARE DIFFERENT. - - int num = this->GetNumTracts(); - - FiberGroupType::Pointer groupFiberBundle = bundle->GetGroupFiberBundle(); - ChildrenListType *fiberList = groupFiberBundle->GetChildren(); - for(ChildrenListType::iterator itLst = fiberList->begin(); - itLst != fiberList->end(); - ++itLst) - { - - 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()) - { - MITK_INFO << "DTI Tract is NULL!!!!! omg"; - continue; - } - - dtiTract->SetId(num++); - this->addSingleDTITract(dtiTract); - } - - ContainerType::Pointer container = bundle->GetTractContainer(); - for(int i=0; iSize();i++) - { - this->PushTract(container->ElementAt(i)); - } - -} - -int mitk::FiberBundle::FindTractByEndpoints(mitk::FiberBundle::DTITubeType::Pointer searchTract) -{ - int searchNrPnts = searchTract->GetNumberOfPoints(); - mitk::FiberBundle::DTITubeType::PointListType searchPntList = searchTract->GetPoints(); - - typedef mitk::FiberBundle::DTITubeType::PointType PointType; - - DTITubePointType searchPointFirst = searchPntList.at(0); - PointType searchPos1 = searchPointFirst.GetPosition(); - DTITubePointType searchPointLast = searchPntList.at(searchNrPnts-1); - PointType searchPos2 = searchPointLast.GetPosition(); - - FiberGroupType::Pointer groupFiberBundle = this->GetGroupFiberBundle(); - ChildrenListType *fiberList = groupFiberBundle->GetChildren(); - for(ChildrenListType::iterator itLst = fiberList->begin(); - itLst != fiberList->end(); - ++itLst) - { - - 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()) - { - MITK_INFO << "DTI Tract is NULL!!!!! omg"; - continue; - } - - mitk::FiberBundle::DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); - int fibrNrPnts = dtiTract->GetNumberOfPoints(); - - DTITubePointType point_first = dtiPntList.at(0); - PointType pos1 = point_first.GetPosition(); - DTITubePointType point_last = dtiPntList.at(fibrNrPnts-1); - PointType pos2 = point_last.GetPosition(); - - if( (pos1 == searchPos1 && pos2 == searchPos2) || - (pos2 == searchPos1 && pos1 == searchPos2) ) - { - return dtiTract->GetId(); - } - } - - return -1; -} - -mitk::FiberBundle::Pointer mitk::FiberBundle::SubstractBundle(mitk::FiberBundle::Pointer bundle) -{ - - mitk::FiberBundle::Pointer retval = mitk::FiberBundle::New(); - retval->SetGeometry(this->GetGeometry()); - - mitk::FiberBundle::Pointer largeBundle = bundle; - mitk::FiberBundle::Pointer smallBundle = this; - - MITK_INFO << "large children " << largeBundle->GetGroupFiberBundle()->GetNumberOfChildren() << "!="<GetNumTracts(); - MITK_INFO << "small children " << smallBundle->GetGroupFiberBundle()->GetNumberOfChildren() << "!="<GetNumTracts(); - - if(this->GetGroupFiberBundle()->GetNumberOfChildren() > bundle->GetGroupFiberBundle()->GetNumberOfChildren()) - { - MITK_INFO << "this is large (" << this->GetNumTracts() << ">" << bundle->GetNumTracts() << ")"; - largeBundle = this; - smallBundle = bundle; - } - - - ContainerType::Pointer container = largeBundle->GetTractContainer(); - int counter = 0; - - FiberGroupType::Pointer groupFiberBundle = largeBundle->GetGroupFiberBundle(); - ChildrenListType *fiberList = groupFiberBundle->GetChildren(); - MITK_INFO << "large number children " << groupFiberBundle->GetNumberOfChildren(); - for(ChildrenListType::iterator itLst = fiberList->begin(); - itLst != fiberList->end(); - ++itLst) - { - - 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()) - { - MITK_INFO << "DTI Tract is NULL!!!!! omg"; - continue; - } - - int delId = smallBundle->FindTractByEndpoints(dtiTract); - if( delId == -1 ) - { - retval->addSingleDTITract(dtiTract); - retval->PushTract(container->ElementAt(counter)); - } - - MITK_INFO << "Counter " << counter++; - } - - return retval; -} - -mitk::FiberBundle::ContainerPointType mitk::FiberBundle::GetPoint(int tractIndex, int pointIndex) -{ - if (tractIndex>=0 && tractIndex=0 && pointIndexGetElement(tractIndex)->GetElement(pointIndex); - } - return NULL; -} - -int mitk::FiberBundle::GetNumTracts() -{ - return m_TractContainer->Size(); -} - -int mitk::FiberBundle::GetNumPoints(int tractIndex) -{ - if ((unsigned)tractIndex>=0 && (unsigned)tractIndexSize()) - { - return m_TractContainer->GetElement(tractIndex)->Size(); - - } else { - //added by igi - return NULL; - } - -} - -mitk::FiberBundle::ContainerTractType::Pointer mitk::FiberBundle::GetTract(int tractIndex) -{ - ContainerTractType::Pointer out; - if ((unsigned)tractIndex>0 && (unsigned)tractIndexSize()) - return m_TractContainer->GetElement(tractIndex); - return out; -} - -void mitk::FiberBundle::additkStochTractContainer(itkStochTractContainerType::Pointer itkStochCont) -{ - //for debugging only - m_debugITKContainer = itkStochCont; - //******************** - - - /* transform itkStochContainer to standardized TractContainer */ - - for (itkStochTractContainerType::ConstIterator itCont = itkStochCont->Begin(); - itCont != itkStochCont->End(); - ++itCont) - { - - // get fiber of itkContainer - itkStochTractType::Pointer tract = itCont->Value(); - itkStochTractType::VertexListType::ConstPointer vertexlist = tract->GetVertexList(); - - //init a desired containerFiber - ContainerTractType::Pointer contTract = ContainerTractType::New(); - - //get points of fiber - for( int j=0; j<(int)vertexlist->Size(); ++j) - { - - // put the point of vertex pointList in itkContainer - itkStochTractType::VertexType vertex = vertexlist->GetElement(j); - - //prepare for dtiPoint - ContainerPointType contPnt; - contPnt[0] = (float) vertex[0]; - contPnt[1] = (float) vertex[1]; - contPnt[2] = (float) vertex[2]; - - contTract->InsertElement(contTract->Size(), contPnt); - - /* coordinate testing*/ - /*if ((float)vertex[0] == contPnt[0]) { - MITK_INFO << " [OK] ... X "; - }else { - MITK_INFO << "[FAIL] ... itkX: " << vertex[0] << " " << contPnt[0] << "\n" ; - } - - if ((float)vertex[1] == contPnt[1]) { - MITK_INFO << " [OK] ... Y "; - }else { - MITK_INFO << "[FAIL] ... itkY: " << vertex[1] << " " << contPnt[1] << "\n" ; - } - if ((float)vertex[2] == contPnt[2]) { - MITK_INFO << " [OK] ... Z " << "\n" ; - MITK_INFO << " Values X Y Z: " << contPnt[0] << " " << contPnt[1] << " " << contPnt[2] << "\n"; - }else { - MITK_INFO << "[FAIL] ... itkZ: " << vertex[2] << " " << contPnt[2] << "\n" ; - } - */ - - - - } - - // add filled fiber to container - m_TractContainer->InsertElement(m_TractContainer->Size(), contTract); - - } - - -} - -void mitk::FiberBundle::addTractContainer( ContainerType::Pointer tractContainer ) -{ - m_TractContainer = tractContainer; -} - - -void mitk::FiberBundle::initFiberGroup() -{ - /* iterate through the tractContainer and store fibers in DTISpatialObjects */ - for (ContainerType::ConstIterator itCont = m_TractContainer->Begin(); - itCont != m_TractContainer->End(); - ++itCont) - { - // init new dtiTube and - DTITubeType::Pointer dtiTube = DTITubeType::New(); - DTITubeType::PointListType list; - - // get current tract of container - ContainerTractType::Pointer contTract = itCont->Value(); - - // iterate through the number of points ... use iterator, no index-output is needed anyway - for(ContainerTractType::Iterator itContTrct = contTract->Begin(); - itContTrct != contTract->End(); - ++itContTrct) - { - // init DTITube point - DTITubePointType p; - ContainerPointType cntp = itContTrct->Value(); - p.SetPosition(cntp[0], cntp[1], cntp[2]); - p.SetRadius(1); - - mitk::FiberBundle::fiberPostprocessing_setTensorMatrix( &p ); - - - mitk::FiberBundle::fiberPostprocessing_FA( &p ); - //mitk::FiberBundle::fiberPostprocessing_setTensorMatrix( &p ); - - p.AddField(DTITubePointType::GA, 3); - - p.SetColor(1,0,0,1); - list.push_back(p); - } - // dtiTubes - dtiTube->GetProperty()->SetName("dtiTube"); - dtiTube->SetId(itCont->Index()); - dtiTube->SetPoints(list); - m_GroupFiberBundle->AddSpatialObject(dtiTube); - } -} - -void mitk::FiberBundle::fiberPostprocessing_setTensorMatrix(DTITubePointType *dtiP) -{ - float tMatrix[6]; - tMatrix[0]=0.0f; - tMatrix[1]=1.0f; - tMatrix[2]=2.0f; - tMatrix[3]=3.0f; - tMatrix[4]=4.0f; - tMatrix[5]=5.0f; - - dtiP->SetTensorMatrix(tMatrix); - - -} - -/* this method is a HowTo method, used for debugging only */ -void mitk::FiberBundle::fiberPostprocessing_setPoint(DTITubePointType *dtiP, ContainerPointType vrtx) -{ - /* get values of variable referenced by a ponter - double vtxIdx1, vtxIdx2, vtxIdx3; - vtxIdx1 = * (double*) &vrtx[0]; - vtxIdx2 = * (double*) &vrtx[1]; - vtxIdx3 = * (double*) &vrtx[2]; - - dtiP->SetPosition(vtxIdx1, vtxIdx2, vtxIdx3); - */ - - dtiP->SetPosition(vrtx[0], vrtx[1], vrtx[2]); -} - -void mitk::FiberBundle::fiberPostprocessing_FA(DTITubePointType *dtiP) -{ - debug_PrototypeCounter ++; - float valFA; - - if (debug_PrototypeCounter % 10 < 5) { - valFA = 1.0; - } else if (debug_PrototypeCounter % 10 == 7) { - valFA = 0.3; - } else if (debug_PrototypeCounter % 10 == 8) { - valFA = 0; - } else { - valFA = 0.5; - } - - dtiP->AddField(DTITubePointType::FA, valFA); - -} - - -/* methods for high speed perfoermance dispay or live-monitoring of fiber results */ -void mitk::FiberBundle::addContainer4speedDisplay(ContainerType::Pointer speedTractContainer) -{ - -} - - - - -void mitk::FiberBundle::addSingleDTITract(mitk::FiberBundle::DTITubeType::Pointer dtiFbrTrct) -{ - - //MITK_INFO << " start addSingleDTITract(): " << m_GroupFiberBundle->GetNumberOfChildren(); - m_GroupFiberBundle->AddSpatialObject(dtiFbrTrct); - //MITK_INFO << "end addSingleDTITract(): " << m_GroupFiberBundle->GetNumberOfChildren(); - - -} - -mitk::FiberBundle::FiberGroupType::Pointer mitk::FiberBundle::getGroupFiberBundle() -{ - return m_GroupFiberBundle; -} - -std::vector mitk::FiberBundle::getAllIDsInFiberBundle() -{ - std::vector allFBIds; - - FiberGroupType::Pointer fiberGroup = this->getGroupFiberBundle(); - ChildrenListType *FiberList; - FiberList = fiberGroup->GetChildren(); - - for(ChildrenListType::iterator itLst = FiberList->begin(); - itLst != FiberList->end(); - ++itLst) - { - - 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()) { - MITK_INFO << "DTI Tract is NULL!!!!! omg"; - continue; } - - allFBIds.push_back(dtiTract->GetId()); - - } - - return allFBIds; - - -} - - -mitk::FiberBundle::Pointer mitk::FiberBundle::extractFibersById(std::vector idSet) -{ - - - mitk::FiberBundle::Pointer resultingFibers = mitk::FiberBundle::New(); - resultingFibers->SetGeometry(this->GetGeometry()); - resultingFibers->SetBounds(this->GetBounds()); - - //get Fiber by ID - //get childrenList - //compare if current FiberID is in idSet - - FiberGroupType::Pointer fiberGroup = this->getGroupFiberBundle(); - ChildrenListType *FiberList; - FiberList = fiberGroup->GetChildren(); - MITK_INFO << "writing fibers into datastructure:...."; - - for (int cg=0; cgPushTract( m_TractContainer->GetElement(trctId) ); - - } - MITK_INFO << "init new fiberBundle..."; - resultingFibers->initFiberGroup(); - MITK_INFO << "init new fiberBundle [DONE]"; - - /* - for(ChildrenListType::iterator itLst = FiberList->begin(); - itLst != FiberList->end(); - ++itLst) - { - - 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()) { - MITK_INFO << "DTI Tract is NULL!!!!! omg"; - continue; } - - // MITK_INFO << "current DTI tract id: " << dtiTract->GetId(); - - std::vector::iterator retFibers = find(idSet.begin(), idSet.end(), dtiTract->GetId()); - - - if (retFibers != idSet.end()) { - //MITK_INFO << "Fiber and ID equal: "; - - - DTITubeType::Pointer copyDTITract = this->copySingleDTITract(dtiTract); - - MITK_INFO << "fibercontainer before adding new tract" << resultingFibers->GetNumTracts(); - resultingFibers->addSingleDTITract(copyDTITract); - MITK_INFO << "fibercontainer after adding new tract" << resultingFibers->GetNumTracts(); - - - } - //else { - // MITK_INFO << "Fiber and ID not ident!"; - //} - - //std::set::iterator retFibers - //retFibers = idSet.find(dtiTract->GetId()); - - } */ - - return resultingFibers; - -} - - -/* extract fibers using planar Figures */ -//mitk::FiberBundle::Pointer mitk::FiberBundle::extractFibersPF(mitk::PlanarFigure::Pointer pf) -std::vector mitk::FiberBundle::extractFibersByPF(mitk::PlanarFigure::Pointer pf, std::vector* smaller_set) -{ - - // if incoming pf is a pfc - mitk::PlanarFigureComposite::Pointer pfcomp= dynamic_cast(pf.GetPointer()); - if (!pfcomp.IsNull()) { - //PFC - - - switch (pfcomp->getOperationType()) { - case 0: - { - //AND - std::vector childResults = this->extractFibersByPF(pfcomp->getChildAt(0), smaller_set); - std::vector tmpChild = childResults; - for (int i=1; igetNumberOfChildren(); ++i) - { - tmpChild = extractFibersByPF(pfcomp->getChildAt(i),&tmpChild); - } - std::vector AND_Assamblage(tmpChild.begin(), tmpChild.end()); - return AND_Assamblage; - } - case 1: - { - //OR - std::vector childResults = this->extractFibersByPF(pfcomp->getChildAt(0), smaller_set); - std::sort(childResults.begin(), childResults.end()); - std::vector tmp_container(m_TractContainer->Size()); - std::vector::iterator end; - for (int i=1; igetNumberOfChildren(); ++i) - { - std::vector tmpChild = extractFibersByPF(pfcomp->getChildAt(i), smaller_set); - sort(tmpChild.begin(), tmpChild.end()); - - end = std::set_union(childResults.begin(), childResults.end(), - tmpChild.begin(), tmpChild.end(), - tmp_container.begin() ); - - childResults.assign(tmp_container.begin(), end); - - } - - std::vector OR_Assamblage(childResults.begin(), childResults.end()); - return OR_Assamblage; - } - case 2: - { - //NOT - - // FIRST AN AND OPERATION - std::vector childResults = this->extractFibersByPF(pfcomp->getChildAt(0), smaller_set); - std::sort(childResults.begin(), childResults.end()); - std::vector tmpChild = childResults; - for (int i=1; igetNumberOfChildren(); ++i) - { - tmpChild = extractFibersByPF(pfcomp->getChildAt(i),&tmpChild); - } - std::vector AND_Assamblage(tmpChild.begin(), tmpChild.end()); - - // get IDs of interesting fibers - std::vector interesting_fibers; - if(!smaller_set) - interesting_fibers = this->getAllIDsInFiberBundle(); - else - interesting_fibers.assign(smaller_set->begin(), smaller_set->end()); - std::sort(interesting_fibers.begin(), interesting_fibers.end()); - - // all interesting fibers that are not in the AND assemblage - std::vector tmp_not(interesting_fibers.size()); - std::vector::iterator end; - end = std::set_difference(interesting_fibers.begin(), interesting_fibers.end(), - AND_Assamblage.begin(), AND_Assamblage.end(), - tmp_not.begin() ); - std::vector NOT_Assamblage(tmp_not.begin(),end); - return NOT_Assamblage; - - } - default: - MITK_INFO << "we have an UNDEFINED composition... ERROR" ; - break; - - - } - - } else { - - mitk::PlanarCircle::Pointer circleName = mitk::PlanarCircle::New(); - mitk::PlanarRectangle::Pointer rectName = mitk::PlanarRectangle::New(); - mitk::PlanarPolygon::Pointer polyName = mitk::PlanarPolygon::New(); - - if (pf->GetNameOfClass() == circleName->GetNameOfClass() ) - { - //MITK_INFO << "We have a circle :-) " ; - - - int cntGaps = 0; - //init output FiberBundle - mitk::FiberBundle::Pointer FB_Clipped = mitk::FiberBundle::New(); - FB_Clipped->SetGeometry(this->GetGeometry()); - - //get geometry containing the plane which we need to calculate the xrossingPoints - mitk::Geometry2D::ConstPointer pfgeometry = pf->GetGeometry2D(); - const mitk::PlaneGeometry* planeGeometry = dynamic_cast (pfgeometry.GetPointer()); - std::vector XingPoints; - std::vector fiberIDs; - - - //################################################################# - //############### Find Gap, FrontFace BackFace #################### - //################################################################# - - //get fibercontainer and iterate through the fibers - FiberGroupType::Pointer fiberGroup = this->getGroupFiberBundle(); - - //extract single fibers - ChildrenListType *FiberList; - FiberList = fiberGroup->GetChildren(); - - - - // iterate through each single tract - //int cntFibId = -1; - for(ChildrenListType::iterator itLst = FiberList->begin(); - itLst != FiberList->end(); - ++itLst) - { - - //MITK_INFO << "***************** NEW FIBER *********************"; - //cntFibId++; - 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()) { - MITK_INFO << " could not cast groupFiberBundle child into dtiTract!... LEVEL 4 ERROR"; - continue; } - - if (smaller_set && std::find(smaller_set->begin(), smaller_set->end(), dtiTract->GetId())==smaller_set->end()) - continue; - - //get list of points - int fibrNrPnts = dtiTract->GetNumberOfPoints(); - mitk::FiberBundle::DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); - - // if one fiber is represented by just one point.... - // check if this point is on the plane - if (fibrNrPnts <= 0) - { - MITK_INFO << "HyperERROR in mitkFiberBundle.cpp, No point in fiber....check ur algorithm:"; - continue; - } - - - /* for finding a gap we need to have knowledge of the previous normal - * be aware that there can be more than 1 gaps! - */ - - int prevPntFacing = -999999; - int currPntFacing = -999999; - //double prevFacing = -99999999099; - mitk::Point3D prevFiberPntmm; - - for(int i=0; iGetGeometry()->IndexToWorld(tmpFiberVec, currentFiberPntmm); - double faceing = pfgeometry->SignedDistance(currentFiberPntmm); - - //MITK_INFO << "FacingOutput: " << faceing; - - /////////////////////////////////////// - - if (faceing < 0) { - //backface - currPntFacing = TRACTPOINT_BACKFACE; - //MITK_INFO << "is BACKFACE" << currentFiberPntmm ; - - } else if (faceing > 0) { - //frontface - currPntFacing = TRACTPOINT_FRNTFACE; - // MITK_INFO << "is FRONTFACE" << currentFiberPntmm ; - - } else if (faceing == 0) { - //onplane - currPntFacing = TRACTPOINT_ON_PLANE; - //MITK_INFO << "is on PLANE" << currentFiberPntmm ; - } - - - //////////////////////////////////////// - - - if (currPntFacing == TRACTPOINT_ON_PLANE) - { //strike, - //calculate distance - //TODO SOURCE THIS CONTROLSTRUCTURE OUT - if(isPointInSelection(tmpFiberVec,pf)) - { - DTITubeType::Pointer copyDTITract = copySingleDTITract(dtiTract); - //MITK_INFO << "GroupFB extract after copy of Children: " << fiberGroup->GetNumberOfChildren(); - - FB_Clipped->addSingleDTITract(copyDTITract); - } - - - } else { - // Point is BACKFACE or FRONTFACE - if (i > 0) - { - //check if there is a gap between previous and current - bool isGap = checkForGap(currPntFacing, prevPntFacing); - - if (isGap == true) { - ++cntGaps; - - // - mitk::Vector3D LineDirection; - LineDirection[0] = currentFiberPntmm[0] - prevFiberPntmm[0]; - LineDirection[1] = currentFiberPntmm[1] - prevFiberPntmm[1]; - LineDirection[2] = currentFiberPntmm[2] - prevFiberPntmm[2]; - - - mitk::Line3D Xingline( prevFiberPntmm, LineDirection ); - - mitk::Point3D intersectionPoint; - - Vector3D planeNormal = planeGeometry->GetNormal(); - planeNormal.Normalize(); - - Vector3D lineDirection = Xingline.GetDirection(); - lineDirection.Normalize(); - - double t = planeNormal * lineDirection; - if ( fabs( t ) < eps ) - { - - } - - Vector3D diff; - diff = planeGeometry->GetOrigin() - Xingline.GetPoint(); - t = ( planeNormal * diff ) / t; - - intersectionPoint = Xingline.GetPoint() + lineDirection * t; - // bool successXing = planeGeometry->IntersectionPoint( Xingline, intersectionPoint ); - //mitk::Point3D intersectionPointmm; - //planeGeometry->IndexToWorld(intersectionPoint,intersectionPointmm ); - - // MITK_INFO << "PlaneIntersectionPoint: " << intersectionPoint; - - if (false) { - MITK_INFO << " ERROR CALCULATING INTERSECTION POINT.....should not happen!! "; - } - //TODO more nice if this if is outside... - bool pntInROI = isPointInSelection(intersectionPoint,pf); - if(pntInROI) - { - // MITK_INFO << "POINT ALSO in ROI"; - - // MITK_INFO << "GroupFB extract before copy new object. of Children: " << fiberGroup->GetNumberOfChildren(); - /* dtiTubeSpatial::Pointer can not occur in 2 GroupSpatialObjects, therefore we have to copy the whole dtiTract of current List and add the copy to the desired FiberBundle */ - - // DTITubeType::Pointer copyDTITract = copySingleDTITract(dtiTract); - // MITK_INFO << "GroupFB extract after copy of Children: " << fiberGroup->GetNumberOfChildren(); - - //FB_Clipped->addSingleDTITract(copyDTITract); - - //MITK_INFO << "GroupFB extract after adding dtiTract to now FB NR. of Children: " << fiberGroup->GetNumberOfChildren(); - //MITK_INFO << "DTI Tract ID: " << dtiTract->GetId(); - // MITK_INFO << "size of Vector before pushing: " << fiberIDs.size(); - fiberIDs.push_back(dtiTract->GetId()); - // MITK_INFO << "size of Vector after pushing: " << fiberIDs.size(); - //MITK_INFO << "GroupFB extract after adding dtiTract to now FB NR. of Children: " << fiberGroup->GetNumberOfChildren(); - break; - - - } - - } - - // MITK_INFO << "---no gap---"; - - } //endif i>0 - - - } //endif Facing - // MITK_INFO << "GroupFB extract end Facing, NR. of Children: " << fiberGroup->GetNumberOfChildren(); - - - //update point flag - prevPntFacing = currPntFacing; - prevFiberPntmm = currentFiberPntmm; - } //end for fiberPoints - //MITK_INFO ;<< "GroupFB extract end of single tract, NR. of Children: " << fiberGroup->GetNumberOfChildren(); - - } //end for fiberTracts - // MITK_INFO << "GroupFB extract end of iterating through fiberBundle, NR. of Children: " << fiberGroup->GetNumberOfChildren(); - - // MITK_INFO << "selected " << fiberIDs.size() << " fibers " << " | counted gaps: " << cntGaps; - return fiberIDs; - - - - - - - } else if (pf->GetNameOfClass() == rectName->GetNameOfClass() ){ - - MITK_INFO << "We have a rectangle :-) " ; - - } else if (pf->GetNameOfClass() == polyName->GetNameOfClass() ) { - - //MITK_INFO << "We have a polygon :-) " ; - int cntGaps = 0; - //init output FiberBundle - mitk::FiberBundle::Pointer FB_Clipped = mitk::FiberBundle::New(); - FB_Clipped->SetGeometry(this->GetGeometry()); - - //get geometry containing the plane which we need to calculate the xrossingPoints - mitk::Geometry2D::ConstPointer pfgeometry = pf->GetGeometry2D(); - const mitk::PlaneGeometry* planeGeometry = dynamic_cast (pfgeometry.GetPointer()); - std::vector XingPoints; - std::vector fiberIDs; - - - //################################################################# - //############### Find Gap, FrontFace BackFace #################### - //################################################################# - - //get fibercontainer and iterate through the fibers - FiberGroupType::Pointer fiberGroup = this->getGroupFiberBundle(); - - //extract single fibers - ChildrenListType *FiberList; - FiberList = fiberGroup->GetChildren(); - int nrFibrs = fiberGroup->GetNumberOfChildren(); - - - - // iterate through each single tract - int cntFib = 1; - for(ChildrenListType::iterator itLst = FiberList->begin(); - itLst != FiberList->end(); - ++itLst) - { - if (cntFib % 500 == 0) { - MITK_INFO << "================\n prosessed fibers: " << cntFib << " of " << nrFibrs;; - } - ++cntFib; - - - - //MITK_INFO << "***************** NEW FIBER *********************"; - //cntFibId++; - 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()) { - MITK_INFO << " could not cast groupFiberBundle child into dtiTract!... LEVEL 4 ERROR"; - continue; } - - if (smaller_set && std::find(smaller_set->begin(), smaller_set->end(), dtiTract->GetId())==smaller_set->end()) - continue; - - - - //get list of points - int fibrNrPnts = dtiTract->GetNumberOfPoints(); - mitk::FiberBundle::DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); - - // if one fiber is represented by just one point.... - // check if this point is on the plane - if (fibrNrPnts <= 0) - { - MITK_INFO << "HyperERROR in mitkFiberBundle.cpp, No point in fiber....check ur algorithm:"; - continue; - } - - - /* for finding a gap we need to have knowledge of the previous normal - * be aware that there can be more than 1 gaps! - */ - - int prevPntFacing = -999999; - int currPntFacing = -999999; - //double prevFacing = -99999999099; - mitk::Point3D prevFiberPntmm; - - - - for(int i=0; iGetGeometry()->IndexToWorld(tmpFiberVec, currentFiberPntmm); - double faceing = pfgeometry->SignedDistance(currentFiberPntmm); - - //MITK_INFO << "FacingOutput: " << faceing; - - /////////////////////////////////////// - - if (faceing < 0) { - //backface - currPntFacing = TRACTPOINT_BACKFACE; - //MITK_INFO << "is BACKFACE" << currentFiberPntmm ; - - } else if (faceing > 0) { - //frontface - currPntFacing = TRACTPOINT_FRNTFACE; - // MITK_INFO << "is FRONTFACE" << currentFiberPntmm ; - - } else if (faceing == 0) { - //onplane - currPntFacing = TRACTPOINT_ON_PLANE; - //MITK_INFO << "is on PLANE" << currentFiberPntmm ; - } - - - //////////////////////////////////////// - - - if (currPntFacing == TRACTPOINT_ON_PLANE) - { //strike, - //calculate distance - //TODO SOURCE THIS CONTROLSTRUCTURE OUT - if(isPointInSelection(tmpFiberVec,pf)) - { - DTITubeType::Pointer copyDTITract = copySingleDTITract(dtiTract); - //MITK_INFO << "GroupFB extract after copy of Children: " << fiberGroup->GetNumberOfChildren(); - - FB_Clipped->addSingleDTITract(copyDTITract); - } - - - } else { - // Point is BACKFACE or FRONTFACE - if (i > 0) - { - //check if there is a gap between previous and current - bool isGap = checkForGap(currPntFacing, prevPntFacing); - - if (isGap == true) { - ++cntGaps; - - // - mitk::Vector3D LineDirection; - LineDirection[0] = currentFiberPntmm[0] - prevFiberPntmm[0]; - LineDirection[1] = currentFiberPntmm[1] - prevFiberPntmm[1]; - LineDirection[2] = currentFiberPntmm[2] - prevFiberPntmm[2]; - - - mitk::Line3D Xingline( prevFiberPntmm, LineDirection ); - - mitk::Point3D intersectionPoint; - - Vector3D planeNormal = planeGeometry->GetNormal(); - planeNormal.Normalize(); - - Vector3D lineDirection = Xingline.GetDirection(); - lineDirection.Normalize(); - - double t = planeNormal * lineDirection; - if ( fabs( t ) < eps ) - { - - } - - Vector3D diff; - diff = planeGeometry->GetOrigin() - Xingline.GetPoint(); - t = ( planeNormal * diff ) / t; - - intersectionPoint = Xingline.GetPoint() + lineDirection * t; - // bool successXing = planeGeometry->IntersectionPoint( Xingline, intersectionPoint ); - //mitk::Point3D intersectionPointmm; - //planeGeometry->IndexToWorld(intersectionPoint,intersectionPointmm ); - - // MITK_INFO << "PlaneIntersectionPoint: " << intersectionPoint; - - if (false) { - MITK_INFO << " ERROR CALCULATING INTERSECTION POINT.....should not happen!! "; - } - //TODO more nice if this if is outside... - bool pntInROI = isPointInSelection(intersectionPoint,pf); - if(pntInROI) - { - // MITK_INFO << "POINT ALSO in ROI"; - - // MITK_INFO << "GroupFB extract before copy new object. of Children: " << fiberGroup->GetNumberOfChildren(); - /* dtiTubeSpatial::Pointer can not occur in 2 GroupSpatialObjects, therefore we have to copy the whole dtiTract of current List and add the copy to the desired FiberBundle */ - - // DTITubeType::Pointer copyDTITract = copySingleDTITract(dtiTract); - // MITK_INFO << "GroupFB extract after copy of Children: " << fiberGroup->GetNumberOfChildren(); - - //FB_Clipped->addSingleDTITract(copyDTITract); - - //MITK_INFO << "GroupFB extract after adding dtiTract to now FB NR. of Children: " << fiberGroup->GetNumberOfChildren(); - //MITK_INFO << "DTI Tract ID: " << dtiTract->GetId(); - // MITK_INFO << "size of Vector before pushing: " << fiberIDs.size(); - fiberIDs.push_back(dtiTract->GetId()); - // MITK_INFO << "size of Vector after pushing: " << fiberIDs.size(); - //MITK_INFO << "GroupFB extract after adding dtiTract to now FB NR. of Children: " << fiberGroup->GetNumberOfChildren(); - break; - - - } - - } - - // MITK_INFO << "---no gap---"; - - } //endif i>0 - - - } //endif Facing - // MITK_INFO << "GroupFB extract end Facing, NR. of Children: " << fiberGroup->GetNumberOfChildren(); - - - //update point flag - prevPntFacing = currPntFacing; - prevFiberPntmm = currentFiberPntmm; - } //end for fiberPoints - //MITK_INFO ;<< "GroupFB extract end of single tract, NR. of Children: " << fiberGroup->GetNumberOfChildren(); - - } //end for fiberTracts - // MITK_INFO << "GroupFB extract end of iterating through fiberBundle, NR. of Children: " << fiberGroup->GetNumberOfChildren(); - - // MITK_INFO << "selected " << fiberIDs.size() << " fibers " << " | counted gaps: " << cntGaps; - return fiberIDs; - - - } else { - - MITK_INFO << "[ERROR] unhandled PlanarFigureType found!"; - } - - } - - - - - - - - - - -} - - -mitk::FiberBundle::DTITubeType::Pointer mitk::FiberBundle::copySingleDTITract(mitk::FiberBundle::DTITubeType::Pointer currentDtiFiber) -{ - - DTITubeType::Pointer newCopyDtiFiber = DTITubeType::New(); - //*** get ID - newCopyDtiFiber->SetId( currentDtiFiber->GetId() ); - - //*** get points - DTITubeType::PointListType list; - - - //get list of dtiPoints - int fibrNrPnts = currentDtiFiber->GetNumberOfPoints(); - mitk::FiberBundle::DTITubeType::PointListType dtiPntList = currentDtiFiber->GetPoints(); - - for(int i=0; iSetPoints(list); - std::string dtiname = currentDtiFiber->GetProperty()->GetName(); - newCopyDtiFiber->GetProperty()->SetName(dtiname.c_str()); - - - - return newCopyDtiFiber; - - -} - - - - -/* This Method checks - * To recognize a gap between the 2 points, the previous must differ from the current - * but if the previous is on the plane and the current one not, then mark this situation as no gap - * if both, previous and current are on plane, you'll never jump into this Method - */ -bool mitk::FiberBundle::checkForGap(int crntPntFacing, int prevPntFacing) -{ - - bool isGap = false; - if (prevPntFacing != TRACTPOINT_ON_PLANE && crntPntFacing != prevPntFacing) - { - isGap = true; - - } else if (prevPntFacing == TRACTPOINT_ON_PLANE && crntPntFacing == TRACTPOINT_ON_PLANE) { - MITK_INFO << "###########################################"; - MITK_INFO << "$$$ HYPER ERROR, LOGIC MALFUNCTION!! previous point and current point in a fiber are recognized as a potential GAP! THIS IS NOT ALLOWED $$$"; - MITK_INFO << "###########################################"; - } - - return isGap; - -} - -mitk::Point3D mitk::FiberBundle::calculateCrossingPoint(mitk::Point3D pntFrnt, mitk::Point3D pntbck, mitk::PlanarFigure::Pointer pf) -{ - - mitk::Point3D pntXing; - - //################################################################# - //######### Calculate intersection of plane and fiber ############# - //################################################################# - - // transform in space :-) - - // y = k*x +d - // k = (y1 - y0)/(x1 - x0) - // d = ok - - // z adoption, take xy ratio to plane intersection and adopt it to z coordinate - // z_intersx = (x1 - intersX)/(x1 - x0) * (z1 - z0) + z1 - - double y; - double k; //slope - double d; - - double x0 = pntFrnt[0]; - double y0 = pntFrnt[1]; - double z0 = pntFrnt[2]; - double x1 = pntbck[0]; - double y1 = pntbck[1]; - double z1 = pntbck[2]; - - k = (y1 - y0) / (x1 - x0); - - // if slope == 0 then leave y as it is, change x - - // if slope == 1 then leave x as it is, change y - - // if z of p0 and p1 is the same, just take z - - - /* - - mitk::PlanarCircle::Pointer circleName = mitk::PlanarCircle::New(); - mitk::PlanarRectangle::Pointer rectName = mitk::PlanarRectangle::New(); - mitk::PlanarPolygon::Pointer polyName = mitk::PlanarPolygon::New(); - - if (pf->GetNameOfClass() == circleName->GetNameOfClass() ) - { - MITK_INFO << "We have a circle :-) " ; - //controlpoint 1 is middlepoint - //controlpoint 2 is radiuspoint - mitk::Vector3D V1w = pf->GetWorldControlPoint(0); //centerPoint - mitk::Vector3D V2w = pf->GetWorldControlPoint(1); //radiusPoint - mitk::Vector3D V1; - mitk::Vector3D V2; - this->GetGeometry()->WorldToIndex(V1w, V1); - this->GetGeometry()->WorldToIndex(V2w, V2); - - //calculate distance between those 2 and - mitk::Point3D distV; - distV = V2 - V1; - distV[0] = sqrt( pow(distV[0], 2.0) ); - distV[1] = sqrt( pow(distV[1], 2.0) ); - distV[2] = sqrt( pow(distV[2], 2.0) ); - - mitk::Point3D distPnt; - distPnt = pnt3D - V1; - distPnt[0] = sqrt( pow(distPnt[0], 2.0) ); - distPnt[1] = sqrt( pow(distPnt[1], 2.0) ); - distPnt[2] = sqrt( pow(distPnt[2], 2.0) ); - - if ( (distPnt <= distV) ) { - pntIsInside = true; - - - } - - return pntIsInside; - - //compare the result to the distance of all points an a fiber - - - - - - } else if (pf->GetNameOfClass() == rectName->GetNameOfClass() ){ - - MITK_INFO << "We have a rectangle :-) " ; - - } else if (pf->GetNameOfClass() == polyName->GetNameOfClass() ) { - - MITK_INFO << "We have a polygon :-) " ; - } - - */ - - return pntXing; - - -} - - -bool mitk::FiberBundle::isPointInSelection(mitk::Point3D pnt3D, mitk::PlanarFigure::Pointer pf) -{ - /* TODO needs to be redesigned.... each time because in planarPolygonsection VTK object will be initialized for each point!...PERFORMANCE LACK!!!!!!! */ - - - //calculate distances - mitk::PlanarCircle::Pointer circleName = mitk::PlanarCircle::New(); - mitk::PlanarRectangle::Pointer rectName = mitk::PlanarRectangle::New(); - mitk::PlanarPolygon::Pointer polyName = mitk::PlanarPolygon::New(); - - if (pf->GetNameOfClass() == circleName->GetNameOfClass() ) - { - //MITK_INFO << "We have a circle :-) " ; - //controlpoint 1 is middlepoint - //controlpoint 2 is radiuspoint - mitk::Point3D V1w = pf->GetWorldControlPoint(0); //centerPoint - mitk::Point3D V2w = pf->GetWorldControlPoint(1); //radiusPoint - mitk::Vector3D V1; - mitk::Vector3D V2; - // this->GetGeometry()->WorldToIndex(V1w, V1); - // this->GetGeometry()->WorldToIndex(V2w, V2); - - //calculate distance between those 2 and - double distPF; - distPF = sqrt((double) (V2w[0] - V1w[0]) * (V2w[0] - V1w[0]) + - (V2w[1] - V1w[1]) * (V2w[1] - V1w[1]) + - (V2w[2] - V1w[2]) * (V2w[2] - V1w[2])); - - double XdistPnt = sqrt((double) (pnt3D[0] - V1w[0]) * (pnt3D[0] - V1w[0]) + - (pnt3D[1] - V1w[1]) * (pnt3D[1] - V1w[1]) + - (pnt3D[2] - V1w[2]) * (pnt3D[2] - V1w[2])) ; - - - - if ( (distPF > XdistPnt) ) { - return true; - - } - - return false; - - //compare the result to the distance of all points an a fiber - - - } - - - - else if (pf->GetNameOfClass() == rectName->GetNameOfClass() ){ - - MITK_INFO << "We have a rectangle :-) " ; - - - } else if (pf->GetNameOfClass() == polyName->GetNameOfClass() ) { - - - //create vtkPolygon using controlpoints from planarFigure polygon - vtkSmartPointer polygonVtk = vtkPolygon::New(); - - - //get the control points from pf and insert them to vtkPolygon - unsigned int nrCtrlPnts = pf->GetNumberOfControlPoints(); - // MITK_INFO << "We have a polygon with " << nrCtrlPnts << " controlpoints: " ; - - for (int i=0; iGetPoints()->InsertNextPoint((double)pf->GetWorldControlPoint(i)[0], (double)pf->GetWorldControlPoint(i)[1], (double)pf->GetWorldControlPoint(i)[2] ); - - - } - - //prepare everything for using pointInPolygon function - double n[3]; - polygonVtk->ComputeNormal(polygonVtk->GetPoints()->GetNumberOfPoints(), - static_cast(polygonVtk->GetPoints()->GetData()->GetVoidPointer(0)), n); - - double bounds[6]; - polygonVtk->GetPoints()->GetBounds(bounds); - - double checkIn[3] = {pnt3D[0], pnt3D[1], pnt3D[2]}; - - int isInPolygon = polygonVtk->PointInPolygon(checkIn, polygonVtk->GetPoints()->GetNumberOfPoints() - , static_cast(polygonVtk->GetPoints()->GetData()->GetVoidPointer(0)), bounds, n); - - // MITK_INFO << "======IsPointOnPolygon:========\n" << isInPolygon << "\n ======================== "; - - polygonVtk->Delete(); - - if (isInPolygon == 1) - { - // MITK_INFO << "return true"; - return true; - - - } else if (isInPolygon == 0) - { - // MITK_INFO << "return false"; - return false; - - } else { - - MITK_INFO << "&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*& \n YOUR DRAWN POLYGON DOES IS DEGENERATED AND NOT ACCEPTED \n DRAW A NEW ONE!! HAI CAPITO \n &*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&"; - } - - - - - - } - - -} - - -void mitk::FiberBundle::debug_members() -{ - /* Debug Workflow description - * Test1: check if both, groupSpatialObject and Tract container have the same amount of fiberTracts - * Test2: check if points in tracts contain the same coordinates - * next... to be continued - */ - - - /* ######### TEST 1 START ######### */ - //************************************* - MITK_INFO << " ############### \n *** TEST Equal Amount of Fibers *** \n "; - - unsigned int groupEls = m_GroupFiberBundle->GetNumberOfChildren(); - unsigned int contEls = m_TractContainer->Size(); - unsigned int itkcontEls = m_debugITKContainer->Size(); - - if (groupEls == contEls && contEls == itkcontEls) - { - MITK_INFO << "[OK] .... Test1 passed. # of Fibers: " << groupEls << " \n ******************** "; - } else { - - MITK_INFO << "[FAIL]: Container and FiberGroup do not contain same amount of fibers! \n "; - // MITK_INFO << " Container # of Fibers: " << contEls << " | FiberBundle # of Fibers: " << groupEls << "\n"; - MITK_INFO << " # of Fibers m_Cont: " << contEls << " | GroupFibers: " << groupEls << " | ITKCont: " << itkcontEls << "\n"; - } - /* ######### TEST 1 END ######### */ - //*********************************** - - - - /* ######### TEST 2 START ######### */ - //************************************* - - /* iterate through itkcontainer*/ - itkStochTractContainerType::ConstIterator itITKCnt; - itITKCnt = m_debugITKContainer->Begin(); - - /* extract DTIFiberTracts of the GroupFiberBundle Object */ - // all smartPointers to fibers stored in in a ChildrenList - ChildrenListType * FiberList; - FiberList = m_GroupFiberBundle->GetChildren(); - /* iterate through container, itkcontainer groupFiberBundle in one iteration step */ - ChildrenListType::iterator itLst; //STL "list" itself provides no index output of current iteration step. - itLst = FiberList->begin(); - - - ContainerType::ConstIterator vecIter; - for ( vecIter = m_TractContainer->Begin(); - vecIter != m_TractContainer->End(); - vecIter++ ) - { - - unsigned int itIdx = vecIter->Index(); - MITK_INFO << "FiberIteration: " << itIdx << "\n" ; - - //get single tract of container - ContainerTractType::Pointer contTract = vecIter->Value(); - int contNrPnts = contTract->Size(); - - //get singel tract of itkContainer - itkStochTractType::Pointer itkcontTract = itITKCnt->Value(); - itkStochTractType::VertexListType::ConstPointer itkcontVrtx = itkcontTract->GetVertexList(); - int itkcontNrPnts = itkcontVrtx->Size(); - - /* 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; - DTITubeType::Pointer dtiTract = dynamic_cast (tmp_fbr.GetPointer()); - if (dtiTract.IsNull()) { - MITK_INFO << " ############### *** ERRROR *** ############### \n ############### *** ERRROR *** ############### \n ############### *** ERRROR *** ############### \n "; - return; } - - //get points of tract - int fibrNrPnts = dtiTract->GetNumberOfPoints(); - DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); - - MITK_INFO << " ############### \n *** TEST Equal Amount of Points in Tract *** \n "; - - if (contNrPnts == itkcontNrPnts && itkcontNrPnts == fibrNrPnts) { - MITK_INFO << "[OK] .... Test2 passed. # of Points in fiber: " << fibrNrPnts << " \n ******************** "; - - } else { - MITK_INFO << "[FAIL]: Tracts do not contain same amount of points! \n "; - MITK_INFO << " # of Points m_Cont: " << contNrPnts << " | GroupFibers: " << fibrNrPnts << " | ITKCont: " << itkcontNrPnts << "\n"; - } - - - - - //use for()loop with index instead of iterator cuz of accessing more elements, std vectors provide no index output - for(int ip=0; ipGetElement(ip); - - //get point from itkStochContainer - itkStochTractType::VertexType itkPnt = itkcontVrtx->GetElement(ip); - - //get point from dtiGroup - DTITubePointType tmpDtiPnt = dtiPntList.at(ip); - DTITubePointType::PointType dtiPoint = tmpDtiPnt.GetPosition(); - - - if (tmpcontPnt[0] == (float)itkPnt[0] && (float)itkPnt[0] == (float)dtiPoint[0]) { - MITK_INFO << "TractCont | ITKCont | DTIGroup X: " << tmpcontPnt[0] << "...TEST [OK] " << "\n"; - }else{ - MITK_INFO << "TractCont | ITKCont | DTIGroup X: " << tmpcontPnt[0] << " " << itkPnt[0] << " " << dtiPoint[0] << "...TEST ##### [FAIL] \n"; - } - - if (tmpcontPnt[1] == (float)itkPnt[1] && (float)itkPnt[1] == (float)dtiPoint[1]) { - MITK_INFO << "TractCont | ITKCont | DTIGroup Y: " << tmpcontPnt[1] << "...TEST [OK] " << "\n"; - }else{ - MITK_INFO << "TractCont | ITKCont | DTIGroup Y: " << tmpcontPnt[1] << " " << itkPnt[1] << " " << dtiPoint[1] << "\n"; - } - - if (tmpcontPnt[2] == (float)itkPnt[2] && (float)itkPnt[2] == (float)dtiPoint[2]) { - MITK_INFO << "TractCont | ITKCont | DTIGroup Z: " << tmpcontPnt[2] << "...TEST [OK] " << "\n"; - }else{ - MITK_INFO << "TractCont | ITKCont | DTIGroup Z: " << tmpcontPnt[2] << " " << itkPnt[2] << " " << dtiPoint[2] << "\n"; - } - - } - ++itITKCnt; - ++itLst; - } - -} - -vtkSmartPointer mitk::FiberBundle::GeneratePolydata() -{ - MITK_INFO << "writing polydata"; - //extractn single fibers - //in the groupFiberBundle all smartPointers to single fibers are stored in in a ChildrenList - mitk::FiberBundle::ChildrenListType * FiberList; - FiberList = this->m_GroupFiberBundle->GetChildren(); - - /* ######## FIBER PREPARATION END ######### */ - - /* ######## VTK FIBER REPRESENTATION ######## */ - //create a vtkPoints object and store the all the brainFiber points in it - vtkSmartPointer vtkpoints = vtkPoints::New(); - - //in vtkcells all polylines are stored, actually all id's of them are stored - vtkSmartPointer vtkcells = vtkCellArray::New(); - - //in some cases a fiber includes just 1 point, so put it in here - vtkSmartPointer vtkVrtxs = vtkCellArray::New(); - - //colors and alpha value for each single point, RGBA = 4 components - vtkSmartPointer colorsT = vtkUnsignedCharArray::New(); - colorsT->SetNumberOfComponents(4); - colorsT->SetName("ColorValues"); - - vtkSmartPointer 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 = vtkpoints->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 NULL; } - - //get list of points - int fibrNrPnts = dtiTract->GetNumberOfPoints(); - mitk::FiberBundle::DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); - - //create a new polyline for a dtiTract - //smartpointer - vtkSmartPointer polyLine = vtkPolyLine::New(); - polyLine->GetPointIds()->SetNumberOfIds(fibrNrPnts); - unsigned char rgba[4] = {255,255,255,255}; - - //tubeRadius->SetNumberOfTuples(fibrNrPnts); - //double tbradius = 1;//default value for radius - - if (fibrNrPnts <= 0) { //this should never occour! but who knows - MITK_INFO << "HyperERROR in fiberBundleMapper3D.cpp ...no point in fiberBundle!!! .. check ur trackingAlgorithm"; - continue; - } - - - for (int i=0; iGetGeometry()->IndexToWorld(indexPnt, worldPnt); - double worldFbrPnt[3] = {worldPnt[0], worldPnt[1], worldPnt[2]}; - vtkpoints->InsertNextPoint(worldFbrPnt); - - // tubeRadius->SetTuple1(i,tbradius); //tuple with 1 argument - - - if (fibrNrPnts == 1) { - // if there ist just 1 point in a fiber...wtf, but however represent it as a point - vtkSmartPointer vrtx = vtkVertex::New(); - vrtx->GetPointIds()->SetNumberOfIds(1); - vrtx->GetPointIds()->SetId(i,i+pntIdxHelper); - colorsT->InsertNextTupleValue(rgba); - vtkVrtxs->InsertNextCell(vrtx); - - } else { - - polyLine->GetPointIds()->SetId(i,i+pntIdxHelper); - - //colorcoding orientation based - if (i0) - { - //nimm nur diff1 - mitk::FiberBundle::DTITubePointType nxttmpFiberPntLst = dtiPntList.at(i+1); - mitk::FiberBundle::DTITubePointType::PointType nxttmpFiberPnt = nxttmpFiberPntLst.GetPosition(); - //double nxttmpvtkPnt[3] = {nxttmpFiberPnt[0], nxttmpFiberPnt[1], nxttmpFiberPnt[2]}; - - vnl_vector_fixed< double, 3 > tmpPntvtk((double)tmpvtkPnt[0], (double)tmpvtkPnt[1],(double)tmpvtkPnt[2]); - vnl_vector_fixed< double, 3 > nxttmpPntvtk(nxttmpFiberPnt[0], nxttmpFiberPnt[1], nxttmpFiberPnt[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); - - - - } else if(i==0) { - //explicit handling of startpoint of line - - //nimm nur diff1 - mitk::FiberBundle::DTITubePointType nxttmpFiberPntLst = dtiPntList.at(i+1); - mitk::FiberBundle::DTITubePointType::PointType nxttmpFiberPnt = nxttmpFiberPntLst.GetPosition(); - //double nxttmpvtkPnt[3] = {nxttmpFiberPnt[0], nxttmpFiberPnt[1], nxttmpFiberPnt[2]}; - - vnl_vector_fixed< double, 3 > tmpPntvtk((double)tmpvtkPnt[0], (double)tmpvtkPnt[1],(double)tmpvtkPnt[2]); - vnl_vector_fixed< double, 3 > nxttmpPntvtk(nxttmpFiberPnt[0], nxttmpFiberPnt[1], nxttmpFiberPnt[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); - - - - - } else if(i==fibrNrPnts) { - // nimm nur diff2 - mitk::FiberBundle::DTITubePointType nxttmpFiberPntLst = dtiPntList.at(i-1); - mitk::FiberBundle::DTITubePointType::PointType nxttmpFiberPnt = nxttmpFiberPntLst.GetPosition(); - - vnl_vector_fixed< double, 3 > tmpPntvtk((double)tmpvtkPnt[0], (double)tmpvtkPnt[1],(double)tmpvtkPnt[2]); - vnl_vector_fixed< double, 3 > nxttmpPntvtk(nxttmpFiberPnt[0], nxttmpFiberPnt[1], nxttmpFiberPnt[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); - - - - - } - - colorsT->InsertNextTupleValue(rgba); - - //get FA value - 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->InsertNextCell(polyLine); - - } - - //vtkcells->InitTraversal(); - - // Put points and lines together in one polyData structure - m_PolyData = vtkPolyData::New(); - m_PolyData->SetPoints(vtkpoints); - m_PolyData->SetLines(vtkcells); - if (vtkVrtxs->GetSize() > 0) { - m_PolyData->SetVerts(vtkVrtxs); - } - m_PolyData->GetPointData()->AddArray(colorsT); - m_PolyData->GetPointData()->AddArray(faColors); - return m_PolyData; -} - -/* NECESSARY IMPLEMENTATION OF SUPERCLASS METHODS */ -void mitk::FiberBundle::UpdateOutputInformation() -{ - -} -void mitk::FiberBundle::SetRequestedRegionToLargestPossibleRegion() -{ - -} -bool mitk::FiberBundle::RequestedRegionIsOutsideOfTheBufferedRegion() -{ - return false; -} -bool mitk::FiberBundle::VerifyRequestedRegion() -{ - return true; -} -void mitk::FiberBundle::SetRequestedRegion( itk::DataObject *data ) -{ - -} - - -/* TUTORIAL INSERT POINTS / FIBERS to TRACTCONTAINER */ -// points and vectors do not need to be initiated but itkVectorContainer -/*ContainerPointType pnt1; - pnt1[0] = 1.0; - pnt1[1] = 2.0; - pnt1[2] = 3.0; - - ContainerPointType pnt2; - pnt2[0] = 4.0; - pnt2[1] = 5.0; - pnt2[2] = 6.0; - - ContainerTractType tract1; - tract1.push_back(pnt1); - tract1.push_back(pnt2); - - ContainerType::Pointer testContainer = ContainerType::New(); - unsigned int freeIdx = testContainer->Size(); - MITK_INFO << freeIdx << "\n"; - testContainer->InsertElement(freeIdx, tract1); - - //iterate through all fibers stored in container - for(ContainerType::ConstIterator itCont = testContainer->Begin(); - itCont != testContainer->End(); - itCont++) - { - //get single tract - ContainerTractType tmp_fiber = itCont->Value(); - // MITK_INFO << tmp_fiber << "\n"; - - //iterate through all points within a fibertract - for(ContainerTractType::iterator itPnt = tmp_fiber.begin(); - itPnt != tmp_fiber.end(); - ++itPnt) - { - // get single point with its coordinates - ContainerPointType tmp_pntEx = *itPnt; - MITK_INFO << tmp_pntEx[0] << "\n"; - MITK_INFO << tmp_pntEx[1] << "\n"; - MITK_INFO << tmp_pntEx[2] << "\n"; - } - - } - ################### DTI FIBERs TUTORIAL ########################### - TUTORIAL HOW TO READ POINTS / FIBERS from DTIGroupSpatialObjectContainer - assume our dti fibers are stored in m_GroupFiberBundle - - // all smartPointers to fibers stored in in a ChildrenList - ChildrenListType * FiberList; - FiberList = m_GroupFiberBundle->GetChildren(); - - // iterate through container, itkcontainer groupFiberBundle in one iteration step - for(ChildrenListType::iterator itLst = FiberList->begin(); - itLst != FiberList->end(); - ++FiberList) - { - // 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; - DTITubeType::Pointer dtiTract = dynamic_cast (tmp_fbr.GetPointer()); - if (dtiTract.IsNull()) { - return; } - - //get list of points - int fibrNrPnts = dtiTract->GetNumberOfPoints(); - DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); - - } - - - */ - diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundle.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundle.h deleted file mode 100644 index 345de3a1de..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundle.h +++ /dev/null @@ -1,196 +0,0 @@ - -/*========================================================================= - - 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_FiberBundle_H -#define _MITK_FiberBundle_H - -//includes for MITK datastructure -#include "mitkBaseData.h" -#include - -//=======modernized================ -//includes storing fiberdata -#include //may be replaced by class precompile argument -#include // may be replaced by class -#include // my be replaced by class - - -//includes processing of fibers -// -//=========modernized end=========== - - -#include - -/* This Class represents a bunch of FiberTracts as a Bundle. - A Bundle is represented by a GroupSpatialObject */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include - -namespace mitk { - - /** - * \brief Base Class for Fiber Bundles; */ - class MitkDiffusionImaging_EXPORT FiberBundle : public BaseData - { - public: - - /* friend classes wanna access typedefs - ContainerPointType, ContainerTractType, ContainerType */ - friend class FiberBundleWriter; - friend class FiberBundleReader; - // friend class itkTractsToDWIImageFilter; - - /** Types for the standardized TractContainer **/ - typedef itk::Point ContainerPointType; //no need to init, is no smartpointer - typedef itk::VectorContainer ContainerTractType; - typedef itk::VectorContainer< unsigned int, ContainerTractType::Pointer > ContainerType; //init via smartpointer - - - - /** Types for the ITK Stochastic TractContainer **/ - typedef itk::SlowPolyLineParametricPath< 3 > itkStochTractType; - typedef itk::VectorContainer< unsigned int, itkStochTractType::Pointer > itkStochTractContainerType; - - - // virtual methods that need to be implemented - virtual void UpdateOutputInformation(); - virtual void SetRequestedRegionToLargestPossibleRegion(); - virtual bool RequestedRegionIsOutsideOfTheBufferedRegion(); - virtual bool VerifyRequestedRegion(); - virtual void SetRequestedRegion( itk::DataObject *data ); - - static const int TRACTPOINT_BACKFACE; - static const int TRACTPOINT_ON_PLANE; - static const int TRACTPOINT_FRNTFACE; - - - /* DTITubeSpatialObject Definitions */ - typedef itk::GroupSpatialObject<3> FiberGroupType; - typedef FiberGroupType::ChildrenListType ChildrenListType; - - typedef itk::DTITubeSpatialObject<3> DTITubeType; - typedef itk::DTITubeSpatialObjectPoint<3> DTITubePointType; - - mitkClassMacro( FiberBundle, BaseData ); - itkNewMacro( Self ); - - - /* Handle Output Type of ITK Stochastic Tractography Fiber Tracking */ - void addTractContainer( ContainerType::Pointer ); - void additkStochTractContainer(itkStochTractContainerType::Pointer); - void initFiberGroup(); - void addSingleDTITract(mitk::FiberBundle::DTITubeType::Pointer); - DTITubeType::Pointer copySingleDTITract(DTITubeType::Pointer); - - /* Methods for PlanarFigure ROIs */ - //mitk::FiberBundle::Pointer extractFibersPF(mitk::PlanarFigure::Pointer); - std::vector extractFibersByPF(mitk::PlanarFigure::Pointer, std::vector* set=0); - mitk::FiberBundle::Pointer extractFibersById(std::vector ); - std::vector getAllIDsInFiberBundle(); - - - mitk::Point3D calculateCrossingPoint(mitk::Point3D , mitk::Point3D , mitk::PlanarFigure::Pointer ); //depricated - bool checkForGap(int, int); //depricated - /*********************************/ - - - void debug_members(); - - void SetBounds(float* b); - void SetBounds(double* b); - float* GetBounds(); - - - -//**** REALTIME MONITOR CONTAINER METHOD ****// - //flag overwrite existing bundle - void addContainer4speedDisplay( ContainerType::Pointer ); - - itkGetMacro(GroupFiberBundle, FiberGroupType::Pointer); - itkGetMacro(TractContainer, ContainerType::Pointer); - - //** explicit handling of FiberBundleDataStructure contents *// - void PushPoint(int fiberIndex, ContainerPointType point); - void PushTract(ContainerTractType::Pointer tract); - ContainerPointType GetPoint(int tractIndex, int pointIndex); - ContainerTractType::Pointer GetTract(int tractIndex); - int GetNumTracts(); - int GetNumPoints(int tractIndex); - FiberGroupType::Pointer getGroupFiberBundle(); - - mitk::FiberBundle::Pointer JoinBundle(mitk::FiberBundle::Pointer bundle); - int FindTractByEndpoints(mitk::FiberBundle::DTITubeType::Pointer searchTract); - mitk::FiberBundle::Pointer SubstractBundle(mitk::FiberBundle::Pointer bundle); - void InsertBundle(mitk::FiberBundle::Pointer bundle); - vtkSmartPointer GeneratePolydata(); - -// int SearchFiber(worldPoint, tolerance, resultDistance); - - protected: - FiberBundle(); - virtual ~FiberBundle(); - - private: -// =========MODERNIZED========== -// 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) - vtkSmartPointer m_FiberPolyData; - -// VertexPolyData stores all original points as vertices computed by tracking algorithms - vtkSmartPointer m_VertexPolyData; - vtkSmartPointer m_Particles; - -// ===============Moedernized end===== - FiberGroupType::Pointer m_GroupFiberBundle; - ContainerType::Pointer m_TractContainer; - itkStochTractContainerType::Pointer m_debugITKContainer; - - void fiberPostprocessing_FA( DTITubePointType* ); - void fiberPostprocessing_setPoint(DTITubePointType* , ContainerPointType ); - void fiberPostprocessing_setTensorMatrix(DTITubePointType*); - - int debug_PrototypeCounter; - float m_boundsFB[3]; - - /* Methods for PlanarFigure ROIs */ - bool isPointInSelection(mitk::Point3D, mitk::PlanarFigure::Pointer); - vtkSmartPointer m_PolyData; - - }; - -} // namespace mitk - -#endif /* _MITK_FiberBundle_H */ diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleIOFactory.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleIOFactory.cpp deleted file mode 100644 index c4134a9c20..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleIOFactory.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2007-12-11 14:46:19 +0100 (Di, 11 Dez 2007) $ -Version: $Revision: 6607 $ - -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 "mitkFiberBundleIOFactory.h" -#include "mitkIOAdapter.h" -#include "mitkFiberBundleReader.h" - -#include "itkVersion.h" - -//NOTE>umbenennen in FBReaderType - - -namespace mitk -{ - -FiberBundleIOFactory::FiberBundleIOFactory() -{ - typedef FiberBundleReader FiberBundleReaderType; - this->RegisterOverride("mitkIOAdapter", //beibehalten - "mitkFiberBundleReader", //umbenennen - "Fiber Bundle IO", //angezeigter name - 1, - itk::CreateObjectFunction >::New()); -} - -FiberBundleIOFactory::~FiberBundleIOFactory() -{ -} - -const char* FiberBundleIOFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* FiberBundleIOFactory::GetDescription() const -{ - return "FibreBundleIOFactory, allows the loading of FibreBundles"; -} - -} // end namespace mitk diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleIOFactory.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleIOFactory.h deleted file mode 100644 index 6fb8a2f5a7..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleIOFactory.h +++ /dev/null @@ -1,76 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-05-13 18:06:46 +0200 (Mi, 13 Mai 2009) $ -Version: $Revision: 6590 $ - -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_FIBER_BUNDLE_IO_FACTORY_H_HEADER__ -#define __MITK_FIBER_BUNDLE_IO_FACTORY_H_HEADER__ - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif - -#include "itkObjectFactoryBase.h" -#include "mitkBaseData.h" -#include "MitkDiffusionImagingExports.h" - -//NOTE>umbenennen in internal FiberBundleIOFactory - - -namespace mitk -{ -//##Documentation -//## @brief Create instances of NrrdQBallImageReader objects using an object factory. -//## -//## @ingroup IO -class MitkDiffusionImaging_EXPORT FiberBundleIOFactory : public itk::ObjectFactoryBase -{ -public: - /** Standard class typedefs. */ - typedef FiberBundleIOFactory Self; - typedef itk::ObjectFactoryBase Superclass; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - static FiberBundleIOFactory* FactoryNew() { return new FiberBundleIOFactory;} - /** Run-time type information (and related methods). */ - itkTypeMacro(FiberBundleIOFactory, ObjectFactoryBase); - - /** Register one factory of this type */ - static void RegisterOneFactory(void) - { - FiberBundleIOFactory::Pointer FiberBundleIOFactory = FiberBundleIOFactory::New(); - ObjectFactoryBase::RegisterFactory(FiberBundleIOFactory); - } - -protected: - FiberBundleIOFactory(); - ~FiberBundleIOFactory(); - -private: - FiberBundleIOFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - - -} // end namespace mitk - -#endif // __MITK_FIBER_BUNDLE_IO_FACTORY_H_HEADER__ diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp deleted file mode 100644 index c0abbdd204..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -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 "mitkFiberBundleReader.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -const char* mitk::FiberBundleReader::XML_GEOMETRY = "geometry"; - -const char* mitk::FiberBundleReader::XML_MATRIX_XX = "xx"; - -const char* mitk::FiberBundleReader::XML_MATRIX_XY = "xy"; - -const char* mitk::FiberBundleReader::XML_MATRIX_XZ = "xz"; - -const char* mitk::FiberBundleReader::XML_MATRIX_YX = "yx"; - -const char* mitk::FiberBundleReader::XML_MATRIX_YY = "yy"; - -const char* mitk::FiberBundleReader::XML_MATRIX_YZ = "yz"; - -const char* mitk::FiberBundleReader::XML_MATRIX_ZX = "zx"; - -const char* mitk::FiberBundleReader::XML_MATRIX_ZY = "zy"; - -const char* mitk::FiberBundleReader::XML_MATRIX_ZZ = "zz"; - -const char* mitk::FiberBundleReader::XML_ORIGIN_X = "origin_x"; - -const char* mitk::FiberBundleReader::XML_ORIGIN_Y = "origin_y"; - -const char* mitk::FiberBundleReader::XML_ORIGIN_Z = "origin_z"; - -const char* mitk::FiberBundleReader::XML_SPACING_X = "spacing_x"; - -const char* mitk::FiberBundleReader::XML_SPACING_Y = "spacing_y"; - -const char* mitk::FiberBundleReader::XML_SPACING_Z = "spacing_z"; - -const char* mitk::FiberBundleReader::XML_SIZE_X = "size_x"; - -const char* mitk::FiberBundleReader::XML_SIZE_Y = "size_y"; - -const char* mitk::FiberBundleReader::XML_SIZE_Z = "size_z"; - -const char* mitk::FiberBundleReader::XML_FIBER_BUNDLE = "fiber_bundle"; - -const char* mitk::FiberBundleReader::XML_FIBER = "fiber"; - -const char* mitk::FiberBundleReader::XML_PARTICLE = "particle"; - -const char* mitk::FiberBundleReader::XML_ID = "id"; - -const char* mitk::FiberBundleReader::XML_POS_X = "pos_x"; - -const char* mitk::FiberBundleReader::XML_POS_Y = "pos_y"; - -const char* mitk::FiberBundleReader::XML_POS_Z = "pos_z"; - -const char* mitk::FiberBundleReader::XML_NUM_FIBERS = "num_fibers"; - -const char* mitk::FiberBundleReader::XML_NUM_PARTICLES = "num_particles"; - -const char* mitk::FiberBundleReader::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; - -const char* mitk::FiberBundleReader::XML_FILE_VERSION = "file_version" ; - -const char* mitk::FiberBundleReader::VERSION_STRING = "0.1" ; - -namespace mitk -{ - - void FiberBundleReader - ::GenerateData() - { - MITK_INFO << "Reading fiber bundle"; - if ( ( ! m_OutputCache ) ) - { - Superclass::SetNumberOfRequiredOutputs(0); - this->GenerateOutputInformation(); - } - - if (!m_OutputCache) - { - itkWarningMacro("Tree cache is empty!"); - } - - - Superclass::SetNumberOfRequiredOutputs(1); - Superclass::SetNthOutput(0, m_OutputCache.GetPointer()); - } - - void FiberBundleReader::GenerateOutputInformation() - { - m_OutputCache = OutputType::New(); - - std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); - ext = itksys::SystemTools::LowerCase(ext); - - const std::string& locale = "C"; - const std::string& currLocale = setlocale( LC_ALL, NULL ); - - if ( locale.compare(currLocale)!=0 ) - { - try - { - setlocale(LC_ALL, locale.c_str()); - } - catch(...) - { - MITK_INFO << "Could not set locale " << locale; - } - } - - if ( m_FileName == "") - { - - } - else if (ext == ".fib_deprecated") - { - try - { - TiXmlDocument doc( m_FileName ); - doc.LoadFile(); - - TiXmlHandle hDoc(&doc); - TiXmlElement* pElem; - TiXmlHandle hRoot(0); - - pElem = hDoc.FirstChildElement().Element(); - - // save this for later - hRoot = TiXmlHandle(pElem); - - pElem = hRoot.FirstChildElement(FiberBundleReader::XML_GEOMETRY).Element(); - - // read geometry - mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); - - // read origin - mitk::Point3D origin; - double temp = 0; - pElem->Attribute(FiberBundleReader::XML_ORIGIN_X, &temp); - origin[0] = temp; - pElem->Attribute(FiberBundleReader::XML_ORIGIN_Y, &temp); - origin[1] = temp; - pElem->Attribute(FiberBundleReader::XML_ORIGIN_Z, &temp); - origin[2] = temp; - geometry->SetOrigin(origin); - - // read spacing - float spacing[3]; - pElem->Attribute(FiberBundleReader::XML_SPACING_X, &temp); - spacing[0] = temp; - pElem->Attribute(FiberBundleReader::XML_SPACING_Y, &temp); - spacing[1] = temp; - pElem->Attribute(FiberBundleReader::XML_SPACING_Z, &temp); - spacing[2] = temp; - geometry->SetSpacing(spacing); - - // read transform - vtkMatrix4x4* m = vtkMatrix4x4::New(); - pElem->Attribute(FiberBundleReader::XML_MATRIX_XX, &temp); - m->SetElement(0,0,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_XY, &temp); - m->SetElement(1,0,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_XZ, &temp); - m->SetElement(2,0,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_YX, &temp); - m->SetElement(0,1,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_YY, &temp); - m->SetElement(1,1,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_YZ, &temp); - m->SetElement(2,1,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_ZX, &temp); - m->SetElement(0,2,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_ZY, &temp); - m->SetElement(1,2,temp); - pElem->Attribute(FiberBundleReader::XML_MATRIX_ZZ, &temp); - m->SetElement(2,2,temp); - - m->SetElement(0,3,origin[0]); - m->SetElement(1,3,origin[1]); - m->SetElement(2,3,origin[2]); - m->SetElement(3,3,1); - geometry->SetIndexToWorldTransformByVtkMatrix(m); - - // read bounds - float bounds[] = {0, 0, 0, 0, 0, 0}; - pElem->Attribute(FiberBundleReader::XML_SIZE_X, &temp); - bounds[1] = temp; - pElem->Attribute(FiberBundleReader::XML_SIZE_Y, &temp); - bounds[3] = temp; - pElem->Attribute(FiberBundleReader::XML_SIZE_Z, &temp); - bounds[5] = temp; - geometry->SetFloatBounds(bounds); - - // read bounds - float bounds2[] = {0, 0, 0}; - bounds2[0] = bounds[1]; - bounds2[1] = bounds[3]; - bounds2[2] = bounds[5]; - m_OutputCache->SetBounds(bounds2); - - geometry->SetImageGeometry(true); - m_OutputCache->SetGeometry(geometry); - - // generate tract container - ContainerType::Pointer tractContainer = ContainerType::New(); - - int fiberID = 0; - pElem = hRoot.FirstChildElement(FiberBundleReader::XML_FIBER_BUNDLE).FirstChild().Element(); - for( pElem; pElem; pElem=pElem->NextSiblingElement()) - { - TiXmlElement* pElem2 = pElem->FirstChildElement(); - ContainerTractType::Pointer tract = ContainerTractType::New(); - for( pElem2; pElem2; pElem2=pElem2->NextSiblingElement()) - { - ContainerPointType point; - pElem2->Attribute(FiberBundleReader::XML_POS_X, &temp); - point[0] = temp; - pElem2->Attribute(FiberBundleReader::XML_POS_Y, &temp); - point[1] = temp; - pElem2->Attribute(FiberBundleReader::XML_POS_Z, &temp); - point[2] = temp; - - tract->InsertElement(tract->Size(), point); - - } - pElem->Attribute(FiberBundleReader::XML_ID, &fiberID); - tractContainer->CreateIndex(fiberID); - tractContainer->SetElement(fiberID, tract); - - } - m_OutputCache->addTractContainer(tractContainer); - m_OutputCache->initFiberGroup(); - - MITK_INFO << "Fiber bundle read"; - } - catch(...) - { - MITK_INFO << "Could not read file "; - } - - MITK_INFO << "Fiber bundle read"; - } - - try - { - setlocale(LC_ALL, currLocale.c_str()); - } - catch(...) - { - MITK_INFO << "Could not reset locale " << currLocale; - } - } - - void FiberBundleReader::Update() - { - this->GenerateData(); - } - - const char* FiberBundleReader - ::GetFileName() const - { - return m_FileName.c_str(); - } - - - void FiberBundleReader - ::SetFileName(const char* aFileName) - { - m_FileName = aFileName; - } - - - const char* FiberBundleReader - ::GetFilePrefix() const - { - return m_FilePrefix.c_str(); - } - - - void FiberBundleReader - ::SetFilePrefix(const char* aFilePrefix) - { - m_FilePrefix = aFilePrefix; - } - - - const char* FiberBundleReader - ::GetFilePattern() const - { - return m_FilePattern.c_str(); - } - - - void FiberBundleReader - ::SetFilePattern(const char* aFilePattern) - { - m_FilePattern = aFilePattern; - } - - - bool FiberBundleReader - ::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) - { - // First check the extension - if( filename == "" ) - { - return false; - } - std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); - ext = itksys::SystemTools::LowerCase(ext); - - if (ext == ".fib_deprecated") - { - return true; - } - - return false; - } - -} //namespace MITK diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.h deleted file mode 100644 index 09b32561a9..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.h +++ /dev/null @@ -1,147 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -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 __mitkFiberBundleReader_h -#define __mitkFiberBundleReader_h - -#include "mitkCommon.h" -#include "itkVectorContainer.h" -#include "mitkFileReader.h" -#include "mitkFiberBundle.h" -#include "itkSlowPolyLineParametricPath.h" - -//NOTE>umbenennen in FiberBundleSource - -namespace mitk -{ - - /** \brief - */ - - class FiberBundleReader : public FileReader, public BaseProcess - { - public: - - /** Types for the standardized TractContainer **/ - /* direct linked includes of mitkFiberBundle DataStructure */ - typedef mitk::FiberBundle::ContainerPointType ContainerPointType; - typedef mitk::FiberBundle::ContainerTractType ContainerTractType; - typedef mitk::FiberBundle::ContainerType ContainerType; - - - typedef mitk::FiberBundle OutputType; - - mitkClassMacro( FiberBundleReader, BaseProcess ); - itkNewMacro(Self); - - const char* GetFileName() const; - void SetFileName(const char* aFileName); - const char* GetFilePrefix() const; - void SetFilePrefix(const char* aFilePrefix); - const char* GetFilePattern() const; - void SetFilePattern(const char* aFilePattern); - - static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); - -// itkGetMacro(GroupFiberBundle, FiberGroupType::Pointer); -// itkGetMacro(TractContainer, ContainerType::Pointer); - - virtual void Update(); - - - static const char* XML_GEOMETRY; - - static const char* XML_MATRIX_XX; - - static const char* XML_MATRIX_XY; - - static const char* XML_MATRIX_XZ; - - static const char* XML_MATRIX_YX; - - static const char* XML_MATRIX_YY; - - static const char* XML_MATRIX_YZ; - - static const char* XML_MATRIX_ZX; - - static const char* XML_MATRIX_ZY; - - static const char* XML_MATRIX_ZZ; - - static const char* XML_ORIGIN_X; - - static const char* XML_ORIGIN_Y; - - static const char* XML_ORIGIN_Z; - - static const char* XML_SPACING_X; - - static const char* XML_SPACING_Y; - - static const char* XML_SPACING_Z; - - static const char* XML_SIZE_X; - - static const char* XML_SIZE_Y; - - static const char* XML_SIZE_Z; - - static const char* XML_FIBER_BUNDLE; - - static const char* XML_FIBER; - - static const char* XML_PARTICLE; - - static const char* XML_ID; - - static const char* XML_POS_X; - - static const char* XML_POS_Y; - - static const char* XML_POS_Z; - - static const char* VERSION_STRING; - - static const char* XML_FIBER_BUNDLE_FILE; - - static const char* XML_FILE_VERSION; - - static const char* XML_NUM_FIBERS; - - static const char* XML_NUM_PARTICLES; - - protected: - - /** Does the real work. */ - virtual void GenerateData(); - virtual void GenerateOutputInformation(); - - OutputType::Pointer m_OutputCache; - - std::string m_FileName; - std::string m_FilePrefix; - std::string m_FilePattern; - ContainerType::Pointer m_TractContainer; - - private: - void operator=(const Self&); //purposely not implemented - }; - -} //namespace MITK - -#endif // __mitkFiberBundleReader_h diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSerializer.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSerializer.cpp deleted file mode 100644 index d78fe3b912..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSerializer.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 1.12 $ - -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 "mitkFiberBundleSerializer.h" -#include "mitkFiberBundle.h" -#include "mitkFiberBundleWriter.h" - -#include - - -MITK_REGISTER_SERIALIZER(FiberBundleSerializer) - - -mitk::FiberBundleSerializer::FiberBundleSerializer() -{ -} - - -mitk::FiberBundleSerializer::~FiberBundleSerializer() -{ -} - - -std::string mitk::FiberBundleSerializer::Serialize() -{ - const FiberBundle* fb = dynamic_cast( m_Data.GetPointer() ); - if (fb == NULL) - { - MITK_ERROR << " Object at " << (const void*) this->m_Data - << " is not an mitk::FiberBundle. Cannot serialize as FiberBundle."; - return ""; - } - - std::string filename( this->GetUniqueFilenameInWorkingDirectory() ); - filename += "_"; - filename += m_FilenameHint; - filename += ".fib"; - - std::string fullname(m_WorkingDirectory); - fullname += "/"; - fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str()); - - try - { - FiberBundleWriter::Pointer writer = FiberBundleWriter::New(); - writer->SetFileName(fullname); - writer->SetInputFiberBundle(const_cast(fb)); - writer->Write(); - } - catch (std::exception& e) - { - MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data - << " to " - << fullname - << ": " - << e.what(); - return ""; - } - return filename; -} - diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSerializer.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSerializer.h deleted file mode 100644 index 820aef2fb7..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSerializer.h +++ /dev/null @@ -1,40 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 1.12 $ - -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 mitkFiberBundleSerializer_h_included -#define mitkFiberBundleSerializer_h_included - -#include "MitkDiffusionImagingExports.h" -#include "mitkBaseDataSerializer.h" - -namespace mitk -{ -/** - \brief Serializes mitk::Surface for mitk::SceneIO -*/ -class MitkDiffusionImaging_EXPORT FiberBundleSerializer : public BaseDataSerializer -{ - public: - mitkClassMacro( FiberBundleSerializer, BaseDataSerializer ); - itkNewMacro(Self); - virtual std::string Serialize(); - protected: - FiberBundleSerializer(); - virtual ~FiberBundleSerializer(); -}; -} // namespace -#endif diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSource.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSource.cpp deleted file mode 100644 index 0c780e249f..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSource.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*========================================================================= - -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 "mitkQBallImageSource.h" - - -mitk::QBallImageSource::QBallImageSource() -{ - // Create the output. We use static_cast<> here because we know the default - // output must be of type TOutputImage - OutputImageType::Pointer output - = static_cast(this->MakeOutput(0).GetPointer()); - Superclass::SetNumberOfRequiredOutputs(1); - Superclass::SetNthOutput(0, output.GetPointer()); -} - -mitk::QBallImageSource::DataObjectPointer mitk::QBallImageSource::MakeOutput( unsigned int /*idx*/ ) -{ - return static_cast(OutputImageType::New().GetPointer()); -} diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSource.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSource.h deleted file mode 100644 index ce50970b88..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleSource.h +++ /dev/null @@ -1,52 +0,0 @@ -/*========================================================================= - -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 QBallImageSource_H_HEADER_INCLUDED_C1E7D6EC -#define QBallImageSource_H_HEADER_INCLUDED_C1E7D6EC - -#include "mitkImageSource.h" -#include "mitkQBallImage.h" - -//NOTE>umbenennen .. ableiten von DataSource - - -namespace mitk { - -class QBallImageSource : public ImageSource -{ -public: - - typedef mitk::QBallImage OutputImageType; - typedef OutputImageType::Pointer OutputImagePointer; - typedef SlicedData::RegionType OutputImageRegionType; - typedef itk::DataObject::Pointer DataObjectPointer; - - mitkClassMacro(QBallImageSource,ImageSource); - itkNewMacro(Self); - - virtual DataObjectPointer MakeOutput(unsigned int idx); - -protected: - QBallImageSource(); - virtual ~QBallImageSource() {} - -}; - -} // namespace mitk - -#endif /* QBallImageSource_H_HEADER_INCLUDED_C1E7D6EC */ diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp deleted file mode 100644 index cac2bca968..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2008-12-10 18:05:13 +0100 (Mi, 10 Dez 2008) $ -Version: $Revision: 15922 $ - -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 "mitkFiberBundleWriter.h" -#include - -const char* mitk::FiberBundleWriter::XML_GEOMETRY = "geometry"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_XX = "xx"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_XY = "xy"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_XZ = "xz"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_YX = "yx"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_YY = "yy"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_YZ = "yz"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_ZX = "zx"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_ZY = "zy"; - -const char* mitk::FiberBundleWriter::XML_MATRIX_ZZ = "zz"; - -const char* mitk::FiberBundleWriter::XML_ORIGIN_X = "origin_x"; - -const char* mitk::FiberBundleWriter::XML_ORIGIN_Y = "origin_y"; - -const char* mitk::FiberBundleWriter::XML_ORIGIN_Z = "origin_z"; - -const char* mitk::FiberBundleWriter::XML_SPACING_X = "spacing_x"; - -const char* mitk::FiberBundleWriter::XML_SPACING_Y = "spacing_y"; - -const char* mitk::FiberBundleWriter::XML_SPACING_Z = "spacing_z"; - -const char* mitk::FiberBundleWriter::XML_SIZE_X = "size_x"; - -const char* mitk::FiberBundleWriter::XML_SIZE_Y = "size_y"; - -const char* mitk::FiberBundleWriter::XML_SIZE_Z = "size_z"; - -const char* mitk::FiberBundleWriter::XML_FIBER_BUNDLE = "fiber_bundle"; - -const char* mitk::FiberBundleWriter::XML_FIBER = "fiber"; - -const char* mitk::FiberBundleWriter::XML_PARTICLE = "particle"; - -const char* mitk::FiberBundleWriter::XML_ID = "id"; - -const char* mitk::FiberBundleWriter::XML_POS_X = "pos_x"; - -const char* mitk::FiberBundleWriter::XML_POS_Y = "pos_y"; - -const char* mitk::FiberBundleWriter::XML_POS_Z = "pos_z"; - -const char* mitk::FiberBundleWriter::XML_NUM_FIBERS = "num_fibers"; - -const char* mitk::FiberBundleWriter::XML_NUM_PARTICLES = "num_particles"; - -const char* mitk::FiberBundleWriter::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; - -const char* mitk::FiberBundleWriter::XML_FILE_VERSION = "file_version" ; - -const char* mitk::FiberBundleWriter::VERSION_STRING = "0.1" ; - -const char* mitk::FiberBundleWriter::ASCII_FILE = "ascii_file" ; - -const char* mitk::FiberBundleWriter::FILE_NAME = "file_name" ; - -mitk::FiberBundleWriter::FiberBundleWriter() - : m_FileName(""), m_FilePrefix(""), m_FilePattern(""), m_Success(false) -{ - this->SetNumberOfRequiredInputs( 1 ); -} - - -mitk::FiberBundleWriter::~FiberBundleWriter() -{} - - -void mitk::FiberBundleWriter::GenerateData() -{ - try - { - MITK_INFO << "Writing fiber bundle"; - m_Success = false; - InputType* input = this->GetInput(); - if (input == NULL) - { - itkWarningMacro(<<"Sorry, input to FiberBundleWriter is NULL!"); - return; - } - if ( m_FileName == "" ) - { - itkWarningMacro( << "Sorry, filename has not been set!" ); - return ; - } - - const std::string& locale = "C"; - const std::string& currLocale = setlocale( LC_ALL, NULL ); - - if ( locale.compare(currLocale)!=0 ) - { - try - { - setlocale(LC_ALL, locale.c_str()); - } - catch(...) - { - MITK_INFO << "Could not set locale " << locale; - } - } - - std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); - ext = itksys::SystemTools::LowerCase(ext); - - if (ext == ".fib_deprecated") - { - /* direct linked includes of mitkFiberBundle DataStructure */ - typedef mitk::FiberBundle::ContainerPointType ContainerPointType; - typedef mitk::FiberBundle::ContainerTractType ContainerTractType; - typedef mitk::FiberBundle::ContainerType ContainerType; - - ContainerType::Pointer tractContainer = input->GetTractContainer(); - mitk::Geometry3D* geometry = input->GetGeometry(); - - TiXmlDocument documentXML; - TiXmlDeclaration* declXML = new TiXmlDeclaration( "1.0", "", "" ); // TODO what to write here? encoding? etc.... - documentXML.LinkEndChild( declXML ); - - TiXmlElement* mainXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER_BUNDLE_FILE); - mainXML->SetAttribute(mitk::FiberBundleWriter::XML_FILE_VERSION, mitk::FiberBundleWriter::VERSION_STRING); - documentXML.LinkEndChild(mainXML); - - TiXmlElement* geometryXML = new TiXmlElement(mitk::FiberBundleWriter::XML_GEOMETRY); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XX, geometry->GetMatrixColumn(0)[0]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XY, geometry->GetMatrixColumn(0)[1]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XZ, geometry->GetMatrixColumn(0)[2]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YX, geometry->GetMatrixColumn(1)[0]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YY, geometry->GetMatrixColumn(1)[1]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YZ, geometry->GetMatrixColumn(1)[2]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZX, geometry->GetMatrixColumn(2)[0]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZY, geometry->GetMatrixColumn(2)[1]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZZ, geometry->GetMatrixColumn(2)[2]); - - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_X, geometry->GetOrigin()[0]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_Y, geometry->GetOrigin()[1]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_Z, geometry->GetOrigin()[2]); - - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_X, geometry->GetSpacing()[0]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_Y, geometry->GetSpacing()[1]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_Z, geometry->GetSpacing()[2]); - - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_X, input->GetBounds()[0]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_Y, input->GetBounds()[1]); - geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_Z, input->GetBounds()[2]); - - mainXML->LinkEndChild(geometryXML); - - TiXmlElement* fiberBundleXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER_BUNDLE); - fiberBundleXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_FIBERS, tractContainer->size()); - int numParticles = 0; - for (int i=0; iSize(); i++) - { - ContainerTractType::Pointer tract = tractContainer->GetElement(i); - TiXmlElement* fiberXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER); - fiberXML->SetAttribute(mitk::FiberBundleWriter::XML_ID, i); - fiberXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_PARTICLES, tract->Size()); - numParticles += tract->Size(); - for (int j=0; jSize(); j++) - { - TiXmlElement* particleXML = new TiXmlElement(mitk::FiberBundleWriter::XML_PARTICLE); - ContainerPointType p = tract->GetElement(j); - particleXML->SetAttribute(mitk::FiberBundleWriter::XML_ID, j); - particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_X, p[0]); - particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_Y, p[1]); - particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_Z, p[2]); - fiberXML->LinkEndChild(particleXML); - } - fiberBundleXML->LinkEndChild(fiberXML); - } - fiberBundleXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_PARTICLES, numParticles); - mainXML->LinkEndChild(fiberBundleXML); - - documentXML.SaveFile( m_FileName ); - - m_Success = true; - - MITK_INFO << "Fiber bundle written"; - - }else if (ext == ".fib" || ext == ".vtk") { - vtkPolyDataWriter* writer = vtkPolyDataWriter::New(); - writer->SetInput(input->GeneratePolydata()); - writer->SetFileName(m_FileName.c_str()); - writer->SetFileTypeToASCII(); - writer->Write(); - - m_Success = true; - MITK_INFO << "Fiber bundle written as polydata"; - } - try - { - setlocale(LC_ALL, currLocale.c_str()); - } - catch(...) - { - MITK_INFO << "Could not reset locale " << currLocale; - } - } - catch(...) - { - throw; - } -} - - -void mitk::FiberBundleWriter::SetInputFiberBundle( InputType* diffVolumes ) -{ - this->ProcessObject::SetNthInput( 0, diffVolumes ); -} - - -mitk::FiberBundle* mitk::FiberBundleWriter::GetInput() -{ - if ( this->GetNumberOfInputs() < 1 ) - { - return NULL; - } - else - { - return dynamic_cast ( this->ProcessObject::GetInput( 0 ) ); - } -} - - -std::vector mitk::FiberBundleWriter::GetPossibleFileExtensions() -{ - std::vector possibleFileExtensions; - possibleFileExtensions.push_back(".fib"); - possibleFileExtensions.push_back(".vtk"); - return possibleFileExtensions; -} diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h deleted file mode 100644 index bd09c568a3..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h +++ /dev/null @@ -1,216 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ -Version: $Revision: 15096 $ - -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 __mitkFiberBundleWriter_h -#define __mitkFiberBundleWriter_h - -#include -#include -#include "mitkFiberBundle.h" -#include - - -namespace mitk -{ - -/** - * Writes fiber bundles to a file - * @ingroup Process - */ -class FiberBundleWriter : public mitk::FileWriterWithInformation -{ -public: - - mitkClassMacro( FiberBundleWriter, mitk::FileWriterWithInformation ); - - //mitkWriterMacro; - - virtual void Write() - { - if ( this->GetInput() == NULL ) - { - itkExceptionMacro(<<"Write:Please specify an input!"); - return; - } - /* Fill in image information.*/ - this->UpdateOutputInformation(); - (*(this->GetInputs().begin()))->SetRequestedRegionToLargestPossibleRegion(); - this->PropagateRequestedRegion(NULL); - this->UpdateOutputData(NULL); - } - - virtual void Update() - { - Write(); - } - - itkNewMacro( Self ); - - typedef mitk::FiberBundle InputType; - - /** - * Sets the filename of the file to write. - * @param FileName the name of the file to write. - */ - itkSetStringMacro( FileName ); - - /** - * @returns the name of the file to be written to disk. - */ - itkGetStringMacro( FileName ); - - /** - * @warning multiple write not (yet) supported - */ - itkSetStringMacro( FilePrefix ); - - /** - * @warning multiple write not (yet) supported - */ - itkGetStringMacro( FilePrefix ); - - /** - * @warning multiple write not (yet) supported - */ - itkSetStringMacro( FilePattern ); - - /** - * @warning multiple write not (yet) supported - */ - itkGetStringMacro( FilePattern ); - - /** - * Sets the input object for the filter. - * @param input the diffusion volumes to write to file. - */ - void SetInputFiberBundle( InputType* input ); - - /** - * @returns the 0'th input object of the filter. - */ - InputType* GetInput(); - - /** - * Returns false if an error happened during writing - */ - itkGetMacro( Success, bool ); - - /** - * @return possible file extensions for the data type associated with the writer - */ - virtual std::vector GetPossibleFileExtensions(); - - // FileWriterWithInformation methods - virtual const char * GetDefaultFilename() { return "FiberBundle.fib"; } - virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.vtk)"; } - virtual const char * GetDefaultExtension() { return ".fib"; } - virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; - virtual void DoWrite(BaseData::Pointer data) { - if (CanWriteBaseDataType(data)) { - this->SetInputFiberBundle(dynamic_cast(data.GetPointer())); - this->Update(); - } - }; - - static const char* XML_GEOMETRY; - - static const char* XML_MATRIX_XX; - - static const char* XML_MATRIX_XY; - - static const char* XML_MATRIX_XZ; - - static const char* XML_MATRIX_YX; - - static const char* XML_MATRIX_YY; - - static const char* XML_MATRIX_YZ; - - static const char* XML_MATRIX_ZX; - - static const char* XML_MATRIX_ZY; - - static const char* XML_MATRIX_ZZ; - - static const char* XML_ORIGIN_X; - - static const char* XML_ORIGIN_Y; - - static const char* XML_ORIGIN_Z; - - static const char* XML_SPACING_X; - - static const char* XML_SPACING_Y; - - static const char* XML_SPACING_Z; - - static const char* XML_SIZE_X; - - static const char* XML_SIZE_Y; - - static const char* XML_SIZE_Z; - - static const char* XML_FIBER_BUNDLE; - - static const char* XML_FIBER; - - static const char* XML_PARTICLE; - - static const char* XML_ID; - - static const char* XML_POS_X; - - static const char* XML_POS_Y; - - static const char* XML_POS_Z; - - static const char* VERSION_STRING; - - static const char* XML_FIBER_BUNDLE_FILE; - - static const char* XML_FILE_VERSION; - - static const char* XML_NUM_FIBERS; - - static const char* XML_NUM_PARTICLES; - - static const char* ASCII_FILE; - - static const char* FILE_NAME; - -protected: - - FiberBundleWriter(); - - virtual ~FiberBundleWriter(); - - virtual void GenerateData(); - - std::string m_FileName; - - std::string m_FilePrefix; - - std::string m_FilePattern; - - bool m_Success; - -}; - - -} // end of namespace mitk - -#endif //__mitkFiberBundleWriter_h diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriterFactory.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriterFactory.cpp deleted file mode 100644 index 0b4bc55c37..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriterFactory.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2007-12-11 14:46:19 +0100 (Di, 11 Dez 2007) $ -Version: $Revision: 11215 $ - -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 "mitkFiberBundleWriterFactory.h" - -#include "itkCreateObjectFunction.h" -#include "itkVersion.h" - -#include "mitkFiberBundleWriter.h" - -namespace mitk -{ - -template -class CreateFiberBundleWriter : public itk::CreateObjectFunctionBase -{ -public: - - /** Standard class typedefs. */ - typedef CreateFiberBundleWriter Self; - typedef itk::SmartPointer Pointer; - - /** Methods from itk:LightObject. */ - itkFactorylessNewMacro(Self); - LightObject::Pointer CreateObject() { typename T::Pointer p = T::New(); - p->Register(); - return p.GetPointer(); - } - -protected: - CreateFiberBundleWriter() {} - ~CreateFiberBundleWriter() {} - -private: - CreateFiberBundleWriter(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented -}; - -FiberBundleWriterFactory::FiberBundleWriterFactory() -{ - this->RegisterOverride("IOWriter", - "FiberBundleWriter", - "FiberBundle Writer", - 1, - mitk::CreateFiberBundleWriter< mitk::FiberBundleWriter >::New()); -} - -FiberBundleWriterFactory::~FiberBundleWriterFactory() -{ -} - -const char* FiberBundleWriterFactory::GetITKSourceVersion() const -{ - return ITK_SOURCE_VERSION; -} - -const char* FiberBundleWriterFactory::GetDescription() const -{ - return "FiberBundleWriterFactory"; -} - -} // end namespace mitk diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriterFactory.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriterFactory.h deleted file mode 100644 index 15459f7ef1..0000000000 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriterFactory.h +++ /dev/null @@ -1,68 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-05-13 18:06:46 +0200 (Mi, 13 Mai 2009) $ -Version: $Revision: 11215 $ - -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 FIBERBUNDLE_WRITERFACTORY_H_HEADER_INCLUDED -#define FIBERBUNDLE_WRITERFACTORY_H_HEADER_INCLUDED - -#include "itkObjectFactoryBase.h" -#include "mitkBaseData.h" -#include "MitkDiffusionImagingExports.h" - -namespace mitk -{ - -class MitkDiffusionImaging_EXPORT FiberBundleWriterFactory : public itk::ObjectFactoryBase -{ -public: - - mitkClassMacro( mitk::FiberBundleWriterFactory, itk::ObjectFactoryBase ) - - /** Class methods used to interface with the registered factories. */ - virtual const char* GetITKSourceVersion(void) const; - virtual const char* GetDescription(void) const; - - /** Method for class instantiation. */ - itkFactorylessNewMacro(Self); - - /** Register one factory of this type */ - static void RegisterOneFactory(void) - { - static bool IsRegistered = false; - if ( !IsRegistered ) - { - FiberBundleWriterFactory::Pointer ugVtkWriterFactory = FiberBundleWriterFactory::New(); - ObjectFactoryBase::RegisterFactory( ugVtkWriterFactory ); - IsRegistered = true; - } - } - -protected: - FiberBundleWriterFactory(); - ~FiberBundleWriterFactory(); - -private: - FiberBundleWriterFactory(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - -}; - -} // end namespace mitk - -#endif // FIBERBUNDLE_WRITERFACTORY_H_HEADER_INCLUDED - - - diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp.orig b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp.orig new file mode 100644 index 0000000000..2a98af7d51 --- /dev/null +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp.orig @@ -0,0 +1,922 @@ +/*========================================================================= + + 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" + +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const char* mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED = "Color_Orient"; +const char* mitk::FiberBundleX::COLORCODING_FA_BASED = "Color_FA"; +const char* mitk::FiberBundleX::FIBER_ID_ARRAY = "Fiber_IDs"; + +<<<<<<< HEAD + + + +mitk::FiberBundleX::FiberBundleX(vtkSmartPointer fiberPolyData ) + : m_currentColorCoding(NULL) + , m_isModified(false) +{ + //generate geometry of passed polydata + if (fiberPolyData == NULL) + this->m_FiberPolyData = vtkSmartPointer::New(); + else + this->m_FiberPolyData = fiberPolyData; + + this->UpdateFiberGeometry(); +} +======= +mitk::FiberBundleX::FiberBundleX( vtkPolyData* fiberPolyData ) + : m_currentColorCoding(NULL) + , m_isModified(false) + , m_NumFibers(0) +{ + if (fiberPolyData == NULL) + m_FiberPolyData = vtkSmartPointer::New(); + else + m_FiberPolyData = fiberPolyData; + + m_NumFibers = m_FiberPolyData->GetNumberOfLines(); +>>>>>>> bug-10211-FiberProcessingX + + UpdateFiberGeometry(); +} + +mitk::FiberBundleX::~FiberBundleX() +{ + +} + +mitk::FiberBundleX::Pointer mitk::FiberBundleX::GetDeepCopy() +{ + mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(); + +// newFib->m_FiberIdDataSet = vtkSmartPointer::New(); +// newFib->m_FiberIdDataSet->DeepCopy(m_FiberIdDataSet); + newFib->m_FiberPolyData = vtkSmartPointer::New(); + newFib->m_FiberPolyData->DeepCopy(m_FiberPolyData); + newFib->SetColorCoding(m_currentColorCoding); + newFib->m_isModified = m_isModified; + newFib->m_NumFibers = m_NumFibers; + newFib->UpdateFiberGeometry(); + + return newFib; +} + +// merge two fiber bundles +mitk::FiberBundleX::Pointer mitk::FiberBundleX::operator+(mitk::FiberBundleX* fib) +{ + + vtkSmartPointer vNewPolyData = vtkSmartPointer::New(); + vtkSmartPointer vNewLines = vtkSmartPointer::New(); + vtkSmartPointer vNewPoints = vtkSmartPointer::New(); + + vtkSmartPointer vLines = m_FiberPolyData->GetLines(); + vLines->InitTraversal(); + + // add current fiber bundle + int numFibers = GetNumFibers(); + for( int i=0; iGetNextCell ( numPoints, points ); + + vtkSmartPointer container = vtkSmartPointer::New(); + for( int j=0; jInsertNextPoint(m_FiberPolyData->GetPoint(points[j])); + container->GetPointIds()->InsertNextId(id); + } + vNewLines->InsertNextCell(container); + } + + vLines = fib->m_FiberPolyData->GetLines(); + vLines->InitTraversal(); + + // add new fiber bundle + numFibers = fib->GetNumFibers(); + for( int i=0; iGetNextCell ( numPoints, points ); + + vtkSmartPointer container = vtkSmartPointer::New(); + for( int j=0; jInsertNextPoint(fib->m_FiberPolyData->GetPoint(points[j])); + container->GetPointIds()->InsertNextId(id); + } + vNewLines->InsertNextCell(container); + } + + // initialize polydata + vNewPolyData->SetPoints(vNewPoints); + vNewPolyData->SetLines(vNewLines); + + // initialize fiber bundle + mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(vNewPolyData); + return newFib; +} + +// subtract two fiber bundles +mitk::FiberBundleX::Pointer mitk::FiberBundleX::operator-(mitk::FiberBundleX* fib) +{ + + vtkSmartPointer vNewPolyData = vtkSmartPointer::New(); + vtkSmartPointer vNewLines = vtkSmartPointer::New(); + vtkSmartPointer vNewPoints = vtkSmartPointer::New(); + + vtkSmartPointer vLines = m_FiberPolyData->GetLines(); + vLines->InitTraversal(); + + // iterate over current fibers + int numFibers = GetNumFibers(); + for( int i=0; iGetNextCell ( numPoints, points ); + + vtkSmartPointer vLines2 = fib->m_FiberPolyData->GetLines(); + vLines2->InitTraversal(); + int numFibers2 = fib->GetNumFibers(); + bool contained = false; + for( int i2=0; i2GetNextCell ( numPoints2, points2 ); + + // check endpoints + itk::Point point_start = GetItkPoint(m_FiberPolyData->GetPoint(points[0])); + itk::Point point_end = GetItkPoint(m_FiberPolyData->GetPoint(points[numPoints-1])); + itk::Point point2_start = GetItkPoint(fib->m_FiberPolyData->GetPoint(points2[0])); + itk::Point point2_end = GetItkPoint(fib->m_FiberPolyData->GetPoint(points2[numPoints2-1])); + + if (point_start.SquaredEuclideanDistanceTo(point2_start)<=mitk::eps && point_end.SquaredEuclideanDistanceTo(point2_end)<=mitk::eps || + point_start.SquaredEuclideanDistanceTo(point2_end)<=mitk::eps && point_end.SquaredEuclideanDistanceTo(point2_start)<=mitk::eps) + { + // further checking ??? + contained = true; + } + } + + // add to result because fiber is not subtracted + if (!contained) + { + vtkSmartPointer container = vtkSmartPointer::New(); + for( int j=0; jInsertNextPoint(m_FiberPolyData->GetPoint(points[j])); + container->GetPointIds()->InsertNextId(id); + } + vNewLines->InsertNextCell(container); + } + } + + // initialize polydata + vNewPolyData->SetPoints(vNewPoints); + vNewPolyData->SetLines(vNewLines); + + // initialize fiber bundle + mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(vNewPolyData); + return newFib; +} + +itk::Point mitk::FiberBundleX::GetItkPoint(double point[3]) +{ + itk::Point itkPoint; + itkPoint[0] = point[0]; + itkPoint[1] = point[1]; + itkPoint[2] = point[2]; + return itkPoint; +} + +/* + * set polydata (additional flag to recompute fiber geometry, default = true) + */ +void mitk::FiberBundleX::SetFiberPolyData(vtkSmartPointer fiberPD, bool updateGeometry) +{ + if (fiberPD == NULL) + this->m_FiberPolyData = vtkSmartPointer::New(); + else + this->m_FiberPolyData = fiberPD; + +<<<<<<< HEAD + m_isModified = true; +======= + if (updateGeometry) + UpdateFiberGeometry(); + + m_NumFibers = m_FiberPolyData->GetNumberOfLines(); + + m_isModified = true; +>>>>>>> bug-10211-FiberProcessingX +} + +/* + * return vtkPolyData + */ +vtkSmartPointer mitk::FiberBundleX::GetFiberPolyData() +{ + return m_FiberPolyData; +} + +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_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED) && + m_FiberPolyData->GetNumberOfPoints() == + m_FiberPolyData->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_FiberPolyData->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_FiberPolyData->GetNumberOfLines(); + if (numOfFibers < 1) { + MITK_INFO << "\n ========= Number of Fibers is 0 and below ========= \n"; + return; + } + + + /* extract single fibers of fiberBundle */ + vtkCellArray* fiberList = m_FiberPolyData->GetLines(); + fiberList->InitTraversal(); + for (int fi=0; fiGetNextCell(pointsPerFiber, idList); + + // MITK_INFO << "Fib#: " << fi << " of " << numOfFibers << " pnts in fiber: " << pointsPerFiber ; + + /* single fiber checkpoints: is number of points valid */ + if (pointsPerFiber > 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; + + vnl_vector_fixed< double, 3 > diff2; + diff2 = currentPntvtk - prevPntvtk; + + vnl_vector_fixed< double, 3 > diff; + diff = (diff1 - diff2) / 2.0; + 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); + + + } 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==pointsPerFiber-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 (pointsPerFiber == 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_FiberPolyData->GetPointData()->AddArray(colorsT); + + /*========================= + - this is more relevant for renderer than for fiberbundleX datastructure + - think about sourcing this to a explicit method which coordinates colorcoding */ + this->SetColorCoding(COLORCODING_ORIENTATION_BASED); + m_isModified = true; + // =========================== + + //mini test, shall be ported to MITK TESTINGS! + if (colorsT->GetSize() != numOfPoints*componentSize) { + MITK_INFO << "ALLOCATION ERROR IN INITIATING COLOR ARRAY"; + } + +} + +void mitk::FiberBundleX::DoGenerateFiberIds() +{ + if (m_FiberPolyData == NULL) + return; + + // for (int i=0; i<10000000; ++i) + // { + // if(i%500 == 0) + // MITK_INFO << i; + // } + // MITK_INFO << "Generating Fiber Ids"; + vtkSmartPointer idFiberFilter = vtkSmartPointer::New(); + idFiberFilter->SetInput(m_FiberPolyData); + idFiberFilter->CellIdsOn(); + // idFiberFilter->PointIdsOn(); // point id's are not needed + idFiberFilter->SetIdsArrayName(FIBER_ID_ARRAY); + idFiberFilter->FieldDataOn(); + idFiberFilter->Update(); + + m_FiberIdDataSet = idFiberFilter->GetOutput(); + + MITK_INFO << "Generating Fiber Ids...[done] | " << m_FiberIdDataSet->GetNumberOfCells(); + +} + + +//temporarely include only +#include +//========================== +std::vector mitk::FiberBundleX::DoExtractFiberIds(mitk::PlanarFigure::Pointer pf) +{ + + MITK_INFO << "Extracting fiber!"; + /* Handle type of planarfigure */ + // if incoming pf is a pfc + mitk::PlanarFigureComposite::Pointer pfcomp= dynamic_cast(pf.GetPointer()); + if (!pfcomp.IsNull()) { + // process requested boolean operation of PFC + } else + { + + + + mitk::Geometry2D::ConstPointer pfgeometry = pf->GetGeometry2D(); + const mitk::PlaneGeometry* planeGeometry = dynamic_cast (pfgeometry.GetPointer()); + Vector3D planeNormal = planeGeometry->GetNormal(); + planeNormal.Normalize(); + Point3D planeOrigin = planeGeometry->GetOrigin(); + + MITK_INFO << "planeOrigin: " << planeOrigin[0] << " | " << planeOrigin[1] << " | " << planeOrigin[2] << endl; + MITK_INFO << "planeNormal: " << planeNormal[0] << " | " << planeNormal[1] << " | " << planeNormal[2] << endl; + + + /* init necessary vectors hosting pointIds and FiberIds */ + // contains all pointIds which are crossing the cutting plane + std::vector PointsOnPlane; + + // based on PointsOnPlane, all ROI relevant point IDs are stored here + std::vector PointsInROI; + + // vector which is returned, contains all extracted FiberIds + std::vector FibersInROI; + + + /* Define cutting plane by ROI (PlanarFigure) */ + vtkSmartPointer plane = vtkSmartPointer::New(); + plane->SetOrigin(planeOrigin[0],planeOrigin[1],planeOrigin[2]); + plane->SetNormal(planeNormal[0],planeNormal[1],planeNormal[2]); + + //same plane but opposite normal direction. so point cloud will be reduced -> better performance + vtkSmartPointer planeR = vtkSmartPointer::New(); + planeR->SetOrigin(10.0,5.0,0.0); + planeR->SetNormal(0.0,-1.0,0.0); + + + /* get all points/fibers cutting the plane */ + vtkSmartPointer clipper = vtkSmartPointer::New(); + clipper->SetInput(m_FiberIdDataSet); + clipper->SetClipFunction(plane); + clipper->GenerateClipScalarsOn(); + clipper->GenerateClippedOutputOn(); + vtkSmartPointer clipperout1 = clipper->GetClippedOutput(); + + /* for some reason clipperoutput is not initialized for futher processing + * so far only writing out clipped polydata provides requested + */ + vtkSmartPointer writerC = vtkSmartPointer::New(); + writerC->SetInput(clipperout1); + writerC->SetFileName("/vtkOutput/Cout1_FbId_clipLineId0+1+2-tests.vtk"); + writerC->SetFileTypeToASCII(); + writerC->Write(); + + + vtkSmartPointer Rclipper = vtkSmartPointer::New(); + Rclipper->SetInput(clipperout1); + Rclipper->SetClipFunction(planeR); + Rclipper->GenerateClipScalarsOn(); + Rclipper->GenerateClippedOutputOn(); + vtkSmartPointer clipperout = Rclipper->GetClippedOutput(); + + + vtkSmartPointer writerC1 = vtkSmartPointer::New(); + writerC1->SetInput(clipperout); + writerC1->SetFileName("/vtkOutput/FbId_clipLineId0+1+2-tests.vtk"); + writerC1->SetFileTypeToASCII(); + writerC1->Write(); + + + /*======STEP 1====== + * extract all points, which are crossing the plane */ + // Scalar values describe the distance between each remaining point to the given plane. Values sorted by point index + vtkSmartPointer distanceList = clipperout->GetPointData()->GetScalars(); + vtkIdType sizeOfList = distanceList->GetNumberOfTuples(); + PointsOnPlane.reserve(sizeOfList); /* use reserve for high-performant push_back, no hidden copy procedures are processed then! + * size of list can be optimized by reducing allocation, but be aware of iterator and vector size*/ + for (int i=0; iGetTuple(i); + std::cout << "distance of point " << i << " : " << distance[0] << std::endl; + + // check if point is on plane. + // 0.01 due to some approximation errors when calculating distance + if (distance[0] >= -0.01 && distance[0] <= 0.01) + { + std::cout << "adding " << i << endl; + PointsOnPlane.push_back(i); //push back in combination with reserve is fastest way to fill vector with various values + } + + } + + // DEBUG print out all interesting points, stop where array starts with value -1. after -1 no more interesting idx are set! + std::vector::iterator rit = PointsOnPlane.begin(); + while (rit != PointsOnPlane.end() ) { + std::cout << "interesting point: " << *rit << " coord: " << clipperout->GetPoint(*rit)[0] << " | " << clipperout->GetPoint(*rit)[1] << " | " << clipperout->GetPoint(*rit)[2] << endl; + rit++; + } + + + + + + /*=======STEP 2===== + * extract ROI relevant pointIds */ + //ToDo + + mitk::PlanarCircle::Pointer circleName = mitk::PlanarCircle::New(); + mitk::PlanarPolygon::Pointer polyName = mitk::PlanarPolygon::New(); + if (pf->GetNameOfClass() == circleName->GetNameOfClass() ) + { + + if( true /*point in ROI*/) + { + PointsInROI = PointsOnPlane; + } + } + + + + /*======STEP 3======= + * identify fiberIds for points in ROI */ + //prepare resulting vector + FibersInROI.reserve(PointsInROI.size()); + + vtkCellArray *clipperlines = clipperout->GetLines(); + clipperlines->InitTraversal(); + long numOfLineCells = clipperlines->GetNumberOfCells(); + + // go through resulting "sub"lines which are stored as cells, "i" corresponds to current line id. + for (int i=0, ic=0 ; iGetCell(ic, npts, pts); + + // go through point ids in hosting subline, "j" corresponds to current pointindex in current line i. + for (long j=0; jGetCellData()->HasArray("FB_IDs")) + { + int originalFibId = clipperout->GetCellData()->GetArray("FB_IDs")->GetTuple(i)[0]; + std::cout << "found pointid " << PointsInROI[k] << ": " << clipperout->GetPoint(PointsInROI[k])[0] << " | " << clipperout->GetPoint(PointsInROI[k])[1] << " | " << clipperout->GetPoint(PointsInROI[k])[2] << " in subline: " << i << " which belongs to fiber id: " << originalFibId << "\n" << endl; + + // do something to avoid duplicates + int oldFibInRoiSize = FibersInROI.size(); + if (oldFibInRoiSize != 0) { + + + for (int f=0; f::iterator finIt = FibersInROI.begin(); + while ( finIt != FibersInROI.end() ) + { + std::cout << *finIt << endl; + ++finIt; + } + std::cout << "=====================\n"; + + } +} + +void mitk::FiberBundleX::UpdateFiberGeometry() +{ +<<<<<<< HEAD + + + float min = itk::NumericTraits::min(); + float max = itk::NumericTraits::max(); + float b[] = {max, min, max, min, max, min}; + + vtkCellArray* cells = m_FiberPolyData->GetLines(); + cells->InitTraversal(); + for (int i=0; iGetNumberOfCells(); i++) +======= + if (m_NumFibers<=0) + { + mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); + geometry->SetImageGeometry(true); + float b[] = {0, 1, 0, 1, 0, 1}; + geometry->SetFloatBounds(b); + SetGeometry(geometry); + return; + } + float min = itk::NumericTraits::min(); + float max = itk::NumericTraits::max(); + float b[] = {max, min, max, min, max, min}; + + vtkCellArray* cells = m_FiberPolyData->GetLines(); + cells->InitTraversal(); + for (int i=0; iGetNumberOfCells(); i++) + { + vtkCell* cell = m_FiberPolyData->GetCell(i); + int p = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + for (int j=0; j>>>>>> bug-10211-FiberProcessingX + { + +<<<<<<< HEAD + vtkCell* cell = m_FiberPolyData->GetCell(i); + int p = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + for (int j=0; jGetPoint(j, p); + + if (p[0]b[1]) + b[1]=p[0]; + + if (p[1]b[3]) + b[3]=p[1]; + + if (p[2]b[5]) + b[5]=p[2]; + + + } + + } + + // provide some buffer space at borders + + for(int i=0; i<=4; i+=2){ + b[i] -=10; + } + + for(int i=1; i<=5; i+=2){ + b[i] +=10; + } + + mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); + geometry->SetImageGeometry(true); + geometry->SetFloatBounds(b); + this->SetGeometry(geometry); + +======= + if (p[2]b[5]) + b[5]=p[2]; + } + } + + // provide some border margin + for(int i=0; i<=4; i+=2) + b[i] -=10; + for(int i=1; i<=5; i+=2) + b[i] +=10; + + mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); + geometry->SetImageGeometry(true); + geometry->SetFloatBounds(b); + this->SetGeometry(geometry); +>>>>>>> bug-10211-FiberProcessingX +} + +QStringList mitk::FiberBundleX::GetAvailableColorCodings() +{ + QStringList availableColorCodings; + int numColors = m_FiberPolyData->GetPointData()->GetNumberOfArrays(); + for(int i=0; iGetPointData()->GetArrayName(i)); + } + + //this controlstructure shall be implemented by the calling method + if (availableColorCodings.isEmpty()) + MITK_INFO << "no colorcodings available in fiberbundleX"; + + // for(int i=0; im_currentColorCoding = (char*) COLORCODING_ORIENTATION_BASED; + this->m_isModified = true; + + } else if(strcmp (COLORCODING_FA_BASED,requestedColorCoding) == 0 ) { + this->m_currentColorCoding = (char*) COLORCODING_FA_BASED; + this->m_isModified = true; + } else { + MITK_INFO << "FIBERBUNDLE X: UNKNOWN COLORCODING in FIBERBUNDLEX Datastructure"; + this->m_currentColorCoding = "---"; //will cause blank colorcoding of fibers + this->m_isModified = true; + } +} + +bool mitk::FiberBundleX::isFiberBundleXModified() +{ + return m_isModified; +} +void mitk::FiberBundleX::setFBXModificationDone() +{ + m_isModified = false; +} + +void mitk::FiberBundleX::ResampleFibers() +{ + mitk::Geometry3D::Pointer geometry = GetGeometry(); + mitk::Vector3D spacing = geometry->GetSpacing(); + + float minSpacing = 1; + if(spacing[0] newPoly = vtkSmartPointer::New(); + vtkSmartPointer newCellArray = vtkSmartPointer::New(); + vtkSmartPointer newPoints = vtkSmartPointer::New(); + +<<<<<<< HEAD + vtkSmartPointer vLines = m_FiberPolyData->GetLines(); + vLines->InitTraversal(); + int numberOfLines = vLines->GetNumberOfCells(); +======= + vtkSmartPointer vLines = m_FiberPolyData->GetLines(); + vLines->InitTraversal(); + int numberOfLines = m_NumFibers; +>>>>>>> bug-10211-FiberProcessingX + + for (int i=0; iGetNextCell ( numPoints, points ); + + vtkSmartPointer container = vtkSmartPointer::New(); + + double* point = m_FiberPolyData->GetPoint(points[0]); + vtkIdType pointId = newPoints->InsertNextPoint(point); + container->GetPointIds()->InsertNextId(pointId); + + float dtau = 0; + int cur_p = 1; + itk::Vector dR; + float normdR = 0; + + for (;;) + { + while (dtau <= len && cur_p < numPoints) + { + itk::Vector v1; + point = m_FiberPolyData->GetPoint(points[cur_p-1]); + v1[0] = point[0]; + v1[1] = point[1]; + v1[2] = point[2]; + itk::Vector v2; + point = m_FiberPolyData->GetPoint(points[cur_p]); + v2[0] = point[0]; + v2[1] = point[1]; + v2[2] = point[2]; + + dR = v2 - v1; + normdR = std::sqrt(dR.GetSquaredNorm()); + dtau += normdR; + cur_p++; + } + + if (dtau >= len) + { + itk::Vector v1; + point = m_FiberPolyData->GetPoint(points[cur_p-1]); + v1[0] = point[0]; + v1[1] = point[1]; + v1[2] = point[2]; + + itk::Vector v2 = v1 - dR*( (dtau-len)/normdR ); + pointId = newPoints->InsertNextPoint(v2.GetDataPointer()); + container->GetPointIds()->InsertNextId(pointId); + } + else + { + point = m_FiberPolyData->GetPoint(points[numPoints-1]); + pointId = newPoints->InsertNextPoint(point); + container->GetPointIds()->InsertNextId(pointId); + break; + } + dtau = dtau-len; + } + + newCellArray->InsertNextCell(container); + } + + newPoly->SetPoints(newPoints); + newPoly->SetLines(newCellArray); + m_FiberPolyData = newPoly; + UpdateFiberGeometry(); +} + + +/* 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 ) +{ + +} diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp index 435c713550..ac295f0d52 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp @@ -1,149 +1,269 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ 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 "mitkFiberBundleXReader.h" #include #include #include #include +#include +#include +#include #include +#include namespace mitk { void FiberBundleXReader ::GenerateData() { if ( ( ! m_OutputCache ) ) { Superclass::SetNumberOfRequiredOutputs(0); this->GenerateOutputInformation(); } if (!m_OutputCache) { itkWarningMacro("Output cache is empty!"); } Superclass::SetNumberOfRequiredOutputs(1); Superclass::SetNthOutput(0, m_OutputCache.GetPointer()); } void FiberBundleXReader::GenerateOutputInformation() { try { - MITK_INFO << "Reading fiber bundle"; const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); setlocale(LC_ALL, locale.c_str()); std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); ext = itksys::SystemTools::LowerCase(ext); vtkSmartPointer chooser=vtkDataReader::New(); chooser->SetFileName(m_FileName.c_str() ); if( chooser->IsFilePolyData()) { + MITK_INFO << "Reading vtk fiber bundle"; vtkSmartPointer reader = vtkPolyDataReader::New(); reader->SetFileName( m_FileName.c_str() ); reader->Update(); if ( reader->GetOutput() != NULL ) { vtkSmartPointer fiberPolyData = reader->GetOutput(); m_OutputCache = OutputType::New(fiberPolyData); } } + else // try to read deprecated fiber bundle file format + { + MITK_INFO << "Reading xml fiber bundle"; + vtkSmartPointer fiberPolyData = vtkSmartPointer::New(); + vtkSmartPointer cellArray = vtkSmartPointer::New(); + vtkSmartPointer points = vtkSmartPointer::New(); + TiXmlDocument doc( m_FileName ); + if(doc.LoadFile()) + { + TiXmlHandle hDoc(&doc); + TiXmlElement* pElem; + TiXmlHandle hRoot(0); + + pElem = hDoc.FirstChildElement().Element(); + + // save this for later + hRoot = TiXmlHandle(pElem); + + pElem = hRoot.FirstChildElement("geometry").Element(); + + // read geometry + mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); + + // read origin + mitk::Point3D origin; + double temp = 0; + pElem->Attribute("origin_x", &temp); + origin[0] = temp; + pElem->Attribute("origin_y", &temp); + origin[1] = temp; + pElem->Attribute("origin_z", &temp); + origin[2] = temp; + geometry->SetOrigin(origin); + + // read spacing + float spacing[3]; + pElem->Attribute("spacing_x", &temp); + spacing[0] = temp; + pElem->Attribute("spacing_y", &temp); + spacing[1] = temp; + pElem->Attribute("spacing_z", &temp); + spacing[2] = temp; + geometry->SetSpacing(spacing); + + // read transform + vtkMatrix4x4* m = vtkMatrix4x4::New(); + pElem->Attribute("xx", &temp); + m->SetElement(0,0,temp); + pElem->Attribute("xy", &temp); + m->SetElement(1,0,temp); + pElem->Attribute("xz", &temp); + m->SetElement(2,0,temp); + pElem->Attribute("yx", &temp); + m->SetElement(0,1,temp); + pElem->Attribute("yy", &temp); + m->SetElement(1,1,temp); + pElem->Attribute("yz", &temp); + m->SetElement(2,1,temp); + pElem->Attribute("zx", &temp); + m->SetElement(0,2,temp); + pElem->Attribute("zy", &temp); + m->SetElement(1,2,temp); + pElem->Attribute("zz", &temp); + m->SetElement(2,2,temp); + + m->SetElement(0,3,origin[0]); + m->SetElement(1,3,origin[1]); + m->SetElement(2,3,origin[2]); + m->SetElement(3,3,1); + geometry->SetIndexToWorldTransformByVtkMatrix(m); + + // read bounds + float bounds[] = {0, 0, 0, 0, 0, 0}; + pElem->Attribute("size_x", &temp); + bounds[1] = temp; + pElem->Attribute("size_y", &temp); + bounds[3] = temp; + pElem->Attribute("size_z", &temp); + bounds[5] = temp; + geometry->SetFloatBounds(bounds); + geometry->SetImageGeometry(true); + + pElem = hRoot.FirstChildElement("fiber_bundle").FirstChild().Element(); + for( pElem; pElem; pElem=pElem->NextSiblingElement()) + { + TiXmlElement* pElem2 = pElem->FirstChildElement(); + + vtkSmartPointer container = vtkSmartPointer::New(); + + for( pElem2; pElem2; pElem2=pElem2->NextSiblingElement()) + { + itk::Point point; + pElem2->Attribute("pos_x", &temp); + point[0] = temp; + pElem2->Attribute("pos_y", &temp); + point[1] = temp; + pElem2->Attribute("pos_z", &temp); + point[2] = temp; + + geometry->IndexToWorld(point, point); + vtkIdType id = points->InsertNextPoint(point.GetDataPointer()); + container->GetPointIds()->InsertNextId(id); + + } + cellArray->InsertNextCell(container); + } + fiberPolyData->SetPoints(points); + fiberPolyData->SetLines(cellArray); + m_OutputCache = OutputType::New(fiberPolyData); + } + else + { + MITK_INFO << "could not open xml file"; + throw "could not open xml file"; + } + } setlocale(LC_ALL, currLocale.c_str()); MITK_INFO << "Fiber bundle read"; } catch(...) { throw; } } void FiberBundleXReader::Update() { this->GenerateData(); } const char* FiberBundleXReader ::GetFileName() const { return m_FileName.c_str(); } void FiberBundleXReader ::SetFileName(const char* aFileName) { m_FileName = aFileName; } const char* FiberBundleXReader ::GetFilePrefix() const { return m_FilePrefix.c_str(); } void FiberBundleXReader ::SetFilePrefix(const char* aFilePrefix) { m_FilePrefix = aFilePrefix; } const char* FiberBundleXReader ::GetFilePattern() const { return m_FilePattern.c_str(); } void FiberBundleXReader ::SetFilePattern(const char* aFilePattern) { m_FilePattern = aFilePattern; } bool FiberBundleXReader ::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) { // First check the extension if( filename == "" ) { return false; } std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); ext = itksys::SystemTools::LowerCase(ext); if (ext == ".fib") { return true; } return false; } } //namespace MITK diff --git a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp index 8ab6c0fa2a..b0607d5012 100644 --- a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp +++ b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp @@ -1,433 +1,401 @@ /*========================================================================= 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" #include "mitkTbssImageMapper.h" #include "mitkTbssGradientImageMapper.h" -//====depricated fiberstructure===== -#include "mitkFiberBundle.h" -#include "mitkFiberBundleMapper2D.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 "mitkFiberBundleXMapper2D.h" #include "mitkFiberBundleXThreadMonitorMapper3D.h" #include "mitkFiberBundleXThreadMonitor.h" #include "mitkNrrdTbssImageIOFactory.h" #include "mitkNrrdTbssImageWriterFactory.h" #include "mitkNrrdTbssImageWriter.h" #include "mitkNrrdTbssRoiImageIOFactory.h" #include "mitkNrrdTbssRoiImageWriterFactory.h" #include "mitkNrrdTbssRoiImageWriter.h" #include "mitkNrrdTbssGradientImageWriterFactory.h" #include "mitkNrrdTbssGradientImageWriter.h" #include "mitkPlanarCircleMapper3D.h" #include "mitkPlanarPolygonMapper3D.h" typedef short DiffusionPixelType; typedef char TbssRoiPixelType; typedef float TbssPixelType; typedef int TbssGradientPixelType; typedef mitk::DiffusionImage DiffusionImageShort; typedef std::multimap MultimapType; mitk::DiffusionImagingObjectFactory::DiffusionImagingObjectFactory(bool /*registerSelf*/) :CoreObjectFactoryBase() { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "DiffusionImagingObjectFactory c'tor" << std::endl; RegisterIOFactories(); mitk::NrrdDiffusionImageIOFactory::RegisterOneFactory(); mitk::NrrdQBallImageIOFactory::RegisterOneFactory(); mitk::NrrdTensorImageIOFactory::RegisterOneFactory(); - mitk::FiberBundleIOFactory::RegisterOneFactory(); mitk::NrrdTbssImageIOFactory::RegisterOneFactory(); mitk::NrrdTbssRoiImageIOFactory::RegisterOneFactory(); mitk::FiberBundleXIOFactory::RegisterOneFactory(); //modernized mitk::NrrdDiffusionImageWriterFactory::RegisterOneFactory(); mitk::NrrdQBallImageWriterFactory::RegisterOneFactory(); mitk::NrrdTensorImageWriterFactory::RegisterOneFactory(); - mitk::FiberBundleWriterFactory::RegisterOneFactory(); mitk::NrrdTbssImageWriterFactory::RegisterOneFactory(); mitk::NrrdTbssRoiImageWriterFactory::RegisterOneFactory(); mitk::FiberBundleXWriterFactory::RegisterOneFactory();//modernized mitk::NrrdTbssGradientImageWriterFactory::RegisterOneFactory(); 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( NrrdTbssRoiImageWriter::New().GetPointer() ); m_FileWriters.push_back( mitk::FiberBundleXWriter::New().GetPointer() );//modernized m_FileWriters.push_back( mitk::NrrdTbssGradientImageWriter::New().GetPointer() ); 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); } classname = "TbssRoiImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::ImageVtkMapper2D::New(); newMapper->SetDataNode(node); } - classname = "FiberBundle"; - if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) - { - newMapper = mitk::FiberBundleMapper2D::New(); - newMapper->SetDataNode(node); - } - classname = "FiberBundleX"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleXMapper2D::New(); newMapper->SetDataNode(node); } classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::TbssImageMapper::New(); newMapper->SetDataNode(node); } classname = "TbssGradientImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::TbssGradientImageMapper::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { 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 = "FiberBundleXThreadMonitor"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleXThreadMonitorMapper3D::New(); newMapper->SetDataNode(node); } classname = "TbssRoiImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::VolumeDataVtkMapper3D::New(); newMapper->SetDataNode(node); } classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::TbssImageMapper::New(); newMapper->SetDataNode(node); } classname = "PlanarCircle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::PlanarCircleMapper3D::New(); newMapper->SetDataNode(node); } classname = "PlanarPolygon"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::PlanarPolygonMapper3D::New(); newMapper->SetDataNode(node); } classname = "TbssGradientImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::TbssGradientImageMapper::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); - mitk::FiberBundleMapper2D::SetDefaultProperties(node); - } - classname = "FiberBundleX"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::FiberBundleXMapper3D::SetDefaultProperties(node); mitk::FiberBundleXMapper2D::SetDefaultProperties(node); } classname = "FiberBundleXThreadMonitor"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::FiberBundleXThreadMonitorMapper3D::SetDefaultProperties(node); } classname = "TbssRoiImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::ImageVtkMapper2D::SetDefaultProperties(node); mitk::VolumeDataVtkMapper3D::SetDefaultProperties(node); } classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::TbssImageMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "TbssGradientImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::TbssGradientImageMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "PlanarCircle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::PlanarCircleMapper3D::SetDefaultProperties(node); } classname = "PlanarPolygon"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::PlanarPolygonMapper3D::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("*.vtk", "Fiber Bundle")); m_FileExtensionsMap.insert(std::pair("*.tbss", "TBSS data")); m_FileExtensionsMap.insert(std::pair("*.pf", "Planar Figure File")); m_FileExtensionsMap.insert(std::pair("*.roi", "TBSS ROI data")); m_FileExtensionsMap.insert(std::pair("*.tgi", "TBSS gradient image")); 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("*.vtk", "Fiber Bundle")); m_SaveFileExtensionsMap.insert(std::pair("*.tbss", "TBSS data")); m_SaveFileExtensionsMap.insert(std::pair("*.pf", "Planar Figure File")); m_SaveFileExtensionsMap.insert(std::pair("*.roi", "TBSS ROI data")); m_SaveFileExtensionsMap.insert(std::pair("*.tgi", "TBSS gradient image")); } void mitk::DiffusionImagingObjectFactory::RegisterIOFactories() { } void RegisterDiffusionImagingObjectFactory() { static bool oneDiffusionImagingObjectFactoryRegistered = false; if ( ! oneDiffusionImagingObjectFactoryRegistered ) { MITK_DEBUG << "Registering DiffusionImagingObjectFactory..." << std::endl; mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(mitk::DiffusionImagingObjectFactory::New()); oneDiffusionImagingObjectFactoryRegistered = true; } } diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.cpp b/Modules/DiffusionImaging/IODataStructures/mitkParticle.cpp similarity index 100% rename from Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.cpp rename to Modules/DiffusionImaging/IODataStructures/mitkParticle.cpp diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.h b/Modules/DiffusionImaging/IODataStructures/mitkParticle.h similarity index 100% rename from Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.h rename to Modules/DiffusionImaging/IODataStructures/mitkParticle.h diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticleGrid.cpp b/Modules/DiffusionImaging/IODataStructures/mitkParticleGrid.cpp similarity index 100% rename from Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticleGrid.cpp rename to Modules/DiffusionImaging/IODataStructures/mitkParticleGrid.cpp diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticleGrid.h b/Modules/DiffusionImaging/IODataStructures/mitkParticleGrid.h similarity index 100% rename from Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticleGrid.h rename to Modules/DiffusionImaging/IODataStructures/mitkParticleGrid.h diff --git a/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp b/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp index d138099598..76c26d54c8 100644 --- a/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp +++ b/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp @@ -1,275 +1,275 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2007-12-11 14:46:19 +0100 (Di, 11 Dez 2007) $ Version: $Revision: 13129 $ 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 "mitkFiberBundleInteractor.h" #include #include #include #include #include #include #include #include #include #include #include -#include +#include #include "mitkBaseRenderer.h" #include #include #include #include #include #include #include mitk::FiberBundleInteractor::FiberBundleInteractor(const char * type, DataNode* dataNode) : Interactor(type, dataNode), m_LastPosition(0) { m_LastPoint.Fill(0); } mitk::FiberBundleInteractor::~FiberBundleInteractor() {} void mitk::FiberBundleInteractor::SelectFiber(int position) { MITK_INFO << "mitk::FiberBundleInteractor::SelectFiber " << position; mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); if (pointSet == NULL) return; if (pointSet->GetSize()<=0)//if List is empty, then no select of a point can be done! return; mitk::Point3D noPoint;//dummyPoint... not needed anyway noPoint.Fill(0); mitk::PointOperation* doOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); if (m_UndoEnabled) { mitk::PointOperation* undoOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } pointSet->ExecuteOperation(doOp); } void mitk::FiberBundleInteractor::DeselectAllFibers() { MITK_INFO << "mitk::FiberBundleInteractor::DeselectAllFibers "; mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); if (pointSet == NULL) return; mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet(); mitk::PointSet::PointsContainer::Iterator it, end; end = itkPointSet->GetPoints()->End(); for (it = itkPointSet->GetPoints()->Begin(); it != end; it++) { int position = it->Index(); PointSet::PointDataType pointData = {0, false, PTUNDEFINED}; itkPointSet->GetPointData(position, &pointData); if ( pointData.selected )//then declare an operation which unselects this point; UndoOperation as well! { mitk::Point3D noPoint; noPoint.Fill(0); mitk::PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); if (m_UndoEnabled) { mitk::PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } pointSet->ExecuteOperation(doOp); } } } float mitk::FiberBundleInteractor::CanHandleEvent(StateEvent const* stateEvent) const //go through all points and check, if the given Point lies near a line { float returnValue = 0; mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); //checking if a keyevent can be handled: if (posEvent == NULL) { //check, if the current state has a transition waiting for that key event. if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) { return 0.5; } else { return 0; } } //Mouse event handling: //on MouseMove do nothing! reimplement if needed differently if (stateEvent->GetEvent()->GetType() == mitk::Type_MouseMove) { return 0; } //if the event can be understood and if there is a transition waiting for that event if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) { returnValue = 0.5;//it can be understood } //check on the right data-type - mitk::FiberBundle* bundle = dynamic_cast(m_DataNode->GetData()); + mitk::FiberBundleX* bundle = dynamic_cast(m_DataNode->GetData()); if (bundle == NULL) return 0; return 0.5; } bool mitk::FiberBundleInteractor::ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ) { bool ok = false;//for return type bool //checking corresponding Data; has to be a PointSet or a subclass - mitk::FiberBundle* bundle = dynamic_cast(m_DataNode->GetData()); + mitk::FiberBundleX* bundle = dynamic_cast(m_DataNode->GetData()); if (bundle == NULL) return false; // Get Event and extract renderer const Event *event = stateEvent->GetEvent(); BaseRenderer *renderer = NULL; vtkRenderWindow *renderWindow = NULL; vtkRenderWindowInteractor *renderWindowInteractor = NULL; vtkRenderer *currentVtkRenderer = NULL; vtkCamera *camera = NULL; if ( event != NULL ) { renderer = event->GetSender(); if ( renderer != NULL ) { renderWindow = renderer->GetRenderWindow(); if ( renderWindow != NULL ) { renderWindowInteractor = renderWindow->GetInteractor(); if ( renderWindowInteractor != NULL ) { currentVtkRenderer = renderWindowInteractor ->GetInteractorStyle()->GetCurrentRenderer(); if ( currentVtkRenderer != NULL ) { camera = currentVtkRenderer->GetActiveCamera(); } } } } } /*Each case must watch the type of the event!*/ switch (action->GetActionId()) { case AcCHECKHOVERING: { QApplication::restoreOverrideCursor(); // Re-enable VTK interactor (may have been disabled previously) if ( renderWindowInteractor != NULL ) { renderWindowInteractor->Enable(); } const DisplayPositionEvent *dpe = dynamic_cast< const DisplayPositionEvent * >( stateEvent->GetEvent() ); // Check if we have a DisplayPositionEvent if ( dpe != NULL ) { // Check if an object is present at the current mouse position DataNode *pickedNode = dpe->GetPickedObjectNode(); if ( pickedNode != m_DataNode ) - { + { // if(pickedNode == 0) // MITK_INFO << "picked node is NULL, no hovering"; // else // MITK_INFO << "wrong node: " << pickedNode; this->HandleEvent( new StateEvent( EIDNOFIGUREHOVER ) ); ok = true; break; } m_CurrentPickedPoint = dpe->GetWorldPosition(); m_CurrentPickedDisplayPoint = dpe->GetDisplayPosition(); QApplication::setOverrideCursor(Qt::UpArrowCursor); this->HandleEvent( new StateEvent( EIDFIGUREHOVER ) ); } ok = true; break; } break; // case AcSELECTPICKEDOBJECT: // MITK_INFO << "FiberBundleInteractor AcSELECTPICKEDOBJECT"; // break; // case AcDESELECTALL: // MITK_INFO << "FiberBundleInteractor AcDESELECTALL"; // break; case AcREMOVE: { MITK_INFO << "picking fiber at " << m_CurrentPickedPoint; // QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; // multiWidgetEditor->GetStdMultiWidget()->GetRenderWindow1()->GetRenderer()->GetSliceNavigationController()->SelectSliceByPoint( // m_CurrentPickedPoint); BaseRenderer* renderer = mitk::BaseRenderer::GetByName("stdmulti.widget1"); renderer->GetSliceNavigationController()->SelectSliceByPoint( m_CurrentPickedPoint); renderer = mitk::BaseRenderer::GetByName("stdmulti.widget2"); renderer->GetSliceNavigationController()->SelectSliceByPoint( m_CurrentPickedPoint); renderer = mitk::BaseRenderer::GetByName("stdmulti.widget3"); renderer->GetSliceNavigationController()->SelectSliceByPoint( m_CurrentPickedPoint); // mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } break; default: return Superclass::ExecuteAction( action, stateEvent ); } return ok; } diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper2D.cpp b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper2D.cpp deleted file mode 100644 index 3928160bfc..0000000000 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper2D.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* - * mitkFiberBundleMapper2D.cpp - * mitk-all - * - * Created by HAL9000 on 1/17/11. - * Copyright 2011 __MyCompanyName__. All rights reserved. - * - */ - -#include "mitkFiberBundleMapper2D.h" -#include -#include "mitkFiberBundleMapper3D.h" - -#include -#include -#include -#include -//#include - -//#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include -#include -#include - -#include -#include -#include - -#include -#include - -mitk::FiberBundleMapper2D::FiberBundleMapper2D() -{ - - -} - -mitk::FiberBundleMapper2D::~FiberBundleMapper2D() -{ -} - - -const mitk::FiberBundle* mitk::FiberBundleMapper2D::GetInput() -{ - return dynamic_cast ( GetData() ); -} - - - -void mitk::FiberBundleMapper2D::Update(mitk::BaseRenderer * renderer) -{ - - if ( !this->IsVisible( renderer ) ) - { - return; - } - - - // Calculate time step of the input data for the specified renderer (integer value) - // this method is implemented in mitkMapper - this->CalculateTimeStep( renderer ); - - //check if updates occured in the node or on the display - FBLocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); - const DataNode *node = this->GetDataNode(); - if ( (localStorage->m_LastUpdateTime < node->GetMTime()) - || (localStorage->m_LastUpdateTime < node->GetPropertyList()->GetMTime()) //was a property modified? - || (localStorage->m_LastUpdateTime < node->GetPropertyList(renderer)->GetMTime()) ) - { - // MITK_INFO << "UPDATE NEEDED FOR _ " << renderer->GetName(); - this->GenerateDataForRenderer( renderer ); - } - - if ((localStorage->m_LastUpdateTime < renderer->GetDisplayGeometry()->GetMTime()) ) //was the display geometry modified? e.g. zooming, panning) - { - - this->UpdateShaderParameter(renderer); - - } - -} - -void mitk::FiberBundleMapper2D::UpdateShaderParameter(mitk::BaseRenderer * renderer) -{ - FBLocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); - // MITK_INFO << "uSERWAAAAAAAS, da shader brauchat a poor neue zoin"; - //get information about current position of views - mitk::SliceNavigationController::Pointer sliceContr = renderer->GetSliceNavigationController(); - mitk::PlaneGeometry::ConstPointer planeGeo = sliceContr->GetCurrentPlaneGeometry(); - - //generate according cutting planes based on the view position - float sliceN[3], planeOrigin[3]; - - - // since shader uses camera coordinates, transform origin and normal from worldcoordinates to cameracoordinates - - - planeOrigin[0] = (float) planeGeo->GetOrigin()[0]; - planeOrigin[1] = (float) planeGeo->GetOrigin()[1]; - planeOrigin[2] = (float) planeGeo->GetOrigin()[2]; - - sliceN[0] = planeGeo->GetNormal()[0]; - sliceN[1] = planeGeo->GetNormal()[1]; - sliceN[2] = planeGeo->GetNormal()[2]; - - - float tmp1 = planeOrigin[0] * sliceN[0]; - float tmp2 = planeOrigin[1] * sliceN[1]; - float tmp3 = planeOrigin[2] * sliceN[2]; - float d1 = tmp1 + tmp2 + tmp3; //attention, correct normalvector - - - float plane1[4]; - plane1[0] = sliceN[0]; - plane1[1] = sliceN[1]; - plane1[2] = sliceN[2]; - plane1[3] = d1; - - float thickness = 2.0; - if(!this->GetDataNode()->GetPropertyValue("Fiber2DSliceThickness",thickness)) - MITK_INFO << "FIBER2D SLICE THICKNESS PROPERTY ERROR"; - - - bool fiberfading = false; - if(!this->GetDataNode()->GetPropertyValue("Fiber2DfadeEFX",fiberfading)) - MITK_INFO << "FIBER2D SLICE FADE EFX PROPERTY ERROR"; - - - int fiberfading_i = 1; - if (!fiberfading) - fiberfading_i = 0; - - - localStorage->m_PointActor->GetProperty()->AddShaderVariable("slicingPlane",4, plane1); - localStorage->m_PointActor->GetProperty()->AddShaderVariable("fiberThickness",1, &thickness); - localStorage->m_PointActor->GetProperty()->AddShaderVariable("fiberFadingON",1, &fiberfading_i); - - -} - -// ALL RAW DATA FOR VISUALIZATION IS GENERATED HERE. -// vtkActors and Mappers are feeded here -void mitk::FiberBundleMapper2D::GenerateDataForRenderer(mitk::BaseRenderer *renderer) -{ - - //the handler of local storage gets feeded in this method with requested data for related renderwindow - FBLocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); - - //this procedure is depricated, - //not needed after initializaton anymore - mitk::DataNode* node = this->GetDataNode(); - if ( node == NULL ) - { - MITK_INFO << "check DATANODE: ....[Fail] "; - return; - } - /////////////////////////////////// - - - - - - - mitk::FiberBundleMapper3D::Pointer FBMapper3D = dynamic_cast< mitk::FiberBundleMapper3D* > (node->GetMapper( 2 )); - if ( FBMapper3D->GetInput() == NULL ) - { - MITK_INFO << "check FBMapper3D Input: ....[Fail] "; - return; - } - - - - - //feed local storage with data we want to visualize - // localStorage->m_SlicedResult = FBMapper3D->GetCut(planeOrigin, planeN, cutParams); - // localStorage->m_SlicedResult = FBMapper3D->GetVtkFBPolyDataMapper(); - localStorage->m_SlicedResult = (vtkPolyData*) FBMapper3D->getVtkFiberBundleMapper()->GetInputAsDataSet(); - //MITK_INFO << renderer->GetName() << " OutputPoints#: " << localStorage->m_SlicedResult->GetNumberOfPoints(); - - - vtkSmartPointer lut = vtkLookupTable::New(); - lut->Build(); - localStorage->m_PointMapper->SetScalarModeToUsePointFieldData(); - //m_VtkFiberDataMapperGL->SelectColorArray("FaColors"); - localStorage->m_PointMapper->SelectColorArray("ColorValues"); - localStorage->m_PointMapper->SetLookupTable(lut); //apply the properties after the slice was set - //this->ApplyProperties( renderer ); - - //setup the camera according to the actor with zooming/panning etc. - // this->AdjustCamera( renderer, planeGeo ); - - - - // feed the vtk fiber mapper with point data ...TODO do in constructor - localStorage->m_PointMapper->SetInput(localStorage->m_SlicedResult); // in optimized version, mapper is feeded by localStorage->m_cutter->GetOutput(); - localStorage->m_PointActor->SetMapper(localStorage->m_PointMapper); - localStorage->m_PointActor->GetProperty()->ShadingOn(); - - // Applying shading properties - { - //Superclass::ApplyProperties( ls->m_Actor, renderer ) ; - // VTK Properties - //ApplyMitkPropertiesToVtkProperty( this->GetDataNode(), ls->m_Actor->GetProperty(), renderer ); - // Shaders - mitk::ShaderRepository::GetGlobalShaderRepository()->ApplyProperties(this->GetDataNode(),localStorage->m_PointActor,renderer, localStorage->m_LastUpdateTime); - } - - - - this->UpdateShaderParameter(renderer); - - - // We have been modified => save this for next Update() - localStorage->m_LastUpdateTime.Modified(); - - -} - - -vtkProp* mitk::FiberBundleMapper2D::GetVtkProp(mitk::BaseRenderer *renderer) -{ - - //MITK_INFO << "FiberBundleMapper2D GetVtkProp(renderer)"; - this->Update(renderer); - return m_LSH.GetLocalStorage(renderer)->m_PointActor; - -} - - -void mitk::FiberBundleMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) -{ //add shader to datano - - - //####### load shader from file ######### - QString applicationDir = QCoreApplication::applicationDirPath(); - MITK_INFO << "pathAppdir: " << QCoreApplication::applicationDirPath().toStdString().c_str(); - - - if (applicationDir.endsWith("bin")) - applicationDir.append("/"); - else if (applicationDir.endsWith("MacOS")) - { - //on osx, check if path for installer or MITK development is needed - applicationDir.append("/"); - QFile f( applicationDir+"FiberTrackingLUTBaryCoords.bin" ); - if( !f.exists() ) // if file does not exist, then look in MITK development build directory - applicationDir.append("../../../"); - }else - applicationDir.append("\\..\\"); - -// applicationDir.append("/"); //directory to look when building installer - - mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch( applicationDir.toStdString().c_str(), false ); - mitk::ShaderRepository::Pointer shaderRepository = mitk::ShaderRepository::GetGlobalShaderRepository(); - -// std::string filepath = mitk::StandardFileLocations::GetInstance()->FindFile("mitkShaderFiberClipping.xml"); -// if ( filepath.empty() ) -// { -// applicationDir = QCoreApplication::applicationDirPath(); -// applicationDir.append("/../../"); //directory to look when developing in MITK -// mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch( applicationDir.toStdString().c_str(), false ); -// filepath = mitk::StandardFileLocations::GetInstance()->FindFile("mitkShaderFiberClipping.xml"); - -// if ( filepath.empty() ) -// { //for windows systems -// applicationDir = QCoreApplication::applicationDirPath(); -// applicationDir.append("\\..\\"); -// mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch( applicationDir.toStdString().c_str(), false ); - -// } - -// } - - - - shaderRepository->LoadShader(mitk::StandardFileLocations::GetInstance()->FindFile("mitkShaderFiberClipping.xml")); - - - - //#################################################################### - node->SetProperty("shader",mitk::ShaderProperty::New("mitkShaderFiberClipping")); - mitk::ShaderRepository::GetGlobalShaderRepository()->AddDefaultProperties(node,renderer,overwrite); - - - //add other parameters to propertylist - node->AddProperty( "Fiber2DSliceThickness", mitk::FloatProperty::New(2.0f), renderer, overwrite ); - node->AddProperty( "Fiber2DfadeEFX", mitk::BoolProperty::New(true), renderer, overwrite ); - - - Superclass::SetDefaultProperties(node, renderer, overwrite); -} - - - - - -// following methods are essential, they actually call the GetVtkProp() method -// which returns the desired actors -void mitk::FiberBundleMapper2D::MitkRenderOverlay(BaseRenderer* renderer) -{ - // MITK_INFO << "FiberBundleMapper2D MitkRenderOVerlay(renderer)"; - if ( this->IsVisible(renderer)==false ) - return; - - if ( this->GetVtkProp(renderer)->GetVisibility() ) - { - this->GetVtkProp(renderer)->RenderOverlay(renderer->GetVtkRenderer()); - } -} - -void mitk::FiberBundleMapper2D::MitkRenderOpaqueGeometry(BaseRenderer* renderer) -{ - // MITK_INFO << "FiberBundleMapper2D MitkRenderOpaqueGeometry(renderer)"; - if ( this->IsVisible( renderer )==false ) - return; - - if ( this->GetVtkProp(renderer)->GetVisibility() ) - this->GetVtkProp(renderer)->RenderOpaqueGeometry( renderer->GetVtkRenderer() ); -} -void mitk::FiberBundleMapper2D::MitkRenderTranslucentGeometry(BaseRenderer* renderer) -{ - // MITK_INFO << "FiberBundleMapper2D MitkRenderTranslucentGeometry(renderer)"; - if ( this->IsVisible(renderer)==false ) - return; - - //TODO is it possible to have a visible BaseRenderer AND an invisible VtkRenderer??? - if ( this->GetVtkProp(renderer)->GetVisibility() ) - this->GetVtkProp(renderer)->RenderTranslucentPolygonalGeometry(renderer->GetVtkRenderer()); - -} -void mitk::FiberBundleMapper2D::MitkRenderVolumetricGeometry(BaseRenderer* renderer) -{ - // MITK_INFO << "FiberBundleMapper2D MitkRenderVolumentricGeometry(renderer)"; - if(IsVisible(renderer)==false) - return; - - //TODO is it possible to have a visible BaseRenderer AND an invisible VtkRenderer??? - if ( GetVtkProp(renderer)->GetVisibility() ) - this->GetVtkProp(renderer)->RenderVolumetricGeometry(renderer->GetVtkRenderer()); - -} - -mitk::FiberBundleMapper2D::FBLocalStorage::FBLocalStorage() -{ - m_PointActor = vtkSmartPointer::New(); - m_PointMapper = vtkSmartPointer::New(); - -} diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper2D.h b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper2D.h deleted file mode 100644 index c882b75e04..0000000000 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper2D.h +++ /dev/null @@ -1,118 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2010-09-26 20:40:22 +0200 (So, 26 Sep 2010) $ - Version: $Revision$ - - 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 FIBERBUNDLEMAPPER2D_H_HEADER_INCLUDED -#define FIBERBUNDLEMAPPER2D_H_HEADER_INCLUDED - -//MITK Rendering -#include -#include -//#include "MitkDiffusionImagingExports.h" - -#include -#include -#include - - -//#include "FBLocalStorage.h" - -class vtkActor; -//class vtkPropAssembly; //lets see if we need it -class mitkBaseRenderer; -class vtkPolyDataMapper; -class vtkCutter; -class vtkPlane; -class vtkPolyData; - - - -namespace mitk { - - - class FiberBundleMapper2D : public VtkMapper2D - { - - public: - mitkClassMacro(FiberBundleMapper2D, VtkMapper2D); - itkNewMacro(Self); - const mitk::FiberBundle* GetInput(); - - - /** \brief Checks whether this mapper needs to update itself and generate - * data. */ - virtual void Update(mitk::BaseRenderer * renderer); - - - static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false ); - - - //### methods of MITK-VTK rendering pipeline - virtual vtkProp* GetVtkProp(mitk::BaseRenderer* renderer); - virtual void MitkRenderOverlay(BaseRenderer* renderer); - virtual void MitkRenderOpaqueGeometry(BaseRenderer* renderer); - virtual void MitkRenderTranslucentGeometry(BaseRenderer* renderer); - virtual void MitkRenderVolumetricGeometry(BaseRenderer* renderer); - //### end of methods of MITK-VTK rendering pipeline - - - class FBLocalStorage : public mitk::Mapper::BaseLocalStorage - { - public: - /** \brief Point Actor of a 2D render window. */ - vtkSmartPointer m_PointActor; - /** \brief Point Mapper of a 2D render window. */ - vtkSmartPointer m_PointMapper; - /** \brief Point Actor of a 2D render window. */ - // vtkSmartPointer m_TubeActor; //not in use right now - /** \brief Point Mapper of a 2D render window. */ - // vtkSmartPointer m_TubeMapper; //not in use right now - /** \brief Current slice of a 2D render window. */ - // vtkSmartPointer m_cutter; //needed later when optimized 2D mapper - vtkSmartPointer m_SlicingPlane; //needed later when optimized 2D mapper - vtkSmartPointer m_SlicedResult; //might be depricated in optimized 2D mapper - - /** \brief Timestamp of last update of stored data. */ - itk::TimeStamp m_LastUpdateTime; - /** \brief Constructor of the local storage. Do as much actions as possible in here to avoid double executions. */ - FBLocalStorage(); //if u copy&paste from this 2Dmapper, be aware that the implementation of this constructor is in the cpp file - - ~FBLocalStorage() - { - } - }; - - /** \brief This member holds all three LocalStorages for the three 2D render windows. */ - mitk::Mapper::LocalStorageHandler m_LSH; - - - - protected: - FiberBundleMapper2D(); - virtual ~FiberBundleMapper2D(); - - /** Does the actual resampling, without rendering. */ - virtual void GenerateDataForRenderer(mitk::BaseRenderer*); - - void UpdateShaderParameter(mitk::BaseRenderer*); - - - }; - - -}//end namespace - -#endif \ No newline at end of file diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp deleted file mode 100644 index 1712fe5e52..0000000000 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/*========================================================================= - - 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 -#include "mitkFiberBundleMapper3D.h" - - -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include -#include - -#include "mitkFiberBundleInteractor.h" -#include - -//template -mitk::FiberBundleMapper3D::FiberBundleMapper3D() -: m_VtkFiberDataMapperGL(vtkOpenGLPolyDataMapper::New()) -, m_FiberActor(vtkOpenGLActor::New()) -, m_FiberAssembly(vtkPropAssembly::New()) -, m_vtkTubeMapper(vtkOpenGLPolyDataMapper::New()) -, m_tubes(vtkTubeFilter::New()) -, m_TubeActor(vtkOpenGLActor::New()) -{ - - -} - -mitk::FiberBundleMapper3D::~FiberBundleMapper3D() -{ - -} - - -const mitk::FiberBundle* mitk::FiberBundleMapper3D::GetInput() -{ - //MITK_INFO << "FiberBundleMapper3D GetInput()" ; - - return static_cast ( GetData() ); -} - -vtkOpenGLPolyDataMapper* mitk::FiberBundleMapper3D::getVtkFiberBundleMapper() -{ - return m_VtkFiberDataMapperGL; -} - -/* - 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 - - vtkSmartPointer 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 - vtkSmartPointer vtkSmoothCells = vtkCellArray::New(); //cellcontainer for smoothed lines - - //in some cases a fiber includes just 1 point, so put it in here - vtkSmartPointer vtkVrtxs = vtkCellArray::New(); - - //colors and alpha value for each single point, RGBA = 4 components - vtkSmartPointer colorsT = vtkUnsignedCharArray::New(); - colorsT->SetNumberOfComponents(4); - colorsT->SetName("ColorValues"); - - vtkSmartPointer faColors = vtkDoubleArray::New(); - faColors->SetName("FaColors"); - - vtkSmartPointer 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; - - vtkSmartPointer 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///// - vtkSmartPointer xSpline = vtkKochanekSpline::New(); - vtkSmartPointer ySpline = vtkKochanekSpline::New(); - vtkSmartPointer zSpline = vtkKochanekSpline::New(); - - vtkSmartPointer spline = vtkParametricSpline::New(); - spline->SetXSpline(xSpline); - spline->SetYSpline(ySpline); - spline->SetZSpline(zSpline); - spline->SetPoints(vtkpointsDTI); - - - vtkSmartPointer 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 - - vtkSmartPointer 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 - vtkSmartPointer 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); - - - vtkSmartPointer lut = vtkLookupTable::New(); - lut->Build(); - - - // 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_FiberActor = vtkOpenGLActor::New(); - m_FiberActor->SetMapper(m_VtkFiberDataMapperGL); - m_FiberActor->GetProperty()->SetOpacity(0.9); - 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(0.9); - - -} - - - - -//template -void mitk::FiberBundleMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) -{ - - - - // 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->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(...)"; - 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 deleted file mode 100644 index 5234d71650..0000000000 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.h +++ /dev/null @@ -1,92 +0,0 @@ -/*========================================================================= - -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 -#include -#include - - -#include -#include -#include -#include -#include - - -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(); - - vtkOpenGLPolyDataMapper* getVtkFiberBundleMapper(); - protected: - - FiberBundleMapper3D(); - virtual ~FiberBundleMapper3D(); - - void UpdateVtkObjects(); - - - - vtkSmartPointer m_VtkFiberDataMapperGL; - vtkSmartPointer m_FiberActor; - vtkSmartPointer m_FiberAssembly; - - vtkSmartPointer m_vtkTubeMapper; - vtkSmartPointer m_tubes; - vtkSmartPointer m_TubeActor; - - - - - - }; - -} // namespace mitk - - - - -#endif /* FiberBundleMapper3D_H_HEADER_INCLUDED */ - diff --git a/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.h b/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.h index b1aeff7bbf..82c57b0a43 100644 --- a/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.h +++ b/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.h @@ -1,98 +1,97 @@ /*========================================================================= - + 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 PlanarCircleMapper3D_H_HEADER_INCLUDED #define PlanarCircleMapper3D_H_HEADER_INCLUDED //#include "mitkCommon.h" //#include "mitkBaseRenderer.h" -#include #include #include //#include "MitkDiffusionImagingMBIExports.h" #include #include #include #include #include #include #include #include #include //class mitkPlanarCircle; #include namespace mitk { - + //##Documentation //## @brief Mapper for FiberBundles //## @ingroup Mapper // template class /*MitkDiffusionImagingMBI_EXPORT*/ PlanarCircleMapper3D : public VtkMapper3D { public: - + mitkClassMacro(PlanarCircleMapper3D, VtkMapper3D); itkNewMacro(Self); - - + + const mitk::PlanarCircle* 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: - + PlanarCircleMapper3D(); virtual ~PlanarCircleMapper3D(); - + void UpdateVtkObjects(); - - + + vtkAppendPolyData *m_vtkCircleList; - + vtkOpenGLPolyDataMapper *m_VtkCircleDataMapperGL; - + vtkOpenGLActor *m_CircleActor; - - + + vtkPropAssembly *m_CircleAssembly; - + vtkRegularPolygonSource *m_polygonSource; - + }; - + } // namespace mitk #endif /* FiberBundleMapper3D_H_HEADER_INCLUDED */ diff --git a/Modules/DiffusionImaging/files.cmake b/Modules/DiffusionImaging/files.cmake index 3e2044b204..f4d4888653 100644 --- a/Modules/DiffusionImaging/files.cmake +++ b/Modules/DiffusionImaging/files.cmake @@ -1,183 +1,166 @@ SET(CPP_FILES # DicomImport DicomImport/mitkDicomDiffusionImageReader.cpp DicomImport/mitkGroupDiffusionHeadersFilter.cpp DicomImport/mitkDicomDiffusionImageHeaderReader.cpp DicomImport/mitkGEDicomDiffusionImageHeaderReader.cpp DicomImport/mitkPhilipsDicomDiffusionImageHeaderReader.cpp DicomImport/mitkSiemensDicomDiffusionImageHeaderReader.cpp DicomImport/mitkSiemensMosaicDicomDiffusionImageHeaderReader.cpp # DataStructures IODataStructures/mitkDiffusionImagingObjectFactory.cpp # DataStructures -> DWI IODataStructures/DiffusionWeightedImages/mitkDiffusionImageHeaderInformation.cpp IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSource.cpp IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageReader.cpp IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageWriter.cpp IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageIOFactory.cpp IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageWriterFactory.cpp IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSerializer.cpp # DataStructures -> QBall IODataStructures/QBallImages/mitkQBallImageSource.cpp IODataStructures/QBallImages/mitkNrrdQBallImageReader.cpp IODataStructures/QBallImages/mitkNrrdQBallImageWriter.cpp IODataStructures/QBallImages/mitkNrrdQBallImageIOFactory.cpp IODataStructures/QBallImages/mitkNrrdQBallImageWriterFactory.cpp IODataStructures/QBallImages/mitkQBallImage.cpp IODataStructures/QBallImages/mitkQBallImageSerializer.cpp # DataStructures -> Tensor IODataStructures/TensorImages/mitkTensorImageSource.cpp IODataStructures/TensorImages/mitkNrrdTensorImageReader.cpp IODataStructures/TensorImages/mitkNrrdTensorImageWriter.cpp IODataStructures/TensorImages/mitkNrrdTensorImageIOFactory.cpp IODataStructures/TensorImages/mitkNrrdTensorImageWriterFactory.cpp IODataStructures/TensorImages/mitkTensorImage.cpp IODataStructures/TensorImages/mitkTensorImageSerializer.cpp - # DataStructures -> FiberBundle - IODataStructures/FiberBundle/mitkFiberBundle.cpp - IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp - IODataStructures/FiberBundle/mitkFiberBundleReader.cpp - IODataStructures/FiberBundle/mitkFiberBundleIOFactory.cpp - IODataStructures/FiberBundle/mitkFiberBundleWriterFactory.cpp - IODataStructures/FiberBundle/mitkFiberBundleSerializer.cpp - IODataStructures/FiberBundle/mitkParticle.cpp - IODataStructures/FiberBundle/mitkParticleGrid.cpp + IODataStructures/mitkParticle.cpp + IODataStructures/mitkParticleGrid.cpp # DataStructures -> FiberBundleX IODataStructures/FiberBundleX/mitkFiberBundleX.cpp IODataStructures/FiberBundleX/mitkFiberBundleXWriter.cpp IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp IODataStructures/FiberBundleX/mitkFiberBundleXIOFactory.cpp IODataStructures/FiberBundleX/mitkFiberBundleXWriterFactory.cpp IODataStructures/FiberBundleX/mitkFiberBundleXSerializer.cpp IODataStructures/FiberBundleX/mitkFiberBundleXThreadMonitor.cpp - # DataStructures -> PlanarFigureComposite IODataStructures/PlanarFigureComposite/mitkPlanarFigureComposite.cpp - # DataStructures -> Tbss IODataStructures/TbssImages/mitkTbssImageSource.cpp IODataStructures/TbssImages/mitkTbssRoiImageSource.cpp IODataStructures/TbssImages/mitkNrrdTbssImageReader.cpp IODataStructures/TbssImages/mitkNrrdTbssImageIOFactory.cpp IODataStructures/TbssImages/mitkNrrdTbssRoiImageReader.cpp IODataStructures/TbssImages/mitkNrrdTbssRoiImageIOFactory.cpp IODataStructures/TbssImages/mitkTbssImage.cpp IODataStructures/TbssImages/mitkTbssRoiImage.cpp IODataStructures/TbssImages/mitkTbssGradientImage.cpp IODataStructures/TbssImages/mitkNrrdTbssImageWriter.cpp IODataStructures/TbssImages/mitkNrrdTbssImageWriterFactory.cpp IODataStructures/TbssImages/mitkNrrdTbssGradientImageWriter.cpp IODataStructures/TbssImages/mitkNrrdTbssGradientImageWriterFactory.cpp IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.cpp IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriterFactory.cpp IODataStructures/TbssImages/mitkTbssImporter.cpp - # Rendering Rendering/vtkMaskedProgrammableGlyphFilter.cpp Rendering/mitkCompositeMapper.cpp Rendering/mitkVectorImageVtkGlyphMapper3D.cpp Rendering/vtkOdfSource.cxx Rendering/vtkThickPlane.cxx Rendering/mitkOdfNormalizationMethodProperty.cpp Rendering/mitkOdfScaleByProperty.cpp - Rendering/mitkFiberBundleMapper2D.cpp - Rendering/mitkFiberBundleMapper3D.cpp Rendering/mitkFiberBundleXMapper2D.cpp Rendering/mitkFiberBundleXMapper3D.cpp Rendering/mitkFiberBundleXThreadMonitorMapper3D.cpp Rendering/mitkTbssImageMapper.cpp Rendering/mitkTbssGradientImageMapper.cpp Rendering/mitkPlanarCircleMapper3D.cpp Rendering/mitkPlanarPolygonMapper3D.cpp # Interactions Interactions/mitkFiberBundleInteractor.cpp # Algorithms Algorithms/mitkPartialVolumeAnalysisHistogramCalculator.cpp Algorithms/mitkPartialVolumeAnalysisClusteringCalculator.cpp # Tractography Tractography/itkStochasticTractographyFilter.h ) SET(H_FILES # Rendering Rendering/mitkDiffusionImageMapper.h Rendering/mitkTbssImageMapper.h Rendering/mitkTbssGradientImageMapper.h Rendering/mitkOdfVtkMapper2D.h - Rendering/mitkFiberBundleMapper2D.h - Rendering/mitkFiberBundleMapper3D.h Rendering/mitkFiberBundleXMapper3D.h Rendering/mitkFiberBundleXMapper2D.h Rendering/mitkFiberBundleXThreadMonitorMapper3D.h Rendering/mitkPlanarCircleMapper3D.h Rendering/mitkPlanarPolygonMapper3D.h # Reconstruction Reconstruction/itkDiffusionQballReconstructionImageFilter.h Reconstruction/mitkTeemDiffusionTensor3DReconstructionImageFilter.h Reconstruction/itkAnalyticalDiffusionQballReconstructionImageFilter.h Reconstruction/itkPointShell.h Reconstruction/itkOrientationDistributionFunction.h Reconstruction/itkDiffusionIntravoxelIncoherentMotionReconstructionImageFilter.h Reconstruction/itkRegularizedIVIMLocalVariationImageFilter.h Reconstruction/itkRegularizedIVIMReconstructionFilter.h Reconstruction/itkRegularizedIVIMReconstructionSingleIteration.h # IO Datastructures IODataStructures/DiffusionWeightedImages/mitkDiffusionImage.h - IODataStructures/FiberBundle/itkSlowPolyLineParametricPath.h # DataStructures -> FiberBundleX IODataStructures/FiberBundleX/mitkFiberBundleX.h IODataStructures/FiberBundleX/mitkFiberBundleXWriter.h IODataStructures/FiberBundleX/mitkFiberBundleXReader.h IODataStructures/FiberBundleX/mitkFiberBundleXIOFactory.h IODataStructures/FiberBundleX/mitkFiberBundleXWriterFactory.h IODataStructures/FiberBundleX/mitkFiberBundleXSerializer.h IODataStructures/FiberBundleX/mitkFiberBundleXThreadMonitor.h - - # Tractography Tractography/itkGibbsTrackingFilter.h Tractography/itkStochasticTractographyFilter.h # Algorithms Algorithms/itkDiffusionQballGeneralizedFaImageFilter.h Algorithms/itkDiffusionQballPrepareVisualizationImageFilter.h Algorithms/itkTensorDerivedMeasurementsFilter.h Algorithms/itkBrainMaskExtractionImageFilter.h Algorithms/itkB0ImageExtractionImageFilter.h Algorithms/itkTensorImageToDiffusionImageFilter.h Algorithms/itkTensorToL2NormImageFilter.h Algorithms/itkTractDensityImageFilter.h Algorithms/itkTractsToFiberEndingsImageFilter.h Algorithms/itkTractsToRgbaImageFilter.h Algorithms/itkGaussianInterpolateImageFunction.h Algorithms/mitkPartialVolumeAnalysisHistogramCalculator.h Algorithms/mitkPartialVolumeAnalysisClusteringCalculator.h Algorithms/itkDiffusionTensorPrincipleDirectionImageFilter.h Algorithms/itkCartesianToPolarVectorImageFilter.h Algorithms/itkPolarToCartesianVectorImageFilter.h ) SET( TOOL_FILES ) IF(WIN32) ENDIF(WIN32) #MITK_MULTIPLEX_PICTYPE( Algorithms/mitkImageRegistrationMethod-TYPE.cpp )