VTK顯示球體

#ifndef VTKHSWSPHEREWIDGET_H
#define VTKHSWSPHEREWIDGET_H

/*
 * ModuleName: vtkHSWSphereWidget
 * Description: 實現球
 * Author: hsw
 * Date: 2020-03-22
 *
*/

#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkDataSetMapper.h>

class vtkHSWSphereWidget
{
public:
    vtkHSWSphereWidget();
    ~vtkHSWSphereWidget();
public:
    vtkSmartPointer<vtkDataSetMapper> createSphere(double* sphereCenter,
                                                   double sphereRadius,
                                                   int thetaResolution,
                                                   int phiResolution);
private:
    vtkSmartPointer<vtkSphereSource> _sphereSource;
    vtkSmartPointer<vtkDataSetMapper> _sphereMapper;
};

#endif // VTKHSWSPHEREWIDGET_H

 

#include "vtkhswspherewidget.h"

vtkHSWSphereWidget::vtkHSWSphereWidget()
{
    _sphereSource = vtkSmartPointer<vtkSphereSource>::New();
    _sphereMapper = vtkSmartPointer<vtkDataSetMapper>::New();
}

vtkHSWSphereWidget::~vtkHSWSphereWidget()
{
    // TODO...
}

vtkSmartPointer<vtkDataSetMapper> vtkHSWSphereWidget::createSphere(double *sphereCenter,
                                                                    double sphereRadius,
                                                                    int thetaResolution,
                                                                    int phiResolution)
{
    _sphereSource->SetCenter(sphereCenter);
    _sphereSource->SetRadius(sphereRadius);
    _sphereSource->SetThetaResolution(thetaResolution);
    _sphereSource->SetPhiResolution(phiResolution);

    _sphereMapper->SetInputConnection(_sphereSource->GetOutputPort());

    return _sphereMapper;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章