VTK/Examples/Cxx/PolyData/Curvatures

转载 2018年04月14日 22:45:07

VTK/Examples/Cxx/PolyData/Curvatures

VTK‎ | Examples‎ | Cxx
VTK Examples Baseline PolyData TestCurvatures.png

Curvatures.cxx

#include <vtkSmartPointer.h>
 
#include <vtkCurvatures.h>
 
#include <vtkXMLPolyDataReader.h>
 
#include <vtkLookupTable.h>
#include <vtkColorTransferFunction.h>
#include <vtkColorSeries.h>
 
#include <vtkPointData.h>
 
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkScalarBarActor.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->SetCurvatureTypeToMinimum();
  curvaturesFilter->SetCurvatureTypeToMaximum();
  curvaturesFilter->SetCurvatureTypeToGaussian();
  curvaturesFilter->SetCurvatureTypeToMean();
  curvaturesFilter->Update();
 
  // Get scalar range from command line if present, otherwise use
  // range of computed curvature
  double scalarRange[2];
  if (argc >= 4)
    {
    scalarRange[0] = atof(argv[2]);
    scalarRange[1] = atof(argv[3]);
    }
  else
    {
    curvaturesFilter->GetOutput()->GetScalarRange(scalarRange);
    }
 
  int scheme = 16;
  if (argc >= 5)
    {
    scheme = atoi(argv[4]);
    }
 
  // Build a lookup table
  vtkSmartPointer<vtkColorSeries> colorSeries = 
    vtkSmartPointer<vtkColorSeries>::New();
  colorSeries->SetColorScheme(scheme);
  std::cout << "Using color scheme #: "
            << colorSeries->GetColorScheme() << " is "
            << colorSeries->GetColorSchemeName() << std::endl;
 
  vtkSmartPointer<vtkColorTransferFunction> lut = 
    vtkSmartPointer<vtkColorTransferFunction>::New();
  lut->SetColorSpaceToHSV();
 
  // Use a color series to create a transfer function
  int numColors = colorSeries->GetNumberOfColors();
  for (int i = 0; i < numColors; i++)
    {
      vtkColor3ub color = colorSeries->GetColor(i);
    double dColor[3];
    dColor[0] = static_cast<double> (color[0]) / 255.0;
    dColor[1] = static_cast<double> (color[1]) / 255.0;
    dColor[2] = static_cast<double> (color[2]) / 255.0;
    double t = scalarRange[0] + (scalarRange[1] - scalarRange[0])
      / (numColors - 1) * i;
    lut->AddRGBPoint(t, dColor[0], dColor[1], dColor[2]);
    }
 
  // Create a mapper and actor
  vtkSmartPointer<vtkPolyDataMapper> mapper = 
    vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(curvaturesFilter->GetOutputPort());
  mapper->SetLookupTable(lut);
  mapper->SetScalarRange(scalarRange);
 
  vtkSmartPointer<vtkActor> actor = 
    vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
 
  // Create a scalar bar
  vtkSmartPointer<vtkScalarBarActor> scalarBar = 
    vtkSmartPointer<vtkScalarBarActor>::New();
  scalarBar->SetLookupTable(mapper->GetLookupTable());
  scalarBar->SetTitle(
    curvaturesFilter->GetOutput()->GetPointData()->GetScalars()->GetName());
  scalarBar->SetNumberOfLabels(5);
 
  // 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 actors to the scene
  renderer->AddActor(actor);
  renderer->AddActor2D(scalarBar);
 
  renderer->SetBackground(.1, .2, .3); // Background color blue
 
  // Render and interact
  renderWindow->Render();
  renderWindowInteractor->Start();
 
  return EXIT_SUCCESS;
}

zhuan :https://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/Curvatures

VTK/Examples/Cxx/PolyData/VertexConnectivity

原文转自: http://www.paraview.org/Wiki/VTK/Examples/Cxx/PolyData/VertexConnectivity
  • u010025211
  • u010025211
  • 2014-05-07 20:42:38
  • 926

VTK/Examples/Cxx/PolyData/PolyDataPointNormals

This demo adds a normal to each point in a polydata. PolyDataPointNormals.cxx #include #inc...
  • u010025211
  • u010025211
  • 2014-05-15 19:39:50
  • 871

VTK/Examples/Cxx/Meshes/ColoredElevationMap

ColoredElevationMap.cxx #include &amp;lt;vtkVersion.h&amp;gt; #include &amp;lt;vtkSmartPointer.h&am...
  • eric_e
  • eric_e
  • 2018-04-02 01:21:08
  • 15

求两个多边形数据 vtkPolyData 的相交线

vtkIntersectionPolyDataFilter 【简介】 该滤波器计算两个多边形数据 vtkPolyData 的交集。 其第一个输出是 交集线集( a set of lines ); 第二...
  • Jane_yuhui
  • Jane_yuhui
  • 2016-09-13 11:39:44
  • 1364

VTK修炼之道44:图形进阶_vtkPolyData数据源讨论与数据创建

1.VTKPolyData源数据总结 1之前的实例中,我们利用VTKConeSource源数据创建了一个棱锥。实际上VTK内部提供可以写数据源类来快速获取简单的图形数据。下面给出了最常见的几...
  • shenziheng1
  • shenziheng1
  • 2017-02-02 12:06:52
  • 1382

VTK PolyData数据重构-添加point和cell

Method对于已有polydata数据添加新增的点和单元并建立拓扑结构,可以利用polydata的两个方法来构建。...
  • windfz
  • windfz
  • 2017-12-02 16:27:59
  • 138

VTK修炼之道45:图形进阶_vtkPolyData属性数据

1.从图形着色说起 前一个实验显示结果中的图像是白色的,而图形颜色与vtkPolyData属性数据息息相关。由于并未指定任何颜色和属性数据,因此在显示时默认以白色显示。 属性数据包括点属性...
  • shenziheng1
  • shenziheng1
  • 2017-02-02 19:44:33
  • 1228

VTK/ExamplesBoneyard/Cxx/PolyData/AddLineToPolydata

原文转自: http://www.paraview.org/Wiki/VTK/ExamplesBoneyard/Cxx/PolyData/AddLineToPolydata
  • u010025211
  • u010025211
  • 2014-05-07 20:46:18
  • 706

vtkIntersectionPolydataFilter 使用心得

最近想求两个polydata的交集,找到了vtkIntersectionPolydataFilter ,了解到该滤波器的第一个输出是 交集线集( a set of lines ); 第二个和第三个输...
  • Zzhouzhou237
  • Zzhouzhou237
  • 2017-07-30 18:30:19
  • 307

VTK修炼之道43:图形进阶_vtkPolyData数据生成与显示

1.VTK图像处理引言 图像数据的应用非常广泛,最贴近日常生活的应用是3D游戏,其中每个角色的模型、场景等都是图形数据。当然,游戏仅仅是图像数据的一个应用点。图形在CAD(计算机辅助设计)、...
  • shenziheng1
  • shenziheng1
  • 2017-02-01 23:43:52
  • 2872
收藏助手
不良信息举报
您举报文章:VTK/Examples/Cxx/PolyData/Curvatures
举报原因:
原因补充:

(最多只允许输入30个字)