]> Creatis software - creaVtk.git/commitdiff
#3282 creaVtk Feature New Normal - PolyDataInfo
authorEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 24 Jul 2019 14:22:27 +0000 (16:22 +0200)
committerEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 24 Jul 2019 14:22:27 +0000 (16:22 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.h [new file with mode: 0644]
lib/creaVtk/vtkVectorsVisu.cpp
lib/creaVtk/vtkVectorsVisu.h

index 959c59c07ea56d4eff6eb8a54ed0762ba077277a..3939f547890db00092076fde792d500c178c19e7 100644 (file)
@@ -25,14 +25,17 @@ void GrayLevel::Process()
 //      (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')
 //      (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')
-    vtkImageData  *m_image  =  vtkImageData::New();
-    m_image = bbGetInputImage();
 
 
-    int grayLevel = 0;
-    std::vector<double> coord = bbGetInputCoordinate();
+//    vtkImageData  *m_image  =  vtkImageData::New();
+//    m_image = bbGetInputImage();
 
 
-       grayLevel = m_image->GetScalarComponentAsDouble(coord[0],coord[1],coord[2],0);
+    double grayLevel = -9999;
+    std::vector<double> coord = bbGetInputCoordinate();
 
 
+       if (bbGetInputImage()!=NULL)
+       {
+               grayLevel = bbGetInputImage()->GetScalarComponentAsDouble(coord[0],coord[1],coord[2],0);
+       }
        bbSetOutputGrayLevel(grayLevel);
     
 }
        bbSetOutputGrayLevel(grayLevel);
     
 }
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx
new file mode 100644 (file)
index 0000000..5aa1f2d
--- /dev/null
@@ -0,0 +1,97 @@
+//===== 
+// 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 "bbcreaVtkPolyDataInfo.h"
+#include "bbcreaVtkPackage.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PolyDataInfo)
+BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataInfo,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 PolyDataInfo::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')
+//    bbSetOutputOut( bbGetInputIn() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+  
+
+       if ( bbGetInputIn()!=NULL)
+       {
+               bbSetOutputNumberOfCells( bbGetInputIn()->GetNumberOfCells() );
+               bbSetOutputNumberOfLines(  bbGetInputIn()->GetNumberOfLines() );
+               bbSetOutputNumberOfPieces( bbGetInputIn()->GetNumberOfPieces() );
+               bbSetOutputNumberOfPoints(  bbGetInputIn()->GetNumberOfPoints() );
+               bbSetOutputNumberOfPolys( bbGetInputIn()->GetNumberOfPolys() );
+               bbSetOutputNumberOfStrips( bbGetInputIn()->GetNumberOfStrips() );
+               bbSetOutputNumberOfVerts( bbGetInputIn()->GetNumberOfVerts() );
+       } else {
+               bbSetOutputNumberOfCells(-1);
+               bbSetOutputNumberOfLines(-1);
+               bbSetOutputNumberOfPieces(-1);
+               bbSetOutputNumberOfPoints(-1);
+               bbSetOutputNumberOfPolys(-1);
+               bbSetOutputNumberOfStrips(-1);
+               bbSetOutputNumberOfVerts(-1);
+       }// if
+
+}
+//===== 
+// 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 PolyDataInfo::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+   bbSetInputIn(NULL);
+   bbSetOutputNumberOfCells(-9999);
+   bbSetOutputNumberOfLines(-9999);
+   bbSetOutputNumberOfPoints(-9999);
+   bbSetOutputNumberOfPieces(-9999);
+   bbSetOutputNumberOfPolys(-9999);
+   bbSetOutputNumberOfStrips(-9999);
+   bbSetOutputNumberOfVerts(-9999);
+}
+//===== 
+// 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 PolyDataInfo::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 PolyDataInfo::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/bbcreaVtkPolyDataInfo.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.h
new file mode 100644 (file)
index 0000000..b336172
--- /dev/null
@@ -0,0 +1,63 @@
+//===== 
+// 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 __bbcreaVtkPolyDataInfo_h_INCLUDED__
+#define __bbcreaVtkPolyDataInfo_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "vtkPolyData.h"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT PolyDataInfo
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(PolyDataInfo,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( In , vtkPolyData* );
+  BBTK_DECLARE_OUTPUT( NumberOfCells   , double );
+  BBTK_DECLARE_OUTPUT( NumberOfLines   , double );
+  BBTK_DECLARE_OUTPUT( NumberOfPoints  , double );
+  BBTK_DECLARE_OUTPUT( NumberOfPieces  , double );
+  BBTK_DECLARE_OUTPUT( NumberOfPolys   , double );
+  BBTK_DECLARE_OUTPUT( NumberOfStrips  , double );
+  BBTK_DECLARE_OUTPUT( NumberOfVerts   , double );
+  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(PolyDataInfo,bbtk::AtomicBlackBox);
+  BBTK_NAME("PolyDataInfo");
+  BBTK_AUTHOR("InfoDev");
+  BBTK_DESCRIPTION("No Description.");
+  BBTK_CATEGORY("empty");
+
+  BBTK_INPUT(PolyDataInfo,In,"vtkPolyData", vtkPolyData* ,"");
+
+  BBTK_OUTPUT(PolyDataInfo,NumberOfCells,"Number of Cells",double,"");
+  BBTK_OUTPUT(PolyDataInfo,NumberOfLines,"Number of Lines",double,"");
+  BBTK_OUTPUT(PolyDataInfo,NumberOfPoints,"Number of Points",double,"");
+  BBTK_OUTPUT(PolyDataInfo,NumberOfPieces,"Number of Pieces",double,"");
+  BBTK_OUTPUT(PolyDataInfo,NumberOfPolys,"Number of Ploys",double,"");
+  BBTK_OUTPUT(PolyDataInfo,NumberOfStrips,"Number of Strips",double,"");
+  BBTK_OUTPUT(PolyDataInfo,NumberOfVerts,"Number of Verts",double,"");
+
+BBTK_END_DESCRIBE_BLACK_BOX(PolyDataInfo);
+//===== 
+// 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 // __bbcreaVtkPolyDataInfo_h_INCLUDED__
+
index f88c650456a4fc8b3356af713ba27cc1f4d46206..248420aa929128151ccc75ed66031266fe8fecdb 100644 (file)
 #include "vtkDataObject.h"
 #include <vtkPointData.h>
 
 #include "vtkDataObject.h"
 #include <vtkPointData.h>
 
+#include <vtkAppendPolyData.h>
+
 //------------------------------------------------------------------------------
 vtkVectorsVisu::vtkVectorsVisu()
   :vtkVectorsTensorsVisuBase()
 {
 //------------------------------------------------------------------------------
 vtkVectorsVisu::vtkVectorsVisu()
   :vtkVectorsTensorsVisuBase()
 {
-       _vtkarrowsource         = vtkArrowSource::New();
-       _vtkglyph                       = NULL;
-       _vtklinesource          = vtkLineSource ::New();
-       _trans                          = vtkTransform  ::New();
+                                       _vtkarrowsource                 = vtkArrowSource::New();
+                                       _vtkglyph                               = NULL;
+                                       _vtklineGlyphPolyData   = NULL;
+                                       _trans                                  = vtkTransform  ::New();
 
 
+                       double  sizeCross                               = 0.05; 
+       
        double point1[3];
        double point2[3];
        double point1[3];
        double point2[3];
-       point1[0]=1;
-       point1[1]=0;
-       point1[2]=0;
-       point2[0]=-1;
-       point2[1]=0;
-       point2[2]=0;
-       _vtklinesource->SetPoint1( point1 );
-       _vtklinesource->SetPoint2( point2 );
+
+       point1[0] = 1;
+       point1[1] = 0;
+       point1[2] = 0;
+       point2[0] = -1;
+       point2[1] = 0;
+       point2[2] = 0;
+       vtkLineSource   *vtklinesource1                 = vtkLineSource ::New();
+       vtklinesource1->SetPoint1( point1 );
+       vtklinesource1->SetPoint2( point2 );
+       vtklinesource1->Update();
+
+       point1[0] = 0;
+       point1[1] = sizeCross;
+       point1[2] = 0;
+       point2[0] = 0;
+       point2[1] = -sizeCross;
+       point2[2] = 0;
+       vtkLineSource   *vtklinesource2                 = vtkLineSource ::New();
+       vtklinesource2->SetPoint1( point1 );
+       vtklinesource2->SetPoint2( point2 );
+       vtklinesource2->Update();
+
+       point1[0] = 0;
+       point1[1] = 0;
+       point1[2] = sizeCross;
+       point2[0] = 0;
+       point2[1] = 0;
+       point2[2] = -sizeCross;
+       vtkLineSource   *vtklinesource3                 = vtkLineSource ::New();
+       vtklinesource3->SetPoint1( point1 );
+       vtklinesource3->SetPoint2( point2 );
+       vtklinesource3->Update();
+       
+       
+       vtkAppendPolyData *appendPolyData = vtkAppendPolyData::New();
+       appendPolyData->AddInputData( vtklinesource1->GetOutput() );
+       appendPolyData->AddInputData( vtklinesource2->GetOutput() );
+       appendPolyData->AddInputData( vtklinesource3->GetOutput() );
+       appendPolyData->Update();
+       _vtklineGlyphPolyData = appendPolyData->GetOutput();
 }
 
 //------------------------------------------------------------------------------
 }
 
 //------------------------------------------------------------------------------
@@ -99,10 +136,9 @@ void vtkVectorsVisu::Process()
        #endif
                                } else {                                                                                                // source Line
        #if VTK_MAJOR_VERSION <= 5
        #endif
                                } else {                                                                                                // source Line
        #if VTK_MAJOR_VERSION <= 5
-                                       _vtkglyph->SetSource( _vtklinesource->GetOutput() );    
+                                       _vtkglyph->SetSource( _vtklineGlyphPolyData );          
        #else
        #else
-                                       _vtklinesource->Update();
-                                       _vtkglyph->SetSourceData( _vtklinesource->GetOutput() );        
+                                       _vtkglyph->SetSourceData( _vtklineGlyphPolyData );      
        #endif
                                }
                     _vtkglyph->SetScaleModeToScaleByVector();
        #endif
                                }
                     _vtkglyph->SetScaleModeToScaleByVector();
@@ -166,7 +202,7 @@ void vtkVectorsVisu::Process()
        //                      _pdm->SetColorModeToDefault();
        //                       _pdm->SetColorModeToDirectScalars();  // NOT compile
        //                      _pdm->SetScalarModeToUsePointFieldData();
        //                      _pdm->SetColorModeToDefault();
        //                       _pdm->SetColorModeToDirectScalars();  // NOT compile
        //                      _pdm->SetScalarModeToUsePointFieldData();
-                               _pdm->ImmediateModeRenderingOn();   // obsolete
+//                             _pdm->ImmediateModeRenderingOn();   // obsolete
                             _pdm->SetLookupTable( _externalLut );
                             _pdm->SelectColorArray( "angle" );
                        }  // if _externalLut
                             _pdm->SetLookupTable( _externalLut );
                             _pdm->SelectColorArray( "angle" );
                        }  // if _externalLut
index ff5547ac62b5dea49d79ed73290e98a1ef8b6320..c9a34b099540943a9e4d3bc527e8b280eb4241f5 100644 (file)
@@ -70,7 +70,7 @@ protected:
 //---------------------------------------------
 private:
        vtkArrowSource  *_vtkarrowsource;
 //---------------------------------------------
 private:
        vtkArrowSource  *_vtkarrowsource;
-       vtkLineSource   *_vtklinesource;
+       vtkPolyData             *_vtklineGlyphPolyData;
        vtkGlyph3D              *_vtkglyph;
        vtkTransform    *_trans; 
 };
        vtkGlyph3D              *_vtkglyph;
        vtkTransform    *_trans; 
 };