X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMeshActor.cxx;h=b3d3c7f24b2b18fee32a4624d794228cdea29f3e;hb=1c6241402b25efea0052f0464be9a494e761b19e;hp=b946f380a03c9d1a97a2600b5831926cea80e8cd;hpb=c1370c27d5fc65b499d6be1c5dc49a96da0bb8cc;p=clitk.git diff --git a/vv/vvMeshActor.cxx b/vv/vvMeshActor.cxx index b946f38..b3d3c7f 100644 --- a/vv/vvMeshActor.cxx +++ b/vv/vvMeshActor.cxx @@ -1,29 +1,23 @@ /*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Program: vv - Language: C++ - Author : Joel Schaerer (joel.schaerer@insa-lyon.fr) + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr -Copyright (C) 2008 -Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr -CREATIS-LRMN http://www.creatis.insa-lyon.fr + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -=========================================================================*/ + It is distributed under dual licence + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ #include "vvMeshActor.h" #include "clitkCommon.h" +#include #include #include #include @@ -33,98 +27,119 @@ along with this program. If not, see . #include vvMeshActor::vvMeshActor() : - mCutDimension(NULL), mMesh(NULL), - mMarching(NULL), mMapper(NULL), - mActor(NULL), - mSuperpostionMode(false), mTimeSlice(0) + mCutDimension(0), mMesh(ITK_NULLPTR), + mMarching(ITK_NULLPTR), mMapper(ITK_NULLPTR), + mActor(ITK_NULLPTR), + mSuperpostionMode(false), mTimeSlice(0) {} vvMeshActor::~vvMeshActor() { - mMarching->Delete(); - mMapper->Delete(); - mActor->Delete(); + mMarching->Delete(); + mMapper->Delete(); + mActor->Delete(); } void vvMeshActor::Init(vvMesh::Pointer mesh,int time_slice,vvImage::Pointer vf) { - mMesh=mesh; - - mMarching=vtkMarchingSquares::New(); - mTimeSlice=time_slice; - if (static_cast(time_slice)GetNumberOfMeshes()) - mMarching->SetInput(mMesh->GetMask(time_slice)); - else - mMarching->SetInput(mMesh->GetMask(0)); - mMarching->SetValue(0,0.5); - //mMarching->Update(); - - mMapper=vtkPolyDataMapper::New(); - mMapper->SetInput(mMarching->GetOutput()); - //The following line allows to display the contour over the image - //(http://www.nabble.com/What-happens-when-two-actors-are-at-the-same-depth--td23175458.html) - vtkMapper::SetResolveCoincidentTopologyToPolygonOffset(); - mActor=vtkActor::New(); - mActor->SetMapper(mMapper); - mActor->SetPickable(false); - mActor->GetProperty()->EdgeVisibilityOn(); - mActor->GetProperty()->SetEdgeColor(mMesh->r,mMesh->g,mMesh->b); - mActor->GetProperty()->SetLineWidth(2.); + mMesh=mesh; + + mMarching=vtkMarchingSquares::New(); + mTimeSlice=time_slice; + if (static_cast(time_slice)GetNumberOfMeshes()) { +#if VTK_MAJOR_VERSION <= 5 + mMarching->SetInput(mMesh->GetMask(time_slice)); +#else + mMarching->SetInputData(mMesh->GetMask(time_slice)); +#endif + } else { +#if VTK_MAJOR_VERSION <= 5 + mMarching->SetInput(mMesh->GetMask(0)); +#else + mMarching->SetInputData(mMesh->GetMask(0)); +#endif + } + mMarching->SetValue(0,0.5); + //mMarching->Update(); + + mMapper=vtkPolyDataMapper::New(); +#if VTK_MAJOR_VERSION <= 5 + mMapper->SetInput(mMarching->GetOutput()); +#else + mMapper->SetInputConnection(mMarching->GetOutputPort()); +#endif + //The following line allows to display the contour over the image + //(http://www.nabble.com/What-happens-when-two-actors-are-at-the-same-depth--td23175458.html) + vtkMapper::SetResolveCoincidentTopologyToPolygonOffset(); + mActor=vtkActor::New(); + mActor->SetMapper(mMapper); + mActor->SetPickable(false); + mActor->GetProperty()->EdgeVisibilityOn(); + mActor->GetProperty()->SetEdgeColor(mMesh->r,mMesh->g,mMesh->b); + mActor->GetProperty()->SetLineWidth(2.); + mActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL } void vvMeshActor::SetCutSlice(double slice) { - mCutSlice=slice; - vtkImageData* mask; - if (static_cast(mTimeSlice)GetNumberOfMasks()) - mask=mMesh->GetMask(mTimeSlice); - else - mask=mMesh->GetMask(0); - int* dims=mask->GetDimensions(); - int mask_slice=(slice-mask->GetOrigin()[mCutDimension])/mask->GetSpacing()[mCutDimension]; - switch (mCutDimension) - { - case 0: - mMarching->SetImageRange(mask_slice,mask_slice,0,dims[1],0,dims[2]); - break; - case 1: - mMarching->SetImageRange(0,dims[0],mask_slice,mask_slice,0,dims[2]); - break; - case 2: - mMarching->SetImageRange(0,dims[0],0,dims[1],mask_slice,mask_slice); - break; - default: - assert(false); - } - mMarching->Update(); + //DD("SetCutSlice"); + //DD(slice); + mCutSlice=slice; + vtkImageData* mask; + if (static_cast(mTimeSlice)GetNumberOfMasks()) + mask=mMesh->GetMask(mTimeSlice); + else + mask=mMesh->GetMask(0); + int* dims=mask->GetDimensions(); + int mask_slice=(slice-mask->GetOrigin()[mCutDimension])/mask->GetSpacing()[mCutDimension]; + switch (mCutDimension) { + case 0: + mMarching->SetImageRange(mask_slice,mask_slice,0,dims[1],0,dims[2]); + break; + case 1: + mMarching->SetImageRange(0,dims[0],mask_slice,mask_slice,0,dims[2]); + break; + case 2: + mMarching->SetImageRange(0,dims[0],0,dims[1],mask_slice,mask_slice); + break; + default: + assert(false); + } + mMarching->Update(); } void vvMeshActor::SetTimeSlice(int time) { - mTimeSlice=time; - if (static_cast(time)GetNumberOfMasks()) - mMarching->SetInput(mMesh->GetMask(time)); - else - mMarching->SetInput(mMesh->GetMask(0)); - SetCutSlice(mCutSlice); //We need to find the new mask cut slice, - //since masks do not all have the same origin + mTimeSlice=time; + if (static_cast(time)GetNumberOfMasks()) { +#if VTK_MAJOR_VERSION <= 5 + mMarching->SetInput(mMesh->GetMask(time)); +#else + mMarching->SetInputData(mMesh->GetMask(time)); +#endif + } else { +#if VTK_MAJOR_VERSION <= 5 + mMarching->SetInput(mMesh->GetMask(0)); +#else + mMarching->SetInputData(mMesh->GetMask(0)); +#endif + } + SetCutSlice(mCutSlice); //We need to find the new mask cut slice, + //since masks do not all have the same origin } void vvMeshActor::SetSlicingOrientation(unsigned int d) { - mCutDimension=d; + mCutDimension=d; } void vvMeshActor::ToggleSuperposition() { - DD("Warning: superposition not implemented"); + DD("Warning: superposition not implemented"); // std::cout << "vvMeshActor::ToggleSuperposition size = " << mMeshes.size() << std::endl; - if (! mSuperpostionMode && mMesh->GetNumberOfMeshes() > 1) - { - mSuperpostionMode=true; - } - else - { - mSuperpostionMode=false; - } + if (! mSuperpostionMode && mMesh->GetNumberOfMeshes() > 1) { + mSuperpostionMode=true; + } else { + mSuperpostionMode=false; + } }