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://oncora1.lyon.fnclcc.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 vtkCxxRevisionMacro(vvGlyphSource, "DummyRevision");
30 vtkStandardNewMacro(vvGlyphSource);
33 //----------------------------------------------------------------------------
34 int vvGlyphSource::RequestData(
35 vtkInformation *vtkNotUsed(request),
36 vtkInformationVector **vtkNotUsed(inputVector),
37 vtkInformationVector *outputVector)
39 // get the info object
40 vtkInformation *outInfo = outputVector->GetInformationObject(0);
43 vtkPolyData *output = vtkPolyData::SafeDownCast(
44 outInfo->Get(vtkDataObject::DATA_OBJECT()));
47 vtkPoints *pts = vtkPoints::New();
49 vtkCellArray *verts = vtkCellArray::New();
50 verts->Allocate(verts->EstimateSize(1,1),1);
51 vtkCellArray *lines = vtkCellArray::New();
52 lines->Allocate(lines->EstimateSize(4,2),2);
53 vtkCellArray *polys = vtkCellArray::New();
54 polys->Allocate(polys->EstimateSize(1,4),4);
55 vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New();
56 colors->SetNumberOfComponents(3);
57 colors->Allocate(2,2);
63 int filled = this->Filled;
65 this->CreateDash(pts,lines,polys,colors,this->Scale2);
66 this->Filled = filled;
69 int filled = this->Filled;
71 this->CreateCross(pts,lines,polys,colors,this->Scale2);
72 this->Filled = filled;
75 //Call the right function
76 switch (this->GlyphType) {
79 case VTK_VERTEX_GLYPH:
80 this->CreateVertex(pts,verts,colors);
83 this->CreateDash(pts,lines,polys,colors,this->Scale);
86 this->CreateCross(pts,lines,polys,colors,this->Scale);
88 case VTK_THICKCROSS_GLYPH:
89 this->CreateThickCross(pts,lines,polys,colors);
91 case VTK_TRIANGLE_GLYPH:
92 this->CreateTriangle(pts,lines,polys,colors);
94 case VTK_SQUARE_GLYPH:
95 this->CreateSquare(pts,lines,polys,colors);
97 case VTK_CIRCLE_GLYPH:
98 this->CreateCircle(pts,lines,polys,colors);
100 case VTK_DIAMOND_GLYPH:
101 this->CreateDiamond(pts,lines,polys,colors);
103 case VTK_ARROW_GLYPH:
104 this->CreateArrow(pts,lines,polys,colors);
106 case VTK_THICKARROW_GLYPH:
107 this->CreateThickArrow(pts,lines,polys,colors);
109 case VTK_HOOKEDARROW_GLYPH:
110 this->CreateHookedArrow(pts,lines,polys,colors);
112 case VTK_EDGEARROW_GLYPH:
113 this->CreateEdgeArrow(pts,lines,polys,colors);
115 case VTK_SPECIFICARROW_GLYPH:
116 this->CreateSpecificArrow(pts,lines,polys,colors);
120 this->TransformGlyph(pts);
123 output->SetPoints(pts);
126 output->SetVerts(verts);
129 output->SetLines(lines);
132 output->SetPolys(polys);
135 output->GetCellData()->SetScalars(colors);
141 void vvGlyphSource::CreateSpecificArrow(vtkPoints *pts, vtkCellArray *lines,
142 vtkCellArray *polys, vtkUnsignedCharArray *colors)
146 ptIds[0] = pts->InsertNextPoint( 0.0, 0.0, 0.0);
147 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
148 lines->InsertNextCell(2,ptIds);
149 colors->InsertNextValue(0);
150 colors->InsertNextValue(0);
151 colors->InsertNextValue(1);
154 ptIds[0] = pts->InsertNextPoint( 0.7, -0.1, 0.0);
155 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
156 ptIds[2] = pts->InsertNextPoint( 0.7, 0.1, 0.0);
157 lines->InsertNextCell(3,ptIds);
158 colors->InsertNextValue(0);
159 colors->InsertNextValue(1);
160 colors->InsertNextValue(0);
163 void vvGlyphSource::PrintSelf(ostream& os, vtkIndent indent)
165 this->Superclass::PrintSelf(os, indent);