From edfb09c02aa9dfb052b77b3e5a8e717900d3aab4 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Tue, 3 May 2011 07:51:48 +0000 Subject: [PATCH 1/1] no message --- bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx | 123 ++++++++++--------- bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h | 1 + bbtk/src/bbmaracasvisuAxeVolume.cxx | 56 +++++---- 3 files changed, 96 insertions(+), 84 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx index e6e860f..8f2a3ce 100644 --- a/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx +++ b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx @@ -97,26 +97,6 @@ void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube) sphereActorEnd->SetOrigin( 0,0,0 ); sphereActorEnd->SetPosition(bbGetInputlstPointX()[i]*spc[0], bbGetInputlstPointY()[i]*spc[1], bbGetInputlstPointZ()[i]*spc[2] ); - - // color - double r,g,b; - if ( (iTube*3+1) < (int)(bbGetInputColour().size()) ) - { - r = bbGetInputColour()[0+iTube*3]; - g = bbGetInputColour()[1+iTube*3]; - b = bbGetInputColour()[2+iTube*3]; - } else { - r = (rand() % 100) / 100.0; - g = (rand() % 100) / 100.0; - b = (rand() % 100) / 100.0; - } - r = bbGetInputColour()[0]; - g = bbGetInputColour()[1]; - b = bbGetInputColour()[2]; - - - - vtkSmartPointer tube = vtkSmartPointer::New(); //EED vtkTubeFilter *tube = vtkTubeFilter::New(); tube->SetInput(polyData); @@ -131,26 +111,11 @@ void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube) // vtkSmartPointer actor =vtkSmartPointer::New(); vtkSmartPointer actor = vtkSmartPointer::New(); -//EED vtkActor *actor = vtkActor::New(); actor->SetMapper(mapper); - actor->GetProperty()->SetColor( r,g,b ); - actor->GetProperty()->SetOpacity( bbGetInputOpacity() ); - sphereActorStart->GetProperty()->SetColor( r,g,b );; - sphereActorEnd->GetProperty()->SetColor( r,g,b );; - sphereActorStart->GetProperty()->SetOpacity( bbGetInputOpacity() ); - sphereActorEnd->GetProperty()->SetOpacity( bbGetInputOpacity() ); vecVtkActors.push_back( actor ); - vecVtkActors.push_back( sphereActorStart ); vecVtkActors.push_back( sphereActorEnd ); - - - if ( bbGetInputTransform()!=NULL ) - { - actor->SetUserTransform( bbGetInputTransform() ); - sphereActorStart->SetUserTransform( bbGetInputTransform() ); - sphereActorEnd->SetUserTransform( bbGetInputTransform() ); - } + vecVtkActors.push_back( sphereActorStart ); // Interface Update // Interface Update if (bbGetInputRenderer()!=NULL ) @@ -162,6 +127,64 @@ void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube) } +void TubeTreeFilter::SetGraphicProperties() +{ + int iTube,sizeLstAxis=bbGetInputlstIndexs().size(); + + vtkActor *actorTube; + vtkActor *actorSpherEnd; + vtkActor *actorSpherStart; + + + double r,g,b; + r = bbGetInputColour()[0]; + g = bbGetInputColour()[1]; + b = bbGetInputColour()[2]; + for (iTube=0 ; iTubeGetProperty()->SetOpacity( bbGetInputOpacity() ); + actorSpherEnd->GetProperty()->SetOpacity( bbGetInputOpacity() ); + actorSpherStart->GetProperty()->SetOpacity( bbGetInputOpacity() ); + + //Set Colour + if ( bbGetInputTransform()!=NULL ) + { + actorTube->SetUserTransform( bbGetInputTransform() ); + actorSpherEnd->SetUserTransform( bbGetInputTransform() ); + actorSpherStart->SetUserTransform( bbGetInputTransform() ); + } + + if (bbGetInputColourLaw()==1) // One solide colour + { + // + } + + if (bbGetInputColourLaw()==2) // color for differents tubes + { + if ( (iTube*3+1) < (int)(bbGetInputColour().size()) ) + { + r = bbGetInputColour()[0+iTube*3]; + g = bbGetInputColour()[1+iTube*3]; + b = bbGetInputColour()[2+iTube*3]; + } else { + r = (rand() % 100) / 100.0; + g = (rand() % 100) / 100.0; + b = (rand() % 100) / 100.0; + } + } + + actorTube->GetProperty()->SetColor( r,g,b ); + actorSpherEnd->GetProperty()->SetColor( r,g,b ); + actorSpherStart->GetProperty()->SetColor( r,g,b ); + } // for +} + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== @@ -205,31 +228,9 @@ void TubeTreeFilter::Process() bbSetOutputOutTube( vecVtkActors[ bbGetInputiTube()*3 ] ); } else { printf("TubeTreeFilter .ERROR. missing index vector...\n"); - } - - } - - double r,g,b; - r = bbGetInputColour()[0]; - g = bbGetInputColour()[1]; - b = bbGetInputColour()[2]; - for (iTube=0 ; iTubeGetProperty()->SetOpacity( bbGetInputOpacity() ); - actor2->GetProperty()->SetOpacity( bbGetInputOpacity() ); - actor3->GetProperty()->SetOpacity( bbGetInputOpacity() ); - if (bbGetInputColourLaw()==1) - { - actor1->GetProperty()->SetColor( r,g,b ); - actor2->GetProperty()->SetColor( r,g,b ); - actor3->GetProperty()->SetColor( r,g,b ); - } - } // for - + }// vector Actor size + } + SetGraphicProperties(); printf("EED TubeTreeFilter::Process end \n"); } diff --git a/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h index c6ee910..d819ed7 100644 --- a/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h +++ b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h @@ -49,6 +49,7 @@ class bbcreaMaracasVisu_EXPORT TubeTreeFilter private: std::vector vecVtkActors; void DrawOneTube(int iGeneral,int numPoints, int iTube); + void SetGraphicProperties(); int oldLstSize; //===== diff --git a/bbtk/src/bbmaracasvisuAxeVolume.cxx b/bbtk/src/bbmaracasvisuAxeVolume.cxx index de06d97..17f2381 100644 --- a/bbtk/src/bbmaracasvisuAxeVolume.cxx +++ b/bbtk/src/bbmaracasvisuAxeVolume.cxx @@ -7,7 +7,7 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,AxeVolume) BBTK_BLACK_BOX_IMPLEMENTATION(AxeVolume,bbtk::AtomicBlackBox); void AxeVolume::Process() { - + printf("EED AxeVolume::Process start \n"); if ( mimage!=NULL ) @@ -21,12 +21,22 @@ void AxeVolume::Process() int sizeY=ext[3]-ext[2]; int sizeZ=ext[5]-ext[4]; - mimage = vtkImageData::New(); + double spc[3]; + bbGetInputIn()->GetSpacing(spc); + double invSpc[3]; + invSpc[0] = 1/spc[0]; + invSpc[1] = 1/spc[1]; + invSpc[2] = 1/spc[2]; + +printf("EED AxeVolume::Process invSpc %f %f %f\n",invSpc[0],invSpc[1],invSpc[2] ); + + mimage = vtkImageData::New(); mimage->SetDimensions(sizeX,sizeY,sizeZ); mimage->SetOrigin(0,0,0); mimage->SetExtent( 0 , sizeX-1 , 0 , sizeY-1 , 0, sizeZ-1 ); mimage->SetWholeExtent( 0 , sizeX-1 , 0 , sizeY-1 , 0, sizeZ-1 ); mimage->SetScalarTypeToUnsignedShort(); + mimage->SetSpacing(spc); mimage->AllocateScalars(); @@ -53,34 +63,34 @@ void AxeVolume::Process() { if (bbGetInputlstPointR().size()>=1) { - r = bbGetInputlstPointR()[ bbGetInputlstPointR().size()-1 ]; + r = bbGetInputlstPointR()[ bbGetInputlstPointR().size()-1 ] * invSpc[0]; } else { r = 1; } } else { - r = bbGetInputlstPointR()[ iAxe ]; + r = bbGetInputlstPointR()[ iAxe ]* invSpc[0]; } - px = bbGetInputlstPointX()[iAxe]; - py = bbGetInputlstPointY()[iAxe]; - pz = bbGetInputlstPointZ()[iAxe]; -// printf("AxeVolume::Process %d -> %f, %f, %f\n",iAxe, px,py,pz); + px = bbGetInputlstPointX()[iAxe] * invSpc[0]; + py = bbGetInputlstPointY()[iAxe] * invSpc[1]; + pz = bbGetInputlstPointZ()[iAxe] * invSpc[2]; + printf("AxeVolume::Process %d -> %f, %f, %f,%f\n",iAxe, px,py,pz,r); px1 = px - r; py1 = py - r; pz1 = pz - r; px2 = px + r; py2 = py + r; pz2 = pz + r; - rr=r*r; + rr=r*r; - for ( i=px1 ; i<=px2 ; i++ ) + for ( i=px1 ; i<=px2 ; i++ ) { rx = i - px; rx = rx*rx; - for ( j=py1 ; j=0) && (i=0) && (j=0) && (kGetScalarPointer (i, j, k); @@ -91,38 +101,38 @@ void AxeVolume::Process() if ( rx + ry + rz <= rr ) { *p=255; - } + } } // *p==0 } // inside point } //for k } //for j } //for i } // for iAxe - bbSetOutputOut( mimage ); - + bbSetOutputOut( mimage ); + printf("EED AxeVolume::Process end \n"); } - //----------------------------------------------------------------- + //----------------------------------------------------------------- void AxeVolume::bbUserSetDefaultValues() { mimage=NULL; } - - //----------------------------------------------------------------- + + //----------------------------------------------------------------- void AxeVolume::bbUserInitializeProcessing() { } - - //----------------------------------------------------------------- + + //----------------------------------------------------------------- void AxeVolume::bbUserFinalizeProcessing() { } - - //----------------------------------------------------------------- - + + //----------------------------------------------------------------- + } // EO namespace bbcreaMaracasVisu -- 2.45.1