当前位置:   article > 正文

vtk创建立体网格_vtkstructuredgrid

vtkstructuredgrid

    
    vtkNew<vtkStructuredGrid> structuredGrid;
    vtkNew<vtkPoints> points;
    unsigned int numi = 10;
    unsigned int numj = 10;
    unsigned int numk = 10;

    for (unsigned int k = 0; k < numk; k++)
    {
        for (unsigned int j = 0; j < numj; j++)
        {
            for (unsigned int i = 0; i < numi; i++)
            {
                points->InsertNextPoint(i*3, j*3, k*3);
            }
        }
    }

    // Specify the dimensions of the grid
    structuredGrid->SetDimensions(numi, numj, numk);
    structuredGrid->SetPoints(points);

    std::cout << "There are " << structuredGrid->GetNumberOfPoints()
        << " points before shrinking." << std::endl;
    std::cout << "There are " << structuredGrid->GetNumberOfCells()
        << " cells before shrinking." << std::endl;

    vtkNew<vtkShrinkFilter> shrinkFilter;
    shrinkFilter->SetInputData(structuredGrid);
    shrinkFilter->SetShrinkFactor(1);
    shrinkFilter->Update();


    vtkNew<vtkExtractEdges> extract;
    extract->SetInputData(shrinkFilter->GetOutput());
    std::cout << extract->GetOutput()->GetNumberOfCells() << std::endl;
    vtkNew<vtkTubeFilter> tubes;
    tubes->SetInputConnection(extract->GetOutputPort());
    tubes->SetNumberOfSides(4);
    tubes->SetRadius(0.01 * 10);
    tubes->Update();
    vtkNew<vtkPolyDataMapper> ma;
    vtkNew<vtkActor> va;
    ma->SetInputData(tubes->GetOutput());
    va->SetMapper(ma);
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/996065
推荐阅读
相关标签
  

闽ICP备14008679号