]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkStreamLineNumeration.cxx
#2453 creaVtk Feature New Normal - Stream Lines segmentation by Scalars
[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
24 // THE MAIN PROCESSING METHOD BODY
25 //   Here we simply set the input 'In' value to the output 'Out'
26 //   And print out the output value
27 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
28 //    void bbSet{Input|Output}NAME(const TYPE&)
29 //    const TYPE& bbGet{Input|Output}NAME() const 
30 //    Where :
31 //    * NAME is the name of the input/output
32 //      (the one provided in the attribute 'name' of the tag 'input')
33 //    * TYPE is the C++ type of the input/output
34 //      (the one provided in the attribute 'type' of the tag 'input')
35
36         std::string namascalararray="creaNumeration";
37
38         if (bbGetInputStreamLinesIn()!=NULL)
39         {
40                 vtkIdList               *_vtkidlist             = vtkIdList::New();
41                 vtkCellArray    *vtkcellarray           = bbGetInputStreamLinesIn()->GetLines();
42                 long int                nLinesCell                      = vtkcellarray->GetNumberOfCells(); 
43                 long int                ii,iLine;
44                 long int                numberofids;
45
46
47                 vtkDoubleArray  *numeration                     = vtkDoubleArray::New();
48                 numeration->SetName( namascalararray.c_str() );                 
49                 numeration->SetNumberOfComponents(1); 
50                 numeration->SetNumberOfTuples(nLinesCell);
51
52                 // FOR EACH LINE
53                 ii=0;
54                 for ( iLine=0 ; iLine<nLinesCell ; iLine++ )
55                 {
56                         vtkcellarray->GetCell(ii, _vtkidlist );
57                         numberofids = _vtkidlist->GetNumberOfIds();
58                         numeration->SetTuple1(iLine, numberofids);
59                         ii=ii+numberofids+1;
60                 } // for iLine
61
62                 bbGetInputStreamLinesIn()->GetPointData()->AddArray( numeration );
63         } // if bbGetInputStreamLinesIn()
64
65         bbSetOutputStreamLinesOut( bbGetInputStreamLinesIn() );
66         bbSetOutputNameOfScalarArray( namascalararray );
67     
68 }
69
70 //===== 
71 // 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)
72 //===== 
73 void StreamLineNumeration::bbUserSetDefaultValues()
74 {
75 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
76 //    Here we initialize the input 'In' to 0
77         bbSetInputStreamLinesIn( NULL );
78
79 }
80 //===== 
81 // 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)
82 //===== 
83 void StreamLineNumeration::bbUserInitializeProcessing()
84 {
85
86 //  THE INITIALIZATION METHOD BODY :
87 //    Here does nothing 
88 //    but this is where you should allocate the internal/output pointers 
89 //    if any 
90
91   
92 }
93 //===== 
94 // 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)
95 //===== 
96 void StreamLineNumeration::bbUserFinalizeProcessing()
97 {
98
99 //  THE FINALIZATION METHOD BODY :
100 //    Here does nothing 
101 //    but this is where you should desallocate the internal/output pointers 
102 //    if any
103   
104 }
105 }
106 // EO namespace bbcreaVtk
107
108