X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvGlyphSource.cxx;h=3a6763b480aab632c7c199a151f8902e6466a4f5;hb=6aa95a9aeaacfa57a9a17a7aedf7798c5334079e;hp=8801a778ed5e132385e20c700282ffbab5b1f432;hpb=0b7c9b1e1215634b02cbd38d4e4ba101d6111ba8;p=clitk.git diff --git a/vv/vvGlyphSource.cxx b/vv/vvGlyphSource.cxx index 8801a77..3a6763b 100644 --- a/vv/vvGlyphSource.cxx +++ b/vv/vvGlyphSource.cxx @@ -1,9 +1,9 @@ /*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: + Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #include "vvGlyphSource.h" #include "vtkCellArray.h" @@ -26,144 +26,140 @@ #include "vtkPolyData.h" #include "vtkUnsignedCharArray.h" -vtkCxxRevisionMacro(vvGlyphSource, "DummyRevision"); vtkStandardNewMacro(vvGlyphSource); //---------------------------------------------------------------------------- int vvGlyphSource::RequestData( - vtkInformation *vtkNotUsed(request), - vtkInformationVector **vtkNotUsed(inputVector), - vtkInformationVector *outputVector) + vtkInformation *vtkNotUsed(request), + vtkInformationVector **vtkNotUsed(inputVector), + vtkInformationVector *outputVector) { - // get the info object - vtkInformation *outInfo = outputVector->GetInformationObject(0); - - // get the ouptut - vtkPolyData *output = vtkPolyData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - - //Allocate storage - vtkPoints *pts = vtkPoints::New(); - pts->Allocate(6,6); - vtkCellArray *verts = vtkCellArray::New(); - verts->Allocate(verts->EstimateSize(1,1),1); - vtkCellArray *lines = vtkCellArray::New(); - lines->Allocate(lines->EstimateSize(4,2),2); - vtkCellArray *polys = vtkCellArray::New(); - polys->Allocate(polys->EstimateSize(1,4),4); - vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New(); - colors->SetNumberOfComponents(3); - colors->Allocate(2,2); - - this->ConvertColor(); - - //Special options - if ( this->Dash ) - { - int filled = this->Filled; - this->Filled = 0; - this->CreateDash(pts,lines,polys,colors,this->Scale2); - this->Filled = filled; - } - if ( this->Cross ) - { - int filled = this->Filled; - this->Filled = 0; - this->CreateCross(pts,lines,polys,colors,this->Scale2); - this->Filled = filled; - } - - //Call the right function - switch (this->GlyphType) - { - case VTK_NO_GLYPH: - break; - case VTK_VERTEX_GLYPH: - this->CreateVertex(pts,verts,colors); - break; - case VTK_DASH_GLYPH: - this->CreateDash(pts,lines,polys,colors,this->Scale); - break; - case VTK_CROSS_GLYPH: - this->CreateCross(pts,lines,polys,colors,this->Scale); - break; - case VTK_THICKCROSS_GLYPH: - this->CreateThickCross(pts,lines,polys,colors); - break; - case VTK_TRIANGLE_GLYPH: - this->CreateTriangle(pts,lines,polys,colors); - break; - case VTK_SQUARE_GLYPH: - this->CreateSquare(pts,lines,polys,colors); - break; - case VTK_CIRCLE_GLYPH: - this->CreateCircle(pts,lines,polys,colors); - break; - case VTK_DIAMOND_GLYPH: - this->CreateDiamond(pts,lines,polys,colors); - break; - case VTK_ARROW_GLYPH: - this->CreateArrow(pts,lines,polys,colors); - break; - case VTK_THICKARROW_GLYPH: - this->CreateThickArrow(pts,lines,polys,colors); - break; - case VTK_HOOKEDARROW_GLYPH: - this->CreateHookedArrow(pts,lines,polys,colors); - break; - case VTK_EDGEARROW_GLYPH: - this->CreateEdgeArrow(pts,lines,polys,colors); - break; - case VTK_SPECIFICARROW_GLYPH: - this->CreateSpecificArrow(pts,lines,polys,colors); - break; - } - - this->TransformGlyph(pts); - - //Clean up - output->SetPoints(pts); - pts->Delete(); - - output->SetVerts(verts); - verts->Delete(); - - output->SetLines(lines); - lines->Delete(); - - output->SetPolys(polys); - polys->Delete(); - - output->GetCellData()->SetScalars(colors); - colors->Delete(); - - return 1; + // get the info object + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the ouptut + vtkPolyData *output = vtkPolyData::SafeDownCast( + outInfo->Get(vtkDataObject::DATA_OBJECT())); + + //Allocate storage + vtkPoints *pts = vtkPoints::New(); + pts->Allocate(6,6); + vtkCellArray *verts = vtkCellArray::New(); + verts->Allocate(verts->EstimateSize(1,1),1); + vtkCellArray *lines = vtkCellArray::New(); + lines->Allocate(lines->EstimateSize(4,2),2); + vtkCellArray *polys = vtkCellArray::New(); + polys->Allocate(polys->EstimateSize(1,4),4); + vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New(); + colors->SetNumberOfComponents(3); + colors->Allocate(2,2); + + this->ConvertColor(); + + //Special options + if ( this->Dash ) { + int filled = this->Filled; + this->Filled = 0; + this->CreateDash(pts,lines,polys,colors,this->Scale2); + this->Filled = filled; + } + if ( this->Cross ) { + int filled = this->Filled; + this->Filled = 0; + this->CreateCross(pts,lines,polys,colors,this->Scale2); + this->Filled = filled; + } + + //Call the right function + switch (this->GlyphType) { + case VTK_NO_GLYPH: + break; + case VTK_VERTEX_GLYPH: + this->CreateVertex(pts,verts,colors); + break; + case VTK_DASH_GLYPH: + this->CreateDash(pts,lines,polys,colors,this->Scale); + break; + case VTK_CROSS_GLYPH: + this->CreateCross(pts,lines,polys,colors,this->Scale); + break; + case VTK_THICKCROSS_GLYPH: + this->CreateThickCross(pts,lines,polys,colors); + break; + case VTK_TRIANGLE_GLYPH: + this->CreateTriangle(pts,lines,polys,colors); + break; + case VTK_SQUARE_GLYPH: + this->CreateSquare(pts,lines,polys,colors); + break; + case VTK_CIRCLE_GLYPH: + this->CreateCircle(pts,lines,polys,colors); + break; + case VTK_DIAMOND_GLYPH: + this->CreateDiamond(pts,lines,polys,colors); + break; + case VTK_ARROW_GLYPH: + this->CreateArrow(pts,lines,polys,colors); + break; + case VTK_THICKARROW_GLYPH: + this->CreateThickArrow(pts,lines,polys,colors); + break; + case VTK_HOOKEDARROW_GLYPH: + this->CreateHookedArrow(pts,lines,polys,colors); + break; + case VTK_EDGEARROW_GLYPH: + this->CreateEdgeArrow(pts,lines,polys,colors); + break; + case VTK_SPECIFICARROW_GLYPH: + this->CreateSpecificArrow(pts,lines,polys,colors); + break; + } + + this->TransformGlyph(pts); + + //Clean up + output->SetPoints(pts); + pts->Delete(); + + output->SetVerts(verts); + verts->Delete(); + + output->SetLines(lines); + lines->Delete(); + + output->SetPolys(polys); + polys->Delete(); + + output->GetCellData()->SetScalars(colors); + colors->Delete(); + + return 1; } void vvGlyphSource::CreateSpecificArrow(vtkPoints *pts, vtkCellArray *lines, vtkCellArray *polys, vtkUnsignedCharArray *colors) { - //stem - vtkIdType ptIds[3]; - ptIds[0] = pts->InsertNextPoint( 0.0, 0.0, 0.0); - ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0); - lines->InsertNextCell(2,ptIds); - colors->InsertNextValue(0); - colors->InsertNextValue(0); - colors->InsertNextValue(1); - - //arrow head - ptIds[0] = pts->InsertNextPoint( 0.7, -0.1, 0.0); - ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0); - ptIds[2] = pts->InsertNextPoint( 0.7, 0.1, 0.0); - lines->InsertNextCell(3,ptIds); - colors->InsertNextValue(0); - colors->InsertNextValue(1); - colors->InsertNextValue(0); + //stem + vtkIdType ptIds[3]; + ptIds[0] = pts->InsertNextPoint( 0.0, 0.0, 0.0); + ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0); + lines->InsertNextCell(2,ptIds); + colors->InsertNextValue(0); + colors->InsertNextValue(0); + colors->InsertNextValue(1); + + //arrow head + ptIds[0] = pts->InsertNextPoint( 0.7, -0.1, 0.0); + ptIds[1] = pts->InsertNextPoint( 1.0, 0.0, 0.0); + ptIds[2] = pts->InsertNextPoint( 0.7, 0.1, 0.0); + lines->InsertNextCell(3,ptIds); + colors->InsertNextValue(0); + colors->InsertNextValue(1); + colors->InsertNextValue(0); } void vvGlyphSource::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os, indent); + this->Superclass::PrintSelf(os, indent); }