在PolyData的每个顶点处延法向量生成圆锥体

这里写图片描述

关键代码:

    //改变polydata的颜色
    vtkSmartPointer<vtkElevationFilter> colorIt =
      vtkSmartPointer<vtkElevationFilter>::New();
    colorIt->SetInputConnection(sphere->GetOutputPort());
    colorIt->SetLowPoint(0,0,-1);
    colorIt->SetHighPoint(0,0,1);

    //延顶点法向量生成圆锥
    vtkNew<vtkGlyph3D> glyph;
    glyph->SetInputConnection(colorIt->GetOutputPort());
    glyph->SetSourceConnection(cone->GetOutputPort());
    glyph->SetVectorModeToUseNormal();
    glyph->SetScaleModeToScaleByVector();
    glyph->SetColorModeToColorByScale ();
    glyph->SetScaleFactor(0.25);

    //显示线及平滑处理
    sphereActor->GetProperty()->SetEdgeVisibility(true);
    sphereActor->GetProperty()->SetInterpolationToPhong();

demo:
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/Mace/
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/FlatVersusGouraud/
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/ColoredSphere/
https://lorensen.github.io/VTKExamples/site/Cxx/Rendering/CameraBlur/

猜你喜欢

转载自blog.csdn.net/yuxing55555/article/details/80539367