Finite element simulation grid point adaptive marking and interaction method based on VTK
By adopting an adaptive marking method based on VTK, the problem of adaptive and scaling synchronization of mesh point marking in finite element simulation software is solved, which improves user operation efficiency and the intuitiveness of simulation result analysis.
Patent Information
- Application Number
- CN202511617674.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-02-06
AI Technical Summary
Existing finite element simulation software lacks the ability to adapt to size and synchronize scaling when marking mesh points. This results in markers overlapping and obscuring key details in dense mesh areas, and the markers are difficult to adjust synchronously when the model is scaled, affecting the efficiency of user observation and interaction.
By acquiring the mesh data and display window information of the finite element simulation model, the adaptive radius of the spherical marker points is calculated based on VTK, and the size of the marker points is dynamically adjusted in response to mouse wheel events to maintain the visual stability of the marker points during model scaling.
It achieves adaptive adaptation of marker points under different mesh densities and window sizes, improving the smoothness of user operation and interaction efficiency, especially in welding simulation to assist in path planning and simulation result analysis.
Smart Images

Figure CN121480166A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of finite element simulation visualization, and in particular to a finite element simulation grid point adaptive marking and interaction method based on VTK. BACKGROUND
[0002] In order to position and control the accuracy during simulation, ensure that the geometric relationship and physical field distribution of each component in the simulation process accurately reflect the real situation, at present, the mainstream finite element simulation software such as welding simulation and structure analysis can realize basic marking such as high-light display and symbol marking of grid points, but the marking size cannot be dynamically adjusted according to the characteristics of the grid itself, and the core defects are the lack of size adaptive ability and the lack of scaling synchronization.
[0003] The lack of size adaptive ability specifically manifests that the marking size cannot be related to the grid density characteristics, and in the grid dense area of weld and stress concentration, the fixed size marking is easy to overlap with the adjacent grid, shielding the key details, which seriously affects the user observation, and the lack of scaling synchronization is that when the user performs scaling operation on the model, the marking size does not form a linkage mechanism with the model scaling ratio, the model is enlarged, and the marking is enlarged with the model, resulting in that the large marking covers the model body, the model is reduced, and the marking is reduced, even reduced to the naked eye, which destroys the visual coherence and operability of the marking, and increases the interactive burden of the user. SUMMARY
[0004] In order to solve the technical problems existing in the prior art, the present application provides a finite element simulation grid point adaptive marking and interaction method based on VTK.
[0005] In order to solve the above technical problems, the present application provides the following technical scheme: a finite element simulation grid point adaptive marking and interaction method based on VTK, which specifically comprises the following steps:
[0006] S1, obtaining the grid data of the finite element simulation model and the size information of the current display window;
[0007] S2, determining the initial radius of the spherical marking point based on the rendering window size and the grid size;
[0008] S3, generating a visual spherical marking point at the target grid point corresponding to the picking position based on the VTK graphic rendering component;
[0009] S4, responding to the mouse wheel zoom event, inversely dynamically adjusting the radius of the marking point when the model is scaled;
[0010] S5, the display state of the spherical marker point is updated in real time through the rendering interface of VTK, so that the spherical marker point keeps constant visual size during the model scaling process.
[0011] Preferably, the step S1 specifically comprises the following steps:
[0012] S11, the grid data of the simulation model comprises grid node coordinate information, cell topology relationship and cell attribute data: firstly, the grid node coordinate information is extracted, and XYZ coordinate values are stored in a vtkPoints object; then, the cell topology relationship is parsed: four vertex indexes of a tetrahedron cell are read to form a VTK_TETRA cell, and eight vertex indexes of a hexahedron cell are read to construct a VTK_HEXAHEDRON cell, and a complete grid topology structure is gradually established through an InsertNextCell operation; then, physical field attribute data is loaded: a scalar field (such as temperature and stress) is bound as a single-component floating-point array according to point attributes, a vector field (such as displacement) is constructed as a three-component floating-point array, and cell state attributes (such as life and death markers) are attached to the grid as cell attributes; S12, the current display window size information is obtained through a GetSize() function in the vtkWindow, including pixel values of the window width W and the window height H.
[0013] Preferably, the step S2 specifically comprises the following steps:
[0014] S21, the window width W is divided by the preset window adaptation coefficient to obtain the reference radius R0. The calculation formula is as follows:
[0015] ;
[0016] S22, the picking position of the mouse on the grid is obtained through the picking component of VTK, the grid cell to which the picking position belongs is determined, the GetCellId() function in the vtkCellPicker is called to obtain the grid cell ID corresponding to the mouse cursor position, the GetPoint() function in the vtkPoints is called to obtain the coordinates of all vertices in the cell, the Euclidean distance between any two points is calculated according to the vertex coordinates, all vertices in the cell are traversed, the distance between each vertex is obtained, and all vertex distances are compared to determine the minimum distance , the grid adaptation coefficient is set to according to the grid density adaptation requirement, and the generated adaptive radius R is:
[0017] ;
[0018] S23, the and smaller value in as the initial radius .
[0019] Preferably, step S3 specifically includes the following steps:
[0020] S31, the marker point is precisely positioned to the target grid point using the SetCenter() function in vtkSphereSource, and the SetRadius() function in vtkSphereSource is used to... The function sets the initial size of the marker point, which is determined by the initial radius. The center position of the marker point is set using the SetCenter() function in vtkSphereSource, and the smoothness of the sphere is controlled using the SetThetaResolution() and SetPhiResolution() functions.
[0021] S32 establishes a connection between the sphere data source and the mapper through the SetInputConnection (OutputPort) function in vtkAlgorithm, and binds the mapper to the renderable entity through vtkPolyDataMapper, mapping the spherical geometry data into graphic data that the rendering pipeline can recognize, thus realizing data format conversion;
[0022] S33, the color of the marker point is set by the SetColor() function in vtkLight. The spherical marker point has a different color than the mesh model. The marker point is added to the rendering scene by the AddActor() function in vtkRenderer.
[0023] Preferably, step S4 specifically includes the following steps:
[0024] S41, Visual magnification factor of the model when the scroll wheel rolls forward. As the model size increases, the marker points also enlarge. To maintain a visually constant marker point size, the marker point size should be reduced proportionally. The marker radius after scrolling... Adjusted to:
[0025]
[0026] in, This indicates the radius when the roller is not rolling. The initial value is ;
[0027] S42, Visual scaling factor of the model when the scroll wheel rolls backward. As the model size shrinks, the marker points also shrink. To maintain a visually constant marker point size, the marker point size should be enlarged proportionally. The marker radius after scrolling... Adjusted to:
[0028] ;
[0029] in, This indicates the radius when the roller is not rolling. The initial value is ;
[0030] S43, each time the scroll wheel is detected to be scrolling, if it scrolls forward, execute step S41; if it scrolls backward, execute step S42.
[0031] Preferably, in step S5, after each adjustment of the marker point radius, the Render() function in vtkWindow is called to render the marker point in real time, so that changes in the position and size of the marker point are immediately updated on the screen, ensuring the real-time nature of user operation and visual feedback, and maintaining the stability of the visual size of the spherical marker point during model scaling. Stability means that the ratio of the projection diameter of the marker point on the screen to the window width remains constant.
[0032] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0033] 1. This invention solves the problem of adapting marker points to different mesh densities and window sizes by using a dual-dimensional adaptive radius calculation based on window size and mesh features. Through a scaling linkage compensation mechanism, it ensures that the visual size of marker points remains stable during model scaling, thereby improving the smoothness of interaction. Based on VTK, it can be integrated into various simulation software, significantly improving the efficiency and user experience of user operations in finite element pre- and post-processing.
[0034] 2. The adaptive marking and interaction method in this invention is applicable to pre- and post-processing scenarios of welding simulation. It can mark key grid points on the weld trajectory, set key point markings for welding path, assist in path planning, locate through marked points, calculate geometric parameters such as distance and angle between two points, perform grid point measurement and key point marking, display simulation data such as temperature and deformation when the mouse hovers over a marked point, query simulation results for key point markings, and generate analysis curves such as temperature-time and stress-position based on the time series data of marked points, realize the drawing of time and position curves for key point markings, and provide intuitive support for simulation result analysis. Attached Figure Description
[0035] Figure 1 This is a schematic diagram of the adaptive tagging and interaction method steps of the present invention;
[0036] Figure 2This is a schematic diagram of the adaptive tagging and interaction method of the present invention;
[0037] Figure 3 This is a schematic diagram comparing the radii of adaptive marker points for grid density according to the present invention;
[0038] Figure 4 This is a schematic diagram of the marker points during the scaling process of the present invention. Detailed Implementation
[0039] The present invention will be further described below with reference to the accompanying drawings and embodiments, which illustrate the above and other technical features and advantages of the present invention. However, the following embodiments are merely preferred embodiments of the present invention and are not exhaustive.
[0040] Example 1:
[0041] like Figures 1-4 As shown, this invention provides a VTK-based adaptive marking and interaction method for finite element simulation mesh points. The method specifically includes the following steps:
[0042] S1, obtain the mesh data of the finite element simulation model and the size information of the current display window;
[0043] S2, determine the initial radius of the spherical marker point based on the rendering window size and the grid size;
[0044] S3, a VTK-based graphics rendering component, generates visual spherical markers at the target grid points corresponding to the picking position;
[0045] S4, responding to the mouse wheel zoom event, dynamically adjusts the radius of the marker point in the reverse direction when the model is zoomed;
[0046] S5 updates the display status of spherical markers in real time through VTK's rendering interface, ensuring that the visual size of the spherical markers remains constant during model scaling.
[0047] In this embodiment, step S1 specifically includes the following steps:
[0048] S11, the mesh data of the simulation model includes mesh node coordinate information, cell topology and element attribute data: First, extract the mesh node coordinate information, store the XYZ coordinate values into vtkPoints objects, and then parse the cell topology—read 4 vertex indices for tetrahedral elements to form VTK_TETRA elements, read 8 vertex indices for hexahedral elements to construct VTK_HEXAHEDRON elements, and gradually build a complete mesh topology through InsertNextCell operation. Then, load the physical field attribute data: scalar fields (such as temperature and stress) are bound to single-component floating-point arrays by point attributes, vector fields (such as displacement) are constructed into three-component floating-point arrays, and element state attributes (such as birth and death markers) are attached to the mesh as element attributes;
[0049] S12, obtain the current display window size information through the GetSize() function in vtkWindow, including the pixel values of the window width W and the window height H, which are used for subsequent window adaptation calculation of the marker point radius.
[0050] In this embodiment, step S2 specifically includes the following steps:
[0051] S21, based on window width Adaptation coefficient with preset window , reference radius The calculation formula is:
[0052] ;
[0053] S22: The mouse's pickup position on the grid is obtained using VTK's pickup component. The corresponding grid cell is determined, and the GetCellId() method in vtkCellPicker is called to retrieve the ID of the grid cell corresponding to the mouse cursor position. The GetPoint() method in vtkPoints is then called to obtain the coordinates of all vertices in the cell. The Euclidean distance between any two points is calculated based on these vertex coordinates using the following formula:
[0054]
[0055] Iterate through all vertices in the cell, obtain the distance between each vertex, compare the distances between all vertices, and determine the minimum distance. ;
[0056] Based on the mesh density adaptation requirement of ensuring that the radius of the marker point is less than one-fifth of the minimum vertex spacing, the mesh adaptation coefficient is set to... The generated adaptive radius for:
[0057] ;
[0058] S23, Select and smaller value in as the initial radius .
[0059] In this embodiment, step S3 specifically includes the following steps:
[0060] S31, the marker point is precisely positioned to the target grid point using SetCenter() in vtkSphereSource, and then using SetRadius() in vtkSphereSource. Set the initial size of the marker point. The initial size of the marker point is determined by the initial radius. Configure the settings to ensure the dimensions match the calculation results, using the SetCenter function in vtkSphereSource. Set the center position of the marker point, and control the smoothness of the sphere through SetThetaResolution() and SetPhiResolution(). The higher the value, the closer it is to the ideal sphere.
[0061] S32 establishes a connection between the sphere data source and the mapper through SetInputConnection (OutputPort) in vtkAlgorithm, and binds the mapper to the renderable entity through vtkPolyDataMapper, thereby mapping the spherical geometric data (vtkPolyData type) into graphic data that the rendering pipeline can recognize, and realizing data format conversion;
[0062] S33, set the color of the marker point using SetColor (m_point_color) in vtkLight. The spherical marker point uses a different color than the mesh model to ensure that the marker point is always visible. Add the marker point to the rendering scene using AddActor (m_closepoint_actor) in vtkRenderer.
[0063] Where m_point_color represents the RGB value of the marker point color, and m_closepoint_actor represents the actor object of the marker point.
[0064] In this embodiment, step S4 specifically includes the following steps:
[0065] S41, Visual magnification factor of the model when the scroll wheel rolls forward. As the model size increases, the marker points also enlarge. To maintain a visually constant marker point size, the marker point size should be reduced proportionally. The marker radius after scrolling... Adjusted to:
[0066]
[0067] in, This indicates the radius when the roller is not rolling. The initial value is ;
[0068] S42, Visual scaling factor of the model when the scroll wheel rolls backward. As the model size shrinks, the marker points also shrink. To maintain a visually constant marker point size, the marker point size should be enlarged proportionally. The marker radius after scrolling... Adjusted to:
[0069]
[0070] in, This indicates the radius when the roller is not rolling. The initial value is ;
[0071] S43, each time the scroll wheel is detected to be scrolling, if it scrolls forward, execute step S41; if it scrolls backward, execute step S42.
[0072] In this embodiment, after each adjustment of the marker point radius in step S5, the Render() function in vtkWindow is called to render the marker point in real time, so that the changes in the position and size of the marker point are immediately updated on the screen, ensuring the real-time nature of user operation and visual feedback, and keeping the visual size of the spherical marker point stable during model scaling. Stability means that the ratio of the projection diameter of the marker point on the screen to the window width remains constant.
[0073] Example 2:
[0074] In this embodiment, step S1 involves obtaining the mesh data of the finite element simulation model and the size information of the current display window: the mesh data of the welding simulation model is read through VTK's vtkUnstructuredGrid, and the element attribute is the temperature value; the current display window size is obtained as 1920×1080 pixels and the window width W is 1920 pixels through the GetSize() function in vtkWindow.
[0075] In this embodiment, step S2, determining the initial radius of the spherical marker point based on the rendering window size and the mesh size, specifically includes the following steps:
[0076] S21, In order to ensure the basic visibility of the marker points within a 1920-pixel wide window, adjust the window adaptation coefficient. Set to 0.0005, window baseline radius Then it is:
[0077] ;
[0078] S22, by calling the GetCellId() method in vtkCellPicker, the ID of the grid cell corresponding to the mouse cursor position is obtained. When the mouse is in the model area, the grid cell with cell ID 1699 is picked up.
[0079] The GetPointIds() function in vtkCell is called to extract the vertex IDs of the cell as (2254, 2260, 2112). Combined with the GetPoint() function in vtkPoints, the vertex coordinates are obtained as (110.00, 46.03, 66.50), (110.00, 44.56, 59.04), and (110.00, 50.99, 61.73).
[0080] Calculate the Euclidean distance between any two points to obtain the minimum distance. To ensure that the radius of the marked point is less than one-fifth of the minimum vertex spacing, the mesh adaptation coefficient is set to... If it is 0.1, then :
[0081] ;
[0082] like Figure 2 As shown, in densely meshed regions (left image), the mesh size is small, and the Euclidean distance between any two points in a single mesh cell is... If it is smaller, then the result is The radius is relatively small, with a marker ID of 293 and a radius of 0.2. The marker automatically adopts a smaller radius to avoid occluding adjacent grids.
[0083] In sparsely gridded regions (right figure), the region grid size is relatively large, and the Euclidean distance between any two points in a single grid cell is... If it is larger, then the result is The marker point is relatively large, with an ID of 2206 and a radius of 0.34. The marker point uses a large radius to ensure visibility and avoid obscuring the dense mesh of the weld seam.
[0084] S23, Initial radius determined: .
[0085] In this embodiment, step S3 involves generating a visual spherical marker point at the target grid point corresponding to the pickup position using the VTK-based graphics rendering component.
[0086] The marker point is precisely positioned to the target grid point using SetCenter() in vtkSphereSource, and then SetRadius() is called. Set the radius, use SetCenter (x,y,z) to set the center position of the marker point, and use SetThetaResolution(30) and SetPhiResolution(30) to ensure the smoothness of the sphere;
[0087] The geometric data is passed to the mapper through SetInputConnection(), and the mapper is bound to the renderable entity through vtkPolyDataMapper, so as to map the spherical geometric data into graphic data that the rendering pipeline can recognize, thereby realizing data format conversion;
[0088] The marker is associated with m_point_actor via SetMapper(); the marker is set to red and the mesh model is gray RGB (0.5,0.5,0.5) by calling SetColor (1,0,0) in vtkActor; and the marker is added to the rendering scene by adding Actor (m_point_actor) in vtkRenderer.
[0089] In this embodiment, step S4 listens to the mouse wheel scrolling direction by registering the event callback function handle_mousewheel_event(), and responds to the mouse wheel scaling event. When the model scales, the radius of the marker point is dynamically adjusted in the opposite direction.
[0090] As the roller moves forward, the model zooms in. When, adjust the radius of the marker point to ;
[0091] As the roller rolls backward, the model shrinks. When, adjust the radius of the marker point to .
[0092] In this embodiment, step S5 involves updating the display status of the spherical marker points in real time through the VTK rendering interface, so that the visual size of the spherical marker points remains constant during model scaling: calling the Render() function in vtkWindow to refresh the rendering scene in real time, triggering the VTK rendering pipeline to redraw, updating the display status of the spherical marker points in real time through the VTK rendering interface, and immediately rendering the adjusted marker points onto the screen, updating the position and size of the marker points in real time.
[0093] like Figure 3 As shown, Figure (a) shows the marker points before model scaling, with a projected diameter of 25 pixels; Figure (b) shows the marker points after model scaling, with a projected diameter of 25 pixels; and Figure (c) shows the marker points after model scaling, with a projected diameter of 25 pixels. The visual size of the marker points remains stable during the model scaling process.
[0094] The above description is merely a preferred embodiment of the present invention and is illustrative rather than restrictive. Those skilled in the art will understand that many changes, modifications, and even equivalents can be made within the spirit and scope defined by the claims of the present invention, all of which will fall within the protection scope of the present invention.
Claims
1. A VTK-based finite element simulation mesh point adaptive marking and interaction method, characterized in that, The adaptive marking and interaction method for finite element simulation mesh points specifically includes the following steps: S1, obtain the mesh data of the finite element simulation model and the size information of the current display window; S2, determine the initial radius of the spherical marker point based on the rendering window size and the grid size; S3, a VTK-based graphics rendering component, generates visual spherical markers at the target grid points corresponding to the picking position; S4, responding to the mouse wheel zoom event, dynamically adjusts the radius of the marker point in the reverse direction when the model is zoomed; S5 updates the display status of spherical markers in real time through VTK's rendering interface, ensuring that the visual size of the spherical markers remains constant during model scaling.
2. The VTK-based finite element simulation mesh point adaptive marking and interaction method as described in claim 1, characterized in that, Step S1 specifically includes the following steps: S11, the mesh data of the simulation model includes mesh node coordinate information, cell topology and element attribute data: First, extract the mesh node coordinate information, store the XYZ coordinate values into vtkPoints objects, and then parse the cell topology—read 4 vertex indices for tetrahedral elements to form VTK_TETRA elements, read 8 vertex indices for hexahedral elements to construct VTK_HEXAHEDRON elements, and gradually build a complete mesh topology structure through InsertNextCell operation. Then, load the physical field attribute data: scalar fields are bound to single-component floating-point arrays by point attributes, vector fields are constructed into three-component floating-point arrays, and element state attributes are attached to the mesh as element attributes; S12, obtain the current display window size information, including the pixel values of the window width W and the window height H, through the GetSize() function in vtkWindow.
3. The VTK-based finite element simulation mesh point adaptive marking and interaction method as described in claim 1, characterized in that, Step S2 specifically includes the following steps: S21, based on window width Adaptation coefficient with preset window Reference radius The calculation formula is: ; S22: The mouse's picking position on the grid is obtained using VTK's picking component. The corresponding grid cell is determined, and the GetCellId() function in vtkCellPicker is called to retrieve the ID of the grid cell at the cursor position. The GetPoint() function in vtkPoints is called to obtain the coordinates of all vertices in the cell. The Euclidean distance between any two points is calculated based on the vertex coordinates. After iterating through all vertices in the cell and obtaining the distance between each vertex, the distances between all vertices are compared to determine the minimum distance. Based on the mesh density adaptation requirement of ensuring that the radius of the marked point is less than one-fifth of the minimum vertex spacing, the mesh adaptation coefficient is set to [value missing]. The generated adaptive radius for: ; S23, Select and smaller value in as the initial radius .
4. The adaptive marking and interaction method for finite element simulation mesh points based on VTK as described in claim 1, characterized in that, Step S3 specifically includes the following steps: S31, the marker point is precisely positioned to the target grid point using the SetCenter() function in vtkSphereSource, and the SetRadius() function in vtkSphereSource is used to... The function sets the initial size of the marker point, which is determined by the initial radius. The center position of the marker point is set using the SetCenter() function in vtkSphereSource, and the smoothness of the sphere is controlled using the SetThetaResolution() and SetPhiResolution() functions. S32 establishes a connection between the sphere data source and the mapper through the SetInputConnection (OutputPort) function in vtkAlgorithm, and binds the mapper to the renderable entity through vtkPolyDataMapper, mapping the spherical geometry data into graphic data that the rendering pipeline can recognize, thus realizing data format conversion; S33, set the color of the marker point using the SetColor() function in vtkLight. The spherical marker point uses a different color than the mesh model to ensure that the marker point is always visible. Add the marker point to the rendering scene using the AddActor() function in vtkRenderer.
5. The VTK-based finite element simulation mesh point adaptive marking and interaction method as described in claim 1, characterized in that, Step S4 specifically includes the following steps: S41, Visual magnification factor of the model when the scroll wheel rolls forward. As the model size increases, the marker points also enlarge. To maintain a visually constant marker point size, the marker point size should be reduced proportionally. The marker radius after scrolling... Adjusted to: in, This indicates the radius when the roller is not rolling. The initial value is ; S42, Visual scaling factor of the model when the scroll wheel rolls backward. As the model size shrinks, the marker points also shrink. To maintain a visually constant marker point size, the marker point size should be enlarged proportionally. The marker radius after scrolling... Adjusted to: ; in, This indicates the radius when the roller is not rolling. The initial value is ; S43, each time the scroll wheel is detected to be scrolling, if it scrolls forward, execute step S41; if it scrolls backward, execute step S42.
6. The VTK-based finite element simulation mesh point adaptive marking and interaction method as described in claim 1, characterized in that, In step S5, after each adjustment of the marker point radius, the Render() function in vtkWindow is called to render the marker point in real time, so that changes in the position and size of the marker point are immediately updated on the screen, ensuring the real-time nature of user operation and visual feedback, and maintaining the stability of the visual size of the spherical marker point during model scaling. Stability means that the ratio of the projection diameter of the marker point on the screen to the window width remains constant.