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)
4 #include "bbcreaVtkGlyphPolyDataNormals.h"
5 #include "bbcreaVtkPackage.h"
7 #include "vtkProperty.h"
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,GlyphPolyDataNormals)
14 BBTK_BLACK_BOX_IMPLEMENTATION(GlyphPolyDataNormals,bbtk::AtomicBlackBox);
16 // 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)
18 void GlyphPolyDataNormals::Process()
21 // THE MAIN PROCESSING METHOD BODY
22 // Here we simply set the input 'In' value to the output 'Out'
23 // And print out the output value
24 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
25 // void bbSet{Input|Output}NAME(const TYPE&)
26 // const TYPE& bbGet{Input|Output}NAME() const
28 // * NAME is the name of the input/output
29 // (the one provided in the attribute 'name' of the tag 'input')
30 // * TYPE is the C++ type of the input/output
31 // (the one provided in the attribute 'type' of the tag 'input')
37 //Mask Ratio 1-100 Done
38 //Type of Glyph 1-Arrow 2-Line
41 if(bbGetInputIn() == NULL)
43 printf("Warnning! GlyphPolyDataNormals::Process: Missing input PolyData\n");
44 bbSetOutputOut( NULL );
46 if(bbGetInputRenderer() != NULL)
48 if( (actorAdded==true) && (bbGetInputActive()==true) )
50 bbGetInputRenderer()->RemoveActor(normalsActor);
55 } else if(bbGetInputRenderer() == NULL) {
56 printf("Warnning! GlyphPolyDataNormals::Process: Missing Renderer\n");
57 bbSetOutputOut( NULL );
60 arrow->SetTipResolution(4);
61 arrow->SetTipLength(0.5);
62 arrow->SetTipRadius(0.2 * bbGetInputGlyphType());
66 ptMask->SetInputData(bbGetInputIn());
67 ptMask->SetOnRatio(bbGetInputMaskRatio());
68 ptMask->RandomModeOn();
71 glyph->SetSourceData(arrow->GetOutput());
72 glyph->SetInputData(ptMask->GetOutput());
74 //glyph->SetInputData(bbGetInputIn());
75 glyph->SetVectorModeToUseNormal();
76 glyph->SetScaleFactor(bbGetInputSize());
77 glyph->SetColorModeToColorByVector();
78 glyph->SetScaleModeToScaleByVector();
82 normalsMapper->SetInputData(glyph->GetOutput());
83 normalsActor->SetMapper(normalsMapper);
84 normalsActor->GetProperty()->SetOpacity(bbGetInputOpacity());
85 normalsActor->GetProperty()->SetColor(bbGetInputColor()[0],
87 bbGetInputColor()[2]);
89 if(bbGetInputRenderer() != NULL)
91 if( (actorAdded==true) && !(bbGetInputActive()==true) )
93 bbGetInputRenderer()->RemoveActor(normalsActor);
95 } else if(bbGetInputActive() && !actorAdded) {
96 bbGetInputRenderer()->AddActor(normalsActor);
101 bbSetOutputOut( normalsActor );
106 // 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)
108 void GlyphPolyDataNormals::bbUserSetDefaultValues()
111 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
112 // Here we initialize the input 'In' to 0
114 bbSetInputOpacity(1);
115 bbSetInputActive(true);
116 bbSetInputMaskRatio(10);
117 std::vector<double> color;
118 color.push_back(0.0);
119 color.push_back(0.0);
120 color.push_back(0.5);
121 bbSetInputColor(color);
123 bbSetInputGlyphType(1);
124 bbSetInputRenderer(NULL);
125 bbSetOutputOut(NULL);
129 // 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)
131 void GlyphPolyDataNormals::bbUserInitializeProcessing()
134 // THE INITIALIZATION METHOD BODY :
136 // but this is where you should allocate the internal/output pointers
138 arrow = vtkArrowSource::New();
139 ptMask = vtkMaskPoints::New();
140 glyph = vtkGlyph3D::New();
141 normalsMapper = vtkPolyDataMapper::New();
142 normalsActor = vtkActor::New();
146 // 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)
148 void GlyphPolyDataNormals::bbUserFinalizeProcessing()
151 // THE FINALIZATION METHOD BODY :
153 // but this is where you should desallocate the internal/output pointers
158 normalsMapper->Delete();
159 normalsActor->Delete();
164 normalsMapper = NULL;
168 // EO namespace bbcreaVtk