1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #include "vvGlyphSource.h"
20 #include "vtkCellArray.h"
21 #include "vtkCellData.h"
23 #include "vtkInformation.h"
24 #include "vtkInformationVector.h"
25 #include "vtkObjectFactory.h"
26 #include "vtkPolyData.h"
27 #include "vtkUnsignedCharArray.h"
29 vtkStandardNewMacro(vvGlyphSource);
32 //----------------------------------------------------------------------------
33 int vvGlyphSource::RequestData(
34 vtkInformation *vtkNotUsed(request),
35 vtkInformationVector **vtkNotUsed(inputVector),
36 vtkInformationVector *outputVector)
38 // get the info object
39 vtkInformation *outInfo = outputVector->GetInformationObject(0);
42 vtkPolyData *output = vtkPolyData::SafeDownCast(
43 outInfo->Get(vtkDataObject::DATA_OBJECT()));
46 vtkPoints *pts = vtkPoints::New();
48 vtkCellArray *verts = vtkCellArray::New();
49 verts->Allocate(verts->EstimateSize(1,1),1);
50 vtkCellArray *lines = vtkCellArray::New();
51 lines->Allocate(lines->EstimateSize(4,2),2);
52 vtkCellArray *polys = vtkCellArray::New();
53 polys->Allocate(polys->EstimateSize(1,4),4);
54 vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New();
55 colors->SetNumberOfComponents(3);
56 colors->Allocate(2,2);
62 int filled = this->Filled;
64 this->CreateDash(pts,lines,polys,colors,this->Scale2);
65 this->Filled = filled;
68 int filled = this->Filled;
70 this->CreateCross(pts,lines,polys,colors,this->Scale2);
71 this->Filled = filled;
74 //Call the right function
75 switch (this->GlyphType) {
78 case VTK_VERTEX_GLYPH:
79 this->CreateVertex(pts,verts,colors);
82 this->CreateDash(pts,lines,polys,colors,this->Scale);
85 this->CreateCross(pts,lines,polys,colors,this->Scale);
87 case VTK_THICKCROSS_GLYPH:
88 this->CreateThickCross(pts,lines,polys,colors);
90 case VTK_TRIANGLE_GLYPH:
91 this->CreateTriangle(pts,lines,polys,colors);
93 case VTK_SQUARE_GLYPH:
94 this->CreateSquare(pts,lines,polys,colors);
96 case VTK_CIRCLE_GLYPH:
97 this->CreateCircle(pts,lines,polys,colors);
99 case VTK_DIAMOND_GLYPH:
100 this->CreateDiamond(pts,lines,polys,colors);
102 case VTK_ARROW_GLYPH:
103 this->CreateArrow(pts,lines,polys,colors);
105 case VTK_THICKARROW_GLYPH:
106 this->CreateThickArrow(pts,lines,polys,colors);
108 case VTK_HOOKEDARROW_GLYPH:
109 this->CreateHookedArrow(pts,lines,polys,colors);
111 case VTK_EDGEARROW_GLYPH:
112 this->CreateEdgeArrow(pts,lines,polys,colors);
114 case VTK_SPECIFICARROW_GLYPH:
115 this->CreateSpecificArrow(pts,lines,polys,colors);
119 this->TransformGlyph(pts);
122 output->SetPoints(pts);
125 output->SetVerts(verts);
128 output->SetLines(lines);
131 output->SetPolys(polys);
134 output->GetCellData()->SetScalars(colors);
140 void vvGlyphSource::CreateSpecificArrow(vtkPoints *pts, vtkCellArray *lines,
141 vtkCellArray *polys, vtkUnsignedCharArray *colors)
145 ptIds[0] = pts->InsertNextPoint( 0.0, 0.0, 0.0);
146 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
147 lines->InsertNextCell(2,ptIds);
148 colors->InsertNextValue(0);
149 colors->InsertNextValue(0);
150 colors->InsertNextValue(1);
153 ptIds[0] = pts->InsertNextPoint( 0.7, -0.1, 0.0);
154 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
155 ptIds[2] = pts->InsertNextPoint( 0.7, 0.1, 0.0);
156 lines->InsertNextCell(3,ptIds);
157 colors->InsertNextValue(0);
158 colors->InsertNextValue(1);
159 colors->InsertNextValue(0);
162 void vvGlyphSource::PrintSelf(ostream& os, vtkIndent indent)
164 this->Superclass::PrintSelf(os, indent);