VTK入门程序样例分析-vtk与MFc混编(5)

2019-04-21 19:17

二、Filter 1、ImplicitSum

#include \

#include \#include \

#include \#include \#include \#include \#include \#include \#include \#include \#include \

#include #include #include #include

#include

#include

void main() {

// rand()/RAND_MAX;// 0 - RAND_MAX vtkRenderer *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(); }

2、PerlinNoise

#include \ #include \ #include \

#include \ #include \ #include \ #include \ #include \ #include \

#include \ #include \ #include \ #include #include #include #include #include #include

void main() {

srand(time(NULL)) ;

// rand()/RAND_MAX;//

0 - RAND_MAX

vtkRenderer *ren = vtkRenderer::New();

vtkRenderWindow *renWindow = vtkRenderWindow::New(); renWindow->AddRenderer(ren); renWindow->SetSize( 600, 600 );

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); iren->SetRenderWindow(renWindow);

vtkPerlinNoise *perlin=vtkPerlinNoise::New(); perlin-> SetFrequency (2 ,6.25, 5.5); perlin-> SetPhase (0 ,0, 0);

vtkSampleFunction *sample=vtkSampleFunction::New(); sample-> SetImplicitFunction (perlin); sample-> SetSampleDimensions( 65,65 ,20); sample-> ComputeNormalsOff();

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);

////////////// ren->AddActor(actor);

iren->Initialize(); renWindow->Render();

iren->Start(); }

3、样条曲线CSpline

.

#include \ #include \ #include \

#include \ #include \ #include \ #include \ #include \ #include \


VTK入门程序样例分析-vtk与MFc混编(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:ABB机器人RAPID指令中文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: