--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbkwTransferFunctionEditor.cxx,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:07 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+/**
+ * \file
+ * \brief Short description in one line
+ *
+ * Long
+ * description
+ *
+ */
+
+#ifdef USE_KWWIDGETS
+
+#include "bbkwTransferFunctionEditor.h"
+#include "bbkwPackage.h"
+//#include "bbtkUtilities.h"
+
+#include "vtkKWPiecewiseFunctionEditor.h"
+#include "vtkPointData.h"
+
+//#include "vtkKWScale.h"
+#include "vtkObjectFactory.h"
+#include "vtkCommand.h"
+
+namespace bbkw
+{
+
+ //--------------------------------------------------------------------------
+ //-------------------------------------------------------------------------
+ // KwBlackBox implementation
+ //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionEditor,bbtk::KWBlackBox);
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,TransferFunctionEditor);
+
+ //--------------------------------------------------------------------------
+ void TransferFunctionEditor::bbUserConstructor()
+ {
+ bbSetInputIn(0);
+ bbSetOutputOut(0);
+ bbSetOutputWidget(0);
+ }
+
+ //--------------------------------------------------------------------------
+ void TransferFunctionEditor::Process()
+ {
+ // bbSetOutputOut( bbGetInputIn() );
+ vtkPiecewiseFunction* f = bbGetOutputOut();
+ if (!f)
+ {
+ f = vtkPiecewiseFunction::New();
+ bbSetOutputOut(f);
+ }
+ }
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ void TransferFunctionEditor::CreateWidget(vtkKWFrame* parent)
+ {
+ vtkPiecewiseFunction* f = bbGetOutputOut();
+ if (!f)
+ {
+ f = vtkPiecewiseFunction::New();
+ bbSetOutputOut(f);
+ }
+
+ vtkKWPiecewiseFunctionEditor *w = vtkKWPiecewiseFunctionEditor::New();
+ bbSetOutputWidget(w);
+ // w->SetWindowLevelModeChangedCommand((vtkObject*)this,(const char*)"OnChange");
+ //AddObserver(vtkKWPiecewiseFunctionEditor::FunctionChangedCommand,this);
+ w->SetParent((vtkKWWidget*)parent);
+ w->Create();
+
+ w->SetBorderWidth(2);
+ w->SetReliefToGroove();
+ w->SetPadX(2);
+ w->SetPadY(2);
+ // w->ExpandCanvasWidthOff();
+ // w->ExpandCanvasHeightOn();
+ // w->SetCanvasWidth(450);
+ w->SetCanvasHeight( parent->GetHeight() );
+ w->SetLabelText("");//Transfer Function Editor");
+ w->SetBalloonHelpString("Edit the transfer function");
+ w->LockEndPointsParameterOn();
+
+ w->PointIndexVisibilityOff();
+ w->SelectedPointIndexVisibilityOff();
+ w->MidPointVisibilityOff();
+ w->PointGuidelineVisibilityOff();
+ w->MidPointGuidelineVisibilityOff();
+ w->MidPointGuidelineValueVisibilityOff();
+ w->SetMidPointGuidelineValueFormat("%-#6.0f");
+ w->MidPointEntryVisibilityOff();
+ w->SharpnessEntryVisibilityOff();
+ w->SetLabelPositionToTop();
+
+ if ( bbGetInputIn()!=NULL )
+ {
+ vtkKWHistogram *h = vtkKWHistogram::New();
+ h->BuildHistogram( bbGetInputIn()->GetPointData()->GetScalars(), 0);
+ double *range = h->GetRange();
+ f->AddPoint(range[0], 0.0 );
+ f->AddPoint(range[1], 1.0 );
+ w->SetHistogram(h);
+ h->Delete();
+ }
+ else
+ {
+ f->AddPoint(0.0, 0.0);
+ f->AddPoint(1.0, 1.0);
+ }
+
+ w->SetPiecewiseFunction(f);
+
+ w->ParameterTicksVisibilityOn();
+ w->ComputeValueTicksFromHistogramOn();
+ w->SetParameterTicksFormat( w->GetMidPointGuidelineValueFormat());
+
+ w->Delete();
+ f->Delete();
+
+ }
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ void TransferFunctionEditor::OnChange()
+
+ {
+ std::cout << "TransferFunctionEditor::OnChange()" << std::endl;
+ }
+
+ void TransferFunctionEditor::Execute(vtkObject* caller, unsigned long, void*)
+ {
+ std::cout << "$$$$$$$$$$$$ TransferFunctionEditor CB $$$$$$$$$$$$"<<std::endl;
+ /*
+ vtkKWScale* scale = (vtkKWScale*)caller;
+ bbSetOutputOut( scale->GetValue() );
+ bbSetInputIn( scale->GetValue() );
+ // and signal that the output has changed
+ bbSignalOutputModification("Out");
+ */
+ }
+ //--------------------------------------------------------------------------
+
+
+
+} //namespace bbkw
+
+#endif // USE_KWWIDGETS
+
+
--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbkwTransferFunctionEditor.h,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:08 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+/**
+ * \file
+ * \brief Short description in one line
+ *
+ * Long description which
+ * can span multiple lines
+*/
+
+/**
+ * \class bbkw::TransferFunctionEditor
+ * \brief
+
+ * \class bbkw::TransferFunctionEditorWidget
+ * \brief
+ */
+
+#ifdef USE_KWWIDGETS
+#ifdef USE_VTK
+
+// Prevents multiple inclusions : use symbols of the form
+// __FILENAME_INCLUDED__
+// where FILENAME must be replaced by the actual file name
+#ifndef __bbkwTransferFunctionEditor_h_INCLUDED__
+#define __bbkwTransferFunctionEditor_h_INCLUDED__
+
+// Include KWBlackBox definition
+#include "bbtkKWBlackBox.h"
+#include "bbkw_EXPORT.h"
+
+class vtkObject;
+class vtkCommand;
+#include "vtkCommand.h"
+#include "vtkImageData.h"
+#include "vtkPiecewiseFunction.h"
+
+
+// Namespace of the package "kw" is "bbkw"
+// Namespace associated to packages should be of the form :
+// bbPACKAGENAME
+namespace bbkw
+{
+
+ //------------------------------------------------------------------------
+ // The black box
+ class bbkw_EXPORT TransferFunctionEditor : public bbtk::KWBlackBox,
+ public vtkCommand
+ {
+
+ BBTK_BLACK_BOX_INTERFACE(TransferFunctionEditor,bbtk::KWBlackBox);
+
+ BBTK_DECLARE_INPUT(In,vtkImageData*);
+ BBTK_DECLARE_OUTPUT(Out,vtkPiecewiseFunction*);
+
+ BBTK_PROCESS(Process);
+ BBTK_CREATE_KWWIDGET(CreateWidget);
+
+ void Process();
+ void CreateWidget(vtkKWFrame*);
+ virtual void Execute(vtkObject* caller, unsigned long, void*);
+ void OnChange();
+ protected:
+ virtual void bbUserConstructor();
+ };
+ //=================================================================
+
+ //=================================================================
+ // the black box description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(TransferFunctionEditor,bbtk::KWBlackBox);
+ BBTK_NAME("kwTransferFunctionEditor");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ // Already inserted for any KWBlackBox BBTK_CATEGORY("widget");
+ BBTK_DESCRIPTION("Transfer function editor (vtkKWPiecewiseFunctionEditor)");
+ BBTK_INPUT(TransferFunctionEditor,In,
+ "Image from which to extract the histogram to display",
+ vtkImageData*,"");
+ BBTK_OUTPUT(TransferFunctionEditor,Out,"Piecewise function",
+ vtkPiecewiseFunction*,"");
+ BBTK_END_DESCRIBE_BLACK_BOX(TransferFunctionEditor);
+ //=================================================================
+
+
+
+} //namespace bbkw
+
+#endif //__bbkwTransferFunctionEditor_h_INCLUDED__
+
+#endif // USE_KWWIDGETS
+
+#endif // USE_VTK
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbkwViewer3D.cxx,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:08 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.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.
+
+=========================================================================*/
+/**
+ * \file
+ * \brief
+ */
+
+
+#ifdef _USE_WXWIDGETS_
+
+
+#include "bbkwViewer3D.h"
+#include "bbkwPackage.h"
+
+#include "vtkKWRenderWidget.h"
+
+namespace bbkw
+{
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,kwViewer3D);
+ BBTK_BLACK_BOX_IMPLEMENTATION(kwViewer3D,bbtk::KWBlackBox);
+
+ void kwViewer3D::bbUserConstructor()
+ {
+ bbSetInputIn1(NULL);
+ bbSetInputIn2(NULL);
+ bbSetInputIn3(NULL);
+ bbSetInputIn4(NULL);
+ bbSetInputIn5(NULL);
+ bbSetInputObs1(NULL);
+ bbSetInputObs2(NULL);
+ bbSetInputObs3(NULL);
+ bbSetInputObs4(NULL);
+ bbSetInputObs5(NULL);
+ bbSetOutputWidget(NULL);
+ }
+
+ void kwViewer3D::bbUserDestructor()
+ {
+ /*
+ vtkKWRenderWidget* w = (vtkKWRenderWidget*)bbGetOutputWidget();
+ if (w)
+ {
+ w->Delete();
+ }
+ */
+ }
+
+ void kwViewer3D::Process()
+ {
+ vtkKWRenderWidget* w = (vtkKWRenderWidget*)bbGetOutputWidget();
+ if (w)
+ {
+ if ( (bbGetInputIn1()!=NULL) &&
+ (bbGetInputStatus("In1")!=bbtk::UPTODATE))
+ {
+ w->AddViewProp(bbGetInputIn1());
+ }
+ if ( (bbGetInputIn2()!=NULL) &&
+ (bbGetInputStatus("In2")!=bbtk::UPTODATE))
+ {
+ w->AddViewProp(bbGetInputIn2());
+ }
+ if ( (bbGetInputIn3()!=NULL) &&
+ (bbGetInputStatus("In3")!=bbtk::UPTODATE))
+ {
+ w->AddViewProp(bbGetInputIn3());
+ }
+ if ( (bbGetInputIn4()!=NULL) &&
+ (bbGetInputStatus("In4")!=bbtk::UPTODATE))
+ {
+ w->AddViewProp(bbGetInputIn4());
+ }
+ if ( (bbGetInputIn5()!=NULL) &&
+ (bbGetInputStatus("In5")!=bbtk::UPTODATE))
+ {
+ w->AddViewProp(bbGetInputIn5());
+ }
+ w->ResetCamera();
+ w->Render();
+ }
+ }
+
+
+ void kwViewer3D::CreateWidget(vtkKWFrame* parent)
+ {
+ vtkKWRenderWidget *w = vtkKWRenderWidget::New();
+ bbSetOutputWidget(w);
+ w->SetParent((vtkKWWidget*)parent);
+ w->Create();
+ w->SetRenderModeToInteractive();
+
+ Process();
+ w->Delete();
+ /*
+ vtkRenderWindowInteractor *interactor = w->GetInteractor();
+ if (interactor!=NULL)
+ {
+ if (bbGetInputObs1()!=NULL)
+ {
+ bbGetInputObs1()->SetInteractor(interactor);
+ bbGetInputObs1()->EnabledOn();
+ }
+ if (bbGetInputObs2()!=NULL)
+ {
+ bbGetInputObs2()->SetInteractor(interactor);
+ bbGetInputObs2()->EnabledOn();
+ }
+ if (bbGetInputObs3()!=NULL)
+ {
+ bbGetInputObs3()->SetInteractor(interactor);
+ bbGetInputObs3()->EnabledOn();
+ }
+ if (bbGetInputObs4()!=NULL)
+ {
+ bbGetInputObs4()->SetInteractor(interactor);
+ bbGetInputObs4()->EnabledOn();
+ }
+ if (bbGetInputObs5()!=NULL)
+ {
+ bbGetInputObs5()->SetInteractor(interactor);
+ bbGetInputObs5()->EnabledOn();
+ }
+ bbSetOutputInteractor( w->GetInteractor() );
+ }
+
+
+ */
+
+ }
+
+
+
+
+}//namespace bbkw
+
+#endif
+
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbkwViewer3D.h,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:08 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.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.
+
+=========================================================================*//**
+ * \brief Short description in one line
+ *
+ * Long description which
+ * can span multiple lines
+ */
+/**
+ * \file
+ * \brief Pattern for the definition of a new type of Node (header)
+ */
+/**
+ * \class bbtk::NodePatern
+ * \brief Pattern for the definition of a new type of Node
+ */
+
+
+#ifdef USE_KWWIDGETS
+#ifdef USE_VTK
+
+
+#ifndef __bbkwViewer3D_h__
+#define __bbkwViewer3D_h__
+
+#include "bbtkKWBlackBox.h"
+#include "vtkProp3D.h"
+#include "vtkInteractorObserver.h"
+
+#include "bbkw_EXPORT.h"
+
+namespace bbkw
+{
+
+ //------------------------------------------------------------------------
+ class bbkw_EXPORT kwViewer3D : public bbtk::KWBlackBox
+ {
+ BBTK_BLACK_BOX_INTERFACE(kwViewer3D,bbtk::KWBlackBox);
+ BBTK_DECLARE_INPUT(In1, vtkProp3D *);
+ BBTK_DECLARE_INPUT(In2, vtkProp3D *);
+ BBTK_DECLARE_INPUT(In3, vtkProp3D *);
+ BBTK_DECLARE_INPUT(In4, vtkProp3D *);
+ BBTK_DECLARE_INPUT(In5, vtkProp3D *);
+ BBTK_DECLARE_INPUT(Obs1, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs2, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs3, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs4, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs5, vtkInteractorObserver *);
+ BBTK_PROCESS(Process);
+ BBTK_CREATE_KWWIDGET(CreateWidget);
+ // BBTK_ON_SHOW_WIDGET(OnShowWidget);
+
+ void Process();
+ void CreateWidget(vtkKWFrame*);
+ // void OnShowWidget();
+
+ protected:
+ virtual void bbUserConstructor();
+ virtual void bbUserDestructor();
+ };
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(kwViewer3D,bbtk::KWBlackBox);
+ BBTK_NAME("kwViewer3D");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("3D viewer widget (vtkKWRenderWidget)");
+ BBTK_CATEGORY("viewer");
+ BBTK_INPUT(kwViewer3D,In1,"Input actor",vtkProp3D *,"");
+ BBTK_INPUT(kwViewer3D,In2,"Input actor",vtkProp3D *,"");
+ BBTK_INPUT(kwViewer3D,In3,"Input actor",vtkProp3D *,"");
+ BBTK_INPUT(kwViewer3D,In4,"Input actor",vtkProp3D *,"");
+ BBTK_INPUT(kwViewer3D,In5,"Input actor",vtkProp3D *,"");
+ BBTK_INPUT(kwViewer3D,Obs1,"Input observer",vtkInteractorObserver *,"");
+ BBTK_INPUT(kwViewer3D,Obs2,"Input observer",vtkInteractorObserver *,"");
+ BBTK_INPUT(kwViewer3D,Obs3,"Input observer",vtkInteractorObserver *,"");
+ BBTK_INPUT(kwViewer3D,Obs4,"Input observer",vtkInteractorObserver *,"");
+ BBTK_INPUT(kwViewer3D,Obs5,"Input observer",vtkInteractorObserver *,"");
+ BBTK_END_DESCRIBE_BLACK_BOX(kwViewer3D);
+ //=================================================================
+
+
+}//namespace bbtk
+
+#endif //__bbkwViewer3D_h__
+
+#endif //USE_KW
+#endif //USE_VTK
+
Program: bbtk
Module: $RCSfile: bbvtkMIPCreator.h,v $
Language: C++
- Date: $Date: 2008/11/25 11:17:23 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/12/16 12:48:10 $
+ Version: $Revision: 1.7 $
=========================================================================*/
/* ---------------------------------------------------------------------
#include "vtkProp3D.h"
#include "vtkVolume.h"
+#include "bbvtk_EXPORT.h"
+
namespace bbvtk
{
- class /*BBTK_EXPORT*/ MIPCreator : public bbtk::AtomicBlackBox
+ class bbvtk_EXPORT MIPCreator : public bbtk::AtomicBlackBox
{
public:
BBTK_BLACK_BOX_INTERFACE(MIPCreator,bbtk::AtomicBlackBox);
--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbvtkPiecewiseFunction.cxx,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:10 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+/**
+ * \file
+ * \brief
+ */
+
+
+
+#ifdef _USE_VTK_
+
+
+#include "bbvtkPiecewiseFunction.h"
+#include "bbvtkPackage.h"
+
+namespace bbvtk
+{
+
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PiecewiseFunction)
+ BBTK_BLACK_BOX_IMPLEMENTATION(PiecewiseFunction,bbtk::AtomicBlackBox);
+
+
+
+
+
+ void PiecewiseFunction::bbUserConstructor()
+ {
+ Init();
+ // Identity function
+ std::vector<float> x,y;
+ x.push_back(0);
+ x.push_back(1);
+ y.push_back(0);
+ y.push_back(1);
+ bbSetInputX(x);
+ bbSetInputY(y);
+ }
+ void PiecewiseFunction::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
+ {
+ Init();
+ }
+
+ void PiecewiseFunction::Init()
+ {
+ bbSetOutputOut(vtkPiecewiseFunction::New());
+ }
+
+ void PiecewiseFunction::bbUserDestructor()
+ {
+ bbGetOutputOut()->Delete();
+ }
+//---------------------------------------------------------------------
+
+ void PiecewiseFunction::Process()
+ {
+ if ( ( bbGetInputStatus("X") != bbtk::UPTODATE ) ||
+ ( bbGetInputStatus("Y") != bbtk::UPTODATE ) )
+ {
+ if ( bbGetInputX().size() != bbGetInputY().size() )
+ bbtkError(bbGetFullName()
+ <<" : input vectors X and Y do not have the same size");
+ if ( bbGetInputX().size() < 2 )
+ bbtkError(bbGetFullName()
+ <<" : input vectors X and Y have a size < 2");
+ bbGetOutputOut()->RemoveAllPoints ();
+ // std::cout << bbGetInputX().size()<< ","<< bbGetInputY().size()<< std::endl;
+ std::vector<float>::const_iterator x,y;
+ std::vector<float> X = bbGetInputX();
+ std::vector<float> Y = bbGetInputY();
+ for (x = X.begin(), y = Y.begin();
+ x != X.end(), y != Y.end();
+ ++x, ++y )
+ {
+ // std::cout << *x << " -> " << *y << std::endl;
+ bbGetOutputOut()->AddPoint(*x,*y);
+ }
+ }
+ }
+
+}//namespace bbtk
+
+#endif // _USE_VTK_
+
--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbvtkPiecewiseFunction.h,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:10 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+
+/**
+ * \brief Short description in one line
+ *
+ * Long description which
+ * can span multiple lines
+ */
+/**
+ * \file
+ * \brief Pattern for the definition of a new type of Node (header)
+ */
+/**
+ * \class bbtk::NodePatern
+ * \brief Pattern for the definition of a new type of Node
+ */
+
+
+#ifdef _USE_VTK_
+
+
+#ifndef __bbvtkPiecewiseFunction_h_INCLUDED__
+#define __bbvtkPiecewiseFunction_h_INCLUDED__
+
+
+#include "bbtkAtomicBlackBox.h"
+
+#include "vtkPiecewiseFunction.h"
+
+#include "bbvtk_EXPORT.h"
+
+namespace bbvtk
+{
+
+
+
+ class bbvtk_EXPORT PiecewiseFunction : public bbtk::AtomicBlackBox
+ {
+ public:
+ BBTK_BLACK_BOX_INTERFACE(PiecewiseFunction,bbtk::AtomicBlackBox);
+
+ BBTK_DECLARE_INPUT(X,std::vector<float>);
+ BBTK_DECLARE_INPUT(Y,std::vector<float>);
+ BBTK_DECLARE_OUTPUT(Out,vtkPiecewiseFunction*);
+ BBTK_PROCESS(Process);
+ void Process();
+
+ protected:
+ virtual void bbUserConstructor();
+ virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer);
+ virtual void bbUserDestructor();
+ void Init();
+ };
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(PiecewiseFunction,bbtk::AtomicBlackBox);
+ BBTK_NAME("PiecewiseFunction");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Creates a piecewise function");
+ BBTK_CATEGORY("misc");
+ BBTK_INPUT(PiecewiseFunction,X,"X coords of the points of the function",
+ std::vector<float>,"");
+ BBTK_INPUT(PiecewiseFunction,Y,"Y coords of the points of the function",
+ std::vector<float>,"");
+ BBTK_OUTPUT(PiecewiseFunction,Out,"The piecewise function created",
+ vtkPiecewiseFunction*,"");
+ BBTK_END_DESCRIBE_BLACK_BOX(PiecewiseFunction);
+ //=================================================================
+
+
+}//namespace bbvtk
+
+#endif //__bbtvtkPiecewiseFunction_h__
+
+#endif //_USE_VTK_
+
--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbvtkVolumeRenderer.cxx,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:10 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+/**
+ * \file
+ * \brief
+ */
+
+
+
+#ifdef _USE_VTK_
+
+
+#include "bbvtkVolumeRenderer.h"
+#include "bbvtkPackage.h"
+
+namespace bbvtk
+{
+
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,VolumeRenderer)
+ BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRenderer,bbtk::AtomicBlackBox);
+
+
+
+
+
+ void VolumeRenderer::bbUserConstructor()
+ {
+ Init();
+ bbSetInputColorFunction(0);
+ bbSetInputOpacityFunction(0);
+ }
+ void VolumeRenderer::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
+ {
+ Init();
+ }
+
+ void VolumeRenderer::Init()
+ {
+
+ // Create the pipeline
+ // mCast = vtkImageShiftScale::New();
+ // mCast->SetOutputScalarTypeToUnsignedChar();
+ // mCast->ClampOverflowOn();
+
+ // mMIP = vtkVolumeRayCastMIPFunction::New();
+ // mMIP->SetMaximizeMethodToScalarValue();
+
+ mRayCastFunction = vtkVolumeRayCastCompositeFunction::New();
+
+ mMapper = vtkVolumeRayCastMapper::New();
+ mMapper->SetVolumeRayCastFunction(mRayCastFunction);
+
+
+ mVolume = vtkVolume::New();
+ mVolume->SetMapper(mMapper);
+
+ // mMapper->ScalarVisibilityOff();
+ // mMapper->ImmediateModeRenderingOn();
+
+ bbSetOutputOut(mVolume);
+}
+
+ void VolumeRenderer::bbUserDestructor()
+ {
+ mRayCastFunction->Delete();
+ mMapper->Delete();
+ mVolume->Delete();
+
+ }
+//---------------------------------------------------------------------
+
+ void VolumeRenderer::Process()
+ {
+ bool changed = false;
+ if ( bbGetInputStatus("In") != bbtk::UPTODATE )
+ {
+ mMapper->SetInput( bbGetInputIn() );
+ changed = true;
+ }
+ if ( ( bbGetInputStatus("ColorFunction") != bbtk::UPTODATE ) &&
+ ( bbGetInputColorFunction() != 0 ) )
+ {
+ mVolume->GetProperty()->SetColor( bbGetInputColorFunction() );
+ changed = true;
+ }
+ if ( ( bbGetInputStatus("OpacityFunction") != bbtk::UPTODATE ) &&
+ ( bbGetInputOpacityFunction() != 0 ) )
+ {
+ mVolume->GetProperty()->SetScalarOpacity(bbGetInputOpacityFunction());
+ changed = true;
+ }
+
+ if (changed) mMapper->Update();
+
+ }
+
+}//namespace bbtk
+
+#endif // _USE_VTK_
+
--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbvtkVolumeRenderer.h,v $
+ Language: C++
+ Date: $Date: 2008/12/16 12:48:10 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+
+/**
+ * \brief Short description in one line
+ *
+ * Long description which
+ * can span multiple lines
+ */
+/**
+ * \file
+ * \brief Pattern for the definition of a new type of Node (header)
+ */
+/**
+ * \class bbtk::NodePatern
+ * \brief Pattern for the definition of a new type of Node
+ */
+
+
+#ifdef _USE_VTK_
+
+
+#ifndef __bbvtkVolumeRenderer_h_INCLUDED__
+#define __bbvtkVolumeRenderer_h_INCLUDED__
+
+
+#include "bbtkAtomicBlackBox.h"
+
+#include "vtkImageData.h"
+//#include <vtkImageShiftScale.h>
+//#include <vtkVolumeRayCastMIPFunction.h>
+#include "vtkVolumeProperty.h"
+#include "vtkVolumeRayCastCompositeFunction.h"
+#include "vtkVolumeRayCastMapper.h"
+#include "vtkProp3D.h"
+#include "vtkVolume.h"
+
+#include "vtkPiecewiseFunction.h"
+
+#include "bbvtk_EXPORT.h"
+
+namespace bbvtk
+{
+
+
+
+ class bbvtk_EXPORT VolumeRenderer : public bbtk::AtomicBlackBox
+ {
+ public:
+ BBTK_BLACK_BOX_INTERFACE(VolumeRenderer,bbtk::AtomicBlackBox);
+
+ BBTK_DECLARE_INPUT(In,vtkImageData *);
+ BBTK_DECLARE_INPUT(ColorFunction,vtkPiecewiseFunction*);
+ BBTK_DECLARE_INPUT(OpacityFunction,vtkPiecewiseFunction*);
+ BBTK_DECLARE_OUTPUT(Out,vtkProp3D*);
+ BBTK_PROCESS(Process);
+ void Process();
+
+ protected:
+ virtual void bbUserConstructor();
+ virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer);
+ virtual void bbUserDestructor();
+ void Init();
+ private:
+ vtkVolumeProperty * mVolumeProperty;
+ vtkVolumeRayCastCompositeFunction * mRayCastFunction;
+ vtkVolumeRayCastMapper* mMapper;
+ vtkVolume* mVolume;
+ };
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(VolumeRenderer,bbtk::AtomicBlackBox);
+ BBTK_NAME("VolumeRenderer");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Renders a 3D image. Creates a vtkProp3D object to insert into a 3D scene (e.g. a Viewer3D)");
+ BBTK_CATEGORY("3D object creator");
+ BBTK_INPUT(VolumeRenderer,ColorFunction,"Color function",vtkPiecewiseFunction*,"");
+ BBTK_INPUT(VolumeRenderer,OpacityFunction,"Opacity function",vtkPiecewiseFunction*,"");
+ BBTK_INPUT(VolumeRenderer,In,"Input Image",vtkImageData *,"");
+ BBTK_OUTPUT(VolumeRenderer,Out,"3D object to plug into a 3D viewer",vtkProp3D*,"");
+ BBTK_END_DESCRIBE_BLACK_BOX(VolumeRenderer);
+ //=================================================================
+
+
+}//namespace bbvtk
+
+#endif //__bbtvtkVolumeRenderer_h__
+
+#endif //_USE_VTK_
+
--- /dev/null
+description "Volume rendering example"
+author "laurent.guigues at creatis.insa-lyon.fr"
+category "example"
+
+include vtk
+load wxvtk
+
+new LoadHola image
+new PiecewiseFunction color
+new PiecewiseFunction opacity
+new VolumeRenderer renderer
+new Viewer3D viewer
+
+connect image.Out renderer.In
+connect color.Out renderer.ColorFunction
+connect opacity.Out renderer.OpacityFunction
+connect renderer.Out viewer.In1
+
+load std
+set color.X "0 500 1000"
+set color.Y "0 0.01 1"
+set opacity.X "0 500 1000"
+set opacity.Y "0 0.01 0.1"
+
+exec viewer
clear
print " "
print "====================================="
-print "A simple MIP"
+print "Volume rendering"
print "====================================="
-help MIPWithControls
+help VolumeRenderer
message echo 2
new LoadHola image
+new PiecewiseFunction color
+new PiecewiseFunction opacity
+new VolumeRenderer renderer
new Viewer3D viewer
-new MIPWithControls MIP
-connect image.Out MIP.In
-connect MIP.Out viewer.In1
-connect MIP.BoxChange viewer.BoxExecute
+connect image.Out renderer.In
+connect color.Out renderer.ColorFunction
+connect opacity.Out renderer.OpacityFunction
+connect renderer.Out viewer.In1
-new LayoutSplit main
-connect viewer.Widget main.Widget1
-connect MIP.Widget main.Widget2
-set main.Proportion 70
-set main.WinDialog true
-exec main
+set color.X "0 500 1000"
+set color.Y "0 0.01 1"
+set opacity.X "0 500 1000"
+set opacity.Y "0 0.01 0.1"
+
+set viewer.WinDialog true
+exec viewer
message echo 0
message Help 1