A graphics information processing method and device, electronic equipment and storage medium
By generating a Cartesian mesh and using subdivision coefficients and vertex coordinates of the sub-2D graphic to determine the intersection relationship between the mesh cell and the graphic, the problem of high complexity in determining the intersection relationship in Cartesian mesh generation is solved, and efficient determination of the intersection relationship of mesh cells is achieved.
Patent Information
- Application Number
- CN202310804084.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-06-30
AI Technical Summary
In existing technologies, the methods for determining the intersection relationship between grid cells and the graph during the generation of Cartesian grids are highly complex, resulting in low efficiency and making it difficult to meet the needs of rapid generation of complex models in computational fluid dynamics.
By extracting graphic information from the graphic file, a Cartesian mesh is generated, the subdivision coefficient is determined, and the target 2D graphic is segmented to obtain sub-2D graphics. The intersection relationship between the mesh cell and the graphic is determined by using the vertex coordinates and mesh number of the sub-2D graphics, thus avoiding the complex calculations of traditional collision detection.
It enables the rapid and efficient determination of the intersection relationship between grid cells and graphics, improves the efficiency of Cartesian grid generation, has strong adaptability, and low computational difficulty.
Smart Images

Figure CN116758242B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computational fluid dynamics, and in particular to a method, apparatus, electronic device, and storage medium for processing graphic information. Background Technology
[0002] In Computing Fluid Dynamics (CFD), the human cost of mesh generation accounts for approximately 60% of the total human cost of the entire CFD process. With increasingly complex computational models and shorter project cycles, mesh generation has become a key factor restricting the development of CFD. Among various mesh types, Cartesian meshes are gaining popularity due to their simple storage structure, convenient encryption methods, and high generation speed. A Cartesian mesh consists of multiple mesh cells. In the Cartesian mesh generation process, quickly determining whether a mesh cell intersects with a graphic in the graphics file is crucial and directly affects the efficiency of mesh generation. Collision detection technology can be used to determine whether a mesh cell intersects with a graphic in the graphics file. However, the shapes of graphics in collision detection are often quite complex, so applying collision detection technology to determine the intersection relationship between mesh cells and graphics is overkill, and the complexity of the algorithm also determines that this method is relatively slow. Therefore, proposing a method that can quickly determine the intersection relationship between graphics and mesh cells is of great significance for Cartesian mesh generation. Summary of the Invention
[0003] To address at least one of the aforementioned technical problems, this disclosure provides a graphic information processing method, apparatus, electronic device, and storage medium.
[0004] On the one hand, this disclosure provides a method for processing graphic information, including:
[0005] Extract graphic information from the graphic file, whereby the graphic information indicates at least one graphic;
[0006] Generate a Cartesian grid based on the graphical information;
[0007] Determine the subdivision coefficient, which represents the number of segments to be divided along each edge of the target two-dimensional graphic. The target two-dimensional graphic is any graphic from at least one graphic.
[0008] Based on the subdivision coefficient, the target two-dimensional graphic is segmented to obtain at least one sub-two-dimensional graphic, and the shape of the sub-two-dimensional graphic is the same as the shape of the target two-dimensional graphic.
[0009] Determine the first position coordinates and the corresponding grid number of each grid cell. The first position coordinates are the position coordinates of each vertex of the sub-two-dimensional graphic, and the grid number represents the position order of the corresponding grid cell in the Cartesian grid.
[0010] Based on the first position coordinates and grid number, determine the intersection relationship between the grid cell and the graphic.
[0011] In an optional embodiment, determining the intersection relationship between the grid cell and the graphic based on the first location coordinates and the grid number includes:
[0012] Obtain the step size of the grid cells;
[0013] Based on the first position coordinates and the step size, calculate the number corresponding to each first position coordinate to obtain the target number set;
[0014] The grid cells corresponding to the target number set are identified as target grid cells, which are the grid cells that intersect with the graphic.
[0015] In an optional embodiment, based on the first position coordinates and the step size, the corresponding number for each of the first position coordinates is calculated to obtain a target number set, including:
[0016] Obtain the coordinates of the origin of the Cartesian grid;
[0017] Subtract the coordinates of the first position from the coordinates of the origin to obtain the coordinate difference;
[0018] The ratio of the coordinate difference to the step size is determined as the numbering parameter;
[0019] The smallest integer among those greater than the number parameter is determined as the number.
[0020] In an optional embodiment, determining the subdivision coefficients includes:
[0021] Get the length of the longest side of the target 2D shape;
[0022] The subdivision factor is obtained based on the side length and the step size of the grid cell.
[0023] In an optional embodiment, the subdivision factor is obtained based on the side length and the step size of the mesh cells, including:
[0024] Divide the side length by the step size to get the length ratio;
[0025] Determine the precision coefficient;
[0026] Multiply the precision coefficient by the length ratio to obtain the subdivision parameters;
[0027] The smallest integer among those greater than the subdivision parameter is determined as the subdivision coefficient.
[0028] In an optional embodiment, determining the first location coordinates includes:
[0029] Obtain the second position coordinates, which are the position coordinates of each vertex of the target two-dimensional graphic;
[0030] Determine the coordinate coefficients corresponding to each of the second position coordinates. The coordinate coefficients represent the mapping relationship between the position coordinates of each vertex of the sub-two-dimensional graphic and the second position coordinates.
[0031] The first position coordinates are obtained based on the second position coordinates and coordinate coefficients.
[0032] In an optional embodiment, determining the coordinate coefficients corresponding to each of the second position coordinates includes:
[0033] Obtain the sub-coordinate coefficients corresponding to each of the second position coordinates. The sub-coordinate coefficients are not less than zero and not greater than the value of the subdivision coefficient. The sum of the sub-coordinate coefficients is equal to the value of the subdivision coefficient.
[0034] The ratio of the sub-coordinate coefficient to the subdivision coefficient is determined as the coordinate coefficient.
[0035] In a second aspect, the present invention also provides a graphic information processing apparatus, comprising:
[0036] The extraction module is used to extract graphic information from graphic files, where the graphic information indicates at least one graphic.
[0037] The mesh generation module is used to generate Cartesian meshes based on graphical information.
[0038] The subdivision coefficient module is used to determine the subdivision coefficient, which represents the number of segments to be divided on each edge of the target two-dimensional graphic. The target two-dimensional graphic is any graphic from at least one graphic.
[0039] The segmentation module is used to segment the target two-dimensional graphic based on the subdivision coefficient to obtain at least one sub-two-dimensional graphic, the shape of which is the same as that of the target two-dimensional graphic.
[0040] The grid numbering module is used to determine the first position coordinates and the grid number corresponding to each grid cell. The first position coordinates are the position coordinates of each vertex of the sub-two-dimensional graphic, and the grid number represents the position order of the corresponding grid cell in the Cartesian grid.
[0041] The relationship determination module is used to determine the intersection relationship between the grid cell and the graphic based on the first position coordinates and the grid number.
[0042] Thirdly, the present invention also provides an electronic device, comprising:
[0043] processor;
[0044] Memory used to store processor-executable instructions;
[0045] The processor is used to execute instructions to implement the above-mentioned graphics information processing method.
[0046] Fourthly, the present invention also provides a storage medium that, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to perform the above-described graphics information processing method.
[0047] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure.
[0048] Implementing this disclosure will have the following beneficial effects:
[0049] Extract graphic information from the graphic file, which indicates at least one graphic; generate a Cartesian mesh based on the graphic information; determine the subdivision coefficient, which represents the number of segments on each edge of the target 2D graphic, which is any one of the at least one graphic; divide the target 2D graphic based on the subdivision coefficient to obtain at least one sub-2D graphic, the shape of which is the same as that of the target 2D graphic; determine the first position coordinates and the corresponding mesh number of each mesh cell, where the first position coordinates are the position coordinates of each vertex of the sub-2D graphic, and the mesh number represents the position order of the corresponding mesh cell in the Cartesian mesh; determine the intersection relationship between the mesh cell and the graphic based on the first position coordinates and the mesh number.
[0050] This disclosure uses the vertex coordinates and grid cell numbers of each sub-two-dimensional graphic obtained after segmenting the target two-dimensional graphic to determine the intersection relationship between the grid cell and the graphic. This method avoids the large amount of computation in traditional collision detection and can determine the intersection relationship between the grid cell and the graphic in the graphic file more quickly and efficiently. The method of this disclosure only uses the vertex coordinates of the graphic when determining the intersection relationship and does not require other parameters of the graphic. It has strong adaptability and is easy to implement.
[0051] Other features and aspects of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0052] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the accompanying 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. The accompanying drawings are incorporated in and constitute a part of this specification, illustrating embodiments consistent with this disclosure, and are used together with the description to explain the principles of this disclosure, and do not constitute an improper limitation of this disclosure.
[0053] Figure 1 This is a schematic diagram of an implementation environment according to an exemplary embodiment;
[0054] Figure 2 This is a flowchart illustrating a graphical information processing method according to an exemplary embodiment;
[0055] Figure 3 This is a schematic diagram of a two-dimensional graphic representation of a segmented target, according to an exemplary embodiment.
[0056] Figure 4 This is a schematic diagram illustrating a graphical information processing method according to an exemplary embodiment;
[0057] Figure 5 This is a schematic diagram of a graphics information processing apparatus according to an exemplary embodiment;
[0058] Figure 6 This is a block diagram illustrating an electronic device for processing graphic information according to an exemplary embodiment. Detailed Implementation
[0059] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0060] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0061] Various exemplary embodiments, features, and aspects of this disclosure will now be described in detail with reference to the accompanying drawings. Like reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise. The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.
[0062] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0063] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.
[0064] In related technologies, collision detection techniques are typically used to determine whether a mesh cell intersects with a graphic in a graphic file. However, the shapes of graphics in collision detection are often quite complex, so applying collision detection techniques to determine the intersection relationship between mesh cells and graphics is overkill, and the complexity of the algorithm also determines that this method is relatively slow.
[0065] To improve speed and efficiency, this disclosure provides a method for processing graphic information.
[0066] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application environment according to an exemplary embodiment, such as... Figure 1 As shown, the application environment may include server 01 and terminal 02.
[0067] In an optional embodiment, server 01 can be used for computational processing in a graphics information processing method. Specifically, server 01 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0068] In an optional embodiment, terminal 02 can perform computational processing in conjunction with the graphics information processing method of server 01. Specifically, terminal 02 can be, but is not limited to, electronic devices such as smartphones, desktop computers, tablets, laptops, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, and smart wearable devices. Optionally, the operating system running on the electronic device can be, but is not limited to, Android, iOS, Linux, Windows, and Unix systems.
[0069] For example, a graphic file is acquired through terminal 02 and transmitted to server 01; graphic information is extracted from the graphic file through server 01, and the graphic information indicates at least one graphic; a Cartesian grid is generated based on the graphic information; a subdivision coefficient is determined, which represents the number of segments on each edge of the target two-dimensional graphic, and the target two-dimensional graphic is any one of the at least one graphic; based on the subdivision coefficient, the target two-dimensional graphic is segmented to obtain at least one sub-two-dimensional graphic, and the shape of the sub-two-dimensional graphic is the same as that of the target two-dimensional graphic; a first position coordinate and the grid number corresponding to each grid cell are determined, where the first position coordinate is the position coordinate of each vertex of the sub-two-dimensional graphic, and the grid number represents the position order of the corresponding grid cell in the Cartesian grid; the intersection relationship between the grid cell and the graphic is determined according to the first position coordinate and the grid number, and the intersection relationship between the grid cell and the graphic is transmitted to terminal 02.
[0070] In addition, it should be noted that, Figure 1 The example shown is merely one application environment provided by this disclosure; in practical applications, other application environments may also be included.
[0071] In the embodiments described in this specification, the server 01 and the terminal 02 can be directly or indirectly connected through wired or wireless communication, and this disclosure does not impose any restrictions.
[0072] Figure 2This is a flowchart illustrating a graphical information processing method according to an exemplary embodiment, such as... Figure 2 As shown, the graphic information processing method includes the following:
[0073] Step S201: Extract graphic information from the graphic file, the graphic information indicating at least one graphic.
[0074] In this embodiment of the disclosure, the graphic file may be a graphic file storing a three-dimensional model, and the graphic information in the graphic file may be the three-dimensional model stored in the file. The graphic information indicates at least one graphic that is a two-dimensional graphic of the surface that makes up the three-dimensional model. Optionally, the surface of the three-dimensional model may be entirely composed of triangles, and the three-dimensional model may be a three-dimensional model of any object, such as a vehicle, an airplane, or a house.
[0075] Step S202: Generate a Cartesian grid based on the graphic information.
[0076] In this embodiment, the Cartesian mesh comprises multiple mesh elements, each of which is a regular hexahedron with the same side length, each represented as one unit. Generating the Cartesian mesh based on graphical information can be achieved by generating a Cartesian mesh that completely encloses the 3D model, according to its length, width, and height. For example, if the longest position of a 3D model is 19.5 units in the length direction, the widest position is 11.8 units in the width direction, and the widest position is 7.6 units in the height direction, then the generated Cartesian mesh will have at least 20 mesh elements in the length direction, at least 12 mesh elements in the width direction, and at least 8 mesh elements in the height direction. The Cartesian mesh generated in this step can be an initial Cartesian mesh, which can be adjusted subsequently according to computational requirements.
[0077] Step S203: Determine the subdivision coefficient, which represents the number of segments on each edge of the target two-dimensional graphic. The target two-dimensional graphic is any graphic among at least one graphic.
[0078] In this embodiment of the disclosure, determining the subdivision coefficient includes:
[0079] Step S2031: Obtain the length of the longest side of the target two-dimensional graphic.
[0080] In this embodiment of the disclosure, when at least one graphic constituting the surface of the three-dimensional model is entirely composed of triangles, the length of the longest side of the target two-dimensional graphic is the length of the longest side of the triangle.
[0081] Step S2032: Obtain the subdivision coefficient based on the side length and the step size of the grid cell.
[0082] In an optional embodiment, the subdivision factor is obtained based on the side length and the step size of the mesh cells, including:
[0083] Divide the side length by the step length to get the length ratio.
[0084] In this embodiment of the disclosure, the step size of the mesh cell is the side length of the regular hexahedral mesh cell, denoted as de lta, and the side length of the longest side of the target two-dimensional graphic is denoted as length. The ratio of the length of the longest side of the target two-dimensional graphic to the step size of the mesh cell, de lta, is obtained. Optionally, when the target two-dimensional graphic is a triangle, length is the side length of the longest side of the triangle.
[0085] Determine the accuracy coefficient.
[0086] In this embodiment of the disclosure, the precision coefficient is a non-zero positive integer, denoted as k. The default value of k is 2, but it can also be any other non-zero positive integer.
[0087] Multiply the precision coefficient by the length ratio to obtain the subdivision parameters.
[0088] In this embodiment of the disclosure, the subdivision parameter obtained by multiplying the precision coefficient by the length ratio may be a decimal.
[0089] The smallest integer among those greater than the subdivision parameter is determined as the subdivision coefficient.
[0090] In this embodiment of the disclosure, if the subdivision parameter is 4.86, the subdivision coefficient is 5; if the subdivision parameter is 2.53, the subdivision coefficient is 3.
[0091] In one specific implementation, the calculation process of obtaining the subdivision coefficient based on the side length and the step size of the mesh cell can be achieved by the following formula (1):
[0092] n=ceiling(k*length / delta) (1)
[0093] In equation (1), n is the subdivision coefficient, ceiling means rounding up, length is the length of the longest side of the triangle, delta is the step size of the grid cell in the Cartesian grid, and k is a non-zero integer, with the default k = 2.
[0094] Based on the above, in this embodiment of the present disclosure, by dividing the side length by the step size to obtain the length ratio, the length ratio between the target two-dimensional graphic and the grid cell can be determined, and the subdivision coefficient can be adapted to the grid cell step size, thereby facilitating the determination of a suitable number of segments; by introducing a precision coefficient in the calculation process of the subdivision coefficient, different segmentation precisions can be adjusted by adjusting the value of the precision coefficient.
[0095] Step S204: Based on the subdivision coefficient, the target two-dimensional graphic is segmented to obtain at least one sub-two-dimensional graphic, the shape of which is the same as that of the target two-dimensional graphic.
[0096] In this embodiment of the disclosure, such as Figure 3 As shown, in the process of segmenting the target two-dimensional graphic, firstly, according to the subdivision coefficient, the target two-dimensional graphic, such as dividing each side of a triangle, into the number of segments indicated by the subdivision coefficient. Then, the subdivision points on side AC are connected to the corresponding subdivision points on side BC, with the connecting lines parallel to side AB. Similarly, the subdivision points on side AB are connected to the corresponding subdivision points on side AC, with the connecting lines parallel to side BC. Finally, the above connecting lines divide triangle ABC into multiple sub-two-dimensional graphics, i.e., sub-triangles, which are identical in shape to triangle ABC. With a subdivision coefficient of 5, triangle ABC is divided into 5 equal parts along each of its three sides. According to the knowledge of arithmetic sequences, triangle ABC is divided into 25 sub-triangles, generating 21 vertices (including points A, B, C, and points on the sides of the triangles).
[0097] Step S205: Determine the first position coordinates and the grid number corresponding to each grid cell. The first position coordinates are the position coordinates of each vertex of the sub-two-dimensional graphic, and the grid number represents the position order of the corresponding grid cell in the Cartesian grid.
[0098] In this embodiment, the first position coordinates are the position coordinates of each vertex of the sub-two-dimensional graphic. The grid number corresponding to each grid cell represents the positional order of the grid cell in the Cartesian grid. Taking the graphic information as a three-dimensional model as an example, the initial position is denoted as (0,0,0) at the origin of the computational domain corresponding to the three-dimensional model, i.e., the origin of the Cartesian grid. The grid number of the grid cell with this point as its vertex is denoted as (1,1,1), indicating that it is the first grid cell along the x-axis, the first along the y-axis, and the first along the z-axis. If the grid number of a certain grid cell is (8,3,5), it means that the grid cell is the 8th along the x-axis, the 3rd along the y-axis, and the 5th along the z-axis. This grid number is independent of the step size of the grid cell and is only related to the origin position of the Cartesian grid.
[0099] In this embodiment of the disclosure, determining the first position coordinates includes:
[0100] Step S2051: Obtain the second position coordinates, which are the position coordinates of each vertex of the target two-dimensional graphic.
[0101] In this embodiment of the disclosure, when the graphic information is a three-dimensional model, since the surface of the three-dimensional model is composed of multiple two-dimensional graphics, the two-dimensional graphics on the surface of the three-dimensional model can be regarded as spatial two-dimensional graphics, and the vertices of the target two-dimensional graphics can be represented by coordinates under the x-axis, y-axis, and z-axis.
[0102] Step S2052: Determine the coordinate coefficients corresponding to each of the second position coordinates. The coordinate coefficients represent the mapping relationship between the position coordinates of each vertex of the sub-two-dimensional graphic and the second position coordinates.
[0103] In this embodiment of the disclosure, determining the coordinate coefficients corresponding to each of the second position coordinates includes:
[0104] Obtain the sub-coordinate coefficients corresponding to each of the second position coordinates. The sub-coordinate coefficients are not less than zero and are not greater than the value of the subdivision coefficient. The sum of the sub-coordinate coefficients is equal to the value of the subdivision coefficient.
[0105] In this embodiment, the number of sub-coordinate coefficients corresponding to each of the second position coordinates is equal to the number of vertices of the target two-dimensional graphic. When the target two-dimensional graphic is a triangle, the number of sub-coordinate coefficients corresponding to each of the second position coordinates is three, corresponding to vertices A, B, and C respectively, and denoted as i. A i B i C i A i B i C The values of are all integers that are not less than zero and not greater than the subdivision coefficient. The sum of the coefficients of each sub-coordinate corresponding to a certain second position coordinate is equal to the value of the subdivision coefficient n. Specifically, it is shown in the following formula (2):
[0106]
[0107] In equation (2) above, i A i B i C These are the coefficients of each sub-coordinate corresponding to a certain second position coordinate, where n is the subdivision coefficient.
[0108] The ratio of the sub-coordinate coefficient to the subdivision coefficient is determined as the coordinate coefficient.
[0109] In this embodiment, the number of coordinate coefficients corresponding to each second position coordinate is equal to the number of its corresponding sub-coordinate coefficients. Each sub-coordinate coefficient corresponding to the second position coordinate corresponds to each vertex of the target two-dimensional graphic. The ratio of the sub-coordinate coefficient corresponding to a vertex of the target two-dimensional graphic to the subdivision coefficient among the sub-coordinate coefficients of the second position coordinate is determined as the coordinate coefficient corresponding to the second position coordinate and that vertex. Specifically, it is shown in the following formula (3):
[0110] c A =iA / n
[0111] c B =i B / n
[0112] c C =i C / n (3)
[0113] In equation (3) above, i A i B i C These are the coefficients of each sub-coordinate corresponding to a certain second position coordinate, where n is the subdivision coefficient and C is the subdivision coefficient. A C B C C These are the coordinate coefficients corresponding to the second position coordinates and the respective vertices of the target two-dimensional graphic.
[0114] As can be seen from the above, in this embodiment of the present disclosure, by ensuring that the sub-coordinate coefficients are not less than zero and not greater than the value of the subdivision coefficient, and that the sum of all sub-coordinate coefficients is equal to the value of the subdivision coefficient, the sub-coordinate coefficients and the subdivision coefficient can be linked, which facilitates the calculation of the first position coordinates.
[0115] Step S2053: Obtain the first position coordinates based on the second position coordinates and coordinate coefficients.
[0116] In this embodiment of the present disclosure, calculating the first position coordinate based on the second position coordinate and coordinate coefficient can be as follows: multiplying the x-axis coordinate value of each vertex of the target two-dimensional graphic in the second position coordinate with the corresponding coordinate coefficient, and summing the products to obtain the x-axis coordinate value of the first position coordinate; multiplying the y-axis coordinate value of each vertex of the target two-dimensional graphic in the second position coordinate with the corresponding coordinate coefficient, and summing the products to obtain the y-axis coordinate value of the first position coordinate; multiplying the z-axis coordinate value of each vertex of the target two-dimensional graphic in the second position coordinate with the corresponding coordinate coefficient, and summing the products to obtain the z-axis coordinate value of the first position coordinate. Taking the x-axis coordinate value of the first position coordinate as an example, its calculation process is as follows (4):
[0117] x = c A *x A +c B *x B +c C *x C (4)
[0118] In equation (4) above, C A C B C C These represent the coordinates of a certain second position and the coordinate coefficients corresponding to each vertex of the target 2D graphic, respectively. Ax B x C These are the x-axis coordinates of each vertex of the target 2D graphic, where x is the x-axis coordinate of the first position.
[0119] As can be seen from the above, the method of calculating the first position coordinates by using coordinate coefficients and second position coordinates in the embodiments of this disclosure can more quickly obtain the vertex coordinates of the sub-two-dimensional graphics in the target two-dimensional graphics. The above-mentioned method of calculating the first position coordinates only uses the vertex coordinates of the target two-dimensional graphics and is unrelated to other parameters of the target two-dimensional graphics, thus having good adaptability.
[0120] Step S206: Determine the intersection relationship between the grid cell and the graphic based on the first position coordinates and grid number.
[0121] In this embodiment of the disclosure, determining the intersection relationship between the grid cell and the graphic based on the first position coordinates and the grid number includes:
[0122] Step S2061: Obtain the step size of the mesh cells.
[0123] In this embodiment of the disclosure, the step size of the mesh cell is the side length of a regular hexahedron. Optionally, the step size of the mesh cell can be obtained based on the setting parameters of the Cartesian mesh.
[0124] Step S2062: Calculate the number corresponding to each of the first position coordinates based on the first position coordinates and the step size to obtain the target number set.
[0125] In an optional embodiment, based on the first position coordinates and the step size, the corresponding number for each of the first position coordinates is calculated to obtain a target number set, including:
[0126] Obtain the origin coordinates of the Cartesian grid; determine the smallest integer among those greater than the number parameter as the number, and the number belongs to the target number set.
[0127] In this embodiment of the disclosure, the origin coordinates of the Cartesian grid can be denoted as (x... global_ y global_ , z global_ The initial value of the origin coordinates of the Cartesian grid can be (0,0,0).
[0128] Subtract the coordinates of the first position from the coordinates of the origin to obtain the coordinate difference.
[0129] In this embodiment of the disclosure, subtracting the coordinate difference between the first position coordinate and the origin coordinate can be done by subtracting the x-axis coordinate value of the first position coordinate from the x-axis coordinate value of the origin coordinate, subtracting the y-axis coordinate value of the first position coordinate from the y-axis coordinate value of the origin coordinate, and subtracting the z-axis coordinate value of the first position coordinate from the z-axis coordinate value of the origin coordinate.
[0130] The ratio of the coordinate difference to the step size is determined as the numbering parameter; the smallest integer among the integers greater than the numbering parameter is determined as the number, and the number belongs to the target numbering set.
[0131] In this embodiment, the ratio of the x-axis coordinate difference to the step size is determined as the numbering parameter corresponding to the x-axis, the ratio of the y-axis coordinate difference to the step size is determined as the numbering parameter corresponding to the y-axis, and the ratio of the z-axis coordinate difference to the step size is determined as the numbering parameter corresponding to the z-axis. The smallest integer among the integers greater than the x-axis numbering parameter is determined as the x-axis number i of the first position coordinate, the smallest integer among the integers greater than the y-axis numbering parameter is determined as the y-axis number j of the first position coordinate, and the smallest integer among the integers greater than the z-axis numbering parameter is determined as the z-axis number k of the first position coordinate. Based on the above axis numbers, the number corresponding to the first position coordinate can be obtained, denoted as (i, j, k), which belongs to the target number set. Taking the x-axis number i as an example, the above calculation process is specifically as follows (5):
[0132] i = ceiling[(xx global_min ) / delta] (5)
[0133] In equation (5) above, i is the x-axis number of the first position coordinate, ceiling means rounding up, and x is the difference in x-axis coordinates. global_min denoted as x, where x is the origin coordinate of the Cartesian grid, and delta is the step size of the grid cells in the Cartesian grid.
[0134] As can be seen from the above, in this embodiment of the present disclosure, the coordinate difference is obtained by subtracting the first position coordinate from the origin coordinate, and the ratio of the coordinate difference to the step size is determined as the numbering parameter; by determining the smallest integer among the integers greater than the numbering parameter as the number, the label of the first position coordinate can be obtained through simple calculation, which facilitates the position comparison between the first position coordinate and the grid cell.
[0135] Step S2063: Determine the grid cell corresponding to the target number set as the target grid cell. The target grid cell is the grid cell that intersects with the graphic.
[0136] In this embodiment of the disclosure, if the grid number of a certain grid cell corresponds to a certain number in the target number set, then the grid cell corresponding to the grid number intersects with the graphics of the surface that makes up the graphics information in the graphics file, that is, the grid cell corresponding to the grid number intersects with the surface of the graphics information. If the grid number of a certain grid cell does not correspond to any number in the target number set, then the grid cell corresponding to the grid number does not intersect with the surface of the graphics information.
[0137] Based on the above, in this embodiment of the present disclosure, by calculating the number corresponding to each of the first position coordinates according to the first position coordinates and the step size, the target number set can be obtained. The vertices of each sub-two-dimensional graphic in the target two-dimensional graphic, that is, the number of each sampling point in the target two-dimensional graphic, can be obtained. By determining the grid unit corresponding to the target number set as the target grid unit, the grid unit intersecting with the surface of the graphic information can be quickly determined by comparing the numbers.
[0138] The above embodiments determine the intersection relationship between a triangle and Cartesian grid elements starting from the triangle itself, avoiding the strict requirement for geometric integrity when determining intersection using the traditional ray method. This approach is applicable to geometries containing defects such as interference and gaps, and offers excellent fault tolerance. By determining the intersection relationship through discrete triangles, the detection accuracy can be adjusted via an accuracy coefficient k, making it very easy to achieve a balance between efficiency and accuracy.
[0139] In one specific implementation method, the technical solution implementation process in this application embodiment is as follows: Figure 4 As shown, the specific process is as follows:
[0140] 1. Read the drawing file (geometry file).
[0141] 2. Generate a Cartesian grid based on the size of the computational domain set for the graphic file.
[0142] 3. Determine the intersection relationship between triangular cells and Cartesian grid cells in a drawing file. This includes:
[0143] (1) Select any triangular unit.
[0144] (2) Calculate the length of the longest side of the triangle.
[0145] (3) Calculate the subdivision factor n based on the length of the longest side of the triangle and the grid step size of the Cartesian grid. The calculation formula is as follows:
[0146] n = ceiling(k * length / delta)
[0147] Where ceiling indicates rounding up, length is the length of the longest side of the triangle, delta is the Cartesian grid step size, and k is a non-zero integer, with a default value of k=2.
[0148] (4) Divide the triangular unit into several triangles according to the subdivision coefficient, thereby obtaining several sampling points. Triangle ABC is divided into 5 equal parts in the direction of each of the three sides. According to the knowledge of arithmetic sequences, triangle ABC is divided into 25 small triangles, and 21 points are generated at the same time (including points A, B, C and points on the sides).
[0149] (5) For any point P among several sampling points, its coordinates can be represented by the coordinates of the vertices A, B, and C of the triangle. Taking the x-axis coordinates as an example:
[0150] x = c A *x A +c B *x B +c C *x c
[0151] c A =i A / n
[0152] c B =i B / n
[0153] c C =i C / n
[0154] Where n is the subdivision coefficient, i A i B i C The following conditions must be met:
[0155] i A =0, n
[0156] i B =0, n
[0157] i C =0, n
[0158] i A +i B +i C =n
[0159] The coordinates of the point calculated according to the above formula must fall within the range of triangle ABC.
[0160] (6) Calculate the sequential number (i, j, k) of the midpoint P in the Cartesian grid based on the origin coordinates (the point with the smallest coordinates in the x, y, and z directions) and the Cartesian grid step size. Taking i as an example, the calculation method is as follows:
[0161] i = ceiling[(xxglobal_min ) / delta]
[0162] Where, ceiling means rounding up, x global_min The origin coordinates of the Cartesian grid.
[0163] (7) The Cartesian grid cell corresponding to (i, j, k) intersects with the triangular cell.
[0164] (8) Repeat steps (4) to (7) to determine the geometric intersection relationship of all possible Cartesian grid cells that may intersect with the triangular cell.
[0165] (9) Repeat steps (1) to (9) to find all Cartesian grid cells that intersect with triangles in the drawing file.
[0166] (10) After finding all intersecting Cartesian mesh elements, the mesh elements located inside the intersecting Cartesian mesh elements can be removed, and the calculation parameters can be set based on the remaining Cartesian mesh elements to calculate the hydrodynamic data of the model surface in the graphics file.
[0167] Figure 5 This is a block diagram of a graphic information processing apparatus according to an exemplary embodiment. (Refer to...) Figure 5 The device includes an extraction module 501, a mesh generation module 502, a subdivision coefficient module 503, a segmentation module 504, a mesh numbering module 505, and a relationship determination module 506, wherein...
[0168] Extraction module 501 is used to extract graphic information from a graphic file, wherein the graphic information indicates at least one graphic.
[0169] Mesh generation module 502 is used to generate Cartesian meshes based on graphic information;
[0170] The subdivision coefficient module 503 is used to determine the subdivision coefficient, which represents the number of segments to be divided on each side of the target two-dimensional graphic. The target two-dimensional graphic is any graphic among at least one graphic.
[0171] The segmentation module 504 is used to segment the target two-dimensional graphic based on the subdivision coefficient to obtain at least one sub-two-dimensional graphic, the shape of which is the same as the shape of the target two-dimensional graphic.
[0172] The grid numbering module 505 is used to determine the first position coordinates and the grid number corresponding to each grid cell. The first position coordinates are the position coordinates of each vertex of the sub-two-dimensional graphic, and the grid number represents the position order of the corresponding grid cell in the Cartesian grid.
[0173] The relationship determination module 506 is used to determine the intersection relationship between the grid cell and the graphic based on the first position coordinates and the grid number.
[0174] In an optional embodiment, the relationship determination module 506 includes:
[0175] The first acquisition module is used to acquire the step size of the grid cells;
[0176] The numbering calculation module is used to calculate the number corresponding to each of the first position coordinates based on the first position coordinates and the step size, so as to obtain the target number set;
[0177] The target grid cell module is used to identify the grid cells corresponding to the target number set as target grid cells. The target grid cell is the grid cell that intersects with the graphic.
[0178] In an optional embodiment, the number calculation module includes:
[0179] The second acquisition module is used to obtain the origin coordinates of the Cartesian grid;
[0180] The coordinate difference module is used to subtract the coordinates of the first position from the coordinates of the origin to obtain the coordinate difference value;
[0181] The numbering parameter module is used to determine the ratio of the coordinate difference to the step size as the numbering parameter;
[0182] The number determination module is used to determine the smallest integer among the integers greater than the number parameter as the number.
[0183] In an optional embodiment, the subdivision coefficient module 503 includes:
[0184] The third acquisition module is used to obtain the length of the longest side of the target two-dimensional graphic;
[0185] The subdivision factor calculation module is used to obtain the subdivision factor based on the side length and the step size of the mesh cells.
[0186] In an optional embodiment, the subdivision coefficient calculation module includes:
[0187] The length ratio module is used to divide the side length by the step size to obtain the length ratio.
[0188] The accuracy coefficient module is used to determine the accuracy coefficient;
[0189] The subdivision parameter module is used to multiply the precision coefficient by the length ratio to obtain the subdivision parameters;
[0190] The subdivision coefficient determination module is used to determine the smallest integer among the integers greater than the subdivision parameter as the subdivision coefficient.
[0191] In an optional embodiment, the grid numbering module 505 includes:
[0192] The fourth acquisition module is used to acquire the second position coordinates, which are the position coordinates of each vertex of the target two-dimensional graphic;
[0193] The coordinate coefficient module is used to determine the coordinate coefficients corresponding to the second position coordinates. The coordinate coefficients represent the mapping relationship between the position coordinates of each vertex of the sub-two-dimensional graphic and the second position coordinates.
[0194] The first position coordinate module is used to obtain the first position coordinates based on the second position coordinates and coordinate coefficients.
[0195] In an optional embodiment, the coordinate coefficient module includes:
[0196] The fifth acquisition module is used to acquire the sub-coordinate coefficients corresponding to each of the second position coordinates. The sub-coordinate coefficients are not less than zero and not greater than the value of the subdivision coefficient. The sum of the sub-coordinate coefficients is equal to the value of the subdivision coefficient.
[0197] The coordinate coefficient determination module is used to determine the coordinate coefficient by the ratio of the sub-coordinate coefficient to the subdivision coefficient.
[0198] In an exemplary embodiment, an electronic device is also provided, including: a processor; and a memory for storing processor-executable instructions; wherein the processor is used for the instructions to implement the graphics information processing method as described in the embodiments of this disclosure.
[0199] Figure 6 This is a block diagram illustrating an electronic device for processing graphic information according to an exemplary embodiment. The electronic device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the electronic device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a graphical information processing method. The display screen can be a liquid crystal display (LCD) or an e-ink display. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the device's casing, or an external keyboard, touchpad, or mouse.
[0200] Those skilled in the art will understand that Figure 6The structure shown is merely a block diagram of a portion of the structure related to the present disclosure and does not constitute a limitation on the electronic device to which the present disclosure is applied. A specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0201] In an exemplary embodiment, a storage medium is also provided, which, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to perform the graphics information processing method of the present disclosure embodiments.
[0202] In an exemplary embodiment, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the graphics information processing method of the present disclosure embodiments.
[0203] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this disclosure can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0204] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0205] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method for processing graphic information, characterized in that, The method includes: Extract graphic information from the graphic file, wherein the graphic information indicates at least one graphic; Based on the graphic information, a Cartesian grid is generated; A subdivision coefficient is determined, wherein the subdivision coefficient represents the number of segments to be divided on each side of the target two-dimensional graphic, and the target two-dimensional graphic is any one of the at least one graphics; Based on the subdivision coefficient, the target two-dimensional graphic is segmented to obtain at least one sub-two-dimensional graphic, the shape of which is the same as the shape of the target two-dimensional graphic; Determine the first position coordinates and the grid number corresponding to each grid cell. The first position coordinates are the position coordinates of each vertex of the sub-two-dimensional graphic, and the grid number represents the position order of the corresponding grid cell in the Cartesian grid. Based on the first position coordinates and the grid number, the intersection relationship between the grid cell and the graphic is determined.
2. The method according to claim 1, characterized in that, Determining the intersection relationship between the grid cell and the graphic based on the first position coordinates and the grid number includes: Obtain the step size of the grid cell; Based on the first position coordinates and the step size, calculate the number corresponding to each of the first position coordinates to obtain the target number set; The grid cells corresponding to the target number set are determined as target grid cells, and the target grid cells are the grid cells that intersect with the graphic.
3. The method according to claim 2, characterized in that, The step of calculating the number corresponding to each of the first position coordinates based on the first position coordinates and the step size to obtain the target number set includes: Obtain the origin coordinates of the Cartesian grid; Subtract the coordinates of the first position from the coordinates of the origin to obtain the coordinate difference; The ratio of the coordinate difference to the step size is determined as the numbering parameter; The smallest integer among those greater than the number parameter is determined as the number.
4. The method according to claim 1, characterized in that, The determination of the subdivision coefficient includes: Obtain the length of the longest side of the target two-dimensional shape; The subdivision coefficient is obtained based on the side length and the step size of the grid cell.
5. The method according to claim 4, characterized in that, The step of obtaining the subdivision coefficient based on the side length and the step size of the grid cell includes: Divide the side length by the step size to obtain the length ratio; Determine the precision coefficient; Multiplying the precision coefficient by the length ratio yields the subdivision parameters; The smallest integer among those greater than the subdivision parameter is determined as the subdivision coefficient.
6. The method according to claim 1, characterized in that, Determining the first position coordinates includes: Obtain the second position coordinates, which are the position coordinates of each vertex of the target two-dimensional graphic; Determine the coordinate coefficients corresponding to each of the second position coordinates, wherein the coordinate coefficients characterize the mapping relationship between the position coordinates of each vertex of the sub-two-dimensional graphic and the second position coordinates; The first position coordinates are obtained based on the second position coordinates and the coordinate coefficients.
7. The method according to claim 6, characterized in that, Determining the coordinate coefficients corresponding to each of the second position coordinates includes: Obtain the sub-coordinate coefficients corresponding to each of the second position coordinates. The sub-coordinate coefficients are not less than zero and not greater than the value of the subdivision coefficient. The sum of the sub-coordinate coefficients is equal to the value of the subdivision coefficient. The ratio of the sub-coordinate coefficient to the subdivision coefficient is determined as the coordinate coefficient.
8. A graphic information processing device, characterized in that, The device includes: The extraction module is used to extract graphic information from a graphic file, wherein the graphic information indicates at least one graphic. A mesh generation module is used to generate a Cartesian mesh based on the graphic information; A subdivision coefficient module is used to determine a subdivision coefficient, wherein the subdivision coefficient represents the number of segments to be divided on each side of the target two-dimensional graphic, and the target two-dimensional graphic is any one of the at least one graphic. The segmentation module is used to segment the target two-dimensional graphic based on the subdivision coefficient to obtain at least one sub-two-dimensional graphic, wherein the shape of the sub-two-dimensional graphic is the same as the shape of the target two-dimensional graphic. The grid numbering module is used to determine the first position coordinates and the grid number corresponding to each grid cell. The first position coordinates are the position coordinates of each vertex of the sub-two-dimensional graphic, and the grid number represents the position order of the corresponding grid cell in the Cartesian grid. The relationship determination module is used to determine the intersection relationship between the grid cell and the graphic based on the first position coordinates and the grid number.
9. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is used for the instructions to implement the graphics information processing method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the graphics information processing method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Thin shell curved surface simulation method, device, equipment and medium
CN115048825A
Environmental fluid distribution information generation method and device, electronic equipment and storage medium
CN115048877A
