diff --git a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp index 3079077e57..7b320e3524 100644 --- a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp +++ b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp @@ -1,401 +1,438 @@ /*========================================================================= 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 "mitkFiberBundleXThreadMonitorMapper3D.h" #include "mitkFiberBundleXThreadMonitor.h" #include "mitkNrrdTbssImageIOFactory.h" #include "mitkNrrdTbssImageWriterFactory.h" #include "mitkNrrdTbssImageWriter.h" #include "mitkNrrdTbssRoiImageIOFactory.h" #include "mitkNrrdTbssRoiImageWriterFactory.h" #include "mitkNrrdTbssRoiImageWriter.h" +<<<<<<< HEAD #include "mitkNrrdTbssGradientImageWriterFactory.h" #include "mitkNrrdTbssGradientImageWriter.h" +======= +#include "mitkPlanarCircleMapper3D.h" +#include "mitkPlanarPolygonMapper3D.h" +>>>>>>> bug-9661-enable3DPlanarFigureViz 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::FiberBundleMapper2D::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); } +<<<<<<< HEAD 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); + } + + +>>>>>>> bug-9661-enable3DPlanarFigureViz } const char* mitk::DiffusionImagingObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::DiffusionImagingObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } const char* mitk::DiffusionImagingObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::DiffusionImagingObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::DiffusionImagingObjectFactory::CreateFileExtensionsMap() { m_FileExtensionsMap.insert(std::pair("*.dwi", "Diffusion Weighted Images")); m_FileExtensionsMap.insert(std::pair("*.hdwi", "Diffusion Weighted Images")); m_FileExtensionsMap.insert(std::pair("*.nii", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.fsl", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.fslgz", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.qbi", "Q-Ball Images")); m_FileExtensionsMap.insert(std::pair("*.hqbi", "Q-Ball Images")); m_FileExtensionsMap.insert(std::pair("*.dti", "Tensor Images")); m_FileExtensionsMap.insert(std::pair("*.hdti", "Tensor Images")); m_FileExtensionsMap.insert(std::pair("*.fib", "Fiber Bundle")); m_FileExtensionsMap.insert(std::pair("*.vfib", "Fiber Bundle Polydata")); m_FileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle Polydata")); m_FileExtensionsMap.insert(std::pair("*.tbss", "TBSS data")); m_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("*.vfib", "Fiber Bundle Polydata")); m_SaveFileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle Polydata")); 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/Rendering/mitkFiberBundleMapper3D.cpp b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp index b26fc51eae..6b981895c1 100644 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp +++ b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp @@ -1,1145 +1,773 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkProperties.h" #include "mitkFiberBundleMapper3D.h" #include #include #include #include #include #include #include #include #include #include #include #include "vtkVertex.h" #include #include #include #include #include #include "mitkFiberBundleInteractor.h" #include "mitkGlobalInteraction.h" //template mitk::FiberBundleMapper3D::FiberBundleMapper3D() : m_vtkFiberList(NULL), //m_VtkFiberDataMapperGL(NULL), m_VtkFiberDataMapperGL(vtkOpenGLPolyDataMapper::New()), m_vtkTubeMapper(NULL) { MITK_INFO << "FiberBundleMapper3D()"; m_FiberAssembly = vtkPropAssembly::New(); m_FiberActor = vtkOpenGLActor::New(); m_TubeActor = vtkOpenGLActor::New(); - - /* - vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); - colorsT->SetName("Colors"); - colorsT->SetNumberOfComponents(4); - - unsigned char red1[4] = {255, 0, 0 , 10}; - colorsT->InsertNextTupleValue(red1); - - unsigned char red2[4] = {255,0, 0 , 255}; - colorsT->InsertNextTupleValue(red2); - - colorsT->SetValue(3, (unsigned char)(255)); - colorsT->SetValue(7, (unsigned char)(255)); - - - - - - - - //Create points for polyline1. - double origin[3] = {100.0, 400.0, 0.0}; - double p0[3] = {300.0, 400.0, 0.0}; - double p1[3] = {300.0, 200.0, 0.0}; - double p2[3] = {100.0, 300.0, 0.0}; - double p3[3] = {130.0, 250.0, 0.0}; - - //create points for polyline2 - //double p01[3] = {50.0, 50.0, 13.0}; - //double p11[3] = {200.0, 100.0, 13.0}; - - //insert points to vtkPointarray - vtkPoints *pnts = vtkPoints::New(); - pnts->InsertPoint(0,origin); - pnts->InsertPoint(1,p0); - pnts->InsertPoint(2,p1); - pnts->InsertPoint(3,p2); - //pnts->InsertPoint(4,p01); - //pnts->InsertPoint(5,p11); - pnts->InsertPoint(4,p3); - - //generate and define polyline1 - vtkPolyLine *polyLine = vtkPolyLine::New(); - polyLine->GetPointIds()->SetNumberOfIds(4); - polyLine->GetPointIds()->SetId(0,0); - polyLine->GetPointIds()->SetId(1,1); - polyLine->GetPointIds()->SetId(2,2); - polyLine->GetPointIds()->SetId(3,3); - - /*generate and define polyline2 - vtkPolyLine *polyLine2 = vtkPolyLine::New(); - polyLine2->GetPointIds()->SetNumberOfIds(2); - polyLine2->GetPointIds()->SetId(0,4); - polyLine2->GetPointIds()->SetId(1,5); - */ - - /* - vtkVertex *vtx = vtkVertex::New(); - vtx->GetPointIds()->SetNumberOfIds(1); - vtx->GetPointIds()->SetId(0,4); - - vtkCellArray *lines = vtkCellArray::New(); - lines->InsertNextCell(polyLine); - //lines->InsertNextCell(vtx); - //lines->InsertNextCell(polyLine2); - - - vtkCellArray *vertx = vtkCellArray::New(); - vertx->InsertNextCell(vtx); - - vtkPolyData *polyDataT = vtkPolyData::New(); - polyDataT->SetPoints(pnts); - polyDataT->SetLines(lines); - polyDataT->SetVerts(vertx); - - //color and opacity handling - vtkUnsignedCharArray *colorT = vtkUnsignedCharArray::New(); - colorT->SetName("Colors"); - - colorT->SetNumberOfComponents(4); //4 components cuz of RGBA - unsigned char rgba[4] = {255,0,0,255}; - unsigned char rgba2[4] = {0,255,0,255}; - - //if just 1 point in there - colorT->InsertNextTupleValue(rgba); - colorT->InsertNextTupleValue(rgba2); - colorT->InsertNextTupleValue(rgba); - colorT->InsertNextTupleValue(rgba2); - colorT->InsertNextTupleValue(rgba); - - /*for(int i=0; i<6; i++) - { - - - double vtkPntTmp[3]; - pnts->GetPoint(i, vtkPntTmp); - double vtkPntTmpNxt[3]; - pnts->GetPoint(i+1, vtkPntTmpNxt); - - vnl_vector_fixed< double, 3 > tmpPntvtk( vtkPntTmp[0], vtkPntTmp[1],vtkPntTmp[2]); - vnl_vector_fixed< double, 3 > nxttmpPntvtk(vtkPntTmpNxt[0], vtkPntTmpNxt[1], vtkPntTmpNxt[2]); - - vnl_vector_fixed< double, 3 > diff; - diff = tmpPntvtk - nxttmpPntvtk; - diff.normalize(); - - rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); - rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); - rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); - rgba[3] = (unsigned char) (255.0); - - - if(i==3) - { - colorT->InsertNextTupleValue(rgba); - colorT->InsertNextTupleValue(rgba); - }else if(i==4) - { - //do nothing - }else{ - colorT->InsertNextTupleValue(rgba); - } - - - - } - - /* - unsigned char red[4] = {255, 0, 0 , 20}; - unsigned char green[4] = {0, 255, 0 , 190}; - unsigned char blue[4] = {0, 0, 255, 255}; - unsigned char white[4] = {255, 255, 255, 255}; - - colorT->InsertNextTupleValue(red); //color for point0 - colorT->InsertNextTupleValue(green); //color for point1 - colorT->InsertNextTupleValue(blue); - colorT->InsertNextTupleValue(white); - colorT->InsertNextTupleValue(white); - colorT->InsertNextTupleValue(white); //color for point5 - - polyDataT->GetPointData()->AddArray(colorT); - - - vtkTubeFilter *tube = vtkTubeFilter::New(); - tube->SetInput(polyDataT); - tube->SetNumberOfSides(8); - tube->SetRadius(5); - - vtkSmartPointer mapper = - vtkSmartPointer::New(); - mapper->SetInput(polyDataT); - //mapper->SetInputConnection(tube->GetOutputPort()); - mapper->ScalarVisibilityOn(); - mapper->SetScalarModeToUsePointFieldData(); - //mapper->SetColorModeToMapScalars(); - mapper->SelectColorArray("Colors"); - - vtkSmartPointer actor = - vtkSmartPointer::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetOpacity(1.0); - //actor->GetProperty()->SetLineWidth(20); - actor->GetProperty()->SetPointSize(5.0); - - - vtkSmartPointer renderer = - vtkSmartPointer::New(); - renderer->AddActor(actor); - //renderer->SetBackground(.2, .3, .4); - - // Make an oblique view - renderer->GetActiveCamera()->Azimuth(30); - renderer->GetActiveCamera()->Elevation(30); - renderer->ResetCamera(); - - vtkSmartPointer renWin = - vtkSmartPointer::New(); - vtkSmartPointer - iren = vtkSmartPointer::New(); - - iren->SetRenderWindow(renWin); - renWin->AddRenderer(renderer); - //renWin->LineSmoothingOff(); - renWin->SetSize(500, 500); - renWin->Render(); - - vtkSmartPointer style = - vtkSmartPointer::New(); - iren->SetInteractorStyle(style); - - iren->Start(); - MITK_INFO << "swerwas"; - - /* - - - // Spiral tube - double vX, vY, vZ; - unsigned int nV = 256; // No. of vertices - unsigned int nCyc = 5; // No. of spiral cycles - double rT1 = 0.1, rT2 = 0.5;// Start/end tube radii - double rS = 2; // Spiral radius - double h = 10; // Height - unsigned int nTv = 8; // No. of surface elements for each tube vertex - - unsigned int i; - - // Create points and cells for the spiral - vtkSmartPointer points = vtkSmartPointer::New(); - for(i = 0; i < nV; i++) - { - // Spiral coordinates - vX = rS * cos(2 * 3 * nCyc * i / (nV - 1)); - vY = rS * sin(2 * 3 * nCyc * i / (nV - 1)); - vZ = h * i / nV; - points->InsertPoint(i, vX, vY, vZ); - } - - vtkSmartPointer lines = - vtkSmartPointer::New(); - lines->InsertNextCell(nV); - for (i = 0; i < nV; i++) - { - lines->InsertCellPoint(i); - } - - - vtkSmartPointer polyData = - vtkSmartPointer::New(); - polyData->SetPoints(points); - polyData->SetLines(lines); - - - // RBG array (could add Alpha channel too I guess...) - // Varying from blue to red - vtkSmartPointer colors = - vtkSmartPointer::New(); - colors->SetName("Colors"); - colors->SetNumberOfComponents(3); - colors->SetNumberOfTuples(nV); - for (i = 0; i < nV ;i++) - { - - unsigned char red[3] = {char(255 * i/ (nV - 1)),0,char(255 * (nV - 1 - i)/(nV - 1))}; - - colors->InsertNextTupleValue( red); - } - polyData->GetPointData()->AddArray(colors); - - - - vtkSmartPointer mapper = - vtkSmartPointer::New(); - mapper->SetInput(polyData); - mapper->ScalarVisibilityOn(); - mapper->SetScalarModeToUsePointFieldData(); - mapper->SelectColorArray("Colors"); - - vtkSmartPointer actor = - vtkSmartPointer::New(); - actor->SetMapper(mapper); - - vtkSmartPointer renderer = - vtkSmartPointer::New(); - renderer->AddActor(actor); - renderer->SetBackground(.2, .3, .4); - - // Make an oblique view - renderer->GetActiveCamera()->Azimuth(30); - renderer->GetActiveCamera()->Elevation(30); - renderer->ResetCamera(); - - vtkSmartPointer renWin = - vtkSmartPointer::New(); - vtkSmartPointer - iren = vtkSmartPointer::New(); - - iren->SetRenderWindow(renWin); - renWin->AddRenderer(renderer); - renWin->SetSize(500, 500); - renWin->Render(); - - vtkSmartPointer style = - vtkSmartPointer::New(); - iren->SetInteractorStyle(style); - - iren->Start(); - - - - - /* - - double origin[3] = {0.0, 0.0, 0.0}; - double p0[3] = {10.0, 0.0, 0.0}; - double p1[3] = {10.0, 10.0, 0.0}; - double p2[3] = {0.0, 10.0, 0.0}; - double p3[3] = {10.0, 10.0, 0.0}; - double p4[3] = {10.0, 20.0, 0.0}; - double p5[3] = {0.0, 20.0, 0.0}; - - //create a vtkPoints object and store the points in it - vtkSmartPointer points = - vtkSmartPointer::New(); - points->InsertNextPoint(origin); - points->InsertNextPoint(p0); - points->InsertNextPoint(p1); - points->InsertNextPoint(p2); - points->InsertNextPoint(p3); - points->InsertNextPoint(p4); - points->InsertNextPoint(p5); - - vtkSmartPointer polyLine = - vtkSmartPointer::New(); - polyLine->GetPointIds()->SetNumberOfIds(7); - for(unsigned int i = 0; i < 7; i++) - { - polyLine->GetPointIds()->SetId(i,i); - } - - double origin2[3] = {30.0, 0.0, 0.0}; - double p02[3] = {40.0, 0.0, 0.0}; - double p12[3] = {40.0, 20.0, 0.0}; - double p22[3] = {30.0, 20.0, 0.0}; - double p23[3] = {30.0, 0.0, 0.0}; - - - points->InsertNextPoint(origin2); - points->InsertNextPoint(p02); - points->InsertNextPoint(p12); - points->InsertNextPoint(p22); - points->InsertNextPoint(p23); - - vtkSmartPointer polyLine2 = - vtkSmartPointer::New(); - polyLine2->GetPointIds()->SetNumberOfIds(5); - for(unsigned int i = 0; i < 5; i++) - { - polyLine2->GetPointIds()->SetId(i,i+7); - } - - //Create a cell array to store the lines in and add the lines to it - vtkSmartPointer cells = - vtkSmartPointer::New(); - cells->InsertNextCell(polyLine); - cells->InsertNextCell(polyLine2); - - - //Create a polydata to store everything in - vtkSmartPointer polyData = - vtkSmartPointer::New(); - - //add the points to the dataset - polyData->SetPoints(points); - - //add the lines to the dataset - polyData->SetLines(cells); - //setup actor and mapper - vtkSmartPointer mapper = - vtkSmartPointer::New(); - mapper->SetInput(polyData); - - vtkSmartPointer actor = - vtkSmartPointer::New(); - actor->SetMapper(mapper); - - m_FiberAssembly->AddPart(actor); - */ - - - } //template mitk::FiberBundleMapper3D::~FiberBundleMapper3D() { MITK_INFO << "FiberBundleMapper3D(destructor)"; m_FiberActor->Delete(); m_FiberAssembly->Delete(); //m_vtkFiberList->Delete(); //m_VtkFiberDataMapperGL->Delete(); //m_VtkFiberDataMapper->Delete(); } const mitk::FiberBundle* mitk::FiberBundleMapper3D::GetInput() { //MITK_INFO << "FiberBundleMapper3D GetInput()" ; return static_cast ( GetData() ); } 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 vtkPoints* vtkSmoothPoints = vtkPoints::New(); //in smoothpoints the interpolated points representing a fiber are stored. //in vtkcells all polylines are stored, actually all id's of them are stored vtkCellArray *vtkSmoothCells = vtkCellArray::New(); //cellcontainer for smoothed lines //in some cases a fiber includes just 1 point, so put it in here vtkCellArray *vtkVrtxs = vtkCellArray::New(); //colors and alpha value for each single point, RGBA = 4 components vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); colorsT->SetNumberOfComponents(4); colorsT->SetName("ColorValues"); vtkDoubleArray *faColors = vtkDoubleArray::New(); faColors->SetName("FaColors"); vtkDoubleArray *tubeRadius = vtkDoubleArray::New(); tubeRadius->SetName("TubeRadius"); // iterate through FiberList for(mitk::FiberBundle::ChildrenListType::iterator itLst = FiberList->begin(); itLst != FiberList->end(); ++itLst) { //all points are stored in one vtkpoints list, soooooooo that the lines find their point id to start and end we need some kind of helper index who monitors the current ids for a polyline //unsigned long pntIdxHelper = vtkpointsDTI->GetNumberOfPoints(); // lists output is SpatialObject, we know we have DTITubeSpacialObjects // dynamic cast only likes pointers, no smartpointers, so each dsmartpointer has membermethod .GetPointer() itk::SpatialObject<3>::Pointer tmp_fbr; tmp_fbr = *itLst; mitk::FiberBundle::DTITubeType::Pointer dtiTract = dynamic_cast< mitk::FiberBundle::DTITubeType * > (tmp_fbr.GetPointer()); if (dtiTract.IsNull()) { return; } //get list of points int fibrNrPnts = dtiTract->GetNumberOfPoints(); mitk::FiberBundle::DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); //MITK_INFO << "REAL AMOUNT OF FIBERS: " << fibrNrPnts; vtkPoints *vtkpointsDTI = vtkPoints::New(); if (fibrNrPnts <= 0) { //this should never occour! but who knows MITK_INFO << "HyperERROR in fiberBundleMapper3D.cpp ...no point in fiberBundle!!! .. check ur trackingAlgorithm"; continue; } ///////PROCESS ON FIBERS//////// for (int i=0; i1 PFiberBundle->GetGeometry()->IndexToWorld(indexPnt, worldPnt); double worldFbrPnt[3] = {worldPnt[0], worldPnt[1], worldPnt[2]}; vtkpointsDTI->InsertNextPoint(worldFbrPnt); } //MITK_INFO << "REDUCED AMOUNT OF FIBERS: " << vtkpointsDTI->GetNumberOfPoints(); ////POINTS OF DTI ARE READY FOR FUTHER VTK PROCESSING//// } /////PROCESS POLYLINE SMOOTHING///// vtkKochanekSpline* xSpline = vtkKochanekSpline::New(); vtkKochanekSpline* ySpline = vtkKochanekSpline::New(); vtkKochanekSpline* zSpline = vtkKochanekSpline::New(); vtkParametricSpline* spline = vtkParametricSpline::New(); spline->SetXSpline(xSpline); spline->SetYSpline(ySpline); spline->SetZSpline(zSpline); spline->SetPoints(vtkpointsDTI); vtkParametricFunctionSource* functionSource = vtkParametricFunctionSource::New(); functionSource->SetParametricFunction(spline); functionSource->SetUResolution(200); functionSource->SetVResolution(200); functionSource->SetWResolution(200); functionSource->Update(); vtkPolyData* outputFunction = functionSource->GetOutput(); vtkPoints* tmpSmoothPnts = outputFunction->GetPoints(); //smoothPoints of current fiber vtkPolyLine* smoothLine = vtkPolyLine::New(); smoothLine->GetPointIds()->SetNumberOfIds(tmpSmoothPnts->GetNumberOfPoints()); // MITK_INFO << "SMOOTHED AMOUNT OF POINTS:" << tmpSmoothPnts->GetNumberOfPoints(); /////CREATE SMOOTH POLYLINE OBJECT//// /////MANAGE LINE AND CORRELATED POINTS///// int pointHelperCnt = vtkSmoothPoints->GetNumberOfPoints(); //also put current points into global smooth pointcontainer int nrSmPnts = tmpSmoothPnts->GetNumberOfPoints(); tubeRadius->SetNumberOfTuples(nrSmPnts); double tbradius = 1;//default value for radius for(int ism=0; ismGetPointIds()->SetId(ism, ism+pointHelperCnt); vtkSmoothPoints->InsertNextPoint(tmpSmoothPnts->GetPoint(ism)); // MITK_INFO << "LinePntID: " << ism << " linked to: " << ism+pointHelperCnt << " val: " << tmpSmoothPnts->GetPoint(ism)[0] << " " << tmpSmoothPnts->GetPoint(ism)[1] << " " << tmpSmoothPnts->GetPoint(ism)[2]; tubeRadius->SetTuple1(ism,tbradius); //tuple with 1 argument //colorcoding orientation based unsigned char rgba[4] = {0,0,0,0}; if (ism < nrSmPnts-1 && ism>0) { // MITK_INFO << "inbetween fiber, at position:" << ism; // //nimm nur diff1 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(tmpSmoothPnts->GetPoint(ism+1)[0], tmpSmoothPnts->GetPoint(ism+1)[1], tmpSmoothPnts->GetPoint(ism+1)[2]); vnl_vector_fixed< double, 3 > prevtmpPntvtk(tmpSmoothPnts->GetPoint(ism-1)[0], tmpSmoothPnts->GetPoint(ism-1)[1], tmpSmoothPnts->GetPoint(ism-1)[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = tmpPntvtk - nxttmpPntvtk; diff1.normalize(); vnl_vector_fixed< double, 3 > diff2; diff2 = tmpPntvtk - prevtmpPntvtk; diff2.normalize(); vnl_vector_fixed< double, 3 > diff; diff = (diff1 - diff2)/2.0; rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); rgba[3] = (unsigned char) (255.0); } else if(ism==0) { //explicit handling of startpoint of line //nimm nur diff1 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(tmpSmoothPnts->GetPoint(ism+1)[0], tmpSmoothPnts->GetPoint(ism+1)[1], tmpSmoothPnts->GetPoint(ism+1)[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = tmpPntvtk - nxttmpPntvtk; diff1.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff1[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff1[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff1[2])); rgba[3] = (unsigned char) (255.0); // MITK_INFO << "first point color: " << rgba[0] << " " << rgba[1] << " " << rgba[2]; } else if(ism==nrSmPnts-1) { // last point in fiber // nimm nur diff2 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > prevtmpPntvtk(tmpSmoothPnts->GetPoint(ism-1)[0], tmpSmoothPnts->GetPoint(ism-1)[1], tmpSmoothPnts->GetPoint(ism-1)[2]); vnl_vector_fixed< double, 3 > diff2; diff2 = tmpPntvtk - prevtmpPntvtk; diff2.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff2[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff2[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff2[2])); rgba[3] = (unsigned char) (255.0); // // MITK_INFO << "last point color: " << rgba[0] << " " << rgba[1] << " " << rgba[2]; } //end colorcoding // colorsT->InsertNextTupleValue(rgba); }//end of smoothline ///////smooth Fiber ready//////// vtkSmoothCells->InsertNextCell(smoothLine); } //vtkpointsDTI->Delete();//points are not needed anymore TODO uncomment! /* //get FA value ... for that FA has to be interpolated as well as DTItracktLine float faVal = tmpFiberPntLst.GetField(mitk::FiberBundle::DTITubePointType::FA); //use insertNextValue cuz FA Values are reperesented as a single number (1 Tuple containing 1 parameter) faColors->InsertNextValue((double) faVal); */ //vtkcells->InitTraversal(); // Put points and lines together in one polyData structure vtkPolyData *polyData = vtkPolyData::New(); polyData->SetPoints(vtkSmoothPoints); polyData->SetLines(vtkSmoothCells); if (vtkVrtxs->GetSize() > 0) { polyData->SetVerts(vtkVrtxs); } polyData->GetPointData()->AddArray(colorsT); //polyData->GetPointData()->AddArray(faColors); //polyData->GetPointData()->AddArray(tubeRadius); vtkLookupTable *lut = vtkLookupTable::New(); lut->Build(); // m_VtkFiberDataMapperGL = vtkOpenGLPolyDataMapper::New(); m_VtkFiberDataMapperGL->SetInput(polyData); m_VtkFiberDataMapperGL->ScalarVisibilityOn(); m_VtkFiberDataMapperGL->SetScalarModeToUsePointFieldData(); //m_VtkFiberDataMapperGL->SelectColorArray("FaColors"); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); m_VtkFiberDataMapperGL->SetLookupTable(lut); m_vtkTubeMapper = vtkOpenGLPolyDataMapper::New(); //m_FiberActor = vtkOpenGLActor::New(); m_FiberActor->SetMapper(m_VtkFiberDataMapperGL); m_FiberActor->GetProperty()->SetOpacity(1.0); m_FiberActor->GetProperty()->SetPointSize(4.0f); // m_FiberActor->GetProperty()->SetColor(255.0, 0.0, 0.0); m_FiberAssembly->AddPart(m_FiberActor); //setting color and opacity in the fiberActor itself is not recommended //here cuz color and opacity of dataNode will be considered in GetData(baserenderer*) anyway this->GetDataNode()->SetColor(255.0,0,0); this->GetDataNode()->SetOpacity(1.0); } //template void mitk::FiberBundleMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { // nodeCC = 1 ... ROI colorcoding // 2 ... orientation colorcoding // 3 ... FA colorcoding int nodeCC; bool isCCd = this->GetDataNode()->GetPropertyValue("ColorCoding", nodeCC); if ( isCCd && nodeCC == 1 ) { //get color and opacity from DataNode int tmpline; bool isLineProp = this->GetDataNode()->GetPropertyValue("LineWidth",tmpline); bool isPointRep; bool successPointProp = this->GetDataNode()->GetPropertyValue("RepPoints", isPointRep); float pointSize; bool successPointSize = this->GetDataNode()->GetPropertyValue("pointSize", pointSize); if (isLineProp) { m_FiberActor->GetProperty()->SetLineWidth(tmpline); } if(isPointRep) { m_FiberActor->GetProperty()->SetRepresentationToPoints(); m_FiberActor->GetProperty()->SetPointSize(pointSize); } } else if (isCCd && nodeCC == 2) { float tmpopa; this->GetDataNode()->GetOpacity(tmpopa, NULL); m_FiberActor->GetProperty()->SetOpacity((double) tmpopa); } else if (isCCd && nodeCC == 3) { float temprgb[3]; this->GetDataNode()->GetColor( temprgb, NULL ); double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; m_FiberActor->GetProperty()->SetColor(trgb); if(m_VtkFiberDataMapperGL->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_VtkFiberDataMapperGL->ScalarVisibilityOff(); } } else if (isCCd && nodeCC == 4) { if(!m_VtkFiberDataMapperGL->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_VtkFiberDataMapperGL->ScalarVisibilityOn(); } m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 5){ if(!m_VtkFiberDataMapperGL->GetScalarVisibility()) //if visibility is off, switch it on { m_VtkFiberDataMapperGL->ScalarVisibilityOn(); } m_VtkFiberDataMapperGL->SelectColorArray("FaColors"); } else if (isCCd && nodeCC == 6){ //orientationbased colorcoding + FA as opacity //get FA out of polydata, which is saved in faColor vtkDoubleArray vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPointData *tmpPointData = tmpPolyData->GetPointData(); int hasAr = tmpPointData->HasArray("FaColors"); if(!hasAr) return; vtkDoubleArray *tmpFAarray = (vtkDoubleArray*)(tmpPointData->GetArray("FaColors")) ; /*for(int i=0; iGetNumberOfTuples(); i++) { double *tmpTuple; tmpFAarray->GetTuple(i, tmpTuple); for(int j=0; jGetNumberOfComponents(); j++) { MITK_INFO << "FA Value: at index " << i << ": " << tmpTuple[j]; } } */ //since we have our FA values, lets replace the alpha values in colorT //we know each 4th entry is a A value of RGBA int hasArCV = tmpPointData->HasArray("ColorValues"); if(!hasArCV) return; vtkUnsignedCharArray *colorsTtmp = dynamic_cast (tmpPointData->GetArray("ColorValues")); for(int i=0; iGetNumberOfTuples(); i++) { //double *tmpTupleCV = colorsTtmp->GetTuple4(i); double tmpTupleFA = tmpFAarray->GetTuple1(i); tmpTupleFA = tmpTupleFA * 255.0; colorsTtmp->SetComponent(i,3, tmpTupleFA ); // MITK_INFO << "----" << i; //MITK_INFO << tmpTupleCV[0]; //MITK_INFO << tmpTupleCV[1]; //MITK_INFO << tmpTupleCV[2]; //MITK_INFO << tmpTupleCV[3]; //double *test = m_VtkFiberDataMapperGL->GetInput()->GetPointData()->GetArray("ColorValues")->GetTuple4(i); //MITK_INFO << test[0]; //MITK_INFO << test[1]; //MITK_INFO << test[2]; //MITK_INFO << test[3]; } m_VtkFiberDataMapperGL->SelectColorArray(""); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 7){ vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPointData *tmpPointData = tmpPolyData->GetPointData(); int hasArCV = tmpPointData->HasArray("ColorValues"); if(!hasArCV) return; vtkUnsignedCharArray *colorsTtmp = dynamic_cast (tmpPointData->GetArray("ColorValues")); for(int i=0; iGetNumberOfTuples(); i++) { double tmpTupleFA = 255.0; colorsTtmp->SetComponent(i,3, tmpTupleFA ); } m_VtkFiberDataMapperGL->SelectColorArray(""); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 8) { /* something is still missing to activate smoothing or make it work.... */ if (!renderer->GetRenderWindow()->GetLineSmoothing()) { renderer->GetRenderWindow()->SetLineSmoothing(1); renderer->GetRenderWindow()->Modified(); } if (!renderer->GetRenderWindow()->GetPointSmoothing()) { renderer->GetRenderWindow()->SetPointSmoothing(1); renderer->GetRenderWindow()->Modified(); } if (!renderer->GetRenderWindow()->GetPolygonSmoothing()) { renderer->GetRenderWindow()->SetPolygonSmoothing(1); renderer->GetRenderWindow()->Modified(); } } else if (isCCd && nodeCC == 9) { if (renderer->GetRenderWindow()->GetLineSmoothing()) { renderer->GetRenderWindow()->SetLineSmoothing(0); renderer->GetRenderWindow()->Modified(); } if (renderer->GetRenderWindow()->GetPointSmoothing()) { renderer->GetRenderWindow()->SetPointSmoothing(0); renderer->GetRenderWindow()->Modified(); } if (renderer->GetRenderWindow()->GetPolygonSmoothing()) { renderer->GetRenderWindow()->SetPolygonSmoothing(0); renderer->GetRenderWindow()->Modified(); } } else if (isCCd && nodeCC == 10) { // manipulate X Coordinates of selected FiberBundle int tmpXmove; bool isXmove = this->GetDataNode()->GetPropertyValue("Xmove",tmpXmove); if (!isXmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[0] = PtmpPntVal[0] + (double) tmpXmove; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 11) { // manipulate Y Coordinates of selected FiberBundle int tmpYmove; bool isYmove = this->GetDataNode()->GetPropertyValue("Ymove",tmpYmove); if (!isYmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[1] = PtmpPntVal[1] + (double) tmpYmove; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 12) { // manipulate Z Coordinates of selected FiberBundle int tmpZmove; bool isZmove = this->GetDataNode()->GetPropertyValue("Zmove",tmpZmove); if (!isZmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[2] = PtmpPntVal[2] + (double) tmpZmove; //PtmpPntVal[2] = PtmpPntVal[2] + 1; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 13) { int tmpTubeSides; bool isTubeSides = this->GetDataNode()->GetPropertyValue("TubeSides",tmpTubeSides); float tmpRadius; bool isRadius = this->GetDataNode()->GetPropertyValue("TubeRadius",tmpRadius); if (!isTubeSides) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); m_tubes = vtkTubeFilter::New(); m_tubes->SetInput(tmpPolyData); m_tubes->SidesShareVerticesOn(); m_tubes->SetRadius((double)(tmpRadius)); m_tubes->SetNumberOfSides(tmpTubeSides); m_tubes->Modified(); // m_tubes->Update(); m_vtkTubeMapper->SetInputConnection(m_tubes->GetOutputPort()); m_vtkTubeMapper->ScalarVisibilityOn(); m_vtkTubeMapper->SetScalarModeToUsePointFieldData(); m_vtkTubeMapper->SelectColorArray(""); m_vtkTubeMapper->SelectColorArray("ColorValues"); m_TubeActor->SetMapper(m_vtkTubeMapper); m_TubeActor->GetProperty()->SetOpacity(1); m_TubeActor->GetProperty()->BackfaceCullingOn(); m_FiberAssembly->AddPart(m_TubeActor); m_FiberAssembly->Modified(); } else if (isCCd && nodeCC == 14) { float temprgb[3]; this->GetDataNode()->GetColor( temprgb, NULL ); double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; m_TubeActor->GetProperty()->SetColor(trgb); if(m_vtkTubeMapper->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_vtkTubeMapper->ScalarVisibilityOff(); } } else if (isCCd && nodeCC == 15) { m_TubeActor->GetProperty()->SetOpacity(0); m_FiberAssembly->RemovePart(m_TubeActor); m_FiberAssembly->Modified(); }else if (isCCd && nodeCC == 16) { float tmpTubeOpacity; bool isTubeOpacity = this->GetDataNode()->GetPropertyValue("TubeOpacity",tmpTubeOpacity); m_TubeActor->GetProperty()->SetOpacity((double) tmpTubeOpacity); m_TubeActor->Modified(); } else if (isCCd && nodeCC == 17) { m_FiberActor->GetProperty()->SetOpacity(0); m_FiberAssembly->RemovePart(m_FiberActor); m_FiberAssembly->Modified(); }else if (isCCd && nodeCC == 18) { m_FiberActor->GetProperty()->SetOpacity(0); m_FiberAssembly->AddPart(m_FiberActor); m_FiberAssembly->Modified(); } //MITK_INFO << m_VtkFiberDataMapperGL->GetArrayName(); /* int displayIndex(0); this->GetDataNode()->GetIntProperty( "DisplayChannel", displayIndex, renderer ); InputImageType *input = const_cast< InputImageType* >( this->GetInput() ); mitk::DiffusionImage *input2 = dynamic_cast< mitk::DiffusionImage* >( input ); input2->SetDisplayIndexForRendering(displayIndex); Superclass::GenerateDataForRenderer(renderer); */ } //template void mitk::FiberBundleMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { // MITK_INFO << "FiberBundleMapper3D SetDefault Properties(...)"; 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/mitkPlanarCircleMapper3D.cpp b/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.cpp new file mode 100644 index 0000000000..3e901309c3 --- /dev/null +++ b/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.cpp @@ -0,0 +1,230 @@ +/* + * mitkPlanarCircleMapper3D.cpp + * mitk-all + * + * Created by HAL9000 on 2/15/11. + * Copyright 2011 __MyCompanyName__. All rights reserved. + * + */ + + + +/*========================================================================= + + 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 "mitkPlanarCircleMapper3D.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +//#include + +#include +#include + + + + +//template +mitk::PlanarCircleMapper3D::PlanarCircleMapper3D() +: m_vtkCircleList(NULL), +m_VtkCircleDataMapperGL(NULL) + +{ + + m_CircleAssembly = vtkPropAssembly::New(); + m_CircleActor = vtkOpenGLActor::New(); + m_polygonSource = vtkRegularPolygonSource::New(); + + +} + +//template +mitk::PlanarCircleMapper3D::~PlanarCircleMapper3D() +{ + //MITK_INFO << "FiberBundleMapper3D(destructor)"; + m_CircleActor->Delete(); + m_CircleAssembly->Delete(); + m_polygonSource->Delete(); + + +} + + +const mitk::PlanarCircle* mitk::PlanarCircleMapper3D::GetInput() +{ + //MITK_INFO << "FiberBundleMapper3D GetInput()" ; + + return static_cast ( GetData() ); +} + +/* + This method is called once the mapper gets new input, + for UI rotation or changes in colorcoding this method is NOT called + */ +void mitk::PlanarCircleMapper3D::GenerateData() +{ + +// bool is3DEnabled; +// this->GetDataNode()->GetPropertyValue("PlanarCircle_3D",is3DEnabled); +// if (!is3DEnabled) { +// return; +// } + + + /* get my circle */ + mitk::PlanarCircle* PFCircle = dynamic_cast< mitk::PlanarCircle* > (this->GetData()); + + try{ + + + mitk::Point3D V1 = PFCircle->GetWorldControlPoint(0); //centerPoint + mitk::Point3D V2 = PFCircle->GetWorldControlPoint(1); //radiusPoint + + + const mitk::Geometry2D* pfgeometry = PFCircle->GetGeometry2D(); + const mitk::PlaneGeometry* planeGeo = dynamic_cast (pfgeometry); + mitk::Vector3D N = planeGeo->GetNormal(); + + /* calculate Radius + sqrt( (x1-x2)^2 (y1-y2)^2 (z1-z2)^2 ) + */ + + double circleRadius = sqrt( pow( (double)(V1[0]-V2[0]), 2.0) + pow((double)(V1[1]-V2[1]), 2.0) + pow( (double)(V1[2]-V2[2]), 2.0) ); + //MITK_INFO << "circleRadius: " << circleRadius; + + + m_polygonSource->SetNormal((double)N[0],(double)N[1],(double)N[2]); + + m_polygonSource->SetNumberOfSides(50); + m_polygonSource->SetRadius(circleRadius); + m_polygonSource->SetCenter(V1[0],V1[1],V1[2]); + m_polygonSource->Update(); + + // Visualize + m_VtkCircleDataMapperGL = vtkOpenGLPolyDataMapper::New(); + m_VtkCircleDataMapperGL->SetInputConnection(m_polygonSource->GetOutputPort()); + + m_CircleActor = vtkOpenGLActor::New(); + m_CircleActor->SetMapper(m_VtkCircleDataMapperGL); + m_CircleActor->GetProperty()->SetOpacity(0.8); + m_CircleAssembly->AddPart(m_CircleActor); + + this->GetDataNode()->SetColor(200.0,200.0,200.0); + this->GetDataNode()->SetOpacity(0.8); + + } + catch(...) { +// MITK_INFO << "catch in PlanarCircleMapper3D..."; + } + +} + + + + +//template +void mitk::PlanarCircleMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) +{ + // Update Circle in 3D Renderwindow +// bool is3DEnabled; +// this->GetDataNode()->GetPropertyValue("PlanarCircle_3D",is3DEnabled); +// if (!is3DEnabled) { +// return; +// } + + try{ + mitk::PlanarCircle* PFCircle = dynamic_cast< mitk::PlanarCircle* > (this->GetData()); + mitk::Point3D V1 = PFCircle->GetWorldControlPoint(0); //centerPoint + mitk::Point3D V2 = PFCircle->GetWorldControlPoint(1); //radiusPoint + + /* calculate Radius + sqrt( (x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2 ) + */ + + double circleRadius = sqrt( pow( (double)(V1[0]-V2[0]), 2.0) + pow((double)(V1[1]-V2[1]), 2.0) + pow( (double)(V1[2]-V2[2]), 2.0) ); + + m_polygonSource->SetCenter((double)V1[0],(double)V1[1],(double)V1[2]); + m_polygonSource->SetRadius(circleRadius); + m_polygonSource->Update(); + + + float polyOpaq; + this->GetDataNode()->GetOpacity(polyOpaq, NULL); + m_CircleActor->GetProperty()->SetOpacity((double) polyOpaq); + + float temprgb[3]; + this->GetDataNode()->GetColor( temprgb, NULL ); + double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; + m_CircleActor->GetProperty()->SetColor(trgb); + + + } + catch (...) { +// MITK_INFO << "catch generateData(baseRenderer)"; + } +} + +//template +void mitk::PlanarCircleMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) +{ + // node->AddProperty( "PlanarCircle_3D", mitk::BoolProperty::New( true ), renderer, overwrite ); + Superclass::SetDefaultProperties(node, renderer, overwrite); +} + +vtkProp* mitk::PlanarCircleMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) +{ + + //MITK_INFO << "FiberBundleMapper3D GetVtkProp(renderer)"; + return m_CircleAssembly; + +} + +void mitk::PlanarCircleMapper3D::ApplyProperties(mitk::BaseRenderer* renderer) +{ +} + +void mitk::PlanarCircleMapper3D::UpdateVtkObjects() +{ + // MITK_INFO << "FiberBundleMapper3D UpdateVtkObjects()"; + + +} + +void mitk::PlanarCircleMapper3D::SetVtkMapperImmediateModeRendering(vtkMapper *) +{ + + + +} + + + diff --git a/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.h b/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.h new file mode 100644 index 0000000000..b1aeff7bbf --- /dev/null +++ b/Modules/DiffusionImaging/Rendering/mitkPlanarCircleMapper3D.h @@ -0,0 +1,98 @@ +/*========================================================================= + + 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/Rendering/mitkPlanarPolygonMapper3D.cpp b/Modules/DiffusionImaging/Rendering/mitkPlanarPolygonMapper3D.cpp new file mode 100644 index 0000000000..b00194f0fb --- /dev/null +++ b/Modules/DiffusionImaging/Rendering/mitkPlanarPolygonMapper3D.cpp @@ -0,0 +1,235 @@ +/*========================================================================= + + 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 "mitkPlanarPolygonMapper3D.h" +#include +#include + +#include +#include + + + +//template +mitk::PlanarPolygonMapper3D::PlanarPolygonMapper3D() +: m_points(vtkPoints::New()) +, m_polygon(vtkPolygon::New()) +, m_polygonPolyData(vtkPolyData::New()) +, m_polygonsCell(vtkCellArray::New()) +, m_VtkPolygonDataMapperGL(vtkOpenGLPolyDataMapper::New()) +, m_PolygonActor(vtkOpenGLActor::New()) +, m_PolygonAssembly(vtkPropAssembly::New()) +{ + +} + +//template +mitk::PlanarPolygonMapper3D::~PlanarPolygonMapper3D() +{ + //MITK_INFO << "FiberBundleMapper3D(destructor)"; + m_points->Delete(); + m_polygon->Delete(); + m_polygonPolyData->Delete(); + m_polygonsCell->Delete(); + m_VtkPolygonDataMapperGL->Delete(); + m_PolygonActor->Delete(); + m_PolygonAssembly->Delete(); + +} + + +const mitk::PlanarPolygon* mitk::PlanarPolygonMapper3D::GetInput() +{ + //MITK_INFO << "FiberBundleMapper3D GetInput()" ; + + return static_cast ( GetData() ); +} + +/* + This method is called once the mapper gets new input, + for UI rotation or changes in colorcoding this method is NOT called + */ + + +/* */ +void mitk::PlanarPolygonMapper3D::GenerateData() +{ + + + // bool enableIn3D; + //check if property exists + //return if circle should not be painted in 3d View + // bool is3DEnabled; + // this->GetDataNode()->GetPropertyValue("PlanarPolygon_3D",is3DEnabled); + // if (!is3DEnabled) { + // return; + // } + + + try{ + /* get my polygon */ + mitk::PlanarPolygon* PFPolygon = dynamic_cast< mitk::PlanarPolygon* > (this->GetData()); + + //get the control points from pf and insert them to vtkPolygon + unsigned int nrCtrlPnts = 0; + nrCtrlPnts = PFPolygon->GetNumberOfControlPoints(); + + if (nrCtrlPnts <= 2) { + return; + } + + m_points->SetNumberOfPoints(nrCtrlPnts); + + // Create the polygon + m_polygon->GetPointIds()->SetNumberOfIds(nrCtrlPnts); //make a quad + + + //add controlpoints to vtkPoints and link corresponding point id's + for (unsigned int i=0; iInsertPoint(i,(double)PFPolygon->GetWorldControlPoint(i)[0], (double)PFPolygon->GetWorldControlPoint(i)[1], (double)PFPolygon->GetWorldControlPoint(i)[2] ); + m_polygon->GetPointIds()->SetId(i, i); + + } + + m_polygonsCell->Reset(); + m_polygonsCell->InsertNextCell(m_polygon); + + m_polygonPolyData->SetPoints(m_points); + m_polygonPolyData->SetPolys(m_polygonsCell); + + + // Visualize + + m_VtkPolygonDataMapperGL->SetInput(m_polygonPolyData); + m_PolygonActor->SetMapper(m_VtkPolygonDataMapperGL); + m_PolygonAssembly->AddPart(m_PolygonActor); + + this->GetDataNode()->SetColor(200.0,200.0,200.0); + this->GetDataNode()->SetOpacity(0.8); + + //guess 1 call might be enough ;) + m_VtkPolygonDataMapperGL->Modified(); + + } + catch(...) { +// MITK_INFO << "catch in PlanarPolygonMapper3D GenerateData()"; + } + + //MITK_INFO << "_______GENERATE DATA() END_________ \n ==============================="; + +} + + + +/* NEEDS TO BE OPTiMISED!!! */ +//template +void mitk::PlanarPolygonMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) +{ + // bool is3DEnabled; + // this->GetDataNode()->GetPropertyValue("PlanarPolygon_3D",is3DEnabled); + // if (!is3DEnabled) { + // return; + // } + //get the polydata from mapper and then modify points ... thats it what sould happen here + + try{ + + + mitk::PlanarPolygon* PFPolygon = dynamic_cast< mitk::PlanarPolygon* > (this->GetData()); + + //get the control points from pf and insert them to vtkPolygon + unsigned int nrCtrlPnts = 0; + nrCtrlPnts = PFPolygon->GetNumberOfControlPoints(); + + if (nrCtrlPnts <= 2) + return; + + //if there are 3 points available, draw current polygon in 3D + if (nrCtrlPnts == 3) + this->GenerateData(); + + //update points in polygon + + m_points->SetNumberOfPoints(nrCtrlPnts); + + // Create the polygon + m_polygon->GetPointIds()->SetNumberOfIds(nrCtrlPnts); //make a quad + + + //add controlpoints to vtkPoints and link corresponding point id's + for (unsigned int i=0; iInsertPoint(i,(double)PFPolygon->GetWorldControlPoint(i)[0], (double)PFPolygon->GetWorldControlPoint(i)[1], (double)PFPolygon->GetWorldControlPoint(i)[2] ); + m_polygon->GetPointIds()->SetId(i, i); + + } + + + //updates all polygon pipeline + m_VtkPolygonDataMapperGL->Modified(); + + + float polyOpaq; + this->GetDataNode()->GetOpacity(polyOpaq, NULL); + m_PolygonActor->GetProperty()->SetOpacity((double) polyOpaq); + + float temprgb[3]; + this->GetDataNode()->GetColor( temprgb, NULL ); + double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; + m_PolygonActor->GetProperty()->SetColor(trgb); + + + } + catch (...) { +// MITK_INFO << "catch PolygonMapperr3DgenerateData(baseRenderer)"; + } +} + +//template +void mitk::PlanarPolygonMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) +{ + // node->AddProperty( "PlanarPolygon_3D", mitk::BoolProperty::New( true ), renderer, overwrite ); + Superclass::SetDefaultProperties(node, renderer, overwrite); + +} + +vtkProp* mitk::PlanarPolygonMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) +{ + + //MITK_INFO << "FiberBundleMapper3D GetVtkProp(renderer)"; + return m_PolygonAssembly; + +} + + +void mitk::PlanarPolygonMapper3D::UpdateVtkObjects() +{ + // MITK_INFO << "FiberBundleMapper3D UpdateVtkObjects()"; + + +} + +void mitk::PlanarPolygonMapper3D::SetVtkMapperImmediateModeRendering(vtkMapper *) +{ + + + +} + + + diff --git a/Modules/DiffusionImaging/Rendering/mitkPlanarPolygonMapper3D.h b/Modules/DiffusionImaging/Rendering/mitkPlanarPolygonMapper3D.h new file mode 100644 index 0000000000..73332b32e5 --- /dev/null +++ b/Modules/DiffusionImaging/Rendering/mitkPlanarPolygonMapper3D.h @@ -0,0 +1,88 @@ +/*========================================================================= + + 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 PlanarPolygonMapper3D_H +#define PlanarPolygonMapper3D_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include ; + + + + + +namespace mitk { + + //##Documentation + //## @brief Mapper for FiberBundles + //## @ingroup Mapper + // template + class /*MitkDiffusionImagingMBI_EXPORT*/ PlanarPolygonMapper3D : public VtkMapper3D + { + public: + + mitkClassMacro(PlanarPolygonMapper3D, VtkMapper3D); + itkNewMacro(Self); + + + const mitk::PlanarPolygon* 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: + + PlanarPolygonMapper3D(); + virtual ~PlanarPolygonMapper3D(); + + void UpdateVtkObjects(); + + vtkPoints* m_points; + vtkPolygon* m_polygon; + vtkPolyData* m_polygonPolyData; + + vtkCellArray* m_polygonsCell; + vtkOpenGLPolyDataMapper *m_VtkPolygonDataMapperGL; + vtkOpenGLActor *m_PolygonActor; + vtkPropAssembly *m_PolygonAssembly; + + }; + +} // namespace mitk + + + + +#endif /* FiberBundleMapper3D_H_HEADER_INCLUDED */ + diff --git a/Modules/DiffusionImaging/files.cmake b/Modules/DiffusionImaging/files.cmake index e21a1ac38e..3761ae65df 100644 --- a/Modules/DiffusionImaging/files.cmake +++ b/Modules/DiffusionImaging/files.cmake @@ -1,176 +1,180 @@ 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 # 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/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/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/itkTractsToProbabilityImageFilter.h Algorithms/itkTractsToFiberEndingsImageFilter.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 )