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