#ifndef Initial_opengl
#define Initial_opengl
#include <vtkAutoInit.h>
Vtk_module_init (VTKRENDERINGOPENGL)
Vtk_module_init (Vtkinteractionstyle)
#endif
#include <iostream>
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 "vtkPolyVertex.h"
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkCellArray.h>
#include "VtkDelaunay2D.h"
#include "vtkMath.h"
void Myshow (vtkdelaunay2d* aninput)
{
Vtksmartpointer<vtkpolydatamapper> amapper=vtksmartpointer<vtkpolydatamapper>::new ();
Amapper->setinputconnection (Aninput->getoutputport ());
Amapper->scalarvisibilityon ();
Vtksmartpointer<vtkactor> anactor=vtksmartpointer<vtkactor>::new ();
Anactor->setmapper (Amapper);
Anactor->getproperty ()->setinterpolationtoflat ();
Anactor->getproperty ()->edgevisibilityon ();
Anactor->getproperty ()->setpointsize (1);
Anactor->getproperty ()->setcolor (1,0,1);
Vtksmartpointer<vtkrenderer> ren1=vtksmartpointer<vtkrenderer>::new ();
Vtksmartpointer<vtkrenderwindow> renwin=vtksmartpointer<vtkrenderwindow>::new ();
Ren1->addactor (Anactor);
Ren1->resetcamera ();
Ren1->setbackground (1,1,1);
Renwin->addrenderer (REN1);
Renwin->setsize (512,512);
Vtksmartpointer<vtkrenderwindowinteractor> iren=vtksmartpointer<vtkrenderwindowinteractor>::new ();
Vtksmartpointer<vtkinteractorstyletrackballcamera> style=vtksmartpointer< Vtkinteractorstyletrackballcamera>::new ();
Iren->setrenderwindow (Renwin);
Iren->setinteractorstyle (style);
Iren->start ();
}
int main ()
{
Vtksmartpointer<vtkpoints> points=vtksmartpointer<vtkpoints>::new ();
unsigned int gridxsize=60,gridysize=60;
Double r=60;//spherical curvature radius
Double r=0;//any x, y coordinate point, and the distance to the (0,0) point
Double r2=r*r;
Double RCROWN=GRIDXSIZE/2;
Double rcrown2=rcrown*rcrown;//ball Crown radius squared
Double hmax2=r*r-rcrown2;//the maximum arc vector height squared
Double hmax=r-sqrt (HMAX2);//maximum arc vector height
for (double i=0;i<gridxsize;i++)
{
for (double j=0;j<gridysize;j++)
{
Double x= (I-GRIDXSIZE/2), y= (J-GRIDYSIZE/2);
R2=X*X+Y*Y;//R2 represents the square of R
R=SQRT (R2);
Double z=0;
if (R<rcrown)
Do not know why, to add a maximum arc vector height Hmax, in order to get the correct crown, is probably the coordinate direction of the problem it
{
Z=SQRT (R*R-R2)-(R-hmax) +hmax;
Points->insertnextpoint (I,J,Z);
}
Else
Z=hmax;
}
}
Vtksmartpointer<vtkpolydata> polydata=vtksmartpointer<vtkpolydata>::new ();
Polydata->setpoints (points);
Vtksmartpointer<vtkdelaunay2d> delaunay=vtksmartpointer<vtkdelaunay2d>::new ();
Delaunay->setinputdata (Polydata);
Delaunay->update ();
Show in Window
Myshow (Delaunay);
return 0;
}
VTK Beginner One, vtkdelaunay2d creating spherical crown surfaces