VTK beginner One, line of drawing C_line

Source: Internet
Author: User

#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 "vtkLine.h"
#include <vtkInteractorStyleTrackballCamera.h>
void Myshow (vtksmartpointer<vtkunstructuredgrid> agrid)
{
    Set Mapper
    Vtksmartpointer<vtkdatasetmapper> amapper=vtksmartpointer<vtkdatasetmapper>::new ();
    Amapper->setinputdata (Agrid);
    Amapper->scalarvisibilityoff ();
    Vtksmartpointer<vtkactor> anactor=vtksmartpointer<vtkactor>::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);
Create a display window
    Vtksmartpointer<vtkrenderer> ren1=vtksmartpointer<vtkrenderer>::new ();
    Vtksmartpointer<vtkrenderwindow> renwin=vtksmartpointer<vtkrenderwindow>::new ();
    Ren1->addactor (Anactor);
    Renwin->addrenderer (REN1);
    Vtksmartpointer<vtkrenderwindowinteractor> iren=vtksmartpointer<vtkrenderwindowinteractor>::new ();
    Vtksmartpointer<vtkinteractorstyletrackballcamera> style=vtksmartpointer< Vtkinteractorstyletrackballcamera>::new ();
    Iren->setinteractorstyle (style);
    Iren->setrenderwindow (Renwin);
    Renwin->setsize (700,700);
    Ren1->resetcamera ();
    Renwin->render ();
    Iren->start ();
}
int main ()
{
    Geometry data
    Float pts[][3]={{0,0,0},{1,1,0}};
    Vtksmartpointer<vtkpoints> linepointes=vtksmartpointer<vtkpoints>::new ();
    Linepointes->setnumberofpoints (2);
    Linepointes->insertpoint (0,pts[0]);
    Linepointes->insertpoint (1,pts[1]);
    Property data
    Vtksmartpointer<vtkfloatarray> linescalars=vtksmartpointer<vtkfloatarray>::new ();
    Linescalars->setnumberoftuples (2);
    Linescalars->insertvalue (0,0);
    Linescalars->insertvalue (1,0);
    Topological structure
    Vtksmartpointer<vtkline> aline=vtksmartpointer<vtkline>::new ();
    Aline->getpointids ()->setid (0,0);
    Aline->getpointids ()->setid ();
    Combine the above three pieces of data into a grid
    Vtksmartpointer<vtkunstructuredgrid> alinegrid=vtksmartpointer<vtkunstructuredgrid>::new ();
    Alinegrid->setpoints (linepointes);
   Alinegrid->getpointdata ()->setscalars (linescalars);
    Alinegrid->insertnextcell (Aline->getcelltype (), Aline->getpointids ());
/********** displays the struct element in the window ****************************************,
    Myshow (Alinegrid);
    return 0;
}

VTK beginner One, line of drawing C_line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.