In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
VTK commonly used controls and how to achieve cone drawing, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
The following components are commonly used when drawing objects with VTK. In order to deepen understanding, VTK likens the rendering process of an object to a performance (really vivid):
VtkRenderWindow: a drawing window, equivalent to a stage venue for a performance
VtkRenderer-involves the drawing process of lights, cameras, actor; equivalent to the overall performance on the stage
VtkLight-the light source is used to illuminate the scene
VtkCamera-defines the viewing angle, focal length, and visual properties of the scene, equivalent to the visual field of the audience
VtkActor-objects rendered in the scene, attributes and their position in the scene, props displayed in the drawing; actors and props equivalent to the performance
VtkProperty modifies the properties of vtkActor, including color, transparency and light properties (reflection and refraction), and the light used for the performance
VtkMapper-vtkActor geometric mapping, when drawing, you need to convert vtkAcor to geometric attributes before you can draw; multiple vtkActor can set the same mapper.
The following figure is the annotation of each component in the drawing effect of VTK:
When drawing an object, you need to provide the source data, perform a series of operations on the data (reading, format conversion, Filter image processing), and then convert it to vtkMapper. After setting the `vtkMapper by vtkActor, it is passed into the vtkRendener (painter).
When implementing the code, if vtkLight and vtkCamera are not defined, the program will automatically create these two components.
Overall, the data pipeline flow of VTK is as follows:
Here is the use of code to achieve a cone drawing, with the help of a class vtkConeSource.h provided by VTK
# include
# include
# include
# include
# include
# include
# include
# include
# include "vtkAutoInit.h"
VTK_MODULE_INIT (vtkRenderingOpenGL2); / / VTK was built with vtkRenderingOpenGL2
VTK_MODULE_INIT (vtkInteractionStyle)
Int main ()
{
VtkSmartPointer Cone = vtkSmartPointer::New ()
VtkSmartPointer colors = vtkSmartPointer::New ()
Cone- > SetHeight (3.0); / / Cone Height
Cone- > SetRadius (1.0); / / Cone Radius
Cone- > SetResolution (9); / / Cone faces
VtkSmartPointer coneMapper = vtkSmartPointer::New ()
ConeMapper- > SetInputConnection (Cone- > GetOutputPort ()); / / Mapper data
VtkSmartPointer coneActor = vtkSmartPointer::New ()
ConeActor- > SetMapper (coneMapper)
VtkSmartPointer coneRender = vtkSmartPointer::New ()
ConeRender- > AddActor (coneActor)
ConeRender- > SetBackground (colors- > GetColor3d ("MidnightBlue"). GetData (); / / Bachground color
VtkSmartPointer renWindow = vtkSmartPointer::New ()
RenWindow- > AddRenderer (coneRender)
RenWindow- > SetSize (300,300); / / Size of Window
For (auto I = 0; I
< 360; ++i) { //render the image; renWindow->Render ()
/ / rotate the active camera by one degree
ConeRender- > GetActiveCamera ()-> Azimuth (1)
}
Getchar ()
Return EXIT_SUCCESS
}
The final effect is as follows:
Several parameters are set for the cone in the code: height, bottom radius, and the number of included faces (the total number of faces involved in the cone)
VTK in addition to the header file vtkConeSource.h provides conical data, there are ellipses, cubes, rings and other data objects.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.