Method for calculating space envelope volume, computer equipment and readable storage medium
By discretizing the surface of the space envelope into triangular grid units and using ray array detection technology, the problem of volume calculation of complex space envelopes is solved, and automated calculations and high-efficiency volume calculations are achieved.
Patent Information
- Application Number
- CN202411121355.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-09-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
It is difficult to effectively calculate the volume of a complex and irregular spatial envelope using existing technology. Especially when only the three-dimensional coordinates of discrete points on the surface are known, volume calculation becomes difficult.
By discretizing the surface of the space envelope into triangular grid units, establishing a three-dimensional rectangular coordinate system, determining the circumscribed cuboid, and using ray arrays to detect the boundary range, the cubic units are divided into the first and second types, and secondary discretization is performed to Calculate volume.
It realizes the automatic calculation of the volume of complex spatial envelopes, with strong robustness and high calculation efficiency. It does not require too much human intervention and can identify boundary features such as convex corners and depressions.
Smart Images

Figure CN118627362A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of space envelope volume calculation, and in particular to a method for calculating the volume of a space envelope, a computer device and a readable storage medium. Background Art
[0002] Calculation of object volume is a very basic and important operation. It is used in the field of fluid-structure interaction research to calculate the volume of a complete structure or the volume of a structure deformed by force, as well as the volume of objects made of flexible materials that are easily deformed by external influences.
[0003] For spatial geometric bodies with simple and regular shapes, they can be accurately calculated using known theoretical formulas. For slightly more complex and regular spatial geometric bodies, their volume values can be calculated by cutting them into regular bodies, but for geometric bodies with complex and irregular shapes, volume calculation is more difficult. If the only known information about the spatial envelope is the three-dimensional coordinates of discrete points on the surface, and its shape distribution cannot be directly observed, volume calculation will be even more difficult.
[0004] Although the volume calculation of spatial envelope can also be done by algebraic methods, such as using determinants and vector theory, the volume of any polyhedron in three-dimensional space can also be obtained using the coordinates of the polyhedron vertices, but it is necessary to correctly distinguish the clockwise and counterclockwise arrangement of the surface polygon vertices; for example, the Gaussian formula can also be used to convert the volume calculation into the surface area calculation, but it is necessary to find an integral function whose value is always equal to unit 1. For complex and irregular geometric shapes, the solution is more difficult. Summary of the invention
[0005] The present invention aims to solve at least one of the technical problems in the prior art that the existing spatial envelope volume calculation method is complex and difficult to apply to the calculation of complex and irregular geometric shapes.
[0006] To this end, the first aspect of the present invention provides a method for calculating the volume of a spatial envelope.
[0007] A second aspect of the present invention provides a computer device.
[0008] A third aspect of the present invention provides a computer-readable storage medium.
[0009] The present invention provides a method for calculating the volume of a spatial envelope, comprising the following steps: S1, discretizing the surface of the spatial envelope into a mesh surface composed of triangular mesh units; establishing a three-dimensional rectangular coordinate system based on the spatial envelope, and determining the circumscribed cuboid of the spatial envelope according to the maximum and minimum values of the vertex coordinates of all triangular mesh units in the X-axis direction, the Y-axis direction and the Z-axis direction, wherein the coordinates of any point on the spatial envelope are contained in the circumscribed cuboid; S2, using the ray array in the X-axis direction, the Y-axis direction and the Z-axis direction to detect the boundary range of the space envelope, wherein the circumscribed cuboid is discretized into three directions in the X-axis direction, the Y-axis direction and the Z-axis direction cubic units, defining the set of rays where all cubic unit grid lines perpendicular to a coordinate plane are located as a ray array; finding intersection points for each ray in the ray array with all triangular grid units respectively, obtaining intersection coordinates, sorting the intersection coordinates according to their distances from the ray starting point, and after sorting, pairing the intersection coordinates in order to form intersection pairs, the number of the intersection pairs representing the number of internal intervals of the spatial envelope in the current ray direction; S3, searching for a triangular mesh unit intersecting with any cubic unit, and then determining a specific cubic unit intersecting with the triangular mesh unit; S4. According to the detection results of the ray array, the cubic units are divided into first-class cubic units and second-class cubic units, wherein the first-class cubic units include cubic units having intersection points with triangular mesh units on their edges, and the second-class cubic units include cubic units having no intersection points with triangular mesh units on their edges; each first-class cubic unit is discretized twice to form a secondary discrete unit, and whether the secondary discrete unit is inside the spatial envelope is determined according to the triangular mesh units intersecting with the cubic unit, and the number of secondary discrete units located inside the spatial envelope in the same first-class cubic unit is marked; S5. Solve the volume of the part of the first type of cubic unit located inside the spatial envelope according to the mark value, and superimpose the volume of the second type of cubic unit located inside the spatial envelope to calculate the volume of the spatial envelope.
[0010] The method for calculating the volume of a spatial envelope according to the above technical solution of the present invention may also have the following additional technical features: In the above technical solution, step S1 includes: The surface of the space envelope is discretized into a mesh surface composed of triangular mesh units. Vertices and triangular mesh units; the coordinates of the i-th vertex are ; The maximum and minimum values of the vertex coordinates of all triangular mesh units in the X-axis direction, the Y-axis direction and the Z-axis direction are obtained; and the minimum circumscribed cuboid of the spatial envelope is determined according to the maximum and minimum values of the vertex coordinates in the X-axis direction, the Y-axis direction and the Z-axis direction, so that the coordinates of any point on the spatial envelope are contained in the minimum circumscribed cuboid.
[0011] In the above technical solution, step S1 also includes: On the basis of the minimum circumscribed cuboid, the tolerance amount is superimposed to obtain the determined circumscribed cuboid, including:
[0012] in, Indicates the tolerance amount; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the X-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the X-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the X-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the X-axis direction; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the Y-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the Y-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the Y-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the Y-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the Y-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the Y-axis direction; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the Z-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the Z-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the Z-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the Z-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the Z-axis direction.
[0013] In the above technical solution, in step S2, the intersection point formed by the ray piercing the space envelope is defined as the intersection point, that is, the number of intersection points on each ray is an even number; the intersection point of each ray in the ray array is obtained with all the triangular mesh units to obtain the intersection coordinates, including: Find the intersection point of each ray with all triangular mesh units. If the intersection point is inside the current triangular mesh unit, store the intersection point coordinates and record them as the mth intersection point of the current ray. If the intersection point is not inside the current triangular mesh unit, continue to determine the next triangular mesh unit; obtain the intersection point coordinate set; The intersection coordinates are sorted according to their distances from the starting point of the ray, and after sorting, the intersection coordinates are paired in order to form intersection pairs. The number of intersection pairs represents the number of internal intervals of the spatial envelope in the current ray direction, thereby identifying the topological structure of the spatial envelope.
[0014] In the above technical solution, the method for determining whether the intersection point is located inside the current triangular mesh unit includes: Determine whether the sum of the areas of the three triangles formed by the intersection point and the three sides of the triangular mesh unit is equal to the area of the triangular mesh unit; If they are equal, the intersection point is determined to be inside the current triangular mesh unit.
[0015] In the above technical solution, step S3 includes: Will The cube unit is converted into parallel grid planes, along the Y direction parallel grid planes and along the Z direction parallel grid planes; Determine the triangular mesh unit that penetrates any parallel mesh plane as the triangular mesh unit that intersects with the cubic unit; and determine the endpoint coordinates of the intersection line between the triangular mesh unit and the parallel mesh plane; The specific cubic unit intersecting with the triangular mesh unit is determined by using the intersection line; wherein perpendicular lines are drawn from the four vertices of the cubic unit to the intersection line respectively, and if the directions of the four perpendicular vectors are not completely the same, it is determined that the cubic unit intersects with the triangular mesh unit; After completing the judgment of all parallel mesh planes, the duplicate triangular mesh units corresponding to each cubic unit are collected.
[0016] In the above technical solution, step S4 includes: Discretize each first-class cube twice to form a secondary discrete unit; Determine whether any vertex of the cube unit is inside the space envelope; the determination method includes: the vertex located inside the space envelope should be between two corresponding reference points in the three directions of the X-axis direction, the Y-axis direction and the Z-axis direction, respectively, and the two reference points are two points in the matched intersection point pair in step S2; According to whether the direction of the perpendicular vector from the grid center of the secondary discrete unit cell to the cutting plane is the same as the direction of the perpendicular vector from the vertex inside the spatial envelope to the cutting plane, it is judged whether the secondary discrete unit is inside the spatial envelope; if they are the same, it means that the secondary discrete unit is inside the spatial envelope and is marked; all secondary discrete units are marked; The cutting plane includes a plane where any triangular mesh unit at least partially intersects with the cubic unit.
[0017] In the above technical solution, the method for calculating the volume of the spatial envelope includes: Calculate the total volume of the spatial envelope based on the internal volume of each cubic unit; The internal volume of the first type of cube is the sum of the volumes of the secondary discrete units whose labels are located inside the space envelope; In the second type of cube, if all the vertices are located inside the spatial envelope, its internal volume is the volume of a single cube unit; if all the vertices are located outside the spatial envelope, its internal volume is 0.
[0018] The present invention provides a computer device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is loaded and executed by the processor, the method for calculating the volume of a spatial envelope as described in any one of the above technical solutions is implemented.
[0019] The present invention provides a computer-readable storage medium storing a program, which, when loaded by a processor, implements the method for calculating the volume of a spatial envelope as described in any one of the above technical solutions.
[0020] In summary, due to the adoption of the above technical features, the beneficial effects of the present invention are: The calculation method proposed in the present invention is different from the pure algebraic method. It starts from the geometric method. The method is intuitive and easy to understand. At the same time, it has a high degree of automation. It does not require too much human intervention in the calculation process. It can automatically detect the boundary range of spatial envelopes including protruding corners, concave pits, multi-connected domains, etc. It has strong robustness and high calculation efficiency.
[0021] Additional aspects and advantages of the present invention will become apparent from the following description or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which: Figure 1 is a flow chart of a method for calculating the volume of a spatial envelope according to an embodiment of the present invention; Figure 2It is a schematic diagram of the transformation principle between the minimum circumscribed cuboid and the determined circumscribed cuboid in the method for calculating the volume of a space envelope according to an embodiment of the present invention; Figure 3 It is a schematic diagram of the principle of forming intersection points when rays penetrate a spatial envelope in a method for calculating the volume of a spatial envelope according to an embodiment of the present invention; Figure 4 is a schematic diagram of a method for calculating the volume of a space envelope according to an embodiment of the present invention in which the intersection point is outside a triangular mesh unit; Figure 5 is a schematic diagram of a method for calculating the volume of a space envelope according to an embodiment of the present invention in which the intersection point is inside a triangular mesh unit; Figure 6 It is a schematic diagram of the intersection of a triangular mesh unit and a parallel mesh plane in a method for calculating the volume of a space envelope according to an embodiment of the present invention; Figure 7 yes Figure 6 A schematic plan view of a parallel grid plane 1 is shown; Figure 8 It is a schematic diagram of the principle of judging whether the intersection line PQ intersects with the side surface of the cube unit; Fig. 9 It is a schematic diagram of the position determination of the cube unit vertices from the Y-axis perspective; Fig.10 It is a schematic diagram of determining the position of the cube unit vertices from the X-axis perspective; Fig.11 This is a schematic diagram of the first form of spatial envelope arrangement; Fig.12 This is a schematic diagram of the second form of spatial envelope arrangement; Fig.13 It is a schematic diagram of the third form of spatial envelope arrangement; Fig.14 This is a schematic diagram of the fourth form of spatial envelope layout. DETAILED DESCRIPTION
[0023] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0024] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0025] Refer to the following Figures 1 to 14A method for calculating the volume of a spatial envelope provided according to some embodiments of the present invention is described.
[0026] Some embodiments of the present application provide a method for calculating the volume of a spatial envelope.
[0027] like Figure 1 As shown, the first embodiment of the present invention proposes a method for calculating the volume of a spatial envelope, including the following steps S1-S5.
[0028] S1. Discretize the surface of the spatial envelope into a mesh surface composed of triangular mesh units; establish a three-dimensional rectangular coordinate system based on the spatial envelope, and determine the circumscribed cuboid of the spatial envelope according to the maximum and minimum values of the vertex coordinates of all triangular mesh units in the X-axis direction, the Y-axis direction and the Z-axis direction, wherein the coordinates of any point on the spatial envelope are contained in the circumscribed cuboid.
[0029] Specifically, the surface of the spatial envelope is first discretized into a mesh surface composed of triangular mesh units, which can ensure that the three vertices of each discrete triangular mesh unit are coplanar. Vertices and triangular mesh units; the coordinates of the i-th vertex are , In some embodiments, if the surface of the spatial envelope has been discretized into other types of grid units such as quadrilaterals, the conversion can be completed by triangulating the existing grid units.
[0030] Find the maximum and minimum values of the vertex coordinates of all triangular mesh units in the X-axis direction, Y-axis direction, and Z-axis direction, respectively ; and determine the minimum circumscribed cuboid of the spatial envelope according to the maximum and minimum values of the vertex coordinates in the X-axis direction, the Y-axis direction and the Z-axis direction, so that the coordinates of any point on the spatial envelope are contained in the minimum circumscribed cuboid, then the coordinates of any point in the minimum circumscribed cuboid of the spatial envelope ,satisfy: .
[0031] In some embodiments, in order to avoid the situation where the boundary plane of the obtained theoretical minimum circumscribed cuboid and the space envelope is tangent to the surface of the space envelope, the tolerance amount is superimposed on the minimum circumscribed cuboid to obtain the determined circumscribed cuboid, including:
[0032] in, Indicates the tolerance amount, referred to as "small amount"; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the X-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the X-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the X-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the X-axis direction; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the Y-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the Y-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the Y-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the Y-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the Y-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the Y-axis direction; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the Z-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the Z-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the Z-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the Z-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the Z-axis direction.
[0033] The transformation method between the minimum circumscribed cuboid and the determined circumscribed cuboid is as follows: Figure 2 As shown, the tolerance If it is a positive number, it can be the length of a cubic unit. This can avoid the fuzzy state between some rays being tangent to the surface of the spatial envelope and not passing through the spatial envelope in later practical operations, effectively enhancing the robustness of the method.
[0034] S2. Use ray arrays in the X-axis direction, the Y-axis direction and the Z-axis direction to detect the boundary range of the space envelope.
[0035] The circumscribed cuboid is discretized into three directions: X-axis direction, Y-axis direction and Z-axis direction. Specifically, assume that the lengths of the circumscribed cuboids in the above three directions are , and , the number of subdivision units in the three directions is , and , the lengths of each cubic unit in three directions are , and The shortest direction of the three directions of the circumscribed cuboid is used as the basis for segmentation, and each unit after segmentation is as close to a cube as possible, that is, . Each cubic unit is a set of numbers in each direction. express, .
[0036] The set of rays of all cube unit grid lines perpendicular to a coordinate plane is defined as a ray array; specifically, the three coordinate planes of the three-dimensional rectangular coordinate system are the XOY plane, the YOZ plane and the XOZ plane. Figure 3 A schematic diagram of the +Y direction viewing angle of the ray array perpendicular to the XOY plane is shown. It can be understood that the starting point of the ray is not fixed in the XOY plane, but should be determined according to the positional relationship between the three-dimensional rectangular coordinate system and the circumscribed cuboid, for example Figure 3 The ray array shown in Figure 1 shows that the starting point of any ray is located at Plane, of course, can also be located Plane, you can also specify other planes as the starting plane of the ray, as long as the ray is perpendicular to it in the specified direction; at the same time, because it is a ray array formed by the reference cube unit grid line, the number of rays in each ray array is fixed, Figure 3 shown perpendicular to The total number of rays in the plane is Similarly, the total number of rays in the ray array perpendicular to other coordinate planes can be obtained.
[0037] The intersection of each ray in the ray array and all the triangular mesh units is calculated to obtain the intersection coordinates; wherein, each ray in the ray array will pierce the space envelope or not pierce the space envelope, and the ray that pierces the space envelope will form an intersection with the space envelope, and the ray that does not pierce the space envelope will have no intersection. Specifically, the intersection point formed by the ray piercing the space envelope is defined as the intersection point, that is, the number of intersection points on each ray is an even number.
[0038] Find the intersection point of each ray with all triangular mesh units respectively. If the intersection point is inside the current triangular mesh unit (including on the three edges of the triangular mesh unit), store the intersection point coordinates and record them as the mth intersection point of the current ray. If the intersection point is not inside the current triangular mesh unit, abandon the intersection point and continue to judge the next triangular mesh unit; obtain the intersection point coordinate set.
[0039] In one specific embodiment, assuming that the Plane (Plane No. ) a The ray and The coordinates of the intersection points of the triangular mesh units are ,in , , , . Indicates perpendicular to The first plane a The total number of intersection points on the ray.
[0040] Similarly, there are The ray is perpendicular to Plane (Plane No. ),have The line array is perpendicular to Plane (Plane No. ), respectively intersect with all the triangular mesh unit planes on the surface of the spatial envelope. Finally, a series of intersection coordinates are obtained ,in, , , .
[0041] In some embodiments, the area equality method is used to determine whether the intersection point is located inside the current triangular mesh unit. Specifically, it is determined whether the sum of the areas of the three triangles formed by the intersection point and the three sides of the triangular mesh unit is equal to the area of the triangular mesh unit; if they are equal, it is determined that the intersection point is located inside the current triangular mesh unit.
[0042] like Figure 4 and Figure 5 As shown, assuming that the ray a With plane Intersect at point , triangular mesh element Located on the plane If the intersection The sum of the areas of the three triangles formed by the three edges is equal to the triangular mesh unit area , then the intersection point can be determined Located in the triangular mesh unit Internal, that is
[0043] If the intersection Located in the triangular mesh unit Externally, there are:
[0044] in, Represents a triangle area; Represents a triangle area; Represents a triangle area.
[0045] Get the above intersection sequence Then, the intersection coordinates are sorted according to their distances from the starting point of the ray, and after sorting, the intersection coordinates are paired in order to form intersection pairs, and the number of the intersection pairs represents the number of internal intervals of the spatial envelope in the current ray direction.
[0046] Specifically, no matter the spatial envelope is a simply connected domain or a multiply connected domain, no matter the spatial envelope has multiple convex structures, multiple concave structures, or a mixed concave-convex structure, since the surface of the spatial envelope is self-closed, the number of intersections generated by each ray must be an even number, that is, the remainder of 2 is zero. It can also be explained that after a line segment penetrates the spatial envelope, it will immediately pass out of the spatial envelope accordingly, which results in an even number of intersections.
[0047] Since the order of discrete triangular mesh units on the surface of the spatial envelope is random, the order of intersections generated on each line segment is also random, that is, they are not sorted by the distance from the starting point of the line segment. Since the number of intersections is an even number and is actually sorted by the distance from the starting point of the line segment, it is necessary to sort the intersections of each ray currently obtained from small to large. You can choose to sort by bubble sorting, etc. Assuming the first The first plane The first line segment The distance from the starting point of the ray is ,in , , .
[0048] After sorting is completed, the intersection points are paired in order: ,in, The number of intersection pairs It represents the number of internal intervals of the space envelope in the direction of the line segment. Through the above process, the topological structure of the space envelope is identified.
[0049] S3. Search for a triangular mesh unit that intersects with any cubic unit, and then determine a specific cubic unit that intersects with the triangular mesh unit.
[0050] In step S3, it is necessary to find which triangular mesh units each cube unit intersects with, because there are only three positions of all cube units. One is completely outside the spatial envelope and does not intersect with any triangular mesh unit; the second is completely inside the spatial envelope and does not intersect with any triangular mesh unit; the last is that the cube unit intersects with the surface of the spatial envelope, that is, the cube unit intersects with some triangular mesh units.
[0051] In some embodiments, to reduce the amount of calculation, The cube unit is converted into parallel grid planes, along the Y direction parallel grid planes and along the Z direction parallel grid planes, a total of A parallel mesh plane is formed; and then the intersection is calculated with each triangular mesh unit. It can be understood that the parallel mesh plane is composed of the side surfaces of the cube units in the same plane; if the triangular mesh unit penetrates the parallel mesh plane, the triangular mesh unit will definitely intersect with a part of the cube units.
[0052] like Figure 6 As shown, the triangular mesh unit ABC penetrates the parallel mesh plane 1 (k-plane) and intersects it at the line segment PQ. The intersection line PQ falls on the side of some cubic units. To determine whether the triangular mesh unit intersects with the plane, you can draw perpendicular lines between the three vertices and the plane. If the directions of the three perpendicular vectors are not all the same, the triangular mesh unit must intersect with the plane. For intersecting triangular mesh units, you only need to select two pairs of vertices "A and C" and "B and C". The directions of the perpendicular vectors of the two vertices in each pair are opposite. Use straight lines AC and BC to intersect with the parallel mesh plane 1 respectively to obtain the coordinates of the intersection points P and Q.
[0053] The specific cubic unit intersecting with the triangular mesh unit is determined by using the intersection line; wherein, perpendicular lines are drawn from the four vertices of the cubic unit to the intersection line respectively, and if the directions of the four perpendicular vectors are not completely the same, it is determined that the cubic unit intersects with the triangular mesh unit.
[0054] Specifically, Figure 7 is a plan view of parallel grid plane 1, such as Figure 7 As shown, first use point P and point Q to determine the maximum range of all cube units that may intersect with the triangular mesh unit ABC, such as Figure 6 As shown in the largest black box in the figure, there are 9 sides of the cube unit. Then, each cube unit is judged one by one whether it intersects with the line segment PQ.
[0055] The method for determining whether the line segment PQ intersects the side of the cube unit is as follows: Figure 8 As shown in the figure, the four vertices of the cube unit are perpendicular to the line segment PQ. If the directions of the four perpendicular vectors are not exactly the same, the line segment PQ must pass through the cube unit. Figure 8 As shown in , there are only five cubic units intersecting with line segment PQ. Finally, the numbers of the triangular mesh units ABC are stored in these five cubic units.
[0056] In some embodiments, Figure 6 When calculating the intersection of the next parallel mesh plane 2 (k+1 plane) and all triangular mesh units, you only need to add the vertical vector group calculated in the previous step to the interval distance vector between plane k and plane k+1 (direction along the positive direction of the Y axis), which can reduce the amount of calculation. The superposition of the interval vector is equivalent to extending or shortening the vertical vector group in parallel with the end point. Then re-determine whether the three vertical vector directions of each triangular mesh unit are opposite, and you can find out which triangular mesh units the translated mesh plane intersects with.
[0057] After calculating all the three directions After finding the parallel mesh planes, it is necessary to eliminate the duplicate triangular mesh units collected in each cubic unit, because when the triangular mesh unit is narrow and long, it will penetrate the entire cube and intersect with different sides of the same cubic unit and be counted repeatedly.
[0058] S4. According to the detection results of the ray array, the cubic units are divided into first-class cubes and second-class cubes, wherein the first-class cubes include cubic units having intersections with triangular mesh units on their edges, and the second-class cubes include cubic units having no intersections with triangular mesh units on their edges; each first-class cube is discretized twice to form secondary discrete units, and whether the secondary discrete unit is inside the spatial envelope is determined based on the triangular mesh units intersecting with the cubic unit, and the number of secondary discrete units located inside the spatial envelope in the same first-class cube is marked.
[0059] Specifically, according to the ray array detection results, all the cubic units of the circumscribed cuboid can be divided into two categories: the first category is that there are intersections with triangular mesh units on their edges, and the second category is that there are no intersections with triangular mesh units on any of their edges. The first category of cubes must intersect with the surface of the spatial envelope. Assuming that first-kind cubes, The second type of cube is completely inside the space envelope or completely outside the space envelope. Suppose there is A second kind of cube, ,and .
[0060] Each first-class cube is discretized twice, and the discretized cube unit with smaller volume is defined as a secondary discrete unit. Assume that the number of secondary discretizations of the first-class cube in the three directions of X-axis, Y-axis and Z-axis is , and , then the first type of cube is divided into quadratic discrete units; let the lengths of each quadratic discrete unit in the three directions of X-axis, Y-axis and Z-axis be , then the cell center coordinates for:
[0061] Among the indicators It refers to the three-dimensional grid center index of the cube unit where the current secondary discrete unit is located. ;index It refers to the local three-dimensional grid center index of the current secondary discrete unit in the cubic unit. ; , , .
[0062] Determine whether any vertex of the cube unit is inside the spatial envelope; the judgment method includes: the vertex located inside the spatial envelope should be between two corresponding reference points in the three directions of the X-axis direction, the Y-axis direction and the Z-axis direction, respectively, and the two reference points are the two points in the paired intersection pair in step S2.
[0063] Specifically, Fig. 9 and Fig.10 As shown, determine a vertex of a cube unit of the circumscribed cuboid , Whether it is inside the spatial envelope can be determined by whether the vertex is between two intersection points in the three directions of the X-axis, the Y-axis and the Z-axis, and these two intersection points need to be the paired intersection pairs in step S2 and cannot be located between two intersection pairs. Fig. 9 is the Y-axis viewing angle, Fig.10 is the X-axis viewing angle, vertex If the vertex is located between intersection 10 and intersection 11, intersection 20 and intersection 21, and intersection 30 and intersection 31 in the X-axis direction, Y-axis direction, and Z-axis direction, and intersection 10 and intersection 11, intersection 20 and intersection 21, and intersection 30 and intersection 31 are all paired intersections, then the vertex is inside the spatial envelope. Otherwise, the vertex is an external vertex of the spatial envelope.
[0064] In a specific embodiment, the specific operation of the above steps is to determine , and Are the intervals at a certain intersection? If Each can find an intersection point that includes itself, that is:
[0065] in,( , , ) is the position coordinate of the cube unit relative to the circumscribed cuboid, Indicates the first plane perpendicular to the plane numbered 1. The distance between the m1th intersection point of the ray and the spatial envelope and the starting point of the ray, Indicates the first plane perpendicular to the plane numbered 1. The distance between the m1+1th intersection point of the ray and the spatial envelope relative to the starting point of the ray; Indicates the first plane perpendicular to the plane numbered 2. The distance between the m1th intersection point of the ray and the spatial envelope and the starting point of the ray, Indicates the first plane perpendicular to the plane numbered 2. The distance between the m2+1th intersection point of the ray and the spatial envelope relative to the starting point of the ray; Indicates the plane perpendicular to the plane numbered 3. The distance between the m3th intersection point of the ray and the spatial envelope and the starting point of the ray, Indicates the first plane perpendicular to the plane numbered 2. The distance between the m3+1th intersection point of a ray with the spatial envelope and the starting point of the ray. ; ; 。
[0066] Through the above judgment, the vertices of the cube unit can be divided into two parts, that is, one part is located inside the space envelope, and the other part is located outside the space envelope.
[0067] Whether the secondary discrete unit is inside the spatial envelope is determined based on whether the direction of the perpendicular vector from the grid center of the secondary discrete unit cell to the cutting plane is the same as the direction of the perpendicular vector from the vertex inside the spatial envelope to the cutting plane; if they are the same, it means that the secondary discrete unit is inside the spatial envelope and is marked; all secondary discrete units are marked.
[0068] Specifically, the surface of the space envelope has been discretized into triangular mesh units, so each first-class cube can actually be regarded as being cut multiple times by the planes where several triangular mesh units are located.
[0069] Each cut will divide all the secondary discrete units of the current cube unit into two parts, which are distributed on both sides of the cutting plane. Whether the perpendicular vector to the cutting plane is the same as the perpendicular vector from the internal vertex of the spatial envelope to the cutting plane, it is judged whether the secondary discrete unit is inside the spatial envelope; if they are the same, the secondary discrete units on the same side as the internal vertex of the spatial envelope are marked with 1, and the secondary discrete units on the other side are marked with 0. All cutting planes inside the first type of cubic unit are used to mark the secondary discrete units one by one using the above method.
[0070] S5. Solve the volume of the part of the first type of cubic unit located inside the spatial envelope according to the mark value, and superimpose the volume of the second type of cubic unit located inside the spatial envelope to calculate the volume of the spatial envelope.
[0071] Specifically, according to the internal volume of each cubic unit Calculate the total volume of the spatial envelope; The internal volume of the first type of cube is the sum of the volumes of the secondary discrete units marked inside the space envelope; that is:
[0072] Where N represents the number of secondary discrete elements whose discrete element label value is equal to the number of cutting planes; is the volume of a quadratic discrete unit.
[0073] In the second type of cube, all vertices are located inside the space envelope, and its internal volume is the volume of a single cube unit. Assigned to ; If all vertices are outside the space envelope, Assign a value of 0.
[0074] Then the volume of the entire space envelope is for:
[0075] Where b is the number of the cube unit.
[0076] In a specific embodiment of the present invention, in order to have an accurate volume value for comparison, a relatively regular spatial envelope is selected for calculation, such as Fig.11 As shown, a cube with a length, width and height of 1m is placed horizontally. At the same time, the cube is erected vertically along a diagonal line of the cube, such as Fig.12 As shown, in the three-dimensional rectangular coordinate system XYZ, it becomes an irregular spatial envelope with edges and corners. Recalculate its volume value, as shown in Fig.12 The volume values of the two are calculated respectively by the disclosed method, as shown in Table 1.
[0077] In Table 1, numbers 1-3 and 5-7 indicate that only the number of discrete units of the shortest side of the circumscribed cuboid is increased in sequence, which are 21, 31, and 41 respectively. Numbers 3-4 and 7-8 indicate that only the number of secondary discrete units is increased, which are 9261 (21x21x21) and 29791 (31x31x31) respectively. The exact value of the volume of the cube is 1m 3 ,It can be seen from the table that the volume value calculated by this method ,basically reflects the volume value of the cube with high accuracy.
[0078] Table 1 Calculation of cube volume
[0079] In another specific embodiment of the present invention, in order to verify the computing capability of the present disclosure for the volume of multi-connected domains, as shown in FIG. Fig.13 As shown in FIG. 1 , a cube with a length, width and height of 1 m and a three-dimensional sphere with a radius R of 1 m are placed in space to form a multi-connected domain. The volume value of this multi-connected domain is calculated using the method disclosed in the present invention, as shown in Table 2. The exact value of the volume of this multi-connected domain is the volume of the sphere 4πR 3 / 3 m 3 Add the volume of the cube to 1m 3 , about 5.188790m 3 .
[0080] Table 2 Volume calculation of multi-connected domains composed of cubes and spheres
[0081] In another specific embodiment of the present invention, in order to verify the calculation ability of the present disclosure for the volume of the spatially irregular spatial envelope, as shown in FIG. Fig.14 As shown in the figure, a cube with a side length of 0.5m, a cube with a side length of 1m and a hemisphere with a radius of 0.25m are combined together, and the diagonal of the large cube is perpendicular to the horizontal plane, and the entire spatial envelope is erected to form an irregular spatial envelope with edges and corners, concave and convex. The volume value of the spatial envelope is calculated using the method disclosed in the present invention, as shown in Table 3. The exact value of the volume of the spatial envelope is the volume of the two cubes plus the volume of the hemisphere, which is about 1.157725m 3 .
[0082] Table 3 Calculation of volume of irregular spatial envelope
[0083] A second embodiment of the present invention provides a computer device, including a processor and a memory, wherein the memory stores a computer program, and when the computer program is loaded and executed by the processor, the method for calculating the volume of a spatial envelope as described in any of the above embodiments is implemented.
[0084] A third embodiment of the present invention provides a computer-readable storage medium storing a program, which, when loaded by a processor, implements the method for calculating the volume of a spatial envelope as described in any of the above embodiments.
[0085] In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0086] Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for calculating the volume of a spatial envelope, characterized in that: The following steps are involved: S1, discretizing the surface of the spatial envelope into a mesh surface composed of triangular mesh units; establishing a three-dimensional rectangular coordinate system based on the spatial envelope, and determining the circumscribed cuboid of the spatial envelope according to the maximum and minimum values of the vertex coordinates of all triangular mesh units in the X-axis direction, the Y-axis direction and the Z-axis direction, wherein the coordinates of any point on the spatial envelope are contained in the circumscribed cuboid; S2, using the ray array in the X-axis direction, the Y-axis direction and the Z-axis direction to detect the boundary range of the space envelope, wherein the circumscribed cuboid is discretized into three directions in the X-axis direction, the Y-axis direction and the Z-axis direction cubic units, defining the set of rays where all cubic unit grid lines perpendicular to a coordinate plane are located as a ray array; finding intersection points for each ray in the ray array with all triangular grid units respectively, obtaining intersection coordinates, sorting the intersection coordinates according to their distances from the ray starting point, and after sorting, pairing the intersection coordinates in order to form intersection pairs, the number of the intersection pairs representing the number of internal intervals of the spatial envelope in the current ray direction; S3, searching for a triangular mesh unit intersecting with any cubic unit, and then determining a specific cubic unit intersecting with the triangular mesh unit; S4. According to the detection results of the ray array, the cubic units are divided into first-class cubic units and second-class cubic units, wherein the first-class cubic units include cubic units having intersection points with triangular mesh units on their edges, and the second-class cubic units include cubic units having no intersection points with triangular mesh units on their edges; each first-class cubic unit is discretized twice to form a secondary discrete unit, and whether the secondary discrete unit is inside the spatial envelope is determined according to the triangular mesh units intersecting with the cubic unit, and the number of secondary discrete units located inside the spatial envelope in the same first-class cubic unit is marked; S5. Solve the volume of the part of the first type of cubic unit located inside the spatial envelope according to the mark value, and superimpose the volume of the second type of cubic unit located inside the spatial envelope to calculate the volume of the spatial envelope.
2. The method for calculating the volume of a spatial envelope according to claim 1, characterized in that: Step S1 includes: The surface of the space envelope is discretized into a mesh surface composed of triangular mesh units. Vertices and triangular mesh units; the coordinates of the i-th vertex are ; The maximum and minimum values of the vertex coordinates of all triangular mesh units in the X-axis direction, the Y-axis direction and the Z-axis direction are obtained; and the minimum circumscribed cuboid of the spatial envelope is determined according to the maximum and minimum values of the vertex coordinates in the X-axis direction, the Y-axis direction and the Z-axis direction, so that the coordinates of any point on the spatial envelope are contained in the minimum circumscribed cuboid.
3. The method for calculating the volume of a spatial envelope according to claim 2, characterized in that: Step S1 also includes: On the basis of the minimum circumscribed cuboid, the tolerance amount is superimposed to obtain the determined circumscribed cuboid, including: in, Indicates the tolerance amount; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the X-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the X-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the X-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the X-axis direction; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the Y-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the Y-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the Y-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the Y-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the Y-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the Y-axis direction; Indicates the minimum value of the vertex coordinates of all triangular mesh units in the Z-axis direction, that is, the negative boundary value of the minimum circumscribed cuboid in the X-axis direction; Indicates the negative boundary value of the determined circumscribed cuboid in the Z-axis direction; Indicates the maximum value of the vertex coordinates of all triangular mesh units in the Z-axis direction, that is, the positive boundary value of the minimum circumscribed cuboid in the Z-axis direction; Indicates the positive boundary value of the determined circumscribed cuboid in the Z-axis direction.
4. The method for calculating the volume of a spatial envelope according to claim 3, characterized in that: In step S2, the intersection point formed by the ray piercing the space envelope is defined as the intersection point, that is, the number of intersection points on each ray is an even number; the intersection point of each ray in the ray array is obtained with all the triangular mesh units to obtain the intersection coordinates, including: Find the intersection point of each ray with all triangular mesh units. If the intersection point is inside the current triangular mesh unit, store the intersection point coordinates and record them as the mth intersection point of the current ray. If the intersection point is not inside the current triangular mesh unit, continue to determine the next triangular mesh unit; obtain the intersection point coordinate set; The intersection coordinates are sorted according to their distances from the starting point of the ray, and after sorting, the intersection coordinates are paired in order to form intersection pairs. The number of intersection pairs represents the number of internal intervals of the spatial envelope in the current ray direction, thereby identifying the topological structure of the spatial envelope.
5. The method for calculating the volume of a spatial envelope according to claim 4, characterized in that: Methods for determining whether the intersection point is located inside the current triangular mesh unit include: Determine whether the sum of the areas of the three triangles formed by the intersection point and the three sides of the triangular mesh unit is equal to the area of the triangular mesh unit; If they are equal, the intersection is determined to be inside the current triangle mesh unit.
6. The method for calculating the volume of a spatial envelope according to claim 1, characterized in that: Step S3 includes: Will The cube unit is converted into parallel grid planes, along the Y direction parallel grid planes and along the Z direction parallel grid planes; Determine the triangular mesh unit that penetrates any parallel mesh plane as the triangular mesh unit that intersects with the cubic unit; and determine the endpoint coordinates of the intersection line between the triangular mesh unit and the parallel mesh plane; The specific cubic unit intersecting with the triangular mesh unit is determined by using the intersection line; wherein perpendicular lines are drawn from the four vertices of the cubic unit to the intersection line respectively, and if the directions of the four perpendicular vectors are not completely the same, it is determined that the cubic unit intersects with the triangular mesh unit; After completing the judgment of all parallel mesh planes, the duplicate triangular mesh units corresponding to each cubic unit are collected.
7. The method for calculating the volume of a spatial envelope according to claim 1, characterized in that: Step S4 includes: Discretize each first-class cube twice to form a secondary discrete unit; Determine whether any vertex of the cube unit is inside the space envelope; the determination method includes: the vertex located inside the space envelope should be between two corresponding reference points in the three directions of the X-axis direction, the Y-axis direction and the Z-axis direction, respectively, and the two reference points are two points in the matched intersection point pair in step S2; According to whether the direction of the perpendicular vector from the grid center of the secondary discrete unit cell to the cutting plane is the same as the direction of the perpendicular vector from the vertex inside the spatial envelope to the cutting plane, it is judged whether the secondary discrete unit is inside the spatial envelope; if they are the same, it means that the secondary discrete unit is inside the spatial envelope and is marked; all secondary discrete units are marked; The cutting plane includes a plane where any triangular mesh unit at least partially intersects with the cubic unit.
8. The method for calculating the volume of a spatial envelope according to claim 1, characterized in that: The method for calculating the volume of the spatial envelope includes: Calculate the total volume of the spatial envelope based on the internal volume of each cubic unit; The internal volume of the first type of cube is the sum of the volumes of the secondary discrete units whose labels are located inside the space envelope; In the second type of cube, if all the vertices are located inside the spatial envelope, its internal volume is the volume of a single cube unit; if all the vertices are located outside the spatial envelope, its internal volume is 0.
9. A computer device, characterized in that: The method comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is loaded and executed by the processor, the method for calculating the volume of a spatial envelope as claimed in any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium, characterized in that: A program is stored, and when the program is loaded by a processor, the method for calculating the volume of a spatial envelope according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Method for measuring and calculating minimum outer envelope size of object of multi-view image
CN111340873A
Porous medium LBM computational grid generation method
CN112992294A
Optimization method and device for reinforced structure in double-plane envelope, computer equipment and storage medium
CN114595601A
Method and device for setting collision volume of virtual article, equipment and storage medium
CN117180754A
Cited By
Agricultural product grabbing method, device and equipment and storage medium
CN121515171A
