#ifndef VolumeRendererManagerData_H_ #define VolumeRendererManagerData_H_ #include "vtkCommand.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6) #include #endif #include // Callback for moving the planes from the box widget to the mapper class vtkBoxWidgetCallback : public vtkCommand { public: static vtkBoxWidgetCallback *New() { return new vtkBoxWidgetCallback; } virtual void Execute(vtkObject *caller, unsigned long, void*) { vtkBoxWidget *widget = reinterpret_cast(caller); if (this->Mapper) { vtkPlanes *planes = vtkPlanes::New(); widget->GetPlanes(planes); this->Mapper->SetClippingPlanes(planes); planes->Delete(); } } void SetMapper(vtkAbstractMapper* m) { this->Mapper = m; } protected: vtkBoxWidgetCallback() { this->Mapper = 0; } //vtkVolumeRayCastMapper *Mapper; vtkAbstractMapper *Mapper; }; class VolumeRendererManagerData : public vtkObject{ public: VolumeRendererManagerData(vtkImageData* vol, std::string dataname=""); VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname=""); VolumeRendererManagerData(vtkImageData* vol, bool usegpu, std::string dataname=""); ~VolumeRendererManagerData(); /** ** Check if the variables are setted correctly **/ void checkInvariant()throw (char *); /** ** Updates volume **/ void Update(); /** ** get the prop3D **/ vtkProp3D* getProp3D(); /** ** return the id from the daat **/ int getId(); /** ** set data id **/ void setId(int propid); /** ** Get the filanme **/ std::string getDataname(); /** ** Set the filanme **/ void setDataname(std::string dataname); /** ** Set Volume Color **/ void setVolumeColor(std::vector& greylevel, std::vector& red, std::vector& green, std::vector& blue); /** ** Volume Opacity **/ void setVolumeOpacity(std::vector greylevel,std::vector value); /** ** Volume Opacity **/ void setVolumeOpacity(std::vector greylevel,double value); vtkPiecewiseFunction* GetTransferFunction(){ return _tfun; } vtkColorTransferFunction* GetColorFunction(){ return _ctfun; } void changeCompositeMIPFunction(int function) throw (char *); void SetLookupTable(vtkLookupTable* lookuptable); void EnableBoundingBox(vtkRenderWindowInteractor* interactor); void DisableBoundingBox(); protected: /** * Prop 3D (data actor) */ vtkImageData* _vol; /** * Dataname given by the user (ex. filename) **/ std::string _dataname; private: /* * id of the data */ int _id; vtkVolumeRayCastCompositeFunction *_compositeFunction; vtkPlanes *_volumePlanes; vtkVolumeRayCastMapper *_volumeMapper; #if (VTK_MAYOR_VERSION>=5 && VTK_MINOR_VERSION>=6) vtkGPUVolumeRayCastMapper *_volumeMappergpu; #else vtkVolumeRayCastMapper *_volumeMappergpu; #endif vtkVolumeProperty *_volumeProperty; vtkVolume *_newvol; vtkPiecewiseFunction* _tfun; vtkColorTransferFunction* _ctfun; vtkVolumeRayCastMIPFunction* _MIPFunction; /** ** boxwidget to control the volume **/ vtkBoxWidget* _boxWidgetS1; void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false); }; #endif /*VolumeRendererManagerData_H_*/