Difference between revisions of "VTK/Examples/Cxx/Filtering/VertexGlyphFilter"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to: navigation, search
(Replaced content with "= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/Filtering/VertexGlyphFilter VertexGlyphFilter] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExampl...")
 
Line 1: Line 1:
<div class="floatright">[[File:VTK_Examples_Baseline_Filters_TestVertexGlyphFilter.png]]</div>
+
= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/Filtering/VertexGlyphFilter VertexGlyphFilter] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =
This example creates a set of points and adds a vertex at each point using vtkVertexGlyphFilter.
 
 
 
==VertexGlyphFilter.cxx==
 
<source lang="cpp">
 
#include <vtkVersion.h>
 
#include <vtkVertexGlyphFilter.h>
 
#include <vtkPolyData.h>
 
#include <vtkSmartPointer.h>
 
#include <vtkPolyDataMapper.h>
 
#include <vtkActor.h>
 
#include <vtkRenderWindow.h>
 
#include <vtkRenderer.h>
 
#include <vtkRenderWindowInteractor.h>
 
#include <vtkProperty.h>
 
 
int main(int , char *[])
 
{
 
 
  vtkSmartPointer<vtkPoints> points =
 
    vtkSmartPointer<vtkPoints>::New();
 
  points->InsertNextPoint(0,0,0);
 
  points->InsertNextPoint(1,1,1);
 
  points->InsertNextPoint(2,2,2);
 
 
  vtkSmartPointer<vtkPolyData> polydata =
 
    vtkSmartPointer<vtkPolyData>::New();
 
  polydata->SetPoints(points);
 
 
  vtkSmartPointer<vtkVertexGlyphFilter> vertexGlyphFilter =
 
    vtkSmartPointer<vtkVertexGlyphFilter>::New();
 
#if VTK_MAJOR_VERSION <= 5
 
  vertexGlyphFilter->AddInput(polydata);
 
#else
 
  vertexGlyphFilter->AddInputData(polydata);
 
#endif
 
  vertexGlyphFilter->Update();
 
 
  // Create a mapper and actor
 
  vtkSmartPointer<vtkPolyDataMapper> mapper =
 
    vtkSmartPointer<vtkPolyDataMapper>::New();
 
  mapper->SetInputConnection(vertexGlyphFilter->GetOutputPort());
 
 
  vtkSmartPointer<vtkActor> actor =
 
    vtkSmartPointer<vtkActor>::New();
 
  actor->SetMapper(mapper);
 
  actor->GetProperty()->SetPointSize(3);
 
 
 
  // Create a renderer, render window, and interactor
 
  vtkSmartPointer<vtkRenderer> renderer =
 
    vtkSmartPointer<vtkRenderer>::New();
 
  vtkSmartPointer<vtkRenderWindow> renderWindow =
 
    vtkSmartPointer<vtkRenderWindow>::New();
 
  renderWindow->AddRenderer(renderer);
 
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
 
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
 
  renderWindowInteractor->SetRenderWindow(renderWindow);
 
 
  // Add the actor to the scene
 
  renderer->AddActor(actor);
 
  renderer->SetBackground(.3, .6, .3); // Background color green
 
 
  // Render and interact
 
  renderWindow->Render();
 
  renderWindowInteractor->Start();
 
 
  return EXIT_SUCCESS;
 
}
 
</source>
 
 
 
{{VTKCMakeLists|{{SUBPAGENAME}}}}
 

Latest revision as of 22:11, 30 July 2019

See VertexGlyphFilter on the new VTKExamples website.