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