#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
#include<vtkSmartPointer.h>
#include<vtkStructuredPointsReader.h>
#include<vtkPolyDataMapper.h>
#include<vtkMarchingCubes.h>
#include<vtkActor.h>
#include<vtkRenderer.h>
#include<vtkRenderWindow.h>
#include<vtkRenderWindowInteractor.h>
#include<vtkStringArray.h>
#include <vtkStdString.h>
#include <vtkPNGReader.h>
#include <vtkImageViewer2.h>
#include <vtkStdString.h>
#include <vtkPoints.h>
#include <vtkTubeFilter.h>
#include <vtkImplicitModeller.h>
#include <vtkContourFilter.h>
#include<windows.h>
using namespace std;
int main() {
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkPolyData> profile = vtkSmartPointer<vtkPolyData>::New();
points->InsertNextPoint(0,0,0);
points->InsertNextPoint(0,2,0);
points->InsertNextPoint(2,4,0);
points->InsertNextPoint(4,4,0);
lines->InsertNextCell(4);
lines->InsertCellPoint(0);
lines->InsertCellPoint(1);
lines->InsertCellPoint(2);
lines->InsertCellPoint(3);
profile->SetLines(lines);
profile->SetPoints(points);
//tube
vtkSmartPointer<vtkTubeFilter> tube = vtkSmartPointer<vtkTubeFilter>::New();
tube->SetInputData(profile);
tube->SetRadius(.5);
tube->SetNumberOfSides(12);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputData(profile);
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkPolyDataMapper> tubeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
tubeMapper->SetInputConnection(tube->GetOutputPort());
vtkSmartPointer<vtkActor> tubeActor = vtkSmartPointer<vtkActor>::New();
tubeActor->SetMapper(tubeMapper);
//Implicit Modeller
vtkSmartPointer< vtkImplicitModeller> imp = vtkSmartPointer< vtkImplicitModeller>::New();
imp->SetInputData(profile);
imp->SetSampleDimensions(100,100,100);
imp->SetMaximumDistance(0.25);
imp->SetModelBounds(-10,10, -10, 10, - 10, 10);
vtkSmartPointer<vtkContourFilter> contour = vtkSmartPointer<vtkContourFilter>::New();
contour->SetInputConnection(imp->GetOutputPort());
contour->SetValue(0,0.5);
vtkSmartPointer<vtkPolyDataMapper> conMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
conMapper->SetInputConnection(contour->GetOutputPort());
vtkSmartPointer<vtkActor> contourActor = vtkSmartPointer<vtkActor>::New();
contourActor->SetMapper(conMapper);
contourActor->SetPosition(5,0,0);
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renWin->AddRenderer(renderer);
renderer->SetBackground(0.5, 0.3, 0.4);
renderer->AddActor(actor);
renderer->AddActor(tubeActor);
renderer->AddActor(contourActor);
renWin->SetSize(840, 880);
renWin->Render();
interactor->SetRenderWindow(renWin);
interactor->Initialize();
interactor->Start();
return 0;
}