体绘制函数 vtk
来源:互联网 发布:java权限管理的实现 编辑:程序博客网 时间:2024/06/10 03:15
int GetSeeds::volume()
{
// Create the renderer, render window and interactor
vtkSmartPointer<vtkRenderer> rendererVolume = vtkRenderer::New();
vtkSmartPointer<vtkRenderWindow> renWinVolume = vtkRenderWindow::New();
renWinVolume->AddRenderer(rendererVolume);
// Connect it all. Note that funny arithematic on the
// SetDesiredUpdateRate - the vtkRenderWindow divides it
// allocated time across all renderers, and the renderer
// divides it time across all props. If clip is
// true then there are two props
vtkSmartPointer<vtkRenderWindowInteractor> irenVolume = vtkRenderWindowInteractor::New();
irenVolume->SetRenderWindow(renWinVolume);
// irenVolume->GetInteractorStyle()->SetDefaultRenderer(rendererVolume);
// Read the data
vtkSmartPointer<vtkDICOMImageReader> dicomReader = vtkDICOMImageReader::New();
dicomReader->SetDataByteOrderToLittleEndian();
dicomReader->SetDirectoryName(folder.c_str());
dicomReader->SetDataOrigin(0.0, 0.0, 0.0);
// dicomReader->Update();
vtkSmartPointer<vtkImageShiftScale> ShiftScale = vtkImageShiftScale::New();
ShiftScale->SetInput((vtkDataObject *)dicomReader->GetOutput());
ShiftScale->SetOutputScalarTypeToShort();
ShiftScale->SetShift (1024);
ShiftScale->ClampOverflowOn();
vtkSmartPointer<vtkImageCast> readerImageCast = vtkImageCast::New();
readerImageCast->SetInput((vtkDataObject *)ShiftScale->GetOutput());
readerImageCast->SetOutputScalarTypeToUnsignedShort();
readerImageCast->ClampOverflowOn();
vtkSmartPointer<vtkVolumeRayCastCompositeFunction> compositeFunction = vtkVolumeRayCastCompositeFunction::New();
vtkSmartPointer<vtkPlane> plane=vtkPlane::New();
// vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> mapperVolume = vtkFixedPointVolumeRayCastMapper::New();
vtkSmartPointer<vtkVolumeRayCastMapper> mapperVolume = vtkVolumeRayCastMapper::New();
mapperVolume->SetVolumeRayCastFunction(compositeFunction);
mapperVolume->SetInputConnection( readerImageCast->GetOutputPort() );
mapperVolume->AddClippingPlane(plane);
vtkSmartPointer<vtkVolume> volume = vtkVolume::New();
volume->SetMapper( mapperVolume );
/*
// Create our transfer function
vtkSmartPointer<vtkColorTransferFunction> colorFun = vtkColorTransferFunction::New();
vtkSmartPointer<vtkPiecewiseFunction> opacityFun = vtkPiecewiseFunction::New();
// Create the property and attach the transfer functions
// bool independentComponents=true;
vtkSmartPointer<vtkVolumeProperty> propertyVolume = vtkVolumeProperty::New();
// property->SetIndependentComponents(independentComponents);
propertyVolume->SetColor( colorFun );
propertyVolume->SetScalarOpacity( opacityFun );
propertyVolume->SetInterpolationTypeToLinear();
double opacityWindow = 4096;
double opacityLevel = 2048;
// connect up the volume to the property and the mapper
volume->SetProperty( propertyVolume );
colorFun->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0 );
opacityFun->AddSegment( opacityLevel - 0.5*opacityWindow, 0.0,
opacityLevel + 0.5*opacityWindow, 1.0 );
// mapper->SetBlendModeToMaximumIntensity();
*/
vtkSmartPointer<vtkPiecewiseFunction> opacityFun = vtkPiecewiseFunction::New();
opacityFun->AddPoint(1024+20, 0.0); //不透明度映射 第一参数是灰度值,第二个是不透明度
opacityFun->AddPoint(1024+255, 0.2);
// opacityFun->AddPoint(1024+30, 0.8);
// opacityFun->AddPoint(700, 1.0);
// opacityFun->AddPoint(1000, 0.2);
// opacityFun->AddPoint(500, 0.0);
vtkSmartPointer<vtkColorTransferFunction> colorFun = vtkColorTransferFunction::New();
// colorFun->AddRGBPoint(700, 0.0, 0.0, 0.5); //灰度值-RGB映射
colorFun->AddRGBPoint(1024+0.0, 0.0, 0.5, 0.0);
colorFun->AddRGBPoint(1024+60.0, 1.0, 0.0, 0.0);
colorFun->AddRGBPoint(1024+128.0, 0.2, 0.1, 0.9);
colorFun->AddRGBPoint(1024+196.0, 0.27, 0.21, 0.1);
colorFun->AddRGBPoint(1024+255.0, 0.8, 0.8, 0.8);
colorFun->AddRGBPoint(1024+100.0, 0, 0.5, 0);
// colorFun->AddRGBPoint(500, 0.5, 0, 0);
// colorFun->AddRGBPoint(1000, 0, 0.5, 0.0);
vtkSmartPointer<vtkVolumeProperty> propertyVolume = vtkVolumeProperty::New();
propertyVolume->SetColor(colorFun); //载入RGB映射
propertyVolume->SetScalarOpacity(opacityFun); //载入不透明度映射
propertyVolume->ShadeOn();
propertyVolume->SetInterpolationTypeToLinear(); //载入线性差值
propertyVolume->SetAmbient(0.2); // 设置用于显示Surface Model的一些材质属性
propertyVolume->SetDiffuse(0.9);
propertyVolume->SetSpecular(0.2);
propertyVolume->SetSpecularPower(10);
volume->SetProperty(propertyVolume);
// Set the default window size
renWinVolume->SetSize(600,600);
// Add the volume to the scene
rendererVolume->AddVolume( volume );
rendererVolume->SetBackground(1, 1, 1);
// rendererVolume->ResetCamera();
// interact with data
irenVolume->Initialize();
renWinVolume->Render();
irenVolume->Start();
dicomReader->Delete();
return 0;
}
{
// Create the renderer, render window and interactor
vtkSmartPointer<vtkRenderer> rendererVolume = vtkRenderer::New();
vtkSmartPointer<vtkRenderWindow> renWinVolume = vtkRenderWindow::New();
renWinVolume->AddRenderer(rendererVolume);
// Connect it all. Note that funny arithematic on the
// SetDesiredUpdateRate - the vtkRenderWindow divides it
// allocated time across all renderers, and the renderer
// divides it time across all props. If clip is
// true then there are two props
vtkSmartPointer<vtkRenderWindowInteractor> irenVolume = vtkRenderWindowInteractor::New();
irenVolume->SetRenderWindow(renWinVolume);
// irenVolume->GetInteractorStyle()->SetDefaultRenderer(rendererVolume);
// Read the data
vtkSmartPointer<vtkDICOMImageReader> dicomReader = vtkDICOMImageReader::New();
dicomReader->SetDataByteOrderToLittleEndian();
dicomReader->SetDirectoryName(folder.c_str());
dicomReader->SetDataOrigin(0.0, 0.0, 0.0);
// dicomReader->Update();
vtkSmartPointer<vtkImageShiftScale> ShiftScale = vtkImageShiftScale::New();
ShiftScale->SetInput((vtkDataObject *)dicomReader->GetOutput());
ShiftScale->SetOutputScalarTypeToShort();
ShiftScale->SetShift (1024);
ShiftScale->ClampOverflowOn();
vtkSmartPointer<vtkImageCast> readerImageCast = vtkImageCast::New();
readerImageCast->SetInput((vtkDataObject *)ShiftScale->GetOutput());
readerImageCast->SetOutputScalarTypeToUnsignedShort();
readerImageCast->ClampOverflowOn();
vtkSmartPointer<vtkVolumeRayCastCompositeFunction> compositeFunction = vtkVolumeRayCastCompositeFunction::New();
vtkSmartPointer<vtkPlane> plane=vtkPlane::New();
// vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> mapperVolume = vtkFixedPointVolumeRayCastMapper::New();
vtkSmartPointer<vtkVolumeRayCastMapper> mapperVolume = vtkVolumeRayCastMapper::New();
mapperVolume->SetVolumeRayCastFunction(compositeFunction);
mapperVolume->SetInputConnection( readerImageCast->GetOutputPort() );
mapperVolume->AddClippingPlane(plane);
vtkSmartPointer<vtkVolume> volume = vtkVolume::New();
volume->SetMapper( mapperVolume );
/*
// Create our transfer function
vtkSmartPointer<vtkColorTransferFunction> colorFun = vtkColorTransferFunction::New();
vtkSmartPointer<vtkPiecewiseFunction> opacityFun = vtkPiecewiseFunction::New();
// Create the property and attach the transfer functions
// bool independentComponents=true;
vtkSmartPointer<vtkVolumeProperty> propertyVolume = vtkVolumeProperty::New();
// property->SetIndependentComponents(independentComponents);
propertyVolume->SetColor( colorFun );
propertyVolume->SetScalarOpacity( opacityFun );
propertyVolume->SetInterpolationTypeToLinear();
double opacityWindow = 4096;
double opacityLevel = 2048;
// connect up the volume to the property and the mapper
volume->SetProperty( propertyVolume );
colorFun->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0 );
opacityFun->AddSegment( opacityLevel - 0.5*opacityWindow, 0.0,
opacityLevel + 0.5*opacityWindow, 1.0 );
// mapper->SetBlendModeToMaximumIntensity();
*/
vtkSmartPointer<vtkPiecewiseFunction> opacityFun = vtkPiecewiseFunction::New();
opacityFun->AddPoint(1024+20, 0.0); //不透明度映射 第一参数是灰度值,第二个是不透明度
opacityFun->AddPoint(1024+255, 0.2);
// opacityFun->AddPoint(1024+30, 0.8);
// opacityFun->AddPoint(700, 1.0);
// opacityFun->AddPoint(1000, 0.2);
// opacityFun->AddPoint(500, 0.0);
vtkSmartPointer<vtkColorTransferFunction> colorFun = vtkColorTransferFunction::New();
// colorFun->AddRGBPoint(700, 0.0, 0.0, 0.5); //灰度值-RGB映射
colorFun->AddRGBPoint(1024+0.0, 0.0, 0.5, 0.0);
colorFun->AddRGBPoint(1024+60.0, 1.0, 0.0, 0.0);
colorFun->AddRGBPoint(1024+128.0, 0.2, 0.1, 0.9);
colorFun->AddRGBPoint(1024+196.0, 0.27, 0.21, 0.1);
colorFun->AddRGBPoint(1024+255.0, 0.8, 0.8, 0.8);
colorFun->AddRGBPoint(1024+100.0, 0, 0.5, 0);
// colorFun->AddRGBPoint(500, 0.5, 0, 0);
// colorFun->AddRGBPoint(1000, 0, 0.5, 0.0);
vtkSmartPointer<vtkVolumeProperty> propertyVolume = vtkVolumeProperty::New();
propertyVolume->SetColor(colorFun); //载入RGB映射
propertyVolume->SetScalarOpacity(opacityFun); //载入不透明度映射
propertyVolume->ShadeOn();
propertyVolume->SetInterpolationTypeToLinear(); //载入线性差值
propertyVolume->SetAmbient(0.2); // 设置用于显示Surface Model的一些材质属性
propertyVolume->SetDiffuse(0.9);
propertyVolume->SetSpecular(0.2);
propertyVolume->SetSpecularPower(10);
volume->SetProperty(propertyVolume);
// Set the default window size
renWinVolume->SetSize(600,600);
// Add the volume to the scene
rendererVolume->AddVolume( volume );
rendererVolume->SetBackground(1, 1, 1);
// rendererVolume->ResetCamera();
// interact with data
irenVolume->Initialize();
renWinVolume->Render();
irenVolume->Start();
dicomReader->Delete();
return 0;
}
0 0
- 体绘制函数 vtk
- vtk体绘制-例子
- VTK GPU体绘制
- vtk 体绘制小结
- VTK之体绘制
- vtk体绘制
- vtk 体绘制
- VTK体绘制
- VTK:读入DICOM,体绘制
- VTK中的体绘制方法
- 【VTK】三维体绘制方法
- VTK中体绘制方法
- vtk等值面体绘制|纹理映射体绘制 附:不透明传输函数,颜色传输函数、光照与阴影
- VTK修炼之道67:体绘制讨论_不透明度传输函数
- VTK修炼之道68:体绘制讨论_梯度不透明度传输函数
- VTK修炼之道69:体绘制讨论_颜色传输函数
- vtk体绘制交互问题的解决方案
- 基于VTK的体绘制系统实现
- 关于个推“证书只能绑定一个bundleId”问题的解决办法
- 网络基本功系列:细说VLAN和Trunk
- Android LinearLayout 重要属性
- jquery的outerWidth和outerHeight
- 创建快捷方式,如何保证移动目标文件后可以正常使用
- 体绘制函数 vtk
- 【硬件】[其他]:电路 元器件 问题集
- 关于Android achartEngine TimeChartView 的一些设置
- java spring自动装配
- android webview 自定义404错误页面!
- 从一家电子商务网站学到的经验教训
- 教你实现同一IP多域名对应多个站点_908
- hibernate.properties与hibernate.cfg.xml 区别
- 指针