1.参数
vector<double> D = {2000,6500-1200,7800-700-600,2000};
vector<double>X = {700,600,600,600};
2.主代码
#include "InitInclude.h"
#include "vtkPlaneSource.h"
#include <vtkNew.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
#include <vtkPoints.h>
#include <vtkPolygon.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkTriangleFilter.h>
#include <vtkProperty.h>
#include <vtkTriangleFilter.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkLinearExtrusionFilter.h>
#include <vtkBMPReader.h>
#include <vtkImageReader2Factory.h>
#include <vtkPolyDataNormals.h>
#include <vtkTextureMapToPlane.h>
#include <vtkTransformTextureCoords.h>
#include <vector>
#include "vtkInteractorStyleTrackballActor.h"
#include "MouseInteractor.h"
#include "MouseInteractorHighLightActor.h"
//创建一个二维标准的机房图纸,通过拉伸的方式完成三维的建模。初步完成
void creat2Dmodel_0(vector<double> d, vector<double> x)
{
vtkSmartPointer<vtkRenderer> render = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkActor> actorzhuji = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkActor> actorChang = vtkSmartPointer<vtkActor>::New();
//vtkSmartPointer<vtkActor> actorPlotFunction = vtkSmartPointer<vtkActor>::New();
actorzhuji = sheyuan1();
actorChang = chuang1();
actor = juxingqianghouActor(d, x);
//actorPlotFunction = PlotFunction();
//vtkSmartPointer<MouseInteractorHighLightActor> style = vtkSmartPointer <MouseInteractorHighLightActor>::New();
//style->SetDefaultRenderer(render);
//style->ActorA = actorzhuji;
//style->ActorB = actorChang;
render->AddActor(actorzhuji);
render->AddActor(actorChang);
//render->AddActor(actorzhuji);
//render->AddActor(actorChang);
//render->AddActor(actor);
render->SetBackground(1, 1, 1); // Background color dark blue
//vtkSmartPointer<MouseInteractorStyle5> style = vtkSmartPointer <MouseInteractorStyle5>::New();
//style->SetDefaultRenderer(renderer);
//style->ActorA = Actor1;
//style->ActorB = Actor2;
//renderWindowInteractor->SetInteractorStyle(style);
//renderer->AddActor(Actor1);
//renderer->AddActor(Actor2);
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();//renderWindow
renWin->AddRenderer(render);
renWin->SetSize(1024, 768);
vtkNew<vtkRenderWindowInteractor> iren;//renderWindowInteractor
iren->SetRenderWindow(renWin);
//iren->SetInteractorStyle(style);
renWin->Render();
iren->Initialize();
iren->Start(); //blog.csdn.net/liushao1031177/article/details/118443631
int u = 1;
}
3.头文件
使用了公共头文件
4.效果