医站点医维基

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1409|回复: 4

[VTK] VTK例子17-读取三维体数据,三位重建显示——任意平面的裁切

[复制链接]

336

主题

410

回帖

2806

积分

管理员

积分
2806

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2015-12-5 17:59:37 | 显示全部楼层 |阅读模式
读取三维体数据,三位重建显示——任意平面的裁切
//16位非压缩位图的读取与设置
       //16位非压缩位图
       v16 = vtkVolume16Reader::New();   
       //大小为64*64,每个文件大小为64*64*2=8192字节
       v16->SetDataDimensions(64,64);
       imageData = vtkImageData::New();
       imageData = v16->GetOutput();
       imageData->SetOrigin(.0,.0,.0);
       imageData->SetDimensions(64,64,93);
       //两个字节之间的字节序,采用印地安字节序  
       v16->SetDataByteOrderToLittleEndian();               
       v16->SetFilePrefix ("E:/VTK/VTKData/BMPDATA/quarter");
       //设置图片范围(1-93)
       v16->SetImageRange (1,93);
       //点间距                                    
       v16->SetDataSpacing (3.2,3.2,1.5);                  
       v16->Update();
/*
       tfun = vtkPiecewiseFunction::New();
       tfun->AddPoint(  70.0,  .0);
       tfun->AddPoint( 599.0,  .0);
       tfun->AddPoint( 600.0,  .0);
       tfun->AddPoint(1195.0,  .0);
       tfun->AddPoint(1200.0,  .2);
       tfun->AddPoint(1300.0,  .3);
       tfun->AddPoint(2000.0,  .3);
       tfun->AddPoint(4095.0, 1.0);
*/
       ctfun = vtkColorTransferFunction::New();
       ctfun->AddRGBPoint(    .0,  .5,  .0, .0);
       ctfun->AddRGBPoint( 600.0, 0.1,  .5, .5);
       ctfun->AddRGBPoint(1280.0,  .9,  .2, .3);
       ctfun->AddRGBPoint(1960.0, .81, .27, .1);
       ctfun->AddRGBPoint(4095.0,  .5,  .5, .5);
       compositeFunction = vtkVolumeRayCastCompositeFunction::New();
       volumeMapper = vtkVolumeRayCastMapper::New();
       //图像数据载入映射器
       volumeMapper->SetInput(imageData);
       volumeMapper->SetVolumeRayCastFunction(compositeFunction);
       //裁切平面的设置
       plane1 = vtkPlane::New();
       //设置平面初始点
       plane1->SetOrigin(50,50,50);
       //设置平面法线
       plane1->SetNormal(1, 1, 1);
       //加载平面
//     volumeMapper->AddClippingPlane(plane1);
              //裁切平面的设置
       plane2 = vtkPlane::New();
       //设置平面初始点
//     plane2->SetOrigin(80, 80, 80);
       //设置平面法线
//     plane2->SetNormal(-1, -1, -1);
       //加载平面
//     volumeMapper->AddClippingPlane(plane2);
       volumeProperty = vtkVolumeProperty::New();
       volumeProperty->SetColor(ctfun);
//     volumeProperty->SetScalarOpacity(tfun);
       volumeProperty->SetInterpolationTypeToLinear();
       volumeProperty->ShadeOn();
       newvol = vtkVolume::New();
       newvol->SetMapper(volumeMapper);
       newvol->SetProperty(volumeProperty);
       //边界的设置与显示
       outline = vtkOutlineFilter::New();
       outline->SetInput(imageData);
       outlineMapper = vtkPolyDataMapper::New();
       outlineMapper->SetInput(outline->GetOutput());
       outlineActor = vtkActor::New();
       outlineActor->SetMapper(outlineMapper);
       boxWidget = vtkBoxWidget::New();
       boxWidget->SetInteractor(iren);
       boxWidget->SetPlaceFactor(1.0);
       boxWidget->SetInput(imageData);
       boxWidget->PlaceWidget();
       boxWidget->InsideOutOn();
//     boxWidget->AddObserver()
/**/
       render->AddActor(outlineActor);
       render->AddVolume(newvol);
滑动块事件:
       int pos1 = this->m_PosionSlider.GetPos();
       int pos2 = this->m_Slider2.GetPos();
       int pos3 = this->m_Slider3.GetPos();
       int pos4 = this->m_Slider4.GetPos();
       int pos5 = this->m_Slider5.GetPos();
       int pos6 = this->m_Slider6.GetPos();
       CString str;
       str.Format("%d",pos1);
       this->m_Edit1.SetWindowText(str);
       this->m_MyMedical.plane2->SetOrigin(pos1, pos2, pos3);
       this->m_MyMedical.plane2->SetNormal(pos4, pos5, pos6);
       this->m_MyMedical.volumeMapper->AddClippingPlane(this->m_MyMedical.plane2);   
       this->m_MyMedical.VTKToDialog(&(this->m_MyStatic));
17.png
回复

使用道具 举报

37

主题

424

回帖

1169

积分

版主

积分
1169

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-11 12:26:26 | 显示全部楼层
回复

使用道具 举报

4

主题

415

回帖

1084

积分

版主

积分
1084

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-12 15:22:58 | 显示全部楼层
好好好好哈
回复

使用道具 举报

15

主题

428

回帖

1137

积分

版主

积分
1137

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-17 02:02:39 | 显示全部楼层
回复

使用道具 举报

60

主题

416

回帖

1235

积分

版主

积分
1235

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-23 12:51:49 | 显示全部楼层
谢谢你的辛苦劳动了!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|关于我们|医维基|网站地图|Archiver|手机版|医疗之家 ( 沪ICP备2023001278号-1 )  

GMT+8, 2024-5-2 19:18 , Processed in 0.292385 second(s), 31 queries .

Designed by Medical BBS

快速回复 返回顶部 返回列表