diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp index 9e9bdb8dd0..3871e9a0a3 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp @@ -1,183 +1,139 @@ /*========================================================================= 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 -// implementation of all essential methods from superclass +// baptize array names +const char* mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED = "Color_Orient"; +const char* mitk::FiberBundleX::COLORCODING_FA_BASED = "Color_FA"; mitk::FiberBundleX::FiberBundleX() { } mitk::FiberBundleX::~FiberBundleX() { } /* === main input method ==== * set computed fibers from tractography algorithms */ void mitk::FiberBundleX::SetFibers(vtkSmartPointer fiberPD) { m_OriginalFiberPolyData = fiberPD; } /* === main output method === * return fiberbundle as vtkPolyData * Depending on processing of input fibers, this method returns * the latest processed fibers. */ vtkPolyData* mitk::FiberBundleX::GetFibers() { vtkPolyData* returningFibers = m_FiberPolyData; if (returningFibers == NULL) { returningFibers = m_OriginalFiberPolyData; } return returningFibers; } /* * return original set of fiberdata */ vtkPolyData* mitk::FiberBundleX::GetOriginalFibers() { return m_OriginalFiberPolyData; } /*================================= *++++ PROCESSING OF FIBERS +++++++ ================================*/ void mitk::FiberBundleX::DoColorCodingOrientationbased() { - vtkPolyData* fiberSource; //this variable provides the source where operations process on - if (m_FiberPolyData.GetPointer() == NULL) { + /* === decide which polydata to choose === + * usually you call this method when u received fresh fibers from an tracking algorithm. + * In this case the variable m_OriginalFiberPolyData will act as source for creating color + * information for each point. However, if u process on fibers and forgot calling colorcoding + * before calling any other method (e.g. linesmoothing), then - for performance reason - it makes + * sense not to process on the "original" pointset, but on the smoothed one (well, this might lack + * in performance anyway ;-) ). + * + * It might occur that u call this method again - u must be drunk then - but this algorithm takes + * care of ur incapability by checking if there already exists a color array for orientation based + * color information + */ + vtkPolyData* fiberSource; //this variable provides the source where operations actually process on + + + if ( m_FiberPolyData.GetPointer() == NULL ) + { fiberSource = m_OriginalFiberPolyData; - vtkSmartPointer m_FiberPolyData = vtkSmartPointer::New(); - } else { + // if there exists already a colorarray with orientationbased colors...just use it, otherwise it is not original data anymore :-) + if (fiberSource->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED)) + return; + + + } else if (m_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED) ) { fiberSource = m_FiberPolyData; } + + //colors and alpha value for each single point, RGBA = 4 components + vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); + colorsT->SetNumberOfComponents(4); + colorsT->SetName("ColorcodingOrient"); + + + } /* 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 ) { -} - - -/* 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(); - - } - - - */ - +} \ No newline at end of file diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h index 21c34deced..d92086291f 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.h @@ -1,96 +1,100 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision: 11989 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_FiberBundleX_H #define _MITK_FiberBundleX_H //includes for MITK datastructure #include "mitkBaseData.h" #include "MitkDiffusionImagingExports.h" //includes storing fiberdata #include //may be replaced by class precompile argument #include // may be replaced by class #include // my be replaced by class namespace mitk { /** * \brief Base Class for Fiber Bundles; */ class MitkDiffusionImaging_EXPORT FiberBundleX : public BaseData { public: + // names of certain arrays (e.g colorcodings, etc.) + static const char* COLORCODING_ORIENTATION_BASED; + static const char* COLORCODING_FA_BASED; + /* friend classes wanna access typedefs ContainerPointType, ContainerTractType, ContainerType */ friend class FiberBundleXWriter; friend class FiberBundleXReader; // ======virtual methods must have====== virtual void UpdateOutputInformation(); virtual void SetRequestedRegionToLargestPossibleRegion(); virtual bool RequestedRegionIsOutsideOfTheBufferedRegion(); virtual bool VerifyRequestedRegion(); virtual void SetRequestedRegion( itk::DataObject *data ); //======================================= mitkClassMacro( FiberBundleX, BaseData ); itkNewMacro( Self ); // import fiber result from tractography algorithms void SetFibers(vtkSmartPointer); // return original computed fibers ... actually there is no smartpointer needed because original fibers are passed from the tractography filter vtkPolyData* GetOriginalFibers(); // return processed fibers vtkPolyData* GetFibers(); // return vertex polydata vtkPolyData* GetVertices(); void DoColorCodingOrientationbased(); protected: FiberBundleX(); virtual ~FiberBundleX(); private: // The following polydata variables are used for fiber- and pointbased representation of the tractography results. As VTK suggests, one vtkPolyData is used to manage vertices and the other for polylines. // FiberPolyData stores all brain fibers using polylines (in world coordinates) // this variable hosts the original fiber data vtkSmartPointer m_FiberPolyData; // this variable hosts the smoothed fiber data, no smartpointer needed vtkPolyData* m_OriginalFiberPolyData; // VertexPolyData stores all original points as vertices computed by tracking algorithms vtkSmartPointer m_VertexPolyData; }; } // namespace mitk #endif /* _MITK_FiberBundleX_H */