1 /*=========================================================================
5 Author : Pierre Seroul (pierre.seroul@gmail.com)
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 =========================================================================*/
24 #include "vvGlyphSource.h"
26 #include "vtkCellArray.h"
27 #include "vtkCellData.h"
29 #include "vtkInformation.h"
30 #include "vtkInformationVector.h"
31 #include "vtkObjectFactory.h"
32 #include "vtkPolyData.h"
33 #include "vtkUnsignedCharArray.h"
35 vtkCxxRevisionMacro(vvGlyphSource, "DummyRevision");
36 vtkStandardNewMacro(vvGlyphSource);
39 //----------------------------------------------------------------------------
40 int vvGlyphSource::RequestData(
41 vtkInformation *vtkNotUsed(request),
42 vtkInformationVector **vtkNotUsed(inputVector),
43 vtkInformationVector *outputVector)
45 // get the info object
46 vtkInformation *outInfo = outputVector->GetInformationObject(0);
49 vtkPolyData *output = vtkPolyData::SafeDownCast(
50 outInfo->Get(vtkDataObject::DATA_OBJECT()));
53 vtkPoints *pts = vtkPoints::New();
55 vtkCellArray *verts = vtkCellArray::New();
56 verts->Allocate(verts->EstimateSize(1,1),1);
57 vtkCellArray *lines = vtkCellArray::New();
58 lines->Allocate(lines->EstimateSize(4,2),2);
59 vtkCellArray *polys = vtkCellArray::New();
60 polys->Allocate(polys->EstimateSize(1,4),4);
61 vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New();
62 colors->SetNumberOfComponents(3);
63 colors->Allocate(2,2);
70 int filled = this->Filled;
72 this->CreateDash(pts,lines,polys,colors,this->Scale2);
73 this->Filled = filled;
77 int filled = this->Filled;
79 this->CreateCross(pts,lines,polys,colors,this->Scale2);
80 this->Filled = filled;
83 //Call the right function
84 switch (this->GlyphType)
88 case VTK_VERTEX_GLYPH:
89 this->CreateVertex(pts,verts,colors);
92 this->CreateDash(pts,lines,polys,colors,this->Scale);
95 this->CreateCross(pts,lines,polys,colors,this->Scale);
97 case VTK_THICKCROSS_GLYPH:
98 this->CreateThickCross(pts,lines,polys,colors);
100 case VTK_TRIANGLE_GLYPH:
101 this->CreateTriangle(pts,lines,polys,colors);
103 case VTK_SQUARE_GLYPH:
104 this->CreateSquare(pts,lines,polys,colors);
106 case VTK_CIRCLE_GLYPH:
107 this->CreateCircle(pts,lines,polys,colors);
109 case VTK_DIAMOND_GLYPH:
110 this->CreateDiamond(pts,lines,polys,colors);
112 case VTK_ARROW_GLYPH:
113 this->CreateArrow(pts,lines,polys,colors);
115 case VTK_THICKARROW_GLYPH:
116 this->CreateThickArrow(pts,lines,polys,colors);
118 case VTK_HOOKEDARROW_GLYPH:
119 this->CreateHookedArrow(pts,lines,polys,colors);
121 case VTK_EDGEARROW_GLYPH:
122 this->CreateEdgeArrow(pts,lines,polys,colors);
124 case VTK_SPECIFICARROW_GLYPH:
125 this->CreateSpecificArrow(pts,lines,polys,colors);
129 this->TransformGlyph(pts);
132 output->SetPoints(pts);
135 output->SetVerts(verts);
138 output->SetLines(lines);
141 output->SetPolys(polys);
144 output->GetCellData()->SetScalars(colors);
150 void vvGlyphSource::CreateSpecificArrow(vtkPoints *pts, vtkCellArray *lines,
151 vtkCellArray *polys, vtkUnsignedCharArray *colors)
155 ptIds[0] = pts->InsertNextPoint( 0.0, 0.0, 0.0);
156 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
157 lines->InsertNextCell(2,ptIds);
158 colors->InsertNextValue(0);
159 colors->InsertNextValue(0);
160 colors->InsertNextValue(1);
163 ptIds[0] = pts->InsertNextPoint( 0.7, -0.1, 0.0);
164 ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0);
165 ptIds[2] = pts->InsertNextPoint( 0.7, 0.1, 0.0);
166 lines->InsertNextCell(3,ptIds);
167 colors->InsertNextValue(0);
168 colors->InsertNextValue(1);
169 colors->InsertNextValue(0);
172 void vvGlyphSource::PrintSelf(ostream& os, vtkIndent indent)
174 this->Superclass::PrintSelf(os, indent);