From 7f0ed106c64180782dc42d3f3246f410f70aa491 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Wed, 27 May 2009 13:39:37 +0000 Subject: [PATCH] . --- bbtk/src/bbmaracasvisuAnimationSphere.cxx | 175 ++++++++++++++++++++++ bbtk/src/bbmaracasvisuAnimationSphere.h | 63 ++++++++ 2 files changed, 238 insertions(+) create mode 100644 bbtk/src/bbmaracasvisuAnimationSphere.cxx create mode 100644 bbtk/src/bbmaracasvisuAnimationSphere.h diff --git a/bbtk/src/bbmaracasvisuAnimationSphere.cxx b/bbtk/src/bbmaracasvisuAnimationSphere.cxx new file mode 100644 index 0000000..e3555c2 --- /dev/null +++ b/bbtk/src/bbmaracasvisuAnimationSphere.cxx @@ -0,0 +1,175 @@ +#include "bbmaracasvisuAnimationSphere.h" +#include "bbcreaMaracasVisuPackage.h" + + +#include +#include +#include +#include +#include + + + +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,AnimationSphere) +BBTK_BLACK_BOX_IMPLEMENTATION(AnimationSphere,bbtk::AtomicBlackBox); + + +void AnimationSphere::Process() +{ + int iMin,iMax; + double px; + double py; + double pz; + double radio; + double spc[3]; + + if (sphereActor==NULL) + { + // Sphere + vtksphere = vtkSphereSource::New(); + vtksphere->SetThetaResolution (20); + vtksphere->SetPhiResolution (20); + vtksphere->SetRadius( 1 ); + + vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New(); + sphereMapper->SetInput( vtksphere->GetOutput() ); + + sphereActor = vtkActor::New(); + sphereActor->SetMapper(sphereMapper); + sphereActor->SetOrigin(0, 0, 0); + sphereActor->GetProperty()->SetColor( bbGetInputColour()[0] , bbGetInputColour()[1] , bbGetInputColour()[2] ); + sphereActor->GetProperty()->SetOpacity( bbGetInputOpacity() ); + } else { + bbGetInputRenderer()->RemoveActor( sphereActor ); + }// if (sphereActor + + + if (bbGetInputRenderer()!=NULL) + { + bbGetInputRenderer()->AddActor( sphereActor ); + } // if + + + if (bbGetInputRenderer()!=NULL) + { + spc[0]=spc[1]=spc[2]=1; + int i,size; + + if ( (bbGetInputIndex()==0) ){ + iMin=0; + iMax=bbGetInputlstPointX().size(); + } + else if ( bbGetInputIndex()<=(int)(bbGetInputlstIndexs().size()) ) + { + iMin = 0; + iMax = 0; + size = bbGetInputIndex(); + for (i=0;i=0){ + iMin = iMin + bbGetInputlstIndexs()[i-1]; + } + } + } else { + iMin=0; + iMax=-1; + } + + bbSetInputIndex(0); + + std::string newFileName; + + + for ( i=iMin ; iSetPosition( px,py,pz ); + vtksphere->SetRadius( radio ); + if ( bbGetInputTransform()!=NULL ) + { + sphereActor->SetUserTransform( bbGetInputTransform() ); + } + + + bbGetInputRenderer()->Render(); + bbGetInputRenderer()->GetRenderWindow()->Render(); + + if (i%bbGetInputStep()==0) + { + //writing file + std::stringstream strId; + strId << i; + std::string strtmp1 =strId.str(); + std::string strtmp2 = "00000"; + for (int iStr = 0; iStr<(int)(strtmp1.length()) ; iStr++ ) + { + strtmp2[ strtmp2.length()-1-iStr ] = strtmp1[ strtmp1.length()-1-iStr ]; + } + newFileName = "c:/temp/image"+strtmp2+".png"; + + vtkWindowToImageFilter *w2i; + vtkPNGWriter *png; + w2i = vtkWindowToImageFilter::New(); + png = vtkPNGWriter::New(); + w2i->SetInput( bbGetInputRenderer()->GetRenderWindow() ); + png->SetInput( w2i->GetOutput() ); + png->SetFileName( newFileName.c_str() ); + png->Write(); + png->Delete(); + w2i->Delete(); + } // if i%10 + } // for + } // if (bbGetInputRenderer() +} + + +void AnimationSphere::bbUserSetDefaultValues() +{ + sphereActor=NULL; + + bbSetInputRenderer(NULL); + + std::vector colour; + colour.push_back(1.0); + colour.push_back(0.0); + colour.push_back(0.0); + bbSetInputColour(colour); + + bbSetInputOpacity(1); + + std::vector lstInd; + lstInd.push_back(0); + std::vector lstX; + std::vector lstY; + std::vector lstZ; + std::vector lstR; + + bbSetInputTransform(NULL); + bbSetInputIndex(0); + bbSetInputStep(1); +} + + + //----------------------------------------------------------------- + void AnimationSphere::bbUserInitializeProcessing() + { + } + + //----------------------------------------------------------------- + void AnimationSphere::bbUserFinalizeProcessing() + { + } + + //----------------------------------------------------------------- + +} +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbmaracasvisuAnimationSphere.h b/bbtk/src/bbmaracasvisuAnimationSphere.h new file mode 100644 index 0000000..6b1716a --- /dev/null +++ b/bbtk/src/bbmaracasvisuAnimationSphere.h @@ -0,0 +1,63 @@ +#ifndef __bbmaracasvisuAnimationSphere_h_INCLUDED__ +#define __bbmaracasvisuAnimationSphere_h_INCLUDED__ +#include "bbtkAtomicBlackBox.h" +#include "iostream" + + +#include +#include +#include +#include + + +namespace bbcreaMaracasVisu +{ + +class /*BBTK_EXPORT*/ AnimationSphere + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(AnimationSphere,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(Renderer ,vtkRenderer*); + BBTK_DECLARE_INPUT(Index,int); + BBTK_DECLARE_INPUT(Step,int); + BBTK_DECLARE_INPUT(lstIndexs,std::vector); + BBTK_DECLARE_INPUT(lstPointX,std::vector); + BBTK_DECLARE_INPUT(lstPointY,std::vector); + BBTK_DECLARE_INPUT(lstPointZ,std::vector); + BBTK_DECLARE_INPUT(lstRadio ,std::vector); + BBTK_DECLARE_INPUT(Colour ,std::vector); + BBTK_DECLARE_INPUT(Opacity ,double); + BBTK_DECLARE_INPUT(Transform, vtkLinearTransform *); +// BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); + + vtkActor *sphereActor; + vtkSphereSource *vtksphere; + +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(AnimationSphere,bbtk::AtomicBlackBox); +BBTK_NAME("AnimationSphere"); +BBTK_AUTHOR("InfoTeam CREATIS-LRMN"); +BBTK_DESCRIPTION("Animation Sphere"); +BBTK_CATEGORY("Animation"); +BBTK_INPUT(AnimationSphere,Renderer,"Renderer",vtkRenderer*,""); +BBTK_INPUT(AnimationSphere,Index,"Indexs",int,""); +BBTK_INPUT(AnimationSphere,Step,"Step",int,""); +BBTK_INPUT(AnimationSphere,lstIndexs,"list of Indexs",std::vector,""); +BBTK_INPUT(AnimationSphere,lstPointX,"lstPointX",std::vector,""); +BBTK_INPUT(AnimationSphere,lstPointY,"lstPointY",std::vector,""); +BBTK_INPUT(AnimationSphere,lstPointZ,"lstPointZ",std::vector,""); +BBTK_INPUT(AnimationSphere,lstRadio,"lstRadio",std::vector,""); +BBTK_INPUT(AnimationSphere,Colour,"Colour",std::vector,""); +BBTK_INPUT(AnimationSphere,Opacity,"Opacity of the sphere",double,""); +BBTK_INPUT(AnimationSphere,Transform,"vtkTransform", vtkLinearTransform *,""); +//BBTK_OUTPUT(AnimationSphere,Out,"First output",double,""); +BBTK_END_DESCRIBE_BLACK_BOX(AnimationSphere); +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbmaracasvisuAnimationSphere_h_INCLUDED__ + -- 2.45.1