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){
42 printf("Warnning! GlyphPolyDataNormals::Process: Missing input PolyData\n");
43 bbSetOutputOut( NULL );
45 else if(bbGetInputRenderer() == NULL){
46 printf("Warnning! GlyphPolyDataNormals::Process: Missing Renderer\n");
47 bbSetOutputOut( NULL );
51 arrow->SetTipResolution(16);
52 arrow->SetTipLength(0.5);
53 arrow->SetTipRadius(0.2 * bbGetInputGlyphType());
57 ptMask->SetInputData(bbGetInputIn());
58 ptMask->SetOnRatio(bbGetInputMaskRatio());
59 ptMask->RandomModeOn();
62 glyph->SetSourceData(arrow->GetOutput());
63 glyph->SetInputData(ptMask->GetOutput());
65 //glyph->SetInputData(bbGetInputIn());
66 glyph->SetVectorModeToUseNormal();
67 glyph->SetScaleFactor(bbGetInputSize());
68 glyph->SetColorModeToColorByVector();
69 glyph->SetScaleModeToScaleByVector();
73 normalsMapper->SetInputData(glyph->GetOutput());
74 normalsActor->SetMapper(normalsMapper);
75 normalsActor->GetProperty()->SetOpacity(bbGetInputOpacity());
76 normalsActor->GetProperty()->SetColor(bbGetInputColor()[0],
78 bbGetInputColor()[2]);
80 if(bbGetInputRenderer() != NULL){
81 if(actorAdded && !bbGetInputActive()){
82 bbGetInputRenderer()->RemoveActor(normalsActor);
85 else if(bbGetInputActive() && !actorAdded){
86 bbGetInputRenderer()->AddActor(normalsActor);
91 bbSetOutputOut( normalsActor );
96 // 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)
98 void GlyphPolyDataNormals::bbUserSetDefaultValues()
101 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
102 // Here we initialize the input 'In' to 0
104 bbSetInputOpacity(1);
105 bbSetInputActive(false);
106 bbSetInputMaskRatio(10);
107 std::vector<double> color;
108 color.push_back(0.0);
109 color.push_back(0.0);
110 color.push_back(0.5);
111 bbSetInputColor(color);
113 bbSetInputGlyphType(1);
114 bbSetInputRenderer(NULL);
115 bbSetOutputOut(NULL);
119 // 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)
121 void GlyphPolyDataNormals::bbUserInitializeProcessing()
124 // THE INITIALIZATION METHOD BODY :
126 // but this is where you should allocate the internal/output pointers
128 arrow = vtkArrowSource::New();
129 ptMask = vtkMaskPoints::New();
130 glyph = vtkGlyph3D::New();
131 normalsMapper = vtkPolyDataMapper::New();
132 normalsActor = vtkActor::New();
136 // 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)
138 void GlyphPolyDataNormals::bbUserFinalizeProcessing()
141 // THE FINALIZATION METHOD BODY :
143 // but this is where you should desallocate the internal/output pointers
148 normalsMapper->Delete();
149 normalsActor->Delete();
154 normalsMapper = NULL;
158 // EO namespace bbcreaVtk