medimage 发表于 2015-12-5 17:39:33

VTK例子9-ImplicitSum

ImplicitSum#include "stdafx.h"#include "vtkCone.h"#include "vtkPolyDataMapper.h"#include "vtkRenderWindow.h"#include "vtkRenderWindowInteractor.h"#include "vtkSphere.h"#include "vtkActor.h"#include "vtkRenderer.h"#include "vtkPolyData.h"#include "vtkImplicitSum.h"#include "vtkContourFilter.h"#include "vtkPoints.h"#include "stdio.h"#include <vtkSampleFunction.h>#include <vtkGlyph3D.h>#include <vtkProperty.h>#include <vtkCellArray.h>#include <vtkTubeFilter.h>#include <vtkSampleFunction.h> void main(){ //rand()/RAND_MAX;//    0 - RAND_MAXvtkRenderer *ren = vtkRenderer::New();vtkRenderWindow *renWindow = vtkRenderWindow::New();    renWindow->AddRenderer(ren);renWindow->SetSize( 600, 600 );     vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();    iren->SetRenderWindow(renWindow); vtkCone *geomObject1=vtkCone::New(); vtkSphere *geomObject2=vtkSphere::New();    geomObject2-> SetRadius( 0.5);    geomObject2-> SetCenter( 0.5, 0 ,0); vtkImplicitSum *sum=vtkImplicitSum::New();    sum-> SetNormalizeByWeight( 1);    sum-> AddFunction (geomObject1 ,2);    sum-> AddFunction (geomObject2 ,1); vtkSampleFunction *sample=vtkSampleFunction::New();    sample-> SetImplicitFunction( sum);    sample-> SetSampleDimensions( 60, 60 ,60);    sample-> ComputeNormalsOn(); vtkContourFilter *surface=vtkContourFilter::New();    surface-> SetInputConnection (sample->GetOutputPort());    surface-> SetValue (0 ,0.0); vtkPolyDataMapper *mapper=vtkPolyDataMapper::New();    mapper-> SetInputConnection(surface-> GetOutputPort());    mapper-> ScalarVisibilityOff(); vtkActor *actor=vtkActor::New();    actor-> SetMapper (mapper);    actor-> GetProperty()-> SetColor( 0.2 ,0.4 ,0.6);    actor-> GetProperty()-> SetSpecular ( 0.4);    actor-> GetProperty()-> SetDiffuse( 0.7);    actor-> GetProperty()-> SetSpecularPower ( 40);//////////////ren->AddActor(actor); iren->Initialize();renWindow->Render(); iren->Start();}

biomed 发表于 2016-5-12 08:17:58

goooood 顶起

13636600130 发表于 2016-5-14 01:50:05

先看看在说

oevko 发表于 2016-5-14 03:39:48

看看学习一下!

dentaldev 发表于 2016-5-14 07:50:32

顶 顶 顶 顶 顶 顶 顶 顶

RTphysics 发表于 2016-5-20 22:02:07

看看是不是很实用

13636600130 发表于 2016-5-23 10:46:30

好贴,不要沉了
页: [1]
查看完整版本: VTK例子9-ImplicitSum