From: espinosa Date: Mon, 13 Jul 2015 15:52:46 +0000 (+0200) Subject: #2671 creaVtk Feature New Normal - VectorsExtraction X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=cf3087440ef51f6ed4bfd1cdda5b8a14148bc51d;p=creaVtk.git #2671 creaVtk Feature New Normal - VectorsExtraction --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkGenerateArrowSource.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkGenerateArrowSource.cxx new file mode 100644 index 0000000..2d592e2 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkGenerateArrowSource.cxx @@ -0,0 +1,80 @@ +//===== +// 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) +//===== +#include "bbcreaVtkGenerateArrowSource.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,GenerateArrowSource) +BBTK_BLACK_BOX_IMPLEMENTATION(GenerateArrowSource,bbtk::AtomicBlackBox); +//===== +// 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) +//===== +void GenerateArrowSource::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + + vtkArrowSource *arrowSource = vtkArrowSource::New(); + + arrowSource->SetTipResolution(3); + //arrowSource->SetTipRadius(1.0); + //arrowSource->SetTipLength(1.0); + arrowSource->SetShaftRadius(0.04); + arrowSource->Update(); + + bbSetOutputArrowSource(arrowSource->GetOutput()); + + +} +//===== +// 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) +//===== +void GenerateArrowSource::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + // bbSetInputIn(0); + +} +//===== +// 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) +//===== +void GenerateArrowSource::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +//===== +// 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) +//===== +void GenerateArrowSource::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkGenerateArrowSource.h b/bbtk_creaVtk_PKG/src/bbcreaVtkGenerateArrowSource.h new file mode 100644 index 0000000..9ecd02a --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkGenerateArrowSource.h @@ -0,0 +1,49 @@ +//===== +// 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) +//===== +#ifndef __bbcreaVtkGenerateArrowSource_h_INCLUDED__ +#define __bbcreaVtkGenerateArrowSource_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkArrowSource.h" +#include "vtkPolyData.h" +#include "vtkActor.h" + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT GenerateArrowSource + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(GenerateArrowSource,bbtk::AtomicBlackBox); +//===== +// 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) +//===== + BBTK_DECLARE_INPUT(Point,std::vector); + BBTK_DECLARE_OUTPUT(ArrowSource,vtkPolyData*); + BBTK_PROCESS(Process); + void Process(); +//===== +// 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) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(GenerateArrowSource,bbtk::AtomicBlackBox); +BBTK_NAME("GenerateArrowSource"); +BBTK_AUTHOR("Monica ESPINOSA"); +BBTK_DESCRIPTION("No Description."); +BBTK_CATEGORY("empty"); +BBTK_INPUT(GenerateArrowSource,Point,"Coordinate of Point",std::vector,""); +BBTK_OUTPUT(GenerateArrowSource,ArrowSource,"Arrow Representation",vtkPolyData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(GenerateArrowSource); +//===== +// 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) +//===== +} +// EO namespace bbcreaVtk + +#endif // __bbcreaVtkGenerateArrowSource_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx index f26075e..e753ae3 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx @@ -5,6 +5,7 @@ #include "bbcreaVtkPackage.h" #include "vtkDoubleArray.h" + namespace bbcreaVtk { @@ -31,24 +32,46 @@ void VectorsExtraction::Process() if(bbGetInputVectorsFieldImage() != NULL ) { - vtkImageData* m_VectorImage = bbGetInputVectorsFieldImage(); + vtkImageData *m_VectorImage = bbGetInputVectorsFieldImage(); + vtkIdType m_idType; + vtkDoubleArray *velocity = vtkDoubleArray::New(); + + std::vector coord = bbGetInputCoordinates(); + std::vector vec; + + double ang1 = 0;//Angle 1 + double ang2 = 0;//ANgle 2 + + // double *v = static_cast (m_VectorImage->GetScalarPointer(coord[0],coord[1],coord[2])); - std::vector coord = bbGetInputCoordinates(); - vtkDoubleArray* velocity = vtkDoubleArray::New(); + //Find coordinate into the image + m_idType = m_VectorImage->FindPoint(coord[0],coord[1],coord[2]); + std::cout << m_idType; + + //Recuperate vector of vectorFieldImage velocity = vtkDoubleArray::SafeDownCast(m_VectorImage->GetPointData()->GetArray("velocity")); + velocity->Print(std::cout); + + std::cout<< "# components velocity: " << velocity->GetNumberOfComponents()<GetNumberOfTuples()<GetComponent(m_idType,0); + vec[1] = velocity->GetComponent(m_idType,1); + vec[2] = velocity->GetComponent(m_idType,2); + + std::cout << "velocity :" << vec[0] << "," <GetNumberOfComponents()<Print(std::cout); bbSetOutputAngle1(ang1); bbSetOutputAngle2(ang2); + bbSetOutputVector(vec); }// if image != NULL diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.h b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.h index 246e09b..621ef3a 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.h @@ -41,6 +41,7 @@ BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); BBTK_INPUT(VectorsExtraction,Coordinates,"Coordinates (x,y,z)",std::vector,""); BBTK_INPUT(VectorsExtraction,VectorsFieldImage,"Image of Vectors Field",vtkImageData*,""); +BBTK_OUTPUT(VectorsExtraction,Vector,"",std::vector,""); BBTK_OUTPUT(VectorsExtraction,Angle1,"Angle 1 (Helix Angle)",double,""); BBTK_OUTPUT(VectorsExtraction,Angle2,"Angle 2 (Transversal Angle)",double,""); BBTK_END_DESCRIBE_BLACK_BOX(VectorsExtraction);