为什么不能使用Sphere缩放字形?

问题描述 投票:2回答:1

我有一个点云数据集,我想根据其属性值缩放一个点的大小。我遵循以下示例:https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ScaleGlyphs#Download_and_Build_ScaleGlyphs。但是,当我构建项目时,发生了一个错误:abort()被称为:enter image description here。我已经尝试了CubeSource,ArrowSource,CylinderSource,它们都解决了。我真的很困惑为什么我不能使用SphereSource。

如果有人可以帮助,我将不胜感激。预先感谢。

这是我的代码:

void ScalePoints::draw() {

    //load data
    vtkSmartPointer<vtkXMLPolyDataReader> currentReader = readers[currentId];
    vtkSmartPointer<vtkPolyData> polyData = currentReader->GetOutput();

    //set a scalar
    vtkDataArray* scalar = polyData->GetPointData()->GetArray("hh");
    int numPoints = scalar->GetNumberOfValues();  
    polyData->GetPointData()->SetScalars(scalar);

    //create spheres
    vtkSmartPointer<vtkSphereSource> SphereSource = vtkSmartPointer<vtkSphereSource>::New();
    vtkSmartPointer<vtkGlyph3D> glyph3D = vtkSmartPointer<vtkGlyph3D>::New();
    glyph3D->SetScaleModeToScaleByScalar();
    glyph3D->SetSourceConnection(SphereSource->GetOutputPort());
    glyph3D->SetInputData(polyData);
    glyph3D->SetScaleFactor(0.01);
    //glyph3D->SetRange(0.01, 0.05);
    glyph3D->Update();

    //visualize 
    vtkSmartPointer<vtkPolyDataMapper> sMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    sMapper->SetInputConnection(glyph3D->GetOutputPort());
    actor->SetMapper(sMapper);
    actor->GetProperty()->SetOpacity(0.7);
    renderer->AddActor(actor);
}
c++ vtk
1个回答
0
投票

这听起来像个错误。相反,会发生什么:

    SphereSource->Update();
    glyph3D->SetSourceData(SphereSource->GetOutput());
© www.soinside.com 2019 - 2024. All rights reserved.