Difference between revisions of "VTK/Examples/Cxx/GeometricObjects/Vertex"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to navigationJump to search
(Replaced content with "= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/Vertex Vertex] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =")
 
Line 1: Line 1:
<div class="floatright">[[File:VTK_Examples_Baseline_GeometricObjects_TestVertex.png]]</div>
+
= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/Vertex Vertex] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =
==Vertex.cxx==
 
<source lang="cpp">
 
#include <vtkVersion.h>
 
#include <vtkSmartPointer.h>
 
#include <vtkPolyData.h>
 
#include <vtkPoints.h>
 
#include <vtkCellArray.h>
 
#include <vtkVertex.h>
 
#include <vtkPolyDataMapper.h>
 
#include <vtkProperty.h>
 
#include <vtkActor.h>
 
#include <vtkRenderWindow.h>
 
#include <vtkRenderer.h>
 
#include <vtkRenderWindowInteractor.h>
 
 
 
int main(int, char *[])
 
{
 
  vtkSmartPointer<vtkPoints> points =
 
    vtkSmartPointer<vtkPoints>::New();
 
  points->InsertNextPoint(0,0,0);
 
 
 
  vtkSmartPointer<vtkVertex> vertex =
 
    vtkSmartPointer<vtkVertex>::New();
 
  vertex->GetPointIds()->SetId(0, 0);
 
 
 
  vtkSmartPointer<vtkCellArray> vertices =
 
    vtkSmartPointer<vtkCellArray>::New();
 
  vertices->InsertNextCell(vertex);
 
 
 
  vtkSmartPointer<vtkPolyData> polydata =
 
    vtkSmartPointer<vtkPolyData>::New();
 
  polydata->SetPoints(points);
 
  polydata->SetVerts(vertices);
 
 
 
 
 
  // Setup actor and mapper
 
  vtkSmartPointer<vtkPolyDataMapper> mapper =
 
    vtkSmartPointer<vtkPolyDataMapper>::New();
 
#if VTK_MAJOR_VERSION <= 5
 
  mapper->SetInputConnection(polydata->GetProducerPort());
 
#else
 
  mapper->SetInputData(polydata);
 
#endif
 
 
  vtkSmartPointer<vtkActor> actor =
 
    vtkSmartPointer<vtkActor>::New();
 
  actor->SetMapper(mapper);
 
  actor->GetProperty()->SetPointSize(10);
 
 
 
  // Setup render window, renderer, 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);
 
  renderer->AddActor(actor);
 
 
  renderWindow->Render();
 
  renderWindowInteractor->Start();
 
 
 
  return EXIT_SUCCESS;
 
}
 
</source>
 
 
 
{{VTKCMakeLists|{{SUBPAGENAME}}}}
 

Latest revision as of 15:39, 16 August 2019

See Vertex on the new VTKExamples website.