python vtk 画线_VTK初学一,c_Line线段的绘制

#ifndef INITIAL_OPENGL

#define INITIAL_OPENGL

#include

VTK_MODULE_INIT(vtkRenderingOpenGL)

VTK_MODULE_INIT(vtkInteractionStyle)

#endif

#include

using namespace std;

#include "vtkPolyDataMapper.h"

#include "vtkWin32OpenGLRenderWindow.h"

#include "vtkRenderWindow.h"

#include "vtkRenderWindowInteractor.h"

#include "vtkRenderer.h"

#include "vtkPoints.h"

#include "vtkWin32RenderWindowInteractor.h"

#include "vtkProperty.h"

#include "vtkFloatArray.h"

#include "vtkPolyData.h"

#include "vtkDataSetMapper.h"

#include "vtkActor2D.h"

#include "vtkContourFilter.h"

#include "vtkContourValues.h"

#include "vtkUnstructuredGrid.h"

#include "vtkPointData.h"

#include "vtkLine.h"

#include

void myShow(vtkSmartPointer aGrid)

{

//设置映射器

vtkSmartPointer aMapper=vtkSmartPointer::New();

aMapper->SetInputData(aGrid);

aMapper->ScalarVisibilityOff();

vtkSmartPointer anActor=vtkSmartPointer::New();

anActor->SetMapper(aMapper);

// anActor->GetProperty()->SetRepresentationToPoints();

anActor->GetProperty()->SetRepresentationToWireframe();

anActor->GetProperty()->SetDiffuseColor(0,0,1);

anActor->GetProperty()->SetLineWidth(5);

anActor->GetProperty()->SetEdgeColor(1,1,1);

anActor->GetProperty()->SetPointSize(10);

//创建显示窗口

vtkSmartPointer ren1=vtkSmartPointer::New();

vtkSmartPointer renWin=vtkSmartPointer::New();

ren1->AddActor(anActor);

renWin->AddRenderer(ren1);

vtkSmartPointer iren=vtkSmartPointer::New();

vtkSmartPointer style=vtkSmartPointer::New();

iren->SetInteractorStyle(style);

iren->SetRenderWindow(renWin);

renWin->SetSize(700,700);

ren1->ResetCamera();

renWin->Render();

iren->Start();

}

int main()

{

//几何数据

float pts[][3]={{0,0,0},{1,1,0}};

vtkSmartPointer linePointes=vtkSmartPointer::New();

linePointes->SetNumberOfPoints(2);

linePointes->InsertPoint(0,pts[0]);

linePointes->InsertPoint(1,pts[1]);

//属性数据

vtkSmartPointer lineScalars=vtkSmartPointer::New();

lineScalars->SetNumberOfTuples(2);

lineScalars->InsertValue(0,0);

lineScalars->InsertValue(1,0);

//拓扑结构

vtkSmartPointer aLine=vtkSmartPointer::New();

aLine->GetPointIds()->SetId(0,0);

aLine->GetPointIds()->SetId(1,1);

//将以上三部分数据组合成Grid

vtkSmartPointer aLineGrid=vtkSmartPointer::New();

aLineGrid->SetPoints(linePointes);

aLineGrid->GetPointData()->SetScalars(lineScalars);

aLineGrid->InsertNextCell(aLine->GetCellType(),aLine->GetPointIds());

/**********在窗口中显示该结构元****************************************、

myShow(aLineGrid);

return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值