VTK 体重建代码

有时候使用表面重建不能显示细节。因此使用VolumeRender才好。


见代码:

#include "base.h"

void show(vtkSmartPointer<vtkRenderer> renderer){
    // show the renderer window using passed renderer object.
    vtkSmartPointer<vtkRenderWindow> renWin=vtkSmartPointer<vtkRenderWindow>::New();
    renWin->AddRenderer(renderer);
    renWin->SetSize(640,480);
    //renWin->Render();  //Not use it in ray-casting

    vtkSmartPointer<vtkRenderWindowInteractor> iren=vtkSmartPointer<vtkRenderWindowInteractor>::New();
    iren->SetRenderWindow(renWin);

    vtkSmartPointer<vtkInteractorStyleTrackballCamera> style=vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
    iren->SetInteractorStyle(style);
    iren->Initialize();
    iren->Start();

}

// Get all the color scheme names.
// Return a map os the names keyed on their index.

map<int,string> GetAllColorSchemes(){
    //
    map<int,string> colorSchemes;
    vtkSmartPointer<vtkColorSeries> colorSeries=vtkSmartPointer<vtkColorSeries>::New();
    for(int i=0;i<colorSeries->GetNumberOfColorSchemes();++i){
        colorSeries->SetColorScheme(i);
        colorSchemes[i]=colorSeries->GetColorSchemeName();
    }
    return colorSchemes;
}

// The available color scheme indexes and names.
// return a string is the indexes and names.
string AvailableColorSchemes(map<int,string> & colorSchemes){
    ostringstream os;
    for(map<int,string>::const_iterator p=colorSchemes.begin();p!=colorSchemes.end();++p)
        os<<std::setw(3)<<p->first<<"\t"<<p->second<<endl;
    return os.str();
}

// Display the available color schemes.
void DisplayAvailableColorSchemes(){
    string line("---------------------------------------------------\n");
    map<int,string> colorSchemes;
    //colorSchemes=GetAllColorSchemes();
    colorSchemes=GetAllNamedColorSchemes();
    cout<<line<<AvailableColorSchemes(colorSchemes)<<line<<endl;
}

map<int,string> GetAllNamedColorSchemes(){
    //
    map<int,string> colorSchemes;
    vtkSmartPointer<vtkNamedColors> colors=vtkSmartPointer<vtkNamedColors>::New();
    for(int i=0;i<colors->GetNumberOfColors();++i){
        //colors->SetReferenceCount(i);
        colorSchemes[i]=colors->GetColorNames();
    }
    return colorSchemes;
}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值