Method and device for generating geometric model of streamline pipe, equipment and medium
By parallel computing and using a general graphics processing unit to convert streamline geometric data into streamline geometric data in the browser environment, the problems of JavaScript performance overhead and long network transmission time in traditional methods are solved, and high-speed and real-time adjustment of streamline geometric model generation is achieved.
Patent Information
- Application Number
- CN202510452865.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-07-29
AI Technical Summary
The traditional streamlined geometric model generation method results in large performance overhead, long parameter adjustment time on the browser side, and increased network transmission time, which makes the user operation experience poor.
In a browser environment, streamline geometric data is converted into streamlined geometric data through parallel calculations, and data conversion and rendering is used to reduce JavaScript performance overhead and network transmission time.
The operation experience of streamlined tube geometric model generation task has been improved, the generation speed has been increased by 10 to 100 times, the real-time parameter adjustment has been improved, and the increase in the number of streamlines will no longer increase linearly.
Smart Images

Figure CN120388133A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of computer graphics, 3D model rendering technology, and computer-aided engineering, and particularly relates to a method and device, equipment, and medium for generating a streamline tube geometric model. Background Art
[0002] In the field of engineering design, after drawing the CAD digital model corresponding to the R & D product through Computer-Aided Design (CAD) software, in order to ensure a high-performance product during physical production based on the CAD digital model of the product, it is necessary to repeatedly verify whether the performance of the CAD digital model of the designed product meets the production requirements. Therefore, corresponding simulation experiments need to be carried out on Computer-Aided Engineering (CAE) software to test the performance of the CAD digital model of the designed product, so as to ensure that the designed product can be used normally under various working conditions such as efficiency and speed.
[0003] In Computer-Aided Engineering (CAE) software, the flow trajectory of the fluid is simulated to test the performance of the CAD digital model of the product. For example, if a water pump needs to be produced and the water pump is used to conduct water, then detecting the flow trajectory of the water in the water pump can obtain whether the performance of the designed water pump meets the production requirements. And the streamline function in Computer-Aided Engineering (CAE) software is crucial: streamlines provide a visual representation of the flow field in fluid dynamics simulations, showing how the fluid moves, assisting in understanding complex fluid flow patterns, helping engineers and analysts gain in-depth understanding of how the fluid interacts with the product surface, identifying high-speed or low-speed regions, and understanding the overall behavior of the flow, identifying key regions in the flow field, such as regions where flow separation occurs, recirculation zones, or turbulent regions. This information is crucial for optimizing the design and preventing potential problems.
[0004] In the simulation of the flow trajectory of a fluid, in order to facilitate engineers and analysts to more intuitively observe and analyze the process of how the fluid interacts with the product surface, it is necessary to render the generated streamline data to visualize the streamline data. Regarding the rendering of streamlines, the two most commonly used rendering methods are lines and tubes. Compared with lines, the tube rendering method has several advantages: it can help reduce visual clutter when displaying streamline data, especially in complex simulations; by representing the flow path of the fluid as a tube, it is easier to distinguish different flow regions and understand the overall flow behavior; it can enhance insights into flow characteristics such as velocity, pressure, and turbulence, and by changing the thickness or color of the tube according to these parameters, users can more effectively analyze and interpret the flow of the fluid; the tube can highlight important flow structures such as vortices, recirculation zones, and separation points. This helps engineers identify key areas that may require further investigation or optimization; compared with traditional streamline diagrams, the visual representation of flow using tubes is more aesthetically pleasing and easier to interpret, which is particularly important for important presentations and reports with clear display effects and high visual appeal.
[0005] The inventors' research found that there are two traditional ways to generate a streamline tube geometric model from streamlines:
[0006] 1. One way is to generate the geometric data of the streamline on the server side. The user-side browser requests the geometric data of the streamline, and in the browser, JavaScript is used to call the CPU of the user device to generate the geometric data of the streamline tube corresponding to the streamline, and then render it. However, there are many problems with this streamline tube generation method. First, the CPU executes the streamline tube generation task in a serial manner, that is, after one section of the tube is generated, the generation task of the next section of the tube can be carried out. Doing this serial task in the browser using JavaScript takes a lot of time, increasing the performance overhead of JavaScript and bringing a poor user operation experience (that is, the performance of JavaScript is poor); second, every time the tube parameters are adjusted on the browser side, such as the tube diameter and the adjustment of the tube cross-section shape, it takes from a few seconds to dozens of seconds of generation time. As the number of streamlines increases, the generation time increases linearly.
[0007] 2. Another way is to generate the geometric data of the streamline tube corresponding to the streamline on the server side. The user-side browser requests the geometric data of the streamline tube corresponding to the streamline, and then renders it. Since this method generates the streamline tube on the server side, it avoids the problem of increasing the performance overhead of JavaScript and bringing a poor user operation experience in Method 1. However, the data volume of the streamline tube is at least one order of magnitude (10 times) higher than that of the streamline. Therefore, when transmitting the geometric data of the streamline tube corresponding to the streamline from the server side to the browser side for rendering, the network transmission time increases exponentially, and there is also a problem of bringing a poor user operation experience.
[0008] In summary, there is an urgent need for a streamline tube geometric model generation solution that can improve the user experience when performing the task of generating a streamline tube geometric model. Summary of the Invention
[0009] This application provides a method, device, equipment, and medium for generating a streamline tube geometric model to solve the problem of the poor user experience brought by the traditional streamline tube geometric model generation solution when performing the task of generating a streamline tube geometric model.
[0010] The first aspect of this application provides a method for generating a streamline tube geometric model. This method is executed in the browser environment of the user device, and the method includes:
[0011] Obtain the streamline geometric data stored on the server;
[0012] Create a data transmission channel between the browser and the user device;
[0013] Use the data transmission channel to transmit the streamline geometric data to the user device;
[0014] Convert the streamline geometric data into streamline tube geometric data on the user device according to the parallel computing method;
[0015] Render the streamline tube geometric data to obtain a streamline tube geometric model.
[0016] In some embodiments of this application, the user device includes a general-purpose graphics processing unit, and:
[0017] Convert the streamline geometric data into streamline tube geometric data on the general-purpose graphics processing unit according to the parallel computing method.
[0018] In some embodiments of this application, the general-purpose image processing unit includes threads, and the threads have corresponding identifiers, and:
[0019] Based on the identifier, convert the streamline geometric data into streamline tube geometric data on the thread according to the parallel computing method.
[0020] In some embodiments of this application, the step of converting the streamline geometric data into streamline tube geometric data on the thread according to the parallel computing method includes:
[0021] Based on the created compute shader and identifier, convert the streamline geometric data into streamline tube geometric data on the thread according to the parallel computing method.
[0022] In some embodiments of this application, the streamline geometric data includes line segment geometric data, and the step of converting the streamline geometric data into streamline tube geometric data includes:
[0023] On the user device, according to the parallel computing method, the line segment geometric data is converted into line segment tube geometric data, and based on the line segment tube geometric data, the streamline tube geometric data is calculated.
[0024] In some embodiments of the present application, the line segment geometric data includes line vertex geometric data, and the step of converting the line segment geometric data into line segment tube geometric data includes:
[0025] Based on the line vertex geometric data, the normal vectors of the line vertices are calculated in parallel;
[0026] Based on the normal vectors of the line vertices, the attitude matrices of the line vertices are calculated in parallel;
[0027] Based on the preset initial cross-section and the attitude matrix of the line vertices, the target cross-sections of the line vertices are calculated in parallel;
[0028] Based on the target cross-sections of the line vertices, the line segment tube geometric data is calculated in parallel.
[0029] In some embodiments of the present application, the step of converting the streamline geometric data into streamline tube geometric data further includes: storing the normal vectors, attitude matrices, target cross-sections, and line segment tube geometric data in the created shader storage buffer in real time for the user device to call and calculate the streamline tube geometric model.
[0030] The second aspect of the present application provides a streamline tube geometric model generation device, which is configured on the user device, and the streamline tube geometric model generation device of the present application includes:
[0031] A data acquisition module, configured to acquire the geometric data of the streamline stored on the server;
[0032] A channel establishment module, configured to create a data transmission channel between the browser and the user device;
[0033] A data transmission module, configured to use the data transmission channel to transmit the geometric data of the streamline to the user device;
[0034] A streamline tube generation module, configured to convert the geometric data of the streamline into the geometric data of the streamline tube on the user device according to the parallel computing method;
[0035] A streamline tube rendering module, configured to render the geometric data of the streamline tube to obtain the geometric model of the streamline tube.
[0036] The third aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in any one of the first aspects in the above embodiments are implemented.
[0037] The fourth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in any item of the first aspect in the above embodiments is implemented.
[0038] The present application has the following beneficial effects:
[0039] First, the present application obtains the geometric data of the streamline stored on the server on the browser; secondly, a data transmission channel is established between the browser and the user device; then, based on this data transmission channel on the browser, the geometric data of the streamline is transmitted to the user device; finally, on the user device, according to the parallel computing method, the geometric data of the streamline is converted into the geometric data of the streamline tube and rendered to obtain the geometric model of the streamline tube. In the above embodiments of the present application, the geometric data of the streamline is converted into the geometric data of the streamline tube in the browser environment according to the parallel computing method, reducing the performance overhead of JavaScript on the browser. At the same time, the browser obtains the geometric data of the streamline on the server, not the geometric data of the streamline tube, reducing the network transmission time during rendering on the browser side. So that when the user adjusts the contour parameters of the streamline tube, the generation structure of the geometric model of the streamline tube can be viewed in real time, improving the operation experience of the user when performing the task of generating the geometric model of the streamline tube. Description of the Drawings
[0040] The drawings here are incorporated into the specification and form a part of this specification. These drawings show embodiments that conform to the present application and are used together with the specification to illustrate the technical solutions of the present application.
[0041] Figure 1 It is an example schematic diagram of the visualization after rendering the geometric data of the streamline provided by the present application;
[0042] Figure 2 It is an example schematic diagram of the visualization after rendering the geometric data of the streamline tube provided by the present application;
[0043] Figure 3 It is a schematic flowchart of an embodiment of the method for generating the geometric model of the streamline tube provided by the present application;
[0044] Figure 4 It is an example schematic diagram of the original state of the streamline provided by the present application;
[0045] Figure 5 It is a schematic flowchart of an embodiment of the method for calculating the geometric data of the streamline tube corresponding to the streamline provided by the present application;
[0046] Figure 6 It is a schematic flowchart of an embodiment of the method for calculating the normal vector of the line vertex provided by the present application;
[0047] Figure 7It is an exemplary schematic diagram of the visualization of the line vertex normal vector provided by the present application;
[0048] Figure 8 It is a schematic flowchart of an embodiment of the method for calculating the attitude matrix of the line vertex provided by the present application;
[0049] Figure 9 It is a schematic flowchart of an embodiment of the method for calculating the coordinate data of the cross-section vertices in the target cross-section of the line vertex provided by the present application;
[0050] Figure 10 It is an exemplary schematic diagram of the visualization of an octagon simulating a circular cross-section provided by the present application;
[0051] Figure 11 It is an exemplary schematic diagram of the visualization of the coordinate data of the cross-section vertices in the target cross-section of the line vertex provided by the present application;
[0052] Figure 12 It is a schematic flowchart of an embodiment of the method for calculating the geometric data of the streamline tube corresponding to the streamline provided by the present application;
[0053] Figure 13 It is an exemplary schematic diagram of the visualization of the drawing process of the polygonal streamline tube corresponding to the streamline provided by the present application;
[0054] Figure 14 It is an exemplary schematic diagram of the visualization of the drawing process of the circular streamline tube provided by the present application;
[0055] Figure 15 It is an exemplary schematic diagram of the visualization of the geometric model of the streamline tube provided by the present application;
[0056] Figure 16 It is a schematic framework diagram of an embodiment of the streamline tube geometric model generation device provided by the present application;
[0057] Figure 17 It is a schematic framework diagram of an embodiment of the electronic device provided by the present application;
[0058] Figure 18 It is a schematic framework diagram of an embodiment of the computer-readable storage medium provided by the present application. Specific Embodiments
[0059] The solutions of the embodiments of the present application will be described in detail below with reference to the accompanying drawings of the specification.
[0060] In the following description, specific details such as specific system structures, interfaces, and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the present application.
[0061] As used herein, the term "and / or" is merely a description of the relationship between associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this text generally indicates that the associated objects before and after are in an "or" relationship. In addition, "multiple" in this text means two or more than two. In addition, the term "at least one" in this text means any one of multiple or any combination of at least two of multiple. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set composed of A, B, and C.
[0062] As described in the background art, the traditional method of generating a streamline tube geometric model from streamlines has the following problems: (1) It increases the performance overhead of JavaScript, resulting in a poor user operation experience (i.e., the performance of JavaScript is poor); (2) Every time the tube parameters are adjusted on the browser side, such as adjusting the tube diameter and the tube cross-sectional shape, it takes several seconds to dozens of seconds for the generation time. As the number of streamlines increases, the generation time increases linearly; (4) When rendering on the browser side, the network transmission time doubles. The above problems all bring about poor user operation experience problems.
[0063] For example, for a streamline composed of multiple line vertices (1, 2,..., n), the existing method of generating a streamline tube geometric model from streamlines is to generate the geometric data corresponding to the streamline tube in a serial calculation manner, that is, first calculate the geometric data of the streamline tube of the line segment 1-2 composed of line vertices 1 and 2, and then calculate the geometric data of the streamline tube of the line segment 2-3 composed of line vertices 2 and 3, that is, only after the geometric data of the streamline tube of one line segment is completed can the geometric data of the streamline tube of the next line segment be started.
[0064] To solve the above problems, the present application provides a new streamline tube generation scheme. In the scheme of the present application, in the browser environment, the geometric data of the streamline is converted into the geometric data of the streamline tube in a parallel calculation manner, reducing the performance overhead of JavaScript on the browser. At the same time, what the browser obtains from the server is the geometric data of the streamline, not the geometric data of the streamline tube, reducing the network transmission time when rendering on the browser side, so that when the user adjusts the contour parameters of the streamline tube, the generation structure of the geometric model of the streamline tube can be viewed in real time, improving the user's operation experience when performing the task of generating the streamline tube geometric model.
[0065] For example, for a streamline composed of multiple line vertices (1, 2,..., n), the method for generating a streamline tube geometric model according to the present invention is to generate the geometric data corresponding to the streamline tube through parallel computing, that is, the geometric data of the streamline tube corresponding to the line segment 1-2 formed by line vertices 1 and 2 and the line segment 2-3 formed by line vertices 2 and 3 can be calculated simultaneously, that is, the calculation of the geometric data of the streamline tube for different line segments can be completed simultaneously.
[0066] To better understand the present application, before introducing the specific embodiments of the present application, relevant concepts involved in the present application will be introduced in combination with relevant drawings.
[0067] As Figure 1 shown, it shows a visualization schematic diagram after rendering the streamline geometric data. As Figure 2 shown, it shows a visualization schematic diagram after rendering the streamline tube geometric data.
[0068] A General-Purpose Graphics Processing Unit (GPGPU) refers to a technology that uses the GPU of the user device through webgpu on the browser side to execute non-graphic computing tasks (also known as the GPU in webgpu).
[0069] The present application will be described in detail below in combination with the drawings and specific embodiments.
[0070] According to an embodiment of the present application, the present application provides a method for generating a streamline tube geometric model. As Figure 3 shown, this method executes the following steps S1-S5 in the browser environment of the user device to obtain a streamline tube geometric model: S1. Obtain the streamline geometric data stored on the server; S2. Create a data transmission channel between the browser and the user device; S3. Use the data transmission channel to transmit the streamline geometric data to the user device; S4. On the user device, convert the streamline geometric data into streamline tube geometric data according to the parallel computing method; S5. Render the streamline tube geometric data to obtain a streamline tube geometric model.
[0071] To better understand the generation scheme of the streamline tube in the above embodiment of the present application, steps S1-S5 will be described in detail below.
[0072] I. Step S1
[0073] In step S1, obtain the streamline geometric data stored on the server.
[0074] Among them, according to an embodiment of the present application, when the format of the obtained streamline geometric data cannot be processed by the user device, the format of the streamline geometric data is converted so that the converted streamline geometric data can be processed on the user device.
[0075] Among them, according to an embodiment of the present application, the streamline includes line segments, the line segments include line vertices, the streamline geometric data includes line vertex geometric data, the line vertex geometric data includes coordinate data of the line vertices in the initial three-dimensional coordinate system and index data of the line vertices, and the coordinate data of the line vertices is converted into the Float32Array format, and the index data of the line vertices is converted into the Int32Array format. It should be noted that the above format conversion is only one embodiment of the present application. The formats of the coordinate data and index data of the line vertices can be specifically converted according to the data formats supported by the user device, and no specific limitation is made here.
[0076] For example, as Figure 4 shown, it shows an example schematic diagram of the original state of the streamline.
[0077] From the above description, it can be seen that the above embodiments of the present application convert the streamline geometric data into a data format that can be processed by the user device to complete the generation task of the streamline tube, which not only ensures that the data accuracy meets the requirements of graphics rendering and calculation, but also optimizes the memory usage and access speed, enabling the user device to execute parallel computing tasks more efficiently, thereby accelerating the speed of graphics drawing and other computationally intensive operations, and ultimately providing the user with a smoother and faster visual experience and calculation results.
[0078] II. Step S2
[0079] In step S2, a data transmission channel is created between the browser and the user device.
[0080] Among them, according to an embodiment of the present application, the user device includes a general-purpose graphics processing unit. The steps of creating a data transmission channel between the browser and the user device include: requesting and obtaining access rights to the general-purpose graphics processing unit, and configuring the environmental parameters required for using the general-purpose graphics processing unit to achieve creating a data transmission channel between the browser and the user device. According to another embodiment of the present application, a webgpu instance is created to complete the request and obtain access rights to the general-purpose graphics processing unit; a webgpu context of the browser is created to complete the configuration of the environmental parameters required for using the general-purpose graphics processing unit.
[0081] From the above description, it can be seen that the above embodiments of the present application create a webgpu instance and a WebGPU context, which can enable the browser to directly utilize the general-purpose graphics processing unit to convert the streamline geometric data into streamline tube geometric data in a parallel computing manner, reducing the data transmission cost and improving the execution efficiency of the computing task.
[0082] III. Step S3
[0083] In the step S3, the streamline geometric data is transmitted to the user device through the data transmission channel.
[0084] Among them, according to an embodiment of the present application, a shader storage buffer is created in the general-purpose graphics processing unit, and the streamline geometric data is transmitted to the shader storage buffer through the data transmission channel.
[0085] As can be seen from the above description, in the above embodiments of the present application, the streamline geometric data is stored in the shader storage buffer, so that the devices participating in the calculation can access the streamline geometric data at any time when converting the streamline into a streamline tube in a parallel computing manner, improving the data access speed and calculation efficiency.
[0086] IV. Step S4
[0087] In step S4, on the user device, the streamline geometric data is converted into streamline tube geometric data according to the parallel computing method.
[0088] Among them, according to an embodiment of the present application, the streamline geometric data includes line segment geometric data, and the step of converting the streamline geometric data into streamline tube geometric data includes: on the user device, converting the line segment geometric data into line segment tube geometric data according to the parallel computing method, and calculating the streamline tube geometric data based on the line segment tube geometric data.
[0089] As can be seen from the above description, by parallel computing, the geometric data of the line segments in the streamline is converted into line segment tube geometric data, and all the line segment tube geometric data is spliced into streamline tube geometric data, improving the execution efficiency of the calculation task.
[0090] Among them, according to an embodiment of the present application, on the general-purpose graphics processing unit, the streamline geometric data is converted into streamline tube geometric data according to the parallel computing method.
[0091] As can be seen from the above description, using the general-purpose graphics processing unit on the user device to convert the streamline geometric data into streamline tube geometric data according to the parallel computing method reduces the performance overhead of JavaScript on the browser. At the same time, what the browser obtains from the server is the geometric data of the streamline, not the geometric data of the streamline tube, reducing the network transmission time during rendering on the browser side and solving the performance bottleneck problem caused by large data transmission from the CPU to the GPU (in this application, the streamline tube geometric data is calculated in the GPU and the rendering is completed in the GPU). So that when the user adjusts the contour parameters of the streamline tube, the user can view the generation structure of the geometric model of the streamline tube in real time, improving the operation experience of the user when performing the task of generating the geometric model of the streamline tube.
[0092] Among them, according to an embodiment of the present application, the general-purpose image processing unit includes threads, each thread has a corresponding identifier, and based on the identifier, the streamline geometric data is converted into streamline tube geometric data on the thread according to the parallel computing method. Among them, the identifier indicates the identity of the thread to complete the corresponding calculation for the specified line vertex.
[0093] As can be seen from the above description, in the above embodiment of the present application, by giving the corresponding identifier to the thread and enabling it to perform calculations on the specified line vertex, the unnecessary data transmission process can be reduced, and the execution efficiency of parallel computing can be improved.
[0094] Among them, according to an embodiment of the present application, the step of converting the streamline geometric data into streamline tube geometric data on the thread according to the parallel computing method includes: based on the created compute shader and the identifier corresponding to the thread, converting the streamline geometric data into streamline tube geometric data on the thread according to the parallel computing method. Among them, the compute shader includes an execution program for how multiple threads cooperate to complete the parallel task of converting the streamline geometric data into streamline tube geometric data.
[0095] As can be seen from the above embodiment, the present application integrates the execution program set for how multiple threads cooperate to complete the parallel task of converting the streamline geometric data into streamline tube geometric data into a compute shader, enabling the threads to complete the corresponding calculation tasks according to the configuration in the shader, and finally enabling multiple threads to complete the calculation tasks with a high degree of parallelism, flexibility, performance, and resource management capabilities.
[0096] Among them, according to an embodiment of the present application, on the thread, the line segment geometric data is converted into line segment tube geometric data according to the parallel computing method, and based on the line segment tube geometric data, the streamline tube geometric data is calculated.
[0097] As can be seen from the above description, by parallel computing of the threads, the geometric data of the line segments in the streamline is converted into line segment tube geometric data, and all the line segment tube geometric data is spliced into streamline tube geometric data, reducing the unnecessary data transmission process and improving the execution efficiency of the calculation task.
[0098] Among them, according to an embodiment of the present application, the line segment geometric data includes line vertex geometric data, and as Figure 5 shown, the present application converts the line segment geometric data into the line segment tube geometric data by executing steps S41 - S44: S41, based on the line vertex geometric data, parallelly calculate the normal vector of the line vertex; S42, based on the normal vector of the line vertex, parallelly calculate the pose matrix of the line vertex; S43, based on the preset initial cross-section and the pose matrix of the line vertex, parallelly calculate the target cross-section of the line vertex; S44, based on the target cross-section of the line vertex, parallelly calculate the line segment tube geometric data.
[0099] As can be seen from the above description, in the above embodiments of the present application, the normal vector and the pose matrix of the line vertices are calculated, and the target cross-section of the line vertices is obtained based on the pose matrix and the initial cross-section. Finally, the streamline tube geometry data is obtained based on the target cross-section of the line vertices. This method can accurately define and control the pose and position of the line vertices of the streamline in three-dimensional space, so as to accurately define and control the shape and structure of the streamline in three-dimensional space.
[0100] Wherein, according to an embodiment of the present application, the step of converting the streamline geometry data into the streamline tube geometry data further includes: storing the normal vector, the pose matrix, the target cross-section, and the line segment tube geometry data into the created shader storage buffer in real time for the user device to call and calculate the streamline tube geometry model.
[0101] As can be seen from the above description, storing the data into the shader storage buffer enables the devices participating in the calculation to access the streamline geometry data at any time when converting the streamline into the streamline tube in a parallel computing manner, improving the data access speed and calculation efficiency.
[0102] The following will separately expand and explain steps S41 - S44.
[0103] (I) Step S41
[0104] In step S41, based on the line vertex geometry data, the normal vector of the line vertices is calculated in parallel.
[0105] Wherein, according to an embodiment of the present application, the geometry data of the line vertices includes the coordinate data of the line vertices in the initial three-dimensional coordinate system and the index data of the line vertices. As Figure 6 shown, the following steps S411 - S413 are executed in parallel according to the compute shader call thread on the browser to obtain the normal vector of the line vertices: S411. Extract the line vertex geometry data corresponding to the identifier according to the identifier; S412. Based on the index data of the line vertices, obtain the direction of the line segment where the line vertices are located, and subtract the coordinate data of the line vertices from the coordinate data of the other line vertex constituting the corresponding line segment based on this direction to obtain the normal vector of the line vertices.
[0106] For example, as Figure 7 shown, to calculate the normal vectors of 262,144 line vertices, how the normal vector calculation tasks of these 262,144 line vertices are assigned to different workgroups and threads is defined in the compute shader to complete the calculation task. Among them, 1024 workgroups can be called in parallel, each workgroup consists of 256 threads, and 1024 * 256 can calculate the normal vectors of 262,144 line vertices in parallel at one time, and then store the calculation results into the shader storage buffer.
[0107] For each line segment {i, i+1} of the streamline, calculate the normal vector at the line vertex i. According to the coordinate data p{i} of the line vertex {i} and the coordinate data p{i+1} of the line vertex {i+1}, the segment vector N{i} can be calculated as: normal vector N{i} = p{i+1} - p{i}. For the normal vector of the last line vertex n of the streamline, directly take the normal vector at the line vertex n-1; the normal vector of each line vertex is only related to the next connected line vertex and has nothing to do with other line vertices.
[0108] As can be seen from the above description, in the case where the calculation conditions of the present application are satisfied, the normal vector of each line vertex is executed by one thread, and multiple threads calculate the normal vectors of all line vertices in the streamline in parallel, further improving the calculation efficiency of the execution task.
[0109] (2) Step S42
[0110] In step S42, based on the normal vector of the line vertex, the pose matrix of the line vertex is calculated in parallel.
[0111] Among them, according to an embodiment of the present application, as Figure 8 shown, on the browser, according to the compute shader, the following steps S421 - S425 are executed in parallel by threads to obtain the pose matrix of the line vertex: S421. Take the normal vector of the line vertex corresponding to the identifier as the y-axis according to the identifier; S422. Initialize the x-axis, and based on the x-axis and the y-axis, obtain the z-axis; S423. Based on the x-axis, the y-axis, and the z-axis, obtain the target three-dimensional coordinate system of the line vertex; S424. Based on the target three-dimensional coordinate system of the line vertex, obtain the pose matrix of the line vertex.
[0112] For example, for 262144 line vertices, it is defined in the compute shader how the pose matrix calculation tasks of these 262144 line vertices are assigned to different workgroups and threads to complete the calculation tasks. Among them, 1024 workgroups can be called in parallel. Each workgroup consists of 256 threads. Each thread has an associated identifier (i.e., thread id, global_invocation_id). According to the thread id, the normal vector N{i} associated with the current line vertex i is extracted as the y-axis. Assume that X{i} of the pose matrix is [1, 0, 0] (i.e., the x-axis). Cross-multiplying X{i} by N{i} can obtain the direction of the Z{i} axis (i.e., the z-axis). According to the X{i}, Y{i}, and Z{i} directions, the pose matrix M{i} associated with the current line vertex i can be calculated.
[0113] As described above, in the above embodiments of the present application, the attitude matrix of each line vertex is obtained based on the normal vector of each line vertex, which can accurately define the direction and orientation of the line vertex in the three-dimensional space, ensure that the streamline or line has the correct orientation and shape during the visualization process, and thus obtain a more accurate streamline tube geometric model.
[0114] (III) Step S43
[0115] In step S43, based on the preset initial cross-section and the attitude matrix of the line vertex, the target cross-section of the line vertex is calculated in parallel.
[0116] Wherein, according to an embodiment of the present application, as Figure 9 shown, on the browser, according to the compute shader, the following steps S431 - S432 are executed in parallel by the thread to obtain the target cross-section of the line vertex: S431. According to the identifier, based on the attitude matrix of the line vertex corresponding to the identifier and the initial cross-section data, obtain the attitude cross-section data of the line vertex; S432. Based on the coordinate data of the line vertex and the attitude cross-section data of the line vertex, obtain the target cross-section data of the line vertex.
[0117] As described above, in the above embodiments of the present application, the target cross-section of the line vertex is calculated according to the coordinate data and the attitude matrix of the line vertex. This method ensures the authenticity and accuracy of the streamline tube geometric structure, making the streamline not only appear as a simple line, but an entity with width and direction changes, enhancing the visual expressiveness and the intuitiveness of data interpretation.
[0118] Wherein, according to an embodiment of the present application, the initial cross-section is a circular cross-section, and the circular cross-section is simulated by a polygon. The more sides the polygon has, the closer it is to a circle.
[0119] For example, as Figure 10 shown, it shows a schematic diagram of a visualization example of an octagon simulating a circular cross-section, where the size of the polygon is controlled by the radius r and the number of sides of the polygon is controlled by count.
[0120] As described above, in the above embodiments of the present application, a polygon is used to simulate the circular cross-section, reducing the calculation cost of the coordinate data of the cross-section vertices of the then cross-section and improving the calculation efficiency.
[0121] Wherein, according to an embodiment of the present application, step S431 includes: multiplying the attitude matrix of the line vertex by the initial cross-section data to obtain the attitude cross-section data of the line vertex, where the attitude cross-section data includes the attitude coordinate data of the cross-section vertices.
[0122] For example, based on multiplying the attitude matrix M{i} of line vertex i by the initial cross-section data C, the attitude cross-section data MC of the line vertex is obtained.
[0123] As can be seen from the above description, in the above embodiments of the present application, multiplying the attitude matrix of the line vertex by the initial cross-section can change the attitude of the initial cross-section and use it as the attitude cross-section of the line vertex. Among them, the attitude cross-section conforms to the attitude of the line vertex in three-dimensional space, so that the attitude of the line vertex in three-dimensional space can be intuitively reflected through the attitude cross-section.
[0124] Among them, according to an embodiment of the present application, step S432 includes: adding the coordinate data of the line vertex to the attitude coordinate data of the cross-section vertices in the attitude cross-section of the line vertex to obtain the target cross-section data of the line vertex, where the target cross-section data includes the coordinate data of the cross-section vertices.
[0125] For example, MC + P{i} is used to obtain the target cross-section of line vertex i. As Figure 11 shown, it shows a visualization schematic diagram of the coordinate data of the cross-section vertices in the target cross-section of the line vertex.
[0126] As can be seen from the above description, in the above embodiments of the present application, the coordinate data of the line vertex is superimposed on the attitude coordinate data of the cross-section vertices in its corresponding attitude cross-section. This method can correspond the position of the target cross-section of the line vertex to the position of the line vertex in three-dimensional space, and more accurately obtain the streamline geometric model structure.
[0127] (IV) Step S44
[0128] In step S44, based on the target cross-section of the line vertex, the geometric data of the line segment tube is calculated in parallel.
[0129] Among them, according to an embodiment of the present application, as Figure 12 shown, on the browser, according to the compute shader, the following steps S441 - S442 are executed in parallel by the calling thread to obtain the geometric data of the streamline tubes corresponding to multiple streamlines: S441. According to the identifier, based on the coordinate data of the line vertex corresponding to the identifier, calculate the triangle face index data between the line vertices in the line segment; S442. Based on the triangle face index data and the coordinate data of the cross-section vertices in the target cross-section, calculate the geometric data of the line segment tube.
[0130] Among them, according to an embodiment of the present application, S441 includes: storing the triangle face index data in the shader storage buffer; S442 includes: obtaining the triangle face index data and the coordinate data of the cross-section vertices in the target cross-section in the shader storage buffer, and calculating the geometric data of the line segment tube based on these.
[0131] For example, calculate the triangular face indices between two line vertices {i, i+1} in each line segment, that is, the four points p{i}[0, 1] and p{i+1}[0, 1] form a quadrilateral, and the quadrilateral can be split into two triangles. The triangle rule is counterclockwise. The index of triangle 1 is p{i}[0], p{i+1}[0], p{i+1}[1]; the index of triangle 2 is p{i}[0], p{i+1}[1], p{i}[1]; store the calculated triangular face index data in the shader storage buffer. Among them, as Figure 13 shown, it shows a visualization diagram of the drawing process of the polygonal streamline tube corresponding to the streamline.
[0132] As can be seen from the above description, by storing the calculated triangular face index data and the coordinate data of the cross-section vertices in the target cross-section in the shader storage buffer for real-time data calling during subsequent calculation processes, the data transmission process is reduced, and the efficiency of the calculation task is improved.
[0133] V. Step S5
[0134] In step S5, render the streamline tube geometric data to obtain a streamline tube geometric model.
[0135] For example, as Figure 14 shown, it shows a visualization diagram of the drawing process of a circular streamline tube. As Figure 15 shown, it shows a visualization diagram of the streamline tube geometric model.
[0136] Through the research of the above embodiments by the inventor, compared with the existing scheme of generating a corresponding streamline tube geometric model from a streamline, the scheme of generating a streamline tube geometric model from a streamline in the above embodiments of the present application has a generation speed increased by 10 to 100 times, and the streamline generation streamline tube time does not increase linearly with the increase in the number of streamlines. It is basically controlled within 35 milliseconds for less than 1000 streamlines, which can meet the requirements of user real-time interaction.
[0137] Next, the streamline tube geometric model generation scheme proposed by the present application will be introduced from the system side.
[0138] According to an embodiment of the present application, the present application provides a streamline tube geometric model generation device, as Figure 16As shown in the figure, the device includes: a data acquisition module for acquiring the geometric data of the streamline stored on the server; a channel establishment module for creating a data transmission channel between the browser and the user device; a data transmission module for transmitting the geometric data of the streamline to the user device by using the data transmission channel; a streamline tube generation module for converting the geometric data of the streamline into the geometric data of the streamline tube on the user device according to the parallel computing method; and a streamline tube rendering module for rendering the geometric data of the streamline tube to obtain the geometric model of the streamline tube. For the further functions of the streamline tube geometric model generation device, please refer to the description in the above method embodiment, and details will not be repeated here.
[0139] In summary, compared with the existing streamline tube generation solutions, which either call the CPU on the browser side to execute the streamline tube generation task serially or execute the streamline tube task on the server side, converting the geometric data of the streamline into the geometric data of the streamline tube in the browser environment according to the parallel computing method reduces the performance overhead of JavaScript on the browser. At the same time, the browser obtains the geometric data of the streamline on the server, not the geometric data of the streamline tube, reducing the network transmission time during rendering on the browser side and solving the performance bottleneck problem caused by the large data transmission from the CPU to the GPU. So that when the user adjusts the contour parameters of the streamline tube, the user can view the generation structure of the geometric model of the streamline tube in real time, improving the operation experience of the user when performing the streamline tube geometric model generation task.
[0140] Based on the inventive concept of the above embodiment, the present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in the above embodiment are implemented.
[0141] Among them, the electronic device is a device with computing capabilities (such as a workstation, a server, a multi-core computer, etc.).
[0142] It can be seen from the above description that by executing the streamline tube geometric model generation solution of the above embodiment on the electronic device, the efficiency of the electronic device in generating the streamline tube geometric model can be improved.
[0143] The following will be described in detail in conjunction with Figure 17 this.
[0144] As Figure 17 shown, it shows the electronic device 100 of the present application, which specifically may include a processor 110 and a memory 120. The memory 120 is coupled to the processor 110.
[0145] The processor 110 is used to control the operation of the electronic device. The processor 110 may also be referred to as a CPU (Central Processing Unit). The processor 110 may be an integrated circuit chip with the ability to process signals. The processor 110 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor, or the processor 110 may also be any conventional processor, etc.
[0146] The memory 120 is used to store computer programs, which may be RAM, ROM, or other types of storage terminals. Specifically, the memory 120 may include one or more computer-readable storage media, which may be non-transitory or transitory. The memory 120 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage terminals and flash storage terminals. In some embodiments, the non-transitory computer-readable storage media in the memory 120 is used to store at least one program code.
[0147] The processor 110 is used to execute the computer programs stored in the memory 120 to implement the methods described in the method embodiments of the present application.
[0148] In some embodiments, the electronic device may further include: a peripheral terminal interface 130 and at least one peripheral terminal. The processor 110, the memory 120, and the peripheral terminal interface 130 may be connected through a bus or signal lines. Each peripheral terminal may be connected to the peripheral terminal interface 130 through a bus, signal lines, or a circuit board. Specifically, the peripheral terminal includes at least one of a radio frequency circuit 140, a display screen 150, an audio circuit 160, and a power supply 170.
[0149] The peripheral terminal interface 130 may be used to connect at least one peripheral terminal related to I / O (Input / Output) to the processor 110 and the memory 120. In some embodiments, the processor 110, the memory 120, and the peripheral terminal interface 130 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 110, the memory 120, and the peripheral terminal interface 130 may be implemented on a separate chip or circuit board, and this embodiment does not limit this.
[0150] The radio frequency circuit 140 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 140 communicates with the communication network and other Internet of Things devices through electromagnetic signals, and the radio frequency circuit 140 is the communication circuit of the electronic device. The radio frequency circuit 140 converts electrical signals into electromagnetic signals for transmission, or converts the received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 140 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, an operator identity module card, and so on. The radio frequency circuit 140 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 140 may further include a circuit related to NFC (Near Field Communication), which is not limited in this application.
[0151] The display screen 150 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 150 is a touch display screen, the display screen 150 also has the ability to collect touch signals on or above the surface of the display screen 150. The touch signals can be input to the processor 110 as control signals for processing. At this time, the display screen 150 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 150, which is disposed on the front panel of the electronic device; in other embodiments, there may be at least two display screens 150, which are respectively disposed on different surfaces of the electronic device or are in a folding design; in other embodiments, the display screen 150 may be a flexible display screen, which is disposed on a curved surface or a folding surface of the electronic device. Even, the display screen 150 can be set to an irregular non-rectangular shape, that is, a special-shaped screen. The display screen 150 can be prepared from materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0152] The audio circuit 160 may include a microphone and a speaker. The microphone is used to collect sound waves of the operator and the environment, and convert the sound waves into electrical signals for input to the processor 110 for processing, or input to the radio frequency circuit 140 to achieve voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the electronic device. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signal from the processor 110 or the radio frequency circuit 140 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for uses such as ranging. In some embodiments, the audio circuit 160 may further include a headphone jack.
[0153] The power supply 170 is used to supply power to each component in the electronic device. The power supply 170 may be alternating current, direct current, a disposable battery or a rechargeable battery. When the power supply 170 includes a rechargeable battery, the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery may also be used to support fast charging technology.
[0154] For a detailed description of the functions and execution processes of each functional module or component in the embodiments of the electronic device of the present application, reference may be made to the descriptions in the above method embodiments of the present application, and details are not described herein again.
[0155] In several embodiments provided in the present application, it should be understood that the disclosed electronic device and method may be implemented in other ways. For example, the embodiments of the electronic device described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
[0156] The unit described as a separated component may or may not be physically separated, and the component displayed as a unit may or may not be a physical unit, that is, it may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] In addition, in each embodiment of the present application, each functional unit may be integrated into a processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.
[0158] Based on the inventive concept of the above embodiments, the present application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method in any of the above embodiments. The following describes Figure 18 the execution process of the above embodiments in the computer-readable storage medium.
[0159] As Figure 18 shown, it shows the computer-readable storage medium of the present application. If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in the computer-readable storage medium 200. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions / computer programs for causing an Internet of Things device (which may be a personal computer, a server, or a network terminal, etc.) or a processor to execute all or part of the steps of the methods in various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, external hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs, as well as electronic terminals such as computers, mobile phones, laptop computers, tablet computers, cameras, etc. having the above storage media.
[0160] The description of the execution process of the program data in the computer-readable storage medium may refer to the description in the method embodiments of the present application above, and will not be repeated here.
[0161] The above are only the embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be included in the patent protection scope of the present application by the same token.
[0162] Those skilled in the art can understand that in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
Claims
1. A method for generating a streamline tube geometric model, characterized in that, The method is executed in the browser environment of the user equipment, and the method includes: Obtain the streamline geometry data stored on the server; Create a data transmission channel between the browser and the user equipment; Use the data transmission channel to transmit the streamline geometry data to the user equipment; On the user equipment, convert the streamline geometry data into streamline tube geometry data according to the parallel computing method; Render the streamline tube geometry data to obtain a streamline tube geometry model.
2. The method for generating a streamline tube geometric model according to claim 1, characterized in that, The user equipment includes a general-purpose graphics processing unit, and: On the general-purpose graphics processing unit, convert the streamline geometry data into the streamline tube geometry data according to the parallel computing method.
3. The method for generating a streamline tube geometric model according to claim 2, wherein The general-purpose image processing unit includes threads, and the threads have corresponding identifiers, and: Based on the identifier, on the thread, convert the streamline geometry data into the streamline tube geometry data according to the parallel computing method.
4. The method for generating a streamline tube geometric model according to claim 3, wherein The step of converting the streamline geometry data into the streamline tube geometry data on the thread according to the parallel computing method includes: Based on the created compute shader and the identifier, on the thread, convert the streamline geometry data into streamline tube geometry data according to the parallel computing method.
5. The method for generating a streamline tube geometric model according to claim 1, characterized in that The streamline geometry data includes line segment geometry data, and the step of converting the streamline geometry data into streamline tube geometry data includes: On the user equipment, convert the line segment geometry data into line segment tube geometry data according to the parallel computing method, and calculate the streamline tube geometry data according to the line segment tube geometry data.
6. The method for generating the streamline tube geometric model according to claim 5, characterized in that, The line segment geometry data includes line vertex geometry data, and the step of converting the line segment geometry data into the line segment tube geometry data includes: Based on the line vertex geometry data, parallel compute the normal vector of the line vertex; Based on the normal vector of the line vertex, parallel compute the pose matrix of the line vertex; Based on a preset initial cross-section and the pose matrix of the line vertex, parallel compute the target cross-section of the line vertex; Based on the target cross-section of the line vertex, parallel compute the line segment tube geometry data.
7. The method for generating the streamline tube geometric model according to claim 6, wherein The step of converting the streamline geometry data into streamline tube geometry data further includes: storing the normal vector, the pose matrix, the target cross-section, and the line segment tube geometry data into a created shader storage buffer in real time for the user equipment to call and calculate the streamline tube geometry model.
8. A streamline tube geometric model generation device, characterized in that The device is configured on the user equipment, and the device includes: A data acquisition module for acquiring the streamline geometry data stored on the server; A channel establishment module for creating a data transmission channel between the browser and the user equipment; A data transmission module for using the data transmission channel to transmit the streamline geometry data to the user equipment; A streamline tube generation module for converting the streamline geometry data into streamline tube geometry data on the user equipment according to the parallel computing method; A streamline tube rendering module for rendering the streamline tube geometry data to obtain a streamline tube geometry model.
9. An electronic device, characterized in that, Comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implements the steps of the method according to any one of claims 1-7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1-7 are implemented.