]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkStreamLineNumeration.cxx
#3110 creaVtk Bug New Normal - branch vtk7itk4 compilation with vtk7
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkStreamLineNumeration.cxx
1 //===== 
2 // 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)
3 //===== 
4 #include "bbcreaVtkStreamLineNumeration.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include <vtkCellArray.h>
8 #include <vtkPointData.h>
9 #include <vtkDoubleArray.h>
10 #include <vtkPolyData.h>
11 #include "vtkIdList.h"
12
13 namespace bbcreaVtk
14 {
15
16 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,StreamLineNumeration)
17 BBTK_BLACK_BOX_IMPLEMENTATION(StreamLineNumeration,bbtk::AtomicBlackBox);
18 //===== 
19 // 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)
20 //===== 
21 void StreamLineNumeration::Process()
22 {
23 // THE MAIN PROCESSING METHOD BODY
24 //   Here we simply set the input 'In' value to the output 'Out'
25 //   And print out the output value
26 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
27 //    void bbSet{Input|Output}NAME(const TYPE&)
28 //    const TYPE& bbGet{Input|Output}NAME() const 
29 //    Where :
30 //    * NAME is the name of the input/output
31 //      (the one provided in the attribute 'name' of the tag 'input')
32 //    * TYPE is the C++ type of the input/output
33 //      (the one provided in the attribute 'type' of the tag 'input')
34         std::string namascalararray="creaNumeration";
35         if (bbGetInputStreamLinesIn()!=NULL)
36         {
37                 vtkIdList               *_vtkidlist             = vtkIdList::New();
38                 vtkCellArray    *vtkcellarray           = bbGetInputStreamLinesIn()->GetLines();
39                 long int                nLinesCell                      = vtkcellarray->GetNumberOfCells(); 
40                 long int                ii,iLine;
41                 long int                numberofids;
42                 vtkDoubleArray  *numeration                     = vtkDoubleArray::New();
43                 numeration->SetName( namascalararray.c_str() );                 
44                 numeration->SetNumberOfComponents(1); 
45                 numeration->SetNumberOfTuples(nLinesCell);
46                 // FOR EACH LINE
47                 ii=0;
48                 for ( iLine=0 ; iLine<nLinesCell ; iLine++ )
49                 {
50                         vtkcellarray->GetCell(ii, _vtkidlist );
51                         numberofids = _vtkidlist->GetNumberOfIds();
52                         numeration->SetTuple1(iLine, numberofids);
53                         ii=ii+numberofids+1;
54                 } // for iLine
55
56                 bbGetInputStreamLinesIn()->GetPointData()->AddArray( numeration );
57                 bbGetInputStreamLinesIn()->GetPointData()->Modified( );
58                 bbGetInputStreamLinesIn()->GetPointData()->Update( );
59         } // if bbGetInputStreamLinesIn()
60         bbSetOutputStreamLinesOut( bbGetInputStreamLinesIn() );
61         bbSetOutputNameOfScalarArray( namascalararray );
62 }
63
64 //===== 
65 // 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)
66 //===== 
67 void StreamLineNumeration::bbUserSetDefaultValues()
68 {
69 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
70 //    Here we initialize the input 'In' to 0
71         bbSetInputStreamLinesIn( NULL );
72 }
73
74 //===== 
75 // 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)
76 //===== 
77 void StreamLineNumeration::bbUserInitializeProcessing()
78 {
79 //  THE INITIALIZATION METHOD BODY :
80 //    Here does nothing 
81 //    but this is where you should allocate the internal/output pointers 
82 //    if any  
83 }
84
85 //===== 
86 // 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)
87 //===== 
88 void StreamLineNumeration::bbUserFinalizeProcessing()
89 {
90 //  THE FINALIZATION METHOD BODY :
91 //    Here does nothing 
92 //    but this is where you should desallocate the internal/output pointers 
93 //    if any  
94 }
95
96 } // EO namespace bbcreaVtk
97
98