Webgpu-based address cavity pressure stratification visualization method and system
By adopting a WebGPU-based address cavity pressure layer visualization method, the problem of unstable cavity pressure field visualization results was solved, and efficient, stable and intuitive pressure layer display was achieved on the browser side, improving the reliability of engineering collaboration and delivery.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHONGKE HUIZHI (BEIJING) TECH CO LTD
- Filing Date
- 2026-06-10
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies suffer from poor stability in cavity pressure field visualization, insufficient engineering practicality, difficulty in displaying intuitive pressure segment differences on the browser side, frequent model reloading and reconstruction leading to performance lag, and a lack of state saving and recovery mechanisms.
A WebGPU-based address cavity pressure layering visualization method is adopted. By stabilizing the color mapping through extremum exchange and range limitation, the layering boundary is adaptively determined. Non-equidistant layering is performed using local bounding boxes and clipping plane equations. Multi-layer parallel rendering is achieved by combining geometric buffer binding, and view state serialization and persistence are supported.
It improves the visual recognition of the pressure gradient region inside the cavity, reduces video memory usage and data transfer overhead, improves rendering efficiency, and ensures stable and reproducible rendering results.
Smart Images

Figure CN122368282A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of 3D visualization, and in particular relates to a WebGPU-based method and system for hierarchical visualization of address cavity pressure. Background Technology
[0002] In engineering fields such as oil and gas energy storage, chemical plants, underground caverns and storage tanks, it is often necessary to visualize the pressure field distribution inside the cavity to support engineering needs such as monitoring operating conditions, verifying parameters during construction, and accepting and reporting simulation results. With the popularization of 3D visualization technology on browsers, how to achieve intuitive display of the pressure field inside the cavity without relying on professional client software has become an urgent need in engineering practice.
[0003] In existing technologies, common methods for displaying cavity pressure fields include two-dimensional curves, single-section rendering, overall monochrome rendering, and mapping pressure data to model surface textures. These methods typically normalize externally input pressure values according to a fixed threshold and output the rendering results in the form of overall coloring or single section. Moreover, each time the data is updated on the browser side, it is often necessary to reload the model and rebuild all materials and geometry, and there is a lack of persistent storage and verification mechanisms for rendering parameters and viewpoint states.
[0004] However, the above methods have obvious shortcomings in practical engineering applications. On the one hand, overall coloring is difficult to intuitively express the pressure segment differences along the height direction inside the cavity, and key abnormal intervals are easily obscured by geometric details and are difficult to identify. On the other hand, when the range parameter of the input pressure value is abnormal, the fixed threshold normalization method is prone to color distortion or even rendering results that are uninterpretable. Frequent model reloading and full reconstruction cause obvious performance lag and lack state saving and recovery mechanisms. This makes it impossible to stably reproduce the rendering results in different environments, which seriously affects the reliability of engineering collaboration and delivery. Summary of the Invention
[0005] The purpose of this application is to provide a WebGPU-based method and system for visualizing address cavity pressure layers, in order to solve the problems of poor stability and insufficient engineering practicality of the visualization results of address cavity pressure fields in the prior art.
[0006] To address the aforementioned technical problems, in a first aspect, this application provides a WebGPU-based method for hierarchical visualization of address cavity pressure, comprising:
[0007] Receive data packets including model identifier, pressure value sequence, color mapping range, and basic color parameters;
[0008] By exchanging and limiting the extreme values of the color mapping range, a normalized sequence is obtained by mapping and truncating the pressure values in the pressure value sequence.
[0009] The absolute values of the first-order differences between adjacent elements in the pressure numerical sequence are normalized to obtain the pressure distribution sequence.
[0010] Based on the local bounding box, the position where the cumulative pressure probability reaches the division point is determined as the layer boundary according to the pressure distribution sequence, and a non-equidistant boundary array is obtained. The clipping plane equation pair of each layer is constructed according to the upper and lower boundaries in the non-equidistant boundary array. The local bounding box is obtained by spatial alignment by loading the cavity model using the model identifier.
[0011] The display color of each layer is obtained by interpolating the basic color parameters according to the normalization ratio value of the normalization sequence. A geometry buffer and an instantiation buffer are created in WebGPU, and the vertex data of the cavity model in the geometry buffer are bound to the display color and the clipping plane equation in the instantiation buffer.
[0012] Based on the clipping plane equation pairs corresponding to each instance number in the instantiation buffer, a plane test is performed on the vertex coordinates in the geometry buffer, and a color is assigned to the pixels that pass the plane test according to the display color corresponding to each instance number, thereby obtaining a visualization image.
[0013] Optionally, before mapping and truncating the pressure values in the pressure value sequence to obtain a normalized sequence, the method further includes:
[0014] Calculate the sum of squares of the first-order differences of all adjacent elements in the pressure numerical sequence, and divide the sum of squares by the length of the pressure numerical sequence to obtain the pressure fluctuation intensity value.
[0015] When the pressure fluctuation intensity value is greater than a preset first intensity threshold, the target layer number is determined to be a preset first layer number. When the pressure fluctuation intensity value is less than a preset second intensity threshold, the target layer number is determined to be a preset second layer number. When the pressure fluctuation intensity value is between the second intensity threshold and the first intensity threshold, the target layer number is set to a preset third layer number. The first intensity threshold is greater than the second intensity threshold, the first layer number is greater than the third layer number, and the third layer number is greater than the second layer number.
[0016] When the target number of layers is not equal to the length of the pressure value sequence, the pressure value sequence is linearly interpolated and resampled to obtain a target pressure value sequence with a length equal to the target number of layers, which is then used to replace the pressure value sequence.
[0017] Optionally, the step of mapping and truncating the pressure values in the pressure value sequence to obtain a normalized sequence by numerically exchanging and limiting the extreme values of the color mapping range includes:
[0018] After resolving the first and second extreme values in the color mapping range into floating-point numbers, the largest value among the first and second extreme values is determined as the maximum value, and the smallest value is determined as the minimum value.
[0019] When the difference between the maximum value and the minimum value is less than a preset difference threshold, the minimum value is subtracted by a preset offset and the maximum value is added to the preset offset;
[0020] A temporary ratio for each pressure value is obtained by calculating the ratio of the difference between each pressure value and the minimum value in the pressure value sequence to the difference between the maximum value and the minimum value.
[0021] When the temporary ratio is greater than 1, the temporary ratio is replaced with 1; when the temporary ratio is less than 0, the temporary ratio is replaced with 0. The final temporary ratio is used as the normalized ratio value for each pressure value, and all the normalized ratio values are summarized to obtain a normalized sequence.
[0022] Secondly, this application provides a WebGPU-based address cavity pressure hierarchical visualization system, comprising:
[0023] The receiving module is used to receive data packets including model identifiers, pressure value sequences, color mapping ranges, and basic color parameters;
[0024] The mapping module is used to map and truncate the pressure values in the pressure value sequence to obtain a normalized sequence by exchanging and limiting the extreme values of the color mapping range.
[0025] The processing module is used to normalize the absolute value of the first difference between adjacent elements in the pressure numerical sequence to obtain the pressure distribution sequence.
[0026] The construction module is used to determine the position where the cumulative pressure probability reaches the division point as the layer boundary based on the local bounding box and according to the pressure distribution sequence, to obtain a non-equidistant boundary array, and to construct the clipping plane equation pair of each layer according to the upper and lower boundaries in the non-equidistant boundary array. The local bounding box is obtained by spatial alignment by loading the cavity model using the model identifier.
[0027] The binding module is used to interpolate the basic color parameters according to the normalization ratio value of the normalization sequence to obtain the display color of each layer, create a geometry buffer and an instantiation buffer in WebGPU, and bind the vertex data of the cavity model in the geometry buffer with the display color and the clipping plane equation in the instantiation buffer.
[0028] The allocation module is used to perform a plane test on the vertex coordinates in the geometry buffer according to the clipping plane equation pair corresponding to each instance number in the instantiation buffer, and to allocate a color to the pixels that pass the plane test according to the display color corresponding to each instance number, so as to obtain a visualization image.
[0029] Thirdly, this application provides an electronic device, comprising:
[0030] Memory, used to store computer programs;
[0031] A processor, configured to implement the steps of the WebGPU-based address cavity pressure hierarchical visualization method as described in the first aspect above when executing the computer program.
[0032] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps of the WebGPU-based address cavity pressure layering visualization method described in the first aspect above.
[0033] The WebGPU-based address cavity pressure layering visualization method provided in this application has the following advantages: Firstly, it provides a complete and structured source of raw data for subsequent processing by standardizing the input data format. Secondly, it eliminates mapping failures caused by abnormal input parameters through extreme value exchange and range limitation, thus ensuring stable and interpretable color mapping results. Thirdly, it provides a quantitative basis for subsequent adaptive layering by extracting the intensity of changes between adjacent pressure values. Fourthly, it adaptively determines the layering boundary based on the intensity of pressure changes, making the layers denser in areas with large pressure gradients, thereby improving the visual recognition of key areas. Fifthly, it avoids redundant creation by sharing the same model geometry data, thus reducing memory usage and data transfer overhead. Finally, it utilizes the GPU to perform pruning judgment and color allocation on the vertices of each layer in parallel, enabling multi-layer synchronous rendering and improving rendering efficiency.
[0034] Furthermore, this application may optionally provide a closed-loop mechanism for viewpoint state serialization and configuration persistence. Specifically, information such as camera position, orientation, zoom, and viewpoint focus is organized into a structured configuration object and written back to the local persistence medium along with model parameters. After writing back, the configuration content is read again by adding a timestamp parameter for verification to avoid misjudgment caused by browser caching. Then, on the next load, the configuration file, local cache, and URL parameters are merged according to a predetermined priority to restore the previous scene state and rendering parameters. This mechanism can ensure reproducible results for the same model, the same parameters, and the same viewpoint, and supports cross-platform collaboration and project delivery archiving. Attached Figure Description
[0035] To more clearly illustrate the technical solutions of the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 A flowchart illustrating a WebGPU-based method for visualizing address cavity pressure hierarchy in an embodiment of this application;
[0037] Figure 2 A flowchart illustrating a method for generating clipping plane equation pairs provided in an embodiment of this application;
[0038] Figure 3 This is a schematic diagram of the address cavity pressure layer cutting provided in the embodiments of this application;
[0039] Figure 4 This is a schematic diagram of determining non-equidistant layer boundaries by dividing cumulative pressure probability equally according to an embodiment of this application;
[0040] Figure 5 This is a schematic diagram of the binding of the WebGPU geometry buffer and the instantiation buffer, and the instantiation rendering data stream provided in the embodiments of this application;
[0041] Figure 6 A schematic diagram of the structure of a WebGPU-based address cavity pressure layering visualization system provided in this application embodiment;
[0042] Figure 7 This is a schematic diagram of the hardware structure of an electronic device provided in one embodiment of this application. Detailed Implementation
[0043] In the field of 3D visualization of pressure fields in address cavities, existing technologies generally suffer from the following drawbacks: First, the layering method is fixed, using equidistant division of height intervals, which cannot adaptively adjust the layer boundaries according to actual pressure changes. This results in the averaged processing of details in areas with severe pressure gradients, making it difficult to effectively highlight key abnormal intervals. Second, the normalization mapping lacks robustness. When the input pressure range parameters exhibit abnormalities such as inversion or identical values, the fixed threshold mapping method is prone to color distortion, making it difficult for the rendering results to accurately reflect the real pressure distribution. Third, the rendering architecture is inefficient. Each data update often requires the reconstruction of the entire model geometry and materials, which also places a performance burden on the browser, making it difficult to meet the engineering requirements for real-time updates.
[0044] To address the aforementioned issues, this application proposes a WebGPU-based method for visualizing address cavity pressure layers. This method first performs extreme value swapping and range limitation on the input color mapping range parameters to ensure stable output of the normalized mapping under any abnormal input, thereby avoiding color distortion. Next, it extracts the intensity of change between adjacent elements of the pressure value sequence and adaptively determines the layer boundaries by equally dividing the cumulative pressure probability, thus enabling finer layering in areas with drastic pressure fluctuations and improving the visual recognition of key areas. Finally, at the rendering level, by sharing the same cavity model geometry data in the WebGPU and combining it with an instantiation rendering mechanism to complete multi-layer parallel rendering at once, the performance loss from repeated modeling and sequential layer-by-layer rendering can be avoided.
[0045] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0046] To address the problems of existing technologies, embodiments of this application provide a method and system for visualization of address cavity pressure hierarchy based on WebGPU. The method for visualization of address cavity pressure hierarchy based on WebGPU provided in this application embodiment is described below.
[0047] Figure 1 This illustration shows a flowchart of a WebGPU-based address cavity pressure layering visualization method according to an embodiment of this application. Figure 1 As shown.
[0048] S101, Receive a data packet including a model identifier, a pressure value sequence, a color mapping range, and basic color parameters;
[0049] In this sub-step, the model identifier refers to a string or code used to uniquely locate the cavity model. It can include the model file name, model path, server resource address, or database index, and is used to retrieve the corresponding cavity model's geometric data from the server or local storage. The pressure value sequence refers to a set of pressure measurements or simulation calculations obtained by sampling at certain intervals along the height or depth direction of the cavity. It can be a floating-point array, with its length representing the preset number of sampling points. Each element corresponds to a pressure value at a specific height position. The color mapping range refers to the boundary parameters used to map the pressure values to the color space. It can include two values: a minimum pressure value and a maximum pressure value, defining the mapping range from the pressure value to the displayed color. The base color parameter refers to the color reference used to represent the display effect in areas with lower pressure. It can be an RGB vector or HSL color values and serves as the starting color for subsequent color interpolation operations.
[0050] In this embodiment, a data packet containing the above four types of data is received. This data packet can be obtained through HTTP requests, WebSocket messages, or local file reading, etc. Then, the model identifier, such as the string "CavityModelA", is parsed from the data packet; next, the stress value sequence is extracted, such as a floating-point array containing N elements. , where each pressure value The pressure measurement value corresponds to the i-th sampling height position in the cavity. The array length N is the preset number of layers, which can be predetermined in the data acquisition stage according to the engineering monitoring accuracy requirements or simulation data output configuration.
[0051] Simultaneously, color mapping range parameters, such as minimum and maximum pressure values, are read from the data packet. These values can be provided by an external system based on historical pressure statistics or engineering safety thresholds. Basic color parameters are then obtained, such as an RGB vector (0.2, 0.4, 0.8) representing a blue tone. These color parameters can be configured by the user in the interface or preset by engineering specifications. Finally, the model positioning information, pressure distribution data, mapping control parameters, and display style configuration required for subsequent layered visualization processing are fully obtained, laying the data foundation for cavity model loading, pressure normalization processing, and layered boundary calculation.
[0052] In addition, upon receiving the data packet, the model identifiers in the old and new data are compared first. If the model identifiers have changed, the cavity model is reloaded and all layered rendering groups are rebuilt. If the model identifiers have not changed, only the layered rendering groups are rebuilt, that is, only the color parameters, clipping plane parameters and display styles of each layer are updated, without reloading the model geometry data. This avoids unnecessary model reloading and full scene reconstruction, thereby reducing the computational overhead in high-frequency data update scenarios. At the same time, the old geometry buffers and instantiation buffers created before the update should be released in a timely manner after reconstruction to prevent the accumulation of video memory and memory leaks caused by long-term operation.
[0053] It is important to note that, in order to control the computational complexity of the layered construction, a reasonable upper limit should be set for the number of layers, such as no more than 128 layers. When the length of the pressure value sequence exceeds this upper limit, the pressure value sequence can be resampled to limit the number of layers within the upper limit.
[0054] This application provides a structured data foundation for subsequent processes by uniformly receiving complete inputs such as model positioning, pressure data, mapping parameters, and color configurations, ensuring the data integrity and standardization of the visualization process.
[0055] S102. By exchanging and limiting the extreme values of the color mapping range, a normalized sequence is obtained by mapping and truncating the pressure values in the pressure value sequence.
[0056] In one specific implementation, step S102 includes:
[0057] Step 1021: After resolving the first extreme value and the second extreme value in the color mapping range into floating-point numbers, determine the largest value among the first extreme value and the smallest value among the second extreme values as the maximum value and the smallest value as the minimum value;
[0058] In this sub-step, the first extreme value refers to a boundary value in the color mapping range parameter, which can be either the minimum or maximum pressure value. The second extreme value refers to another boundary value in the color mapping range parameter, which, together with the first extreme value, defines the pressure-to-color mapping interval. The maximum value is the larger of the first and second extreme values, and serves as the upper limit of the normalized mapping. The minimum value is the smaller of the first and second extreme values, and serves as the lower limit of the normalized mapping.
[0059] In this embodiment of the application, the first extreme value of the color mapping range parameter is obtained from the data packet. Second extreme value Then and Parse as a floating-point number; if parsing fails, assign a default value or trigger exception handling; if parsing succeeds, compare... and The numerical values are determined, and the larger value is identified as the maximum value. The smaller value is determined as the minimum value. , specifically, if ,but , ;like ,but , .
[0060] Step 1022: When the difference between the maximum value and the minimum value is less than a preset difference threshold, subtract a preset offset from the minimum value and add the preset offset to the maximum value;
[0061] In this sub-step, the preset difference threshold is a critical value used to determine whether the difference between the maximum and minimum values is too small. When the difference is less than this threshold, the mapping interval is considered too narrow and needs to be expanded. The preset offset is a fixed value used to expand the mapping interval, which can be preset according to the typical magnitude of the pressure value.
[0062] In this embodiment of the application, the maximum value is calculated. and minimum value The difference between Then compare the difference with the preset difference threshold. If a comparison is made, If the mapping range is too narrow, it is considered that it needs to be expanded to avoid division by zero errors or numerical instability. The expansion operation is performed by subtracting a preset offset from the minimum value. And add the maximum value to the preset offset. For example, it can be preset , These parameters can be determined based on the magnitude range of the pressure values and the requirements for numerical stability. If an extension is performed, the extended values will replace the original minimum and maximum values for subsequent mapping calculations.
[0063] Step 1023: Obtain a temporary ratio for each pressure value by calculating the ratio of the difference between each pressure value and the minimum value in the pressure value sequence to the difference between the maximum value and the minimum value;
[0064] In this embodiment of the application, the pressure numerical sequence Alternatively, for each pressure value in the target pressure numerical sequence obtained in step 1027, calculate its relative to the minimum value. and maximum value The normalized position, that is, for the i-th pressure value. First, calculate the difference between it and the minimum value. Then calculate the difference between the maximum and minimum values. ; then calculate Obtain the temporary ratio .
[0065] Step 1024: When the temporary ratio is greater than 1, replace the temporary ratio with 1; when the temporary ratio is less than 0, replace the temporary ratio with 0; and use the final temporary ratio as the normalized ratio value for each pressure value, and summarize all the normalized ratio values to obtain a normalized sequence.
[0066] In this sub-step, the normalized scale value refers to the final mapping scale, after truncation, limited to the interval [0,1], used for subsequent color interpolation calculations. The normalized sequence is an array consisting of all normalized scale values, the length of which is equal to the length of the pressure value sequence or the target pressure value sequence.
[0067] In the embodiments of this application, for each temporary ratio Perform interval truncation, that is, if If, then replace it with 1, if If it is, then replace it with 0; if When the value remains unchanged, this truncation operation can be expressed as: Then truncate the values As the normalized ratio value corresponding to the pressure value, after traversing all pressure values and completing the truncation process, all normalized ratio values are summarized to obtain the normalized sequence.
[0068] Before mapping and truncating the pressure values in the pressure numerical sequence to obtain a normalized sequence, S102 further includes:
[0069] Step 1025: Calculate the sum of squares of the first-order differences of all adjacent elements in the pressure numerical sequence, and divide the sum of squares by the length of the pressure numerical sequence to obtain the pressure fluctuation intensity value.
[0070] In this sub-step, the pressure fluctuation intensity value refers to a statistical index used to quantify the severity of pressure changes in a pressure numerical sequence. The larger the value, the more severe the pressure fluctuation in the height direction.
[0071] In this embodiment of the application, the pressure numerical sequence Calculate the first-order difference for all adjacent elements, that is, first calculate the value of the i-th difference. Where i ranges from 0 to N−2; then calculate the sum of squares of all differences. The sum of squares reflects the cumulative intensity of the overall fluctuation of the pressure numerical sequence. Then, the sum of squares is divided by the length of the pressure numerical sequence, which is the total number of pressure values in the pressure numerical sequence, to obtain the pressure fluctuation intensity value I, which is used to adaptively determine the number of layers based on the pressure change characteristics.
[0072] It should be noted that the first-order difference between adjacent pressure values has the same dimension as the pressure value. Therefore, the pressure fluctuation intensity value I obtained by dividing the sum of squares of the first-order differences by the length of the pressure value sequence has the dimension of the pressure square, and it cannot be directly compared with the dimensionless intensity threshold. Therefore, in this embodiment, before calculating the pressure fluctuation intensity value, each pressure value in the pressure value sequence is divided by a preset reference pressure value to perform dimensionless processing on the pressure value sequence. The reference pressure value can be the maximum value of the color mapping range or the rated working pressure of the cavity, so that the first-order difference becomes a dimensionless ratio.
[0073] For example, in this embodiment of the application, before calculating the pressure fluctuation intensity value, the formula is first used. The pressure values in the pressure numerical sequence are dimensionless. For the i-th pressure value, For the preset reference pressure value, This is the dimensionless pressure value.
[0074] Step 1026: When the pressure fluctuation intensity value is greater than a preset first intensity threshold, the target number of layers is determined to be a preset first number of layers; when the pressure fluctuation intensity value is less than a preset second intensity threshold, the target number of layers is determined to be a preset second number of layers; when the pressure fluctuation intensity value is between the second intensity threshold and the first intensity threshold, the target number of layers is set to a preset third number of layers, wherein the first intensity threshold is greater than the second intensity threshold, the first number of layers is greater than the third number of layers, and the third number of layers is greater than the second number of layers.
[0075] In this sub-step, the first intensity threshold refers to the upper limit value used to determine the severity of pressure fluctuations. That is, when the pressure fluctuation intensity value exceeds this threshold, the pressure distribution is considered to have changed significantly, and more layers are needed for a more detailed display. The second intensity threshold refers to the lower limit value used to determine the smoothness of pressure fluctuations. That is, when the pressure fluctuation intensity value is below this threshold, the pressure distribution is considered to be relatively uniform, and fewer layers can be used for a rougher display.
[0076] The target layer number refers to the final layer number adaptively determined based on the pressure fluctuation intensity value. It can be the first, second, or third layer, used for subsequent resampling of the pressure value sequence. The first layer number is a preset, larger layer value when pressure fluctuations are severe; it can be preset according to engineering monitoring accuracy requirements. The second layer number is a preset, smaller layer value when pressure fluctuations are moderate; it can be preset according to computational resource limitations. The third layer number is a preset, medium-level layer value when pressure fluctuations are at a moderate level, with a value between the first and second layer numbers.
[0077] In this embodiment of the application, the pressure fluctuation intensity value I is compared with a preset first intensity threshold. Second intensity threshold The comparison is performed first, determining whether I is greater than... If this condition is met, the target layer number will be set to the preset first layer number. If I is not greater than Then we further determine whether I is less than If this condition is met, the target layer number will be set to the preset second layer number. If I is neither greater than Not less than Then the target layer number will be set to the preset third layer number. ,in, and For example, it can be preset , , , , These thresholds and the number of layers can be determined based on the statistical characteristics of pressure fluctuations and the evaluation of visualization effects in historical engineering data.
[0078] Step 1027: When the target number of layers is not equal to the length of the pressure value sequence, perform linear interpolation resampling on the pressure value sequence to obtain a target pressure value sequence with a length equal to the target number of layers, which is used to replace the pressure value sequence.
[0079] In this sub-step, the target pressure numerical sequence refers to the new pressure numerical sequence obtained by linear interpolation and resampling of the original pressure numerical sequence. Its length is equal to the target layer number and is used for subsequent normalization processing and layer boundary calculation.
[0080] In this embodiment of the application, when the target layer number obtained in step 1026 is not equal to the length N of the original pressure value sequence, it is necessary to perform linear interpolation resampling on the original pressure value sequence. Specifically, the index interval [0, N-1] of the original pressure value sequence in the height direction is mapped to the index interval of the new sequence. ,in, The target layer number obtained in step 1026; and for the j-th position in the new sequence, its corresponding original sequence index. If the original sequence index k is an integer, then the element corresponding to the k-th position is directly taken as the j-th element of the new sequence; if the original sequence index k is not an integer, then the integer part of the k-th position is taken. and And calculate the element at position j using linear interpolation. This yields a target pressure numerical sequence with a length equal to the target layer number, which is then used to replace the original pressure numerical sequence for subsequent processing.
[0081] This application, through extreme value correction and range protection mechanisms, can eliminate mapping failures caused by abnormal input parameters and stably convert pressure values into normalized proportions, thereby ensuring that the color mapping results are interpretable and unaffected by abnormal inputs.
[0082] S103. Normalize the absolute value of the first-order difference between adjacent elements in the pressure numerical sequence to obtain the pressure distribution sequence.
[0083] In this sub-step, the first-order difference absolute value is used to quantify the magnitude of pressure variation between adjacent height locations. Each element in the pressure distribution sequence represents the proportion of the pressure change intensity at the corresponding location in the overall variation, and is used to subsequently determine the adaptive stratification boundary.
[0084] In this embodiment of the application, after resampling is completed in step 1027, all parameters involving sequence length in subsequent steps are based on the length of the resampled target pressure value sequence, and its length is denoted as M. Then, the difference value is calculated for the i-th and i+1-th pressure values in the pressure value sequence obtained in step S102 or the target pressure value sequence obtained in step 1027. Where i ranges from 0 to M-2, resulting in M-1 difference values; then, the absolute value of each difference value is taken to obtain a first-order sequence of absolute difference values. .
[0085] Then, the sum D of all first-order difference absolute values is calculated, which represents the cumulative change in pressure over the entire height range; each first-order difference absolute value is then normalized by dividing the sum D to obtain the pressure change probability at the i-th position. Then, by summing up all the probabilities of pressure changes, a pressure distribution sequence is obtained. .
[0086] This application extracts the intensity of changes in adjacent pressure values and normalizes it into a probability distribution, which can quantify the proportion of pressure gradient at each location and thus provide a weight basis based on the actual pressure change pattern for subsequent adaptive stratification.
[0087] S104. Based on the local bounding box, the position where the cumulative pressure probability reaches the division point is determined as the layer boundary according to the pressure distribution sequence, and a non-equidistant boundary array is obtained. The clipping plane equation pair of each layer is constructed according to the upper and lower boundaries in the non-equidistant boundary array. The local bounding box is obtained by spatial alignment by loading the cavity model using the model identifier.
[0088] In one specific implementation, such as Figure 2 As shown, step S104 includes:
[0089] Step 1041: Starting from the initial height of the local bounding box, take the first pressure probability value in the pressure distribution sequence as the initial cumulative probability value at the end of the first pressure change interval. Add each subsequent pressure probability value to the previous initial cumulative probability value in turn to obtain the initial cumulative probability value at the end of each subsequent pressure change interval, thus constructing an initial cumulative probability value sequence. At the same time, determine the sub-height of each pressure change interval. Based on the sub-height, obtain the sub-start height and sub-end height of each pressure change interval. The sub-height is equal to the total height divided by the number of pressure change intervals. The pressure change interval is the interval between the height positions corresponding to two adjacent pressure values in the pressure value sequence.
[0090] The local bounding box is obtained by loading a cavity model using the model identifier and rotating the cavity model so that its height direction is consistent with the Y-axis direction of the world coordinate system. The starting height is determined by setting the Y-coordinate of the vertex with the smallest Y-axis coordinate in the cavity model and the ending height is determined by setting the Y-coordinate of the vertex with the largest Y-axis coordinate.
[0091] In this sub-step, the local bounding box refers to the spatial boundary of the cavity model in the height direction, encompassing its minimum and maximum extent. It can be obtained by traversing the coordinates of all vertices of the cavity model, with its starting and ending heights corresponding to the minimum and maximum values of the model on the height axis, respectively. The pressure change interval refers to the interval between the height positions corresponding to two adjacent pressure values in the pressure value sequence; its number is equal to the length of the pressure value sequence minus one.
[0092] The initial cumulative probability value refers to the cumulative sum obtained by successively adding up the pressure probability values in the pressure distribution sequence starting from the first pressure change interval. It is used to subsequently determine the location of the stratification boundary. The initial cumulative probability value sequence is an array consisting of the initial cumulative probability values at the end of all pressure change intervals, and its last element must be equal to 1.
[0093] Sub-height refers to the uniformly distributed length of each pressure change interval in the height direction, which is equal to the total height divided by the number of pressure change intervals. Sub-start height refers to the starting position of each pressure change interval in the height direction, and the sub-start height of the first pressure change interval is equal to the starting height of the local bounding box. Sub-end height refers to the ending position of each pressure change interval in the height direction, which is equal to the corresponding sub-start height plus the sub-height. Total height is the difference between the ending height and the starting height of the local bounding box, representing the physical span of the cavity model in the height direction.
[0094] In this embodiment, the corresponding cavity model, such as an FBX or GLTF format file, is first loaded from a server or local storage based on the model identifier. After loading, the model undergoes spatial alignment, i.e., a rotation transformation is used to align the model's height direction with the Y-axis of the world coordinate system. For example, if the height direction in the original model coordinate system is the Z-axis, it needs to be rotated 90° around the X-axis. After alignment, all vertices of the model are traversed, and the Y-axis coordinate of each vertex is extracted to find the minimum Y-coordinate value. and maximum Y coordinate value and will Determine the starting height of the local bounding box, and... Determine the termination height of the local bounding box; then calculate the total height. .
[0095] Next, the sub-height is calculated based on the pressure distribution sequence. ,in, Let be the length of the pressure distribution sequence; then, for the j-th pressure change interval, where j ranges from 0 to M-2, calculate the corresponding sub-initial height. Calculate the corresponding sub-termination height .
[0096] Next, the first pressure probability value in the pressure distribution sequence is... The initial cumulative probability value at the end of the first pressure change interval For the initial cumulative probability value at the end of the j-th pressure change interval, the j-th pressure probability value is used as the basis for determining the probability value. Compared with the previous initial cumulative probability value By adding them together, we finally obtain the initial cumulative probability value sequence. .
[0097] Step 1042: Multiply the equal division step size by 1 to N-1 respectively to obtain N-1 target cumulative probability values, where the equal division step size is equal to 1 / N, and N is the number of pressure numerical sequences;
[0098] In this sub-step, the equal division step size refers to the step size value used to uniformly divide the cumulative probability interval [0,1] into N sub-intervals, which is equal to , where N is the number of pressure numerical sequences. The target cumulative probability value refers to a set of cumulative probability thresholds obtained by multiplying equally divided step sizes by different integer multiples, used to find the corresponding layer boundary position in the initial cumulative probability value sequence.
[0099] In this embodiment of the application, for the pressure value sequence processed in step S102 or the target pressure value sequence obtained in step 1027, the equal division step size is calculated. Then multiply the equal step size by 1, 2, 3, ..., N-1 respectively to obtain N-1 cumulative probability values for the target. .
[0100] Step 1043: Determine the first initial cumulative probability value that is greater than or equal to the target cumulative probability value in the initial cumulative probability value sequence, and determine the pressure change interval corresponding to the initial cumulative probability value as the target pressure change interval;
[0101] In this sub-step, the target pressure change interval refers to the pressure change interval corresponding to the first initial cumulative probability value that is greater than or equal to a certain target cumulative probability value in the initial cumulative probability value sequence. It is used to subsequently interpolate within this interval to determine the specific height position of the stratification boundary.
[0102] In the embodiments of this application, the cumulative probability value for each target is... In the constructed initial cumulative probability value sequence The search proceeds sequentially, starting from the first element of the initial cumulative probability value sequence to find the first element that satisfies the condition. The initial cumulative probability value is determined, and the pressure change interval corresponding to the initial cumulative probability value is determined as the target pressure change interval corresponding to the current target cumulative probability value.
[0103] Step 1044: Based on the ratio between the initial cumulative probability and the final cumulative probability of each target cumulative probability value in the corresponding target pressure change interval, perform linear interpolation between the sub-starting height and the sub-ending height of the corresponding target pressure change interval to obtain the internal boundary height between each layer. Here, the initial cumulative probability of the first pressure change interval is 0, and the initial cumulative probability of subsequent pressure change intervals is the initial cumulative probability value of the previous pressure change interval.
[0104] In this sub-step, the initial cumulative probability refers to the cumulative probability value of a pressure change interval at its starting position in the height direction. The initial cumulative probability of the first pressure change interval is 0, and the initial cumulative probability of subsequent pressure change intervals is equal to the initial cumulative probability value of the previous pressure change interval. The final cumulative probability refers to the cumulative probability value of a pressure change interval at its ending position in the height direction, i.e., the initial cumulative probability value corresponding to that pressure change interval. The internal boundary height refers to the height position between two adjacent layers, used for subsequently constructing the non-equidistant boundary array.
[0105] In this embodiment, the sub-starting height and sub-ending height are obtained for each target pressure change interval; simultaneously, the starting accumulation probability and ending accumulation probability of the target pressure change interval are determined; then, for the j-th pressure change interval, if j=0, the starting accumulation probability is equal to 0; if j≥1, the starting accumulation probability is equal to... The cumulative probability of termination of this pressure change interval is equal to Then, the cumulative probability value for the k-th target is calculated. Assuming the corresponding target pressure change interval is the j-th pressure change interval, then calculate... The relative positional proportion within the range of the initial and final cumulative probabilities of this interval. ,in, The initial cumulative probability, To terminate the cumulative probability, further within the height range of the target pressure change interval. Perform linear interpolation within the interior, i.e., calculate the height of the k-th interior boundary. Finally, the above interpolation calculation is repeated for all N-1 target cumulative probability values to obtain N-1 internal boundary heights.
[0106] Step 1045: Arrange all the internal boundary heights, the starting height of the local bounding box, and the ending height of the local bounding box in height order to obtain a non-equidistant boundary array.
[0107] In this sub-step, the non-equidistant boundary array refers to an ordered array containing the local bounding box start height, all internal boundary heights, and local bounding box end height. Its array length is N+1, which is used to define the upper and lower boundary positions of N layers. The spacing between each boundary is adaptively determined according to the pressure distribution characteristics rather than being uniformly distributed.
[0108] In this embodiment, all internal boundary heights, the start height and end height of the local bounding box are merged into an array, and this array is sorted in ascending order of height values to obtain a non-equidistant boundary array, with an array length of N+1. For example, N=8, start height... Termination height The heights of the 7 internal boundaries are as follows: Then the non-equidistant boundary array is This array defines 8 layers.
[0109] Step 1046: Determine the first boundary of each pair of adjacent boundaries in the non-equidistant boundary array as the lower boundary of the corresponding layer, and determine the second boundary of each pair of adjacent boundaries as the upper boundary of the corresponding layer.
[0110] In the embodiments of this application, for each pair of adjacent boundaries in the non-equidistant boundary array, the previous boundary is determined as the lower boundary of the corresponding layer, and the next boundary is determined as the upper boundary of the corresponding layer. That is, for the m-th layer, its lower boundary is the (m-1)-th element in the array, and its upper boundary is the m-th element in the array, where the value of m ranges from 1 to N.
[0111] Step 1047: Construct a lower clipping plane with its normal pointing to the positive Y-axis for each layer. The constant term of the lower clipping plane is equal to the negative of the lower boundary of the corresponding layer.
[0112] In this embodiment, a corresponding lower clipping plane is constructed for each layer, and the general form of its plane equation is: ,in, Let be the plane normal vector, and d be a constant term; furthermore, for the lower clipping plane, the normal vector points in the positive Y-axis direction, i.e. Then the plane equation simplifies to For example, the lower boundary of the m-th layer is The lower cutting plane of this layer must be retained. Part of, namely Then we obtain the constant term. Then the plane equation of the lower cutting plane is .
[0113] Step 1048: For each layer, construct an upper clipping plane with a normal pointing to the negative Y-axis direction. The constant term of the upper clipping plane is equal to the upper boundary of the corresponding layer.
[0114] In this embodiment of the application, a corresponding upper clipping plane is constructed for each layer, the normal of which points in the negative direction of the Y-axis, i.e. The plane equation simplifies to For example, the upper boundary of the m-th layer is The upper cutting plane of this layer must be retained. Part of, namely Then we obtain the constant term. Then the plane equation of the upper clipping plane is .
[0115] It is important to note that if the root node of the cavity model has a non-zero offset in the world coordinate system (i.e., the root node's own world coordinate Y-value is not zero), then this root node offset should be included in the correction calculation when calculating the constant terms of each layer's clipping plane. Specifically, let the Y-axis offset of the root node in the world coordinate system be... Then, for the m-th layer, the constant term of its lower clipping plane in the world coordinate system should be corrected to: The constant term of the upper cutting plane should be corrected to This ensures that the layered visualization results are correctly aligned under different model import states.
[0116] Step 1049: Use the lower cutting plane and the upper cutting plane as the cutting plane equation pair for each layer.
[0117] In this embodiment, the lower and upper cutting planes are combined into a pair of cutting plane equations for each layer. That is, for the m-th layer, the pair of cutting plane equations includes the normal (0,1,0) and a constant term. The lower cutting plane, and the normal (0,-1,0), and the constant term. The upper cutting plane.
[0118] Specifically, you can refer to Figure 3 The cavity model 10 is bounded by a local bounding box 11 in the height direction 12, i.e., the Y-axis direction of the world coordinate system. The lower end of the local bounding box 11 is the starting height 13, and the upper end is the ending height 14. The cavity model 10 is divided into several layers along the height direction 12. The height interval of each layer is adaptively determined according to the pressure distribution characteristics and is distributed non-equidistantly. That is, the height interval of the layers is smaller and the distribution is denser where the pressure gradient is severe, and the height interval of the layers is larger and the distribution is sparser where the pressure is gentle. Each layer is jointly bounded by a lower clipping plane 21 and an upper clipping plane 22. The normal of the lower clipping plane 21 points to the positive Y-axis direction, and the normal of the upper clipping plane 22 points to the negative Y-axis direction. Only the geometric part of the cavity model 10 located between the lower clipping plane 21 and the upper clipping plane 22 is retained for display, thus forming a clear layered display effect on the geometric data of the same cavity model 10.
[0119] The process for determining the non-equidistant layer boundary can be referred to Figure 4The horizontal axis represents the cumulative pressure probability, and the vertical axis represents the height direction. The cumulative probability curve 51 characterizes the relationship between the cumulative pressure probability and the height. Since the pressure distribution sequence reflects the proportion of pressure gradient at each height position, the cumulative probability curve 51 has a larger slope and rises faster in the height range where the pressure gradient is severe. Then, the cumulative pressure probability is evenly divided on the horizontal axis according to the equal step size to obtain several cumulative probability division points 52. Then, each cumulative probability division point 52 is projected onto the vertical axis along the cumulative probability curve 51 to obtain the corresponding internal boundary height 53. Since the cumulative probability curve 51 rises faster in the area of severe pressure gradient, the height span corresponding to the same cumulative probability division interval in this range is smaller. Therefore, the obtained internal boundary height 53 is more densely distributed in this range, thus realizing fine stratification in the area of severe pressure.
[0120] This application determines the layering boundary by adaptive interpolation within the cavity height range based on the pressure distribution probability, and constructs a non-equidistant boundary array and a pair of clipping plane equations, which can achieve dense layering in areas of intense pressure and sparse layering in areas of gentle pressure.
[0121] S105. Interpolate the basic color parameters according to the normalization ratio value of the normalization sequence to obtain the display color of each layer. Create a geometry buffer and an instantiation buffer in WebGPU, and bind the vertex data of the cavity model in the geometry buffer with the display color and the clipping plane equation in the instantiation buffer.
[0122] In one specific implementation, step S105 includes:
[0123] Step 1051: Subtract each normalization ratio value in the normalization sequence from the value 1 and multiply it by each component of the basic color parameter to obtain the first product corresponding to each component. Multiply each component of the white parameter by each normalization ratio value in the normalization sequence to obtain the second product corresponding to each component. The white parameter includes the red component, green component and blue component with a normalization value of 1.
[0124] In this sub-step, the first product is used to calculate the contribution of the base color to the final displayed color. The white parameter refers to the color vector representing pure white in the RGB color space. The second product is used to calculate the contribution of white to the final displayed color.
[0125] In this embodiment of the application, the components of the basic color parameters in the RGB color space are assumed to be... The value range of each component is [0,1]; then the m-th normalization ratio value in the normalized sequence is... calculate Obtain the weighting coefficients of the base color; then multiply these weighting coefficients by the red, green, and blue components of the base color parameters respectively to obtain three first products; simultaneously, calculate the m-th normalized ratio value in the normalized sequence. Multiply each of the components 1 of the white parameter (1,1,1) to obtain three second products.
[0126] Step 1052: Add the first product of the same component to the corresponding second product to obtain the component value of each color, and obtain the display color of each layer based on the component values of all colors;
[0127] In this embodiment of the application, for each group of first and second products, the two products of the same component are added together to obtain the component value of that component, that is, for the m-th layer, its red component value. Green component value Blue component value Then, these three component values are combined to form the display color of that layer. This is to achieve a linear interpolation transition from the base color to white.
[0128] Step 1053: Create a geometry buffer in WebGPU and write all vertex coordinates and index data of the cavity model into the geometry buffer;
[0129] In this sub-step, the geometry buffer refers to the GPU memory area allocated in WebGPU for storing the vertex coordinates and index data of the cavity model. It can be a Vertex Buffer or an Index Buffer, which the rendering pipeline reads during rendering. Vertex coordinates refer to the position of each vertex in the cavity model in three-dimensional space, and can be floating-point triples of the form (x, y, z). Index data refers to an integer array used to define the vertex connectivity of the model's triangular facets, where every three indices point to three vertices forming a triangle.
[0130] In this embodiment, the buffer creation interface is called in WebGPU to create a geometry buffer for storing the geometric data of the cavity model. Then, all vertex coordinates are extracted from the cavity model. For example, the model contains V vertices, and each vertex occupies 3 floating-point numbers, totaling 12 bytes. At the same time, the index data of the model is extracted. For example, the model contains F triangles, so the length of the index data array is 3F, and each index is an unsigned integer occupying 4 bytes. The vertex coordinate array is then written to the Vertex Buffer of WebGPU, and the index data array is written to the Index Buffer. The two together constitute the geometry buffer.
[0131] Step 1054: Create an instantiated buffer in WebGPU and write the display color and clipping plane equation of each layer into the instantiated buffer in the order of the layers;
[0132] In this embodiment, the buffer creation interface is called in WebGPU to create an instantiated buffer, the size of which is determined by the number of layers N and the amount of parameter data for each layer. Then, the display color and clipping plane equation pair of each layer are written into the instantiated buffer in the order of layers from layer 0 to layer N-1. For layer m, the display color is written first, occupying 3 floating-point numbers, totaling 12 bytes. Then, the clipping plane equation pair of the layer is written, which includes the constant terms of the lower clipping plane and the upper clipping plane, each occupying 1 floating-point number, totaling 4 bytes, for a total of 8 bytes. Therefore, the amount of data occupied by each layer in the instantiated buffer is 12+8=20 bytes, and after writing the data of N layers in sequence, the total size of the instantiated buffer is at least N×20 bytes.
[0133] Step 1055: In the WebGPU rendering pipeline, the geometry buffer is determined as the data source for vertex input, and the instantiation buffer is determined as the data source for instance input.
[0134] In this sub-step, the rendering pipeline refers to the programmable graphics processing flow in the WebGPU used to process vertex data and generate pixel output, which may include vertex shaders, fragment shaders, and related configurations. Vertex input refers to the geometric data read from a specified buffer by the rendering pipeline during the vertex shader stage, used for transforming and clipping vertices. Instance input refers to instance-specific data read from a specified buffer by the rendering pipeline during instantiation drawing, used to assign different rendering parameters to each instance.
[0135] In this embodiment of the application, in the WebGPU rendering pipeline configuration, the data source for vertex input is set to the created geometry buffer. Specifically, in the pipeline's Vertex State configuration, the Vertex Buffer is bound to the vertex attribute slot, for example, the position attribute is bound to slot 0, in the format of three floating-point numbers of type vec3; then, the corresponding input variables are declared in the vertex shader so that the shader can read the coordinate data of each vertex from the geometry buffer.
[0136] At the same time, the data source for instance input is set to the created instance buffer. That is, in the pipeline's Vertex State configuration, the Instance Buffer is bound to the instance attribute slot. For example, the display color is bound to slot 1, the lower clipping plane constant is bound to slot 2, and the upper clipping plane constant is bound to slot 3. The stepMode of each slot is set to instance, which means that each instance reads data once.
[0137] Specifically, such as Figure 5 As shown, the geometry buffer 60 is used to store the vertex coordinates 61 and index data 62 of the cavity model, and the geometry buffer 60 is shared by all layers. Then, the instantiation buffer 70 stores the display color 71 of each layer and the clipping plane equation pair 72 of that layer in the order of the layers. The geometry buffer 60 is determined as the vertex input data source of the rendering pipeline 80, and the instantiation buffer 70 is determined as the instance input data source of the rendering pipeline 80. The rendering pipeline 80 draws N instances 81 at once in an instantiation drawing mode, which is the same as the number of layers. Each instance 81 corresponds to a layer and reads the display color 71 and clipping plane equation pair 72 of that layer from the instantiation buffer 70. Thus, the parallel rendering of multiple layers is completed in one drawing instruction. The display color 71 of each layer is represented by the color interpolation bar 90. The color interpolation bar 90 represents the mapping relationship of the display color linearly transitioning from the base color to white with the normalization ratio value.
[0138] This application generates display colors for each layer through linear color interpolation, and can create and bind shared geometry buffers and instantiated buffers in WebGPU, thereby laying the data and pipeline foundation for efficient parallel rendering.
[0139] S106. Based on the clipping plane equation pairs corresponding to each instance number in the instantiation buffer, perform a plane test on the vertex coordinates in the geometry buffer, and assign a color to the pixels that pass the plane test according to the display color corresponding to each instance number to obtain a visualization image.
[0140] In one specific implementation, step S106 includes:
[0141] Step 1061: Determine the clipping plane equation pair corresponding to each instance number from the instantiation buffer; add the first constant term of the lower clipping plane equation in the clipping plane equation pair to the Y coordinate of each vertex in the geometry buffer to obtain the first test value; add the negative number of the Y coordinate to the second constant term of the upper clipping plane equation in the clipping plane equation pair to obtain the second test value.
[0142] In this sub-step, the first constant term refers to the constant term in the equation of the lower cutting plane. The second constant term refers to the constant term in the equation of the upper cutting plane.
[0143] In this embodiment, during the vertex shader execution phase of WebGPU, for each instance, i.e., each layer's rendering, the current instance number m is first obtained according to the built-in variables; then, the clipping plane equation pair corresponding to instance number m is read from the bound instantiation buffer, which includes the first constant term of the lower clipping plane. and the second constant term of the upper cutting plane Simultaneously, from the bound geometry buffer, the vertex shader processes each vertex sequentially and obtains the coordinates of the current vertex. Then, calculate the first test value for the current vertex. Simultaneously calculate the second test value. .
[0144] Step 1062: Remove vertices and all corresponding pixels whose first test value is less than zero or whose second test value is less than zero;
[0145] In this embodiment of the application, a conditional judgment is made on the first test value and the second test value of each vertex, that is, if If the vertex is below the lower boundary of the current layer, it means that the vertex needs to be removed; if If the vertex is above the upper boundary of the current layer, it also needs to be removed; only if and When both conditions are met, the vertex is located within the height range of the current layer and is allowed to enter the subsequent rendering process through the clipping test.
[0146] Step 1063: Determine the display color corresponding to each instance number from the instantiation buffer, and assign the display color to each remaining pixel after culling to obtain a visualization image.
[0147] In this sub-step, the visualized image refers to the final image output on the screen or frame buffer after layered rendering and color assignment, which can intuitively show the spatial distribution characteristics of the pressure field inside the cavity.
[0148] In this embodiment, the rasterization and fragment shader stages are performed on the vertex GPU that has passed the test. Specifically, in the fragment shader, the display color corresponding to the instance number m is read from the bound instantiation buffer according to the current instance number m. And the displayed color is directly assigned to the output color variable of the fragment shader, for example... ,in, It is a four-dimensional vector. For transparency, specifically, transparency It can be calculated using a linear function based on the normalized proportion, for example... ,in, This is the normalized ratio value. and The preset coefficients can be pre-configured according to the display requirements of the project, so that the high-voltage area and the low-voltage area correspond to different opacities, and the opacity of the low-voltage area is less than that of the high-voltage area; then after processing by the fragment shader, each pixel is assigned the display color of the corresponding layer, that is, the shading of the layer within the specified height range is completed.
[0149] Since the WebGPU is configured to render N instances in an instantiated manner, the GPU processes the rendering of all N layers sequentially or in parallel. Each layer independently executes the clipping and shading processes from steps 1061 to 1063. The layers are spatially isolated through different clipping plane equations and visually distinguished through different display colors. The rendering results of all layers are then mixed and written into the same frame buffer. Since the visible height ranges of each layer do not overlap, a layered effect with color gradients along the height direction is finally formed in the frame buffer. After rendering is completed, the contents of the frame buffer are output to the screen for display or saved as an image file to obtain a visualized image. This image intuitively reflects the layered distribution characteristics of the pressure field inside the cavity with height. The area with high pressure is brighter and closer to white, while the area with low pressure is closer to basic blue.
[0150] This application utilizes the clipping plane equation to perform a plane test on the vertices to eliminate geometry outside the interval, which can assign corresponding layer display colors to the retained pixels and output a non-equidistant layered visualization image that reflects the characteristics of pressure distribution.
[0151] It should be noted that the above embodiments are preferably implemented in a WebGPU environment for rendering and parallel computing. When the runtime environment does not support WebGPU, this application can be downgraded to a WebGL backend to achieve equivalent or approximate effects. That is, in the WebGL backend, the localClippingEnabled option of WebGLRenderer can be enabled, and corresponding clippingPlanes clipping plane parameters can be configured for each layer of material to achieve the same height range limiting logic as the WebGPU solution. Color interpolation and normalization calculations can be completed on the CPU side and passed to the shader through uniform, or layered shading can be achieved using a multi-pass rendering method.
[0152] After completing the visualization process described in S101 to S106 above, this application may optionally provide a configuration persistence and scene recovery mechanism, that is, serialize key parameters such as camera position, orientation, zoom ratio, model identifier, color mapping range, etc. into a structured configuration object, and submit it to the local service disk for storage via a POST request through the write-back interface. After the write-back is completed, a timestamp parameter is added and the configuration content is retrieved again for verification to avoid misjudgment caused by browser caching. When the page is loaded for the next time, the configurations from each source are merged in the order of configuration file, local cache, and URL parameters, and the model display parameters and camera state are restored to the last saved ones, thereby ensuring that the visualization results can be stably reproduced after page refresh or cross-platform loading.
[0153] Figure 6 This is a schematic diagram illustrating a specific implementation of a WebGPU-based address cavity pressure layering visualization system provided in this application. (Refer to...) Figure 6 The system may include:
[0154] The receiving module 610 is used to receive a data packet including a model identifier, a pressure value sequence, a color mapping range, and basic color parameters;
[0155] The mapping module 620 is used to map and truncate the pressure values in the pressure value sequence to obtain a normalized sequence by exchanging and limiting the extreme values of the color mapping range.
[0156] Processing module 630 is used to normalize the absolute value of the first difference between adjacent elements in the pressure numerical sequence to obtain a pressure distribution sequence;
[0157] The construction module 640 is used to determine the position where the cumulative pressure probability reaches the division point as the layer boundary based on the local bounding box and according to the pressure distribution sequence, to obtain a non-equidistant boundary array, and to construct the clipping plane equation pair of each layer according to the upper and lower boundaries in the non-equidistant boundary array. The local bounding box is obtained by spatial alignment by loading the cavity model using the model identifier.
[0158] The binding module 650 is used to interpolate the basic color parameters according to the normalization ratio value of the normalization sequence to obtain the display color of each layer, create a geometry buffer and an instantiation buffer in WebGPU, and bind the vertex data of the cavity model in the geometry buffer with the display color and the clipping plane equation in the instantiation buffer.
[0159] The allocation module 660 is used to perform a plane test on the vertex coordinates in the geometry buffer according to the clipping plane equation pair corresponding to each instance number in the instantiation buffer, and to allocate a color to the pixels that pass the plane test according to the display color corresponding to each instance number, so as to obtain a visualization image.
[0160] The WebGPU-based address cavity pressure hierarchical visualization system of this application is used to implement the aforementioned WebGPU-based address cavity pressure hierarchical visualization method. Therefore, the specific implementation of the WebGPU-based address cavity pressure hierarchical visualization system can be found in the embodiment section of the WebGPU-based address cavity pressure hierarchical visualization method above. The specific implementation can be referred to the description of the corresponding embodiments, and will not be repeated here.
[0161] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of this application is shown.
[0162] The electronic device may include a processor 710 and a memory 720 storing computer program instructions.
[0163] Specifically, the processor 710 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0164] Memory 720 may include mass storage for data or instructions. For example, and not limitingly, memory 720 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 720 may include removable or non-removable (or fixed) media. Where appropriate, memory 720 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 720 is non-volatile solid-state memory.
[0165] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to the first aspect of this disclosure.
[0166] The processor 710 reads and executes computer program instructions stored in the memory 720 to implement any of the WebGPU-based address cavity pressure layering visualization methods in the above embodiments.
[0167] In one example, the electronic device may also include a communication interface 730 and a bus 740. Wherein, as... Figure 7 As shown, the processor 710, memory 720, and communication interface 730 are connected via bus 740 and communicate with each other.
[0168] The communication interface 730 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0169] Bus 740 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 740 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0170] The electronic device can execute the WebGPU-based address cavity pressure hierarchical visualization method in the embodiments of this application, thereby realizing the WebGPU-based address cavity pressure hierarchical visualization method described in conjunction with the accompanying drawings.
[0171] Furthermore, in conjunction with the WebGPU-based address cavity pressure hierarchical visualization method in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. This computer-readable storage medium stores computer program instructions; when executed by a processor, these computer program instructions implement any of the WebGPU-based address cavity pressure hierarchical visualization methods in the above embodiments.
Claims
1. A WebGPU-based method for visualizing address cavity pressure hierarchy, applied to a browser, characterized in that... include: Receive data packets including model identifier, pressure value sequence, color mapping range, and basic color parameters; By exchanging and limiting the extreme values of the color mapping range, a normalized sequence is obtained by mapping and truncating the pressure values in the pressure value sequence. The absolute values of the first-order differences between adjacent elements in the pressure numerical sequence are normalized to obtain the pressure distribution sequence. Based on the local bounding box, the position where the cumulative pressure probability reaches the division point is determined as the layer boundary according to the pressure distribution sequence, and a non-equidistant boundary array is obtained. The clipping plane equation pair of each layer is constructed according to the upper and lower boundaries in the non-equidistant boundary array. The local bounding box is obtained by spatial alignment by loading the cavity model using the model identifier. The display color of each layer is obtained by interpolating the basic color parameters according to the normalization ratio value of the normalization sequence. A geometry buffer and an instantiation buffer are created in WebGPU, and the vertex data of the cavity model in the geometry buffer are bound to the display color and the clipping plane equation in the instantiation buffer. Based on the clipping plane equation pairs corresponding to each instance number in the instantiation buffer, a plane test is performed on the vertex coordinates in the geometry buffer, and a color is assigned to the pixels that pass the plane test according to the display color corresponding to each instance number, thereby obtaining a visualization image.
2. The method according to claim 1, characterized in that, Before mapping and truncating the pressure values in the pressure numerical sequence to obtain a normalized sequence, the method further includes: Calculate the sum of squares of the first-order differences of all adjacent elements in the pressure numerical sequence, and divide the sum of squares by the length of the pressure numerical sequence to obtain the pressure fluctuation intensity value. When the pressure fluctuation intensity value is greater than a preset first intensity threshold, the target layer number is determined to be a preset first layer number. When the pressure fluctuation intensity value is less than a preset second intensity threshold, the target layer number is determined to be a preset second layer number. When the pressure fluctuation intensity value is between the second intensity threshold and the first intensity threshold, the target layer number is set to a preset third layer number. The first intensity threshold is greater than the second intensity threshold, the first layer number is greater than the third layer number, and the third layer number is greater than the second layer number. When the target number of layers is not equal to the length of the pressure value sequence, the pressure value sequence is linearly interpolated and resampled to obtain a target pressure value sequence with a length equal to the target number of layers, which is then used to replace the pressure value sequence.
3. The method according to claim 1, characterized in that, The step of mapping and truncating the pressure values in the pressure value sequence to obtain a normalized sequence by numerically exchanging and limiting the extreme values of the color mapping range includes: After resolving the first and second extreme values in the color mapping range into floating-point numbers, the largest value among the first and second extreme values is determined as the maximum value, and the smallest value is determined as the minimum value. When the difference between the maximum value and the minimum value is less than a preset difference threshold, the minimum value is subtracted by a preset offset and the maximum value is added to the preset offset; A temporary ratio for each pressure value is obtained by calculating the ratio of the difference between each pressure value and the minimum value in the pressure value sequence to the difference between the maximum value and the minimum value. When the temporary ratio is greater than 1, the temporary ratio is replaced with 1; when the temporary ratio is less than 0, the temporary ratio is replaced with 0. The final temporary ratio is used as the normalized ratio value for each pressure value, and all the normalized ratio values are summarized to obtain a normalized sequence.
4. The method according to claim 1, characterized in that, The method, based on local bounding boxes, determines the positions where the cumulative pressure probability reaches equal division points according to the pressure distribution sequence as layer boundaries, resulting in a non-equidistant boundary array, including: Starting from the initial height of the local bounding box, the first pressure probability value in the pressure distribution sequence is used as the initial cumulative probability value at the end of the first pressure change interval. Each subsequent pressure probability value is added to the previous initial cumulative probability value to obtain the initial cumulative probability value at the end of each subsequent pressure change interval, thus constructing an initial cumulative probability value sequence. At the same time, the sub-height of each pressure change interval is determined. Based on the sub-height, the sub-start height and sub-end height of each pressure change interval are obtained. The sub-height is equal to the total height divided by the number of pressure change intervals. The pressure change interval is the interval between the height positions corresponding to two adjacent pressure values in the pressure value sequence. Multiply the equal division step size by 1 to N-1 respectively to obtain N-1 target cumulative probability values, where the equal division step size is equal to 1 / N, and N is the number of pressure numerical sequences; In the initial cumulative probability value sequence, determine the first initial cumulative probability value that is greater than or equal to the target cumulative probability value, and determine the pressure change interval corresponding to the initial cumulative probability value as the target pressure change interval; Based on the ratio between the initial cumulative probability and the final cumulative probability of each target cumulative probability value in the corresponding target pressure change interval, linear interpolation is performed between the sub-starting height and the sub-ending height of the corresponding target pressure change interval to obtain the internal boundary height between each layer. Here, the initial cumulative probability of the first pressure change interval is 0, and the initial cumulative probability of subsequent pressure change intervals is the initial cumulative probability value of the previous pressure change interval. Arrange all the internal boundary heights, the starting height of the local bounding box, and the ending height of the local bounding box in height order to obtain a non-equidistant boundary array.
5. The method according to claim 4, characterized in that, The local bounding box is obtained by loading a cavity model using the model identifier and rotating the cavity model until the height direction of the cavity model is consistent with the Y-axis direction of the world coordinate system. The starting height is determined by setting the Y-coordinate of the vertex with the smallest Y-axis coordinate in the cavity model and the ending height is determined by setting the Y-coordinate of the vertex with the largest Y-axis coordinate. The step of constructing the clipping plane equation pair for each layer based on the upper and lower boundaries in the non-equidistant boundary array further includes: The first boundary of each pair of adjacent boundaries in the non-equidistant boundary array is determined as the lower boundary of the corresponding layer, and the second boundary of each pair of adjacent boundaries is determined as the upper boundary of the corresponding layer. For each layer, a lower clipping plane is constructed with its normal pointing in the positive direction of the Y-axis. The constant term of the lower clipping plane is equal to the negative of the lower boundary of the corresponding layer. For each layer, an upper clipping plane with a normal pointing to the negative Y-axis is constructed, and the constant term of the upper clipping plane is equal to the upper boundary of the corresponding layer; The lower cutting plane and the upper cutting plane are used as the cutting plane equation pairs for each layer.
6. The method according to claim 1, characterized in that, The process of interpolating the base color parameters according to the normalization ratio of the normalization sequence to obtain the display color of each layer, creating a geometry buffer and an instantiation buffer in WebGPU, and binding the vertex data of the cavity model in the geometry buffer with the display color and the clipping plane equation in the instantiation buffer includes: The first product corresponding to each component is obtained by subtracting each normalization ratio value in the normalization sequence from the value 1 and multiplying it by each component of the basic color parameter. The second product corresponding to each component is obtained by multiplying each component of the white parameter by each normalization ratio value in the normalization sequence. The white parameter includes the red component, green component and blue component with a normalization value of 1. The first product of the same component is added to the corresponding second product to obtain the component value of each color, and the display color of each layer is obtained based on the component values of all colors. Create a geometry buffer in WebGPU and write all vertex coordinates and index data of the cavity model into the geometry buffer; In WebGPU, create an instance buffer and write the display color and clipping plane equation of each layer into the instance buffer in the order of the layers; In the WebGPU rendering pipeline, the geometry buffer is defined as the data source for vertex input, and the instantiation buffer is defined as the data source for instance input.
7. The method according to claim 1, characterized in that, The step of performing a plane test on the vertex coordinates in the geometry buffer based on the clipping plane equation pairs corresponding to each instance number in the instantiated buffer, and assigning a color to the pixels that pass the plane test according to the display color corresponding to each instance number to obtain a visualization image, includes: Determine the clipping plane equation pair corresponding to each instance number from the instantiation buffer, add the first constant term of the lower clipping plane equation in the clipping plane equation pair to the Y coordinate of each vertex in the geometry buffer to obtain a first test value, and add the negative number of the Y coordinate to the second constant term of the upper clipping plane equation in the clipping plane equation pair to obtain a second test value. Remove vertices whose first test value is less than zero or whose second test value is less than zero, and all corresponding pixels. The display color corresponding to each instance number is determined from the instantiation buffer, and the display color is assigned to each remaining pixel after culling to obtain a visualization image.
8. A WebGPU-based address cavity pressure hierarchical visualization system, characterized in that, include: The receiving module is used to receive data packets including model identifiers, pressure value sequences, color mapping ranges, and basic color parameters; The mapping module is used to map and truncate the pressure values in the pressure value sequence to obtain a normalized sequence by exchanging and limiting the extreme values of the color mapping range. The processing module is used to normalize the absolute value of the first difference between adjacent elements in the pressure numerical sequence to obtain the pressure distribution sequence. The construction module is used to determine the position where the cumulative pressure probability reaches the division point as the layer boundary based on the local bounding box and according to the pressure distribution sequence, to obtain a non-equidistant boundary array, and to construct the clipping plane equation pair of each layer according to the upper and lower boundaries in the non-equidistant boundary array. The local bounding box is obtained by spatial alignment by loading the cavity model using the model identifier. The binding module is used to interpolate the basic color parameters according to the normalization ratio value of the normalization sequence to obtain the display color of each layer, create a geometry buffer and an instantiation buffer in WebGPU, and bind the vertex data of the cavity model in the geometry buffer with the display color and the clipping plane equation in the instantiation buffer. The allocation module is used to perform a plane test on the vertex coordinates in the geometry buffer according to the clipping plane equation pair corresponding to each instance number in the instantiation buffer, and to allocate a color to the pixels that pass the plane test according to the display color corresponding to each instance number, so as to obtain a visualization image.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the WebGPU-based address cavity pressure hierarchical visualization method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, enables the WebGPU-based address cavity pressure layering visualization method as described in any one of claims 1 to 7.