Skip to content

Instantly share code, notes, and snippets.

@agirault
Created May 15, 2014 21:18
Show Gist options
  • Save agirault/aabbf6ccb96518509683 to your computer and use it in GitHub Desktop.
Save agirault/aabbf6ccb96518509683 to your computer and use it in GitHub Desktop.
//PolyData
ShapePopulationData * Mesh = new ShapePopulationData;
Mesh->ReadMesh(a_filePath);
m_meshList.push_back(Mesh);
//Polydata Mapper
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
#if (VTK_MAJOR_VERSION < 6)
mapper->SetInputConnection(Mesh->GetPolyData()->GetProducerPort());
#else
mapper->SetInputData(Mesh->GetPolyData());
#endif
//Polydata Actor
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
//Glyph
vtkSmartPointer<vtkGlyph3D> glyph = vtkSmartPointer<vtkGlyph3D>::New();
#if (VTK_MAJOR_VERSION < 6)
glyph->SetInputConnection(Mesh->GetPolyData()->GetProducerPort());
#else
glyph->SetInputData(Mesh->GetPolyData());
#endif
glyph->ScalingOn();
glyph->OrientOn();
glyph->ClampingOff();
glyph->SetColorModeToColorByVector();
glyph->SetScaleModeToScaleByVector();
glyph->SetVectorModeToUseVector();
m_glyphList.push_back(glyph);
//Glyph Arrow
vtkSmartPointer<vtkArrowSource> arrow = vtkSmartPointer<vtkArrowSource>::New();
glyph->SetSourceConnection(arrow->GetOutputPort());
//Glyph Mapper
vtkSmartPointer<vtkPolyDataMapper> glyphMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
#if (VTK_MAJOR_VERSION < 6)
glyphMapper->SetInputConnection(glyph->GetOutputPort());
#else
glyphMapper->SetInputData(glyph->GetOutput());
#endif
//Glyph Actor
vtkSmartPointer<vtkActor> glyphActor = vtkSmartPointer<vtkActor>::New();
glyphActor->SetMapper(glyphMapper);
//Renderer
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->AddActor(glyphActor);
// Then renderWindow and Interactor...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment