Difference between revisions of "VTK/Examples/Cxx/PolyData/Curvatures"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to navigationJump to search
(Replaced content with "= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/Curvatures Curvatures] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<div class="floatright">[[File:VTK_Examples_Baseline_PolyData_TestCurvatures.png]]</div>
+
= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/Curvatures Curvatures] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =
==Curvatures.cxx==
 
<source lang="cpp">
 
#include <vtkSmartPointer.h>
 
#include <vtkCurvatures.h>
 
#include <vtkXMLPolyDataReader.h>
 
#include <vtkXMLPolyDataWriter.h>
 
#include <vtkPolyDataMapper.h>
 
#include <vtkActor.h>
 
#include <vtkRenderWindow.h>
 
#include <vtkRenderer.h>
 
#include <vtkRenderWindowInteractor.h>
 
 
 
int main(int argc, char *argv[])
 
{
 
  // Parse command line arguments
 
  if(argc != 2)
 
    {
 
    std::cerr << "Usage: " << argv[0] << " Filename(.vtp)" << std::endl;
 
    return EXIT_FAILURE;
 
    }
 
 
  // Create a polydata
 
  vtkSmartPointer<vtkXMLPolyDataReader> reader =
 
    vtkSmartPointer<vtkXMLPolyDataReader>::New();
 
  reader->SetFileName(argv[1]);
 
 
 
  vtkSmartPointer<vtkCurvatures> curvaturesFilter =
 
    vtkSmartPointer<vtkCurvatures>::New();
 
  curvaturesFilter->SetInputConnection(reader->GetOutputPort());
 
  //curvaturesFilter->SetCurvatureTypeToGaussian();
 
  //curvaturesFilter->SetCurvatureTypeToMean();
 
  //curvaturesFilter->SetCurvatureTypeToMaximum();
 
  curvaturesFilter->SetCurvatureTypeToMinimum();
 
     
 
  // To inspect more closely, if required
 
  vtkSmartPointer<vtkXMLPolyDataWriter> writer =
 
    vtkSmartPointer<vtkXMLPolyDataWriter>::New();
 
  writer->SetInputConnection(curvaturesFilter->GetOutputPort());
 
  writer->SetFileName("gauss.vtp");
 
  writer->Write();
 
 
 
  // Create a mapper and actor
 
  vtkSmartPointer<vtkPolyDataMapper> mapper =
 
    vtkSmartPointer<vtkPolyDataMapper>::New();
 
  mapper->SetInputConnection(curvaturesFilter->GetOutputPort());
 
  mapper->SetScalarRange(curvaturesFilter->GetOutput()->GetScalarRange());
 
 
 
  vtkSmartPointer<vtkActor> actor =
 
    vtkSmartPointer<vtkActor>::New();
 
  actor->SetMapper(mapper);
 
 
  // 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(.1, .2, .3); // Background color blue
 
 
  //Render and interact
 
  renderWindow->Render();
 
  renderWindowInteractor->Start();
 
  return EXIT_SUCCESS;
 
}
 
</source>
 
 
 
==CMakeLists.txt==
 
<source lang="cmake">
 
cmake_minimum_required(VERSION 2.6)
 
 
 
PROJECT(Curvatures)
 
 
 
FIND_PACKAGE(VTK REQUIRED)
 
INCLUDE(${VTK_USE_FILE})
 
 
 
ADD_EXECUTABLE(Curvatures Curvatures.cxx)
 
TARGET_LINK_LIBRARIES(Curvatures vtkHybrid)
 
 
 
</source>
 

Latest revision as of 15:36, 9 September 2019