A method, device and computer equipment for cutting real-scene three-dimensional models
By using the closed boundary line cropping method in the three-dimensional model of tilt photogrammetry, the problem that cannot be applied to all intersection situations in the prior art is solved, and fine cropping is achieved under various crop perspectives, which improves the presentation effect and usability of the model.
Patent Information
- Application Number
- CN202111027077.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-02
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2041-09-02
AI Technical Summary
The existing three-dimensional model cropping method of tilt photogrammetry cannot be applied to all intersection situations, resulting in model distortion and data redundancy, affecting the presentation effect and usability of the model.
The closed boundary line cutting method is adopted. By obtaining the closed boundary line that fits the surface of the model, the irregular triangular mesh structure is projected into two-dimensional space, the topological relationship is judged, and the triangle is deleted or divided according to the topological relationship is realized to achieve fine cutting.
Flexible cropping of real scene three-dimensional models from various crop perspectives is suitable for all intersection situations, improving the presentation and usability of the model.
Smart Images

Figure CN113706713B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of real-scene three-dimensional model processing, and in particular relates to a real-scene three-dimensional model clipping method, device and computer equipment. Background Art
[0002] With the continuous advancement of Geographic Information System (GIS) technology, the development and application of 3D data has gradually matured, finding widespread application in fields such as digital cities, digital pipelines, and digital geology. Over the past few decades, numerous researchers have proposed various data structures that improve data access and storage efficiency while providing a more realistic representation of terrain features. Without distinguishing between true 3D and quasi-3D, models can be uniformly categorized based on geometric relationships into surface-based, volume-based, and hybrid models.
[0003] UAV oblique photogrammetry, which has gradually matured in the past decade, has been widely used in the fields of three-dimensional digital cities, quantitative analysis of landslides, glacier surveys, and reconstruction of outcrops. The model generated by oblique photogrammetry data is a surface-based model with a basic structure of triangulated irregular networks (TIN). The target area of oblique photogrammetry is generally a large-scale feature, and the number of images taken is often large. The number of point clouds generated by the images is huge. If the traditional model format is used to store a TIN model composed of a large number of points at the same resolution at one time, the rendering effect of the model will be significantly reduced. To solve this problem, a level of detail model is usually used so that the smaller the model boundary is, the higher the model point density is, and the clearer the model is. However, the model built by oblique photogrammetry has the following problems: (1) Due to factors such as sensor error or model reconstruction error, the model is distorted and the local display effect is poor, thereby affecting the overall quality of the model; (2) There are irrelevant features in the model, which leads to data redundancy and even affects the research on the target feature. Therefore, there is an urgent need for a method to crop irrelevant parts of the oblique photogrammetry three-dimensional model to improve the rendering effect and usability of the model.
[0004] The difficulty of cutting a 3D model depends on the geometric structure of the model. The more complex the structure, the more cutting work is required. Volume-based models are often used in fields such as 3D printing. The cutting process of this type of model is more complicated. Usually, a plane is used to cut the surface of the model while cutting the internal model at the same time. After both are cut, a good connection between the internal and external structures must be ensured. Hybrid-based models are usually geometric forms such as prisms. They are often used in 3D geological models that contain internal information. When cutting a hybrid model, it is necessary to cut the intersecting faces of the prism. Face-based models are often used for data that does not have internal information. Cutting a surface model only requires cutting the model surface. Taking a triangulated surface model as an example, a plane is usually used to cut the model. The intersection between the plane and the model is calculated and constructed into a cutting boundary. The triangulated network that intersects the boundary is subdivided, and based on the relative relationship with the plane, it is determined whether the newly generated triangles should be retained to complete the cutting of the model.
[0005] Plane clipping is relatively simple, typically only intersecting at two sides of a triangle or at a vertex. This makes clipping relatively easy to implement. However, using a plane to clip complex surface models often requires multiple clipping cycles to achieve the desired clipping effect. Furthermore, the model's boundaries become straight and smooth after clipping. Using curves to determine the clipping region allows for flexible selection and ensures that the clipping boundary retains the desired undulations of the model object. However, using curves as clipping conditions complicates the intersection of curves and triangles, with multiple possible outcomes. This inevitably leads to missed intersections in algorithm design. Therefore, it is necessary to find a triangulated mesh clipping method that is applicable to all intersection situations.
[0006] Furthermore, although oblique photogrammetric 3D models have been widely used, it is currently difficult to find effective algorithms in the literature for cropping oblique photogrammetric 3D models with a detailed hierarchy. SuperMap software can use a plane to crop oblique photogrammetric 3D models. Its cropping angle is fixed and can only crop the model in a direction perpendicular to the ground surface. This method is good for vertically vertical objects such as buildings and can be used for the individualization of urban buildings. However, it is not suitable for cropping objects with oblique angles or models with vertical overlap, such as rock layers. Plane cropping also has the disadvantage of not being able to select the cropping area well. Summary of the Invention
[0007] In order to solve the problem that the existing oblique photogrammetry 3D model clipping method is not applicable to all intersection situations, the purpose of the present invention is to provide a new real-scene 3D model clipping method, device, computer equipment and computer-readable storage medium, which can flexibly clip the real-scene 3D model under various clipping perspectives, and by using closed boundary lines drawn to fit the model surface, the real-scene 3D model can be clipped more finely, and thus can be applicable to all intersection situations, and can also clip each level model of a multi-layer real-scene 3D model with a detailed hierarchy, which is convenient for practical application and promotion.
[0008] In a first aspect, the present invention provides a method for cutting a real-scene three-dimensional model, comprising:
[0009] For a real-life 3D model with an irregular triangulated network structure, obtaining a corresponding closed boundary line drawn to fit the surface of the model;
[0010] Projecting the irregular triangulated network structure into a two-dimensional space according to a drawing perspective of the closed boundary line to obtain a plurality of two-dimensional triangles;
[0011] For each of the plurality of two-dimensional triangles, determining a corresponding topological relationship type with the closed boundary line in the two-dimensional space;
[0012] For each two-dimensional triangle whose topological relationship type represents a triangle within a closed boundary, deleting the corresponding triangle in the irregular triangulated network structure;
[0013] For each two-dimensional triangle whose topological relationship type represents the intersection of a triangle and a closed boundary, if the number of corresponding intersection points is less than two, then when the centroid of the corresponding triangle is located inside the closed boundary line in the two-dimensional space, the corresponding triangle is deleted from the irregular triangulated network structure; otherwise, the corresponding triangle in the irregular triangulated network structure is triangulated into multiple new triangles using the Delaunay triangulation algorithm;
[0014] For each of the multiple new triangles, if it is determined that the corresponding topological relationship with the closed boundary line is that the triangle is within the closed boundary, deleting the new triangle in the irregular triangulated network structure;
[0015] According to the new irregular triangulated network structure obtained after the deletion process, a new real-scene three-dimensional model with the cropping completed is obtained.
[0016] Based on the above invention content, a new solution for cropping a face-based real-life three-dimensional model using a curve that fits the model surface is provided. That is, after obtaining a closed boundary line drawn to fit the model surface, the irregular triangulated network structure of the real-life three-dimensional model is projected into a two-dimensional space according to the drawing perspective of the closed boundary line. Then, the topological relationship between each triangle and the closed boundary line is judged in the two-dimensional space, and the triangles within the boundary are deleted based on the judgment result, and the new triangles within the boundary that are obtained by decomposing the triangles that intersect with the boundary are deleted. Finally, a new real-life three-dimensional model with the cropping is obtained based on the new irregular triangulated network structure obtained after the deletion process. Therefore, not only can the real-life three-dimensional model be flexibly cropped under various cropping perspectives, but the real-life three-dimensional model can also be cropped more finely by using the closed boundary line drawn to fit the model surface. Therefore, it can be applied to all intersection situations, which is convenient for practical application and promotion.
[0017] In a second aspect, the present invention provides a real-scene three-dimensional model clipping device, comprising a boundary line acquisition module, a triangle projection module, a topological relationship determination module, a first deletion module, a triangulation module, a second deletion module, and a clipping completion module;
[0018] The boundary line acquisition module is used to obtain a corresponding closed boundary line drawn in accordance with the surface of the real-scene three-dimensional model having an irregular triangulated network structure;
[0019] The triangle projection module is communicatively connected to the boundary line acquisition module and is used to project the irregular triangulated network structure into a two-dimensional space according to the drawing perspective of the closed boundary line to obtain a plurality of two-dimensional triangles;
[0020] The topological relationship determination module is communicatively connected to the triangle projection module and is configured to determine, for each of the plurality of two-dimensional triangles, a corresponding topological relationship type with the closed boundary line in the two-dimensional space;
[0021] The first deletion module is communicatively connected to the topological relationship determination module and is configured to delete, for each two-dimensional triangle whose topological relationship type represents a triangle within a closed boundary, the corresponding triangle from the irregular triangulated network structure, and, for each two-dimensional triangle whose topological relationship type represents a triangle intersecting the closed boundary, delete the corresponding triangle from the irregular triangulated network structure if the number of corresponding intersection points is less than two and the centroid of the corresponding triangle is located inside the closed boundary line in the two-dimensional space;
[0022] The triangulation module is communicatively connected to the topological relationship determination module and is configured to, for each two-dimensional triangle where the topological relationship type represents the intersection of the triangle and the closed boundary, use a Delaunay triangulation algorithm to triangulate the corresponding triangle in the irregular triangulated network structure into a plurality of new triangles if the number of corresponding intersection points is not less than two.
[0023] The second deletion module is communicatively connected to the triangulation module and is configured to delete, for each of the multiple new triangles, the new triangle from the new irregular triangulated network structure if it is determined that the corresponding new triangle has a topological relationship with the closed boundary line that the triangle is within the closed boundary;
[0024] The clipping completion module is communicatively connected to the first deletion module and the second deletion module, and is used to obtain a new real-scene three-dimensional model that has completed clipping based on a new irregular triangulated network structure obtained through the deletion process.
[0025] In a third aspect, the present invention provides a computer device comprising a memory, a processor and a transceiver which are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive information, and the processor is used to read the computer program and execute the real-scene three-dimensional model clipping method as described in the first aspect or any possible design of the first aspect.
[0026] In a fourth aspect, the present invention provides a computer-readable storage medium having instructions stored thereon. When the instructions are run on a computer, the real-scene three-dimensional model clipping method as described in the first aspect or any possible design of the first aspect is executed.
[0027] In a fifth aspect, the present invention provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to execute the real-scene three-dimensional model clipping method as described in the first aspect or any possible design of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0029] Figure 1 It is a flow chart of the method for cutting a real-scene 3D model provided by the present invention.
[0030] Figure 2This is a principle example diagram of the present invention for determining the topological relationship between a point and a closed boundary line using the ray method.
[0031] Figure 3 This is a principle example diagram of the present invention for determining the topological relationship between a point and a closed boundary line using the improved ray method.
[0032] Figure 4 This is an example diagram of the triangle topological relationship provided by the present invention.
[0033] Figure 5 This is an example diagram of the topological relationship between multiple two-dimensional triangles and closed boundary lines provided by the present invention.
[0034] Figure 6 is an example diagram of the intersection relationship between the boundary triangle and the closed boundary line provided by the present invention, wherein: Figure 6 (a) shows that the boundary triangle is inside the closed boundary line and has an intersection point with the closed boundary line. Figure 6 (b) in the figure shows the intersection relationship where the boundary triangle is outside the closed boundary line and has an intersection point with the closed boundary line. Figure 6 (c) in the figure shows the intersection relationship between different sides of the boundary triangle and the closed boundary line at two intersection points. Figure 6 (d) in the figure shows the intersection relationship between the same side of the boundary triangle and the closed boundary line at two intersection points. Figure 6 (e) in the figure shows the intersection relationship between different sides of the boundary triangle and the closed boundary line with more than two intersection points. Figure 6 (f) in the figure shows the intersection relationship where the same side of the boundary triangle has more than two intersection points with the closed boundary line.
[0035] Figure 7 is an example diagram of the intersection relationship under different coordinate systems provided by the present invention, wherein: Figure 7 (a) shows the intersection relationship in the two-dimensional space coordinate system. Figure 7 (b) in FIG. 1 shows the intersection relationship in a three-dimensional space coordinate system.
[0036] Figure 8 This is an example diagram of the two-dimensional intersection relationship between a triangle and a closed boundary line provided by the present invention.
[0037] Figure 9 This is an example diagram of the camera line-of-sight projection relationship from the boundary segment endpoints to the spatial triangle provided by the present invention.
[0038] Figure 10 This is an example diagram of boundary lines of constraint conditions within a spatial triangle provided by the present invention.
[0039] Figure 11is an example diagram of the triangulation results of different Delaunay triangulation algorithms provided by the present invention, wherein: Figure 11 (a) shows the triangulation result without constraints. Figure 11 (b) in the figure shows the constrained triangulation result.
[0040] Figure 12 This is an example diagram of the rapid screening of new triangles provided by the present invention.
[0041] Figure 13 This is an example diagram of texture coordinate calculation provided by the present invention.
[0042] Figure 14 It is a schematic diagram of the structure of the detail level model provided by the present invention divided according to the quadtree.
[0043] Figure 15 This is an example diagram of the cropping result of the real-scene 3D model provided by the present invention, wherein: Figure 15 (a1) in FIG. 3 shows the front view surface of the model with texture pixels after drawing the closed boundary line. Figure 15 (a2) in the figure shows the model front view surface with triangulated mesh after drawing the closed boundary line. Figure 15 (b1) in FIG. 4 shows the side view surface of the model with texture pixels after drawing the closed boundary line. Figure 15 (b2) in FIG. 1 shows the side view surface of the model with a triangulated network after drawing the closed boundary line. Figure 15 (c1) in the figure shows the model front view surface after cropping and with texture pixels. Figure 15 (c2) in the figure shows the model front view surface with triangulated mesh after trimming. Figure 15 (d1) in the figure shows the side view surface of the model after cropping and with texture pixels. Figure 15 (d2) in the figure shows the side view surface of the model with triangulated mesh after trimming. Figure 15 (e1) in the figure shows the higher level model front view surface after cropping and with texture pixels, Figure 15 (e2) in the figure shows the front view surface of the higher level model with triangulated mesh after trimming. Figure 15 (f1) in the figure shows the top-level model front view surface after cropping and with texture pixels. Figure 15 (f2) in FIG. 5 shows the top-level model front view surface after cropping and with a triangulated mesh.
[0044] Figure 16 This is an example diagram of the cropping results of the real-scene 3D model provided by the present invention at different cropping perspectives, wherein: Figure 16 (a1) in the figure shows the model cropping result with texture pixels when viewed from the perspective of the model below the cropping. Figure 16(a2) in the figure shows the model clipping result with triangulated mesh when viewed from the perspective of the model below the clipping. Figure 16 (b1) in FIG shows the model cropping result with texture pixels when viewed from the model perspective above the cropping. Figure 16 (b2) in the figure shows the model clipping result with triangulated mesh when viewed from the clipping upper model perspective.
[0045] Figure 17 This is an example diagram of the result of cropping a real-scene 3D model using the SuperMap iDesktop 10i software provided by the present invention, wherein: Figure 17 (a) shows the cropping result at the normal viewing angle. Figure 17 (b) in FIG. 5 shows the cropping result at a vertical viewing angle.
[0046] Figure 18 It is a structural schematic diagram of the real scene three-dimensional model cutting device provided by the present invention.
[0047] Figure 19 It is a structural schematic diagram of the computer device provided by the present invention.
[0048] In the above drawings: 100 - closed boundary line; 200 - camera. DETAILED DESCRIPTION
[0049] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments. It should be noted that although the description of these embodiments is intended to help understand the present invention, it does not constitute a limitation of the present invention. The specific structural and functional details disclosed herein are merely intended to describe exemplary embodiments of the present invention. However, the present invention can be embodied in many alternative forms, and it should not be understood that the present invention is limited to the embodiments set forth herein.
[0050] It should be understood that although the terms first, second, etc. may be used herein to describe various objects, these objects should not be limited by these terms. These terms are merely used to distinguish one object from another. For example, a first object can be referred to as a second object, and similarly, a second object can be referred to as a first object without departing from the scope of the exemplary embodiments of the present invention.
[0051] It should be understood that the term "and / or" that may appear in this document is merely a description of the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may indicate three situations: A exists alone, B exists alone, or A and B exist at the same time. The term " / and" that may appear in this document describes another type of association object relationship, indicating that two relationships may exist. For example, A / and B may indicate two situations: A exists alone, or A and B exist at the same time. In addition, the character " / " that may appear in this document generally indicates that the previous and subsequent associated objects are in an "or" relationship.
[0052] like Figure 1 As shown, the real-scene three-dimensional model clipping method provided in the first aspect of this embodiment can be executed by, but is not limited to, a computer device with certain computing resources, such as a personal computer (PC, which refers to a multi-purpose computer with a size, price and performance suitable for personal use; desktops, laptops, small laptops, tablets and ultrabooks are all personal computers), smart phones, personal digital assistants (PADs) or wearable devices, so that for a real-scene three-dimensional model with an irregular triangulated network structure, the real-scene three-dimensional model can be flexibly clipped at various clipping perspectives, and by using closed boundary lines drawn to fit the model surface, the real-scene three-dimensional model can be clipped more finely, and then it can be applied to all intersection situations, which is convenient for practical application and promotion. Figure 1 As shown, the real-scene 3D model clipping method may include, but is not limited to, the following steps S1 to S7.
[0053] S1. For a real-life three-dimensional model having an irregular triangulated network structure, obtain a corresponding closed boundary line drawn to fit the surface of the model.
[0054] In step S1, the real-life 3D model may be, but is not limited to, a surface-based model such as an oblique photogrammetry 3D model. The closed boundary line is a cropping boundary line, which can be obtained by responding to a user's human-computer interaction operation on a mouse. That is, for a real-life 3D model having an irregular triangulated network structure, a corresponding closed boundary line drawn to fit the model surface is obtained, including but not limited to the following steps S11 to S14: S11. Converting the screen coordinates of a mouse moved on a display screen displaying the real-life 3D model into mouse spatial coordinates in the 3D space of the real-life 3D model; S12. Constructing a first ray based on the mouse spatial coordinates and the spatial position of a camera, wherein the starting point of the first ray is the spatial position of the camera and passes through the mouse spatial coordinates, and the camera spatial position refers to the spatial coordinates of the camera used to image the real-life 3D model in the 3D space; S13. Determining the intersection point of the first ray with the model surface of the real-life 3D model using a collision detection method; S14. Sequentially obtaining multiple model surface intersection points by moving the mouse to form a closed boundary line along any direction. The mouse spatial coordinates and the spatial position of the camera are respectively coordinates in the world coordinate system, wherein the specific conversion process of the mouse spatial coordinates can be derived based on a conventional coordinate system transformation method. The collision detection method is a conventional method for determining whether line segments intersect, such as using a 2D vector cross product method. Therefore, the coordinates of the intersection of the model surface in the world coordinate system can be determined based on the conventional collision detection method, and by sequentially connecting the discrete plurality of model surface intersections in a circumferential direction (i.e., clockwise or counterclockwise from the camera perspective), a closed boundary line composed of a plurality of boundary line segments in a circumferential direction can be formed in series.
[0055] S2. Projecting the irregular triangulated network structure into a two-dimensional space according to a drawing perspective of the closed boundary line to obtain a plurality of two-dimensional triangles.
[0056] In step S2, the drawing perspective is the perspective of the camera that images the real-scene three-dimensional model. In addition, the three-dimensional space coordinates can be converted into two-dimensional space coordinates through conventional projection methods.
[0057] S3. For each of the plurality of two-dimensional triangles, determine a corresponding topological relationship type with the closed boundary line in the two-dimensional space.
[0058] In the step S3, the topological relationship type between the two-dimensional triangle and the closed boundary line can be divided into three types: the triangle is inside the closed boundary, the triangle is outside the closed boundary, and the triangle intersects the closed boundary. Since the topological relationship between the triangle and the clipping boundary line cannot be accurately expressed in three-dimensional space, it is necessary to project the three-dimensional space coordinates of the irregular triangulated network structure into the two-dimensional space according to the perspective when drawing the boundary line (i.e., the drawing perspective of the closed boundary line) so as to judge the topological relationship in the two-dimensional space. Specifically, for each of the multiple two-dimensional triangles, the corresponding topological relationship type with the closed boundary line in the two-dimensional space is determined respectively, including but not limited to the following steps S31 to S34.
[0059] S31. For each of the multiple two-dimensional triangles, if it is determined that the corresponding three vertices are not all located inside or outside the closed boundary line in the two-dimensional space, then the corresponding topological relationship type with the closed boundary line in the two-dimensional space is determined to be the intersection of the triangle and the closed boundary.
[0060] In step S31, the two-dimensional triangle is regarded as an independent entity, and its three vertices are judged whether they are located inside or outside the closed boundary line in the two-dimensional space. Therefore, the ray method can be used to judge the topological relationship between each vertex and the closed boundary line in the two-dimensional space: whether the vertex is inside the closed boundary or the vertex is outside the closed boundary. The principle of the ray method can be as follows: Figure 2 As shown, assuming that the circumferential drawing direction of the closed boundary line is counterclockwise and is composed of multiple small boundary line segments, a second ray can be drawn horizontally for point P0. Each time this second ray crosses the closed boundary line, a record is made. If the number of final records is an odd number, point P0 is determined to be inside the closed boundary line, and if the number of final records is an even number, point P0 is determined to be outside the closed boundary line. Considering that the intersection of the third ray drawn for point P1 is relatively special, that is, there is a case where the boundary line segment connecting intersection point 6 and intersection point 7 coincides with the third ray, and there is a case where intersection point 8 is the intersection point of two adjacent boundary line segments. For these two cases, it can be stipulated that when judging the intersection, if the boundary line segment coincides with the ray, it is not considered an intersection; and when the endpoint of the boundary line segment intersects with the ray, only the intersection at the starting endpoint of the boundary line segment is determined to be an intersection point. The set of points where the third ray intersects the closed boundary line includes points 6, 8, and 9, satisfying the fact that point P1 is inside the closed boundary line. Furthermore, the time complexity of determining the topological relationship between all vertices and the closed boundary line using the ray method is O(i), where i represents the total number of boundary segments of the closed boundary line.
[0061] In step S31, Figure 2 As shown, it is also considered that there are few boundary segments that actually intersect with the ray, and they are all in the same horizontal area. Therefore, in order to reduce unnecessary intersection judgments, the ray judgment method can be improved, that is, Figure 3 , for the boundary line segment of the closed boundary line, in the vertical direction, the dividing lines S0, S1, S2, S3, .... and S N Divided into N areas, where N represents a natural number not less than 2 and its value is generally determined by the total number of boundary segments. In order to ensure that all boundary segments can be correctly divided, the vertical coordinate value of the dividing line S0 is set to be slightly larger than the maximum vertical coordinate value of the closed boundary line. N The vertical coordinate value is slightly smaller than the minimum vertical coordinate value of the closed boundary line, and the vertical step length of the division is the dividing line S0 and the dividing line S N The difference in the vertical coordinates is then divided by N. In addition, it should be noted that the boundary line segments intersecting with the dividing line should be stored separately by the upper and lower areas of the dividing line, otherwise the boundary line segments to be divided need to be divided into two line segments belonging to the upper and lower areas respectively. After completing the area division, for the points whose topological relationships are to be determined, the ray method is used to record the number of times the corresponding horizontal rays intersect with the boundary line segments in the corresponding segmented areas; for example, since the vertical coordinate value of point P0 is greater than the vertical coordinate value of the dividing line S2 and less than the vertical coordinate value of the dividing line S1, point P0 only needs to record the number of intersections in the segmented area (S2, S1), which greatly reduces the number of boundary line segments that need to be judged whether they intersect with the first ray, and can further reduce the required time complexity.
[0062] After using the above-mentioned ray method to determine the topological relationship between the three vertices of the two-dimensional triangle and the closed boundary line in the two-dimensional space, if the three vertices are not all located inside or outside the closed boundary line in the two-dimensional space, that is, the three vertices have different topological relationships, then it can be directly determined that the topological relationship type of the two-dimensional triangle and the closed boundary line in the two-dimensional space is that the triangle intersects the closed boundary; if the three vertices in the two-dimensional space are all located inside the closed boundary line, then it can be temporarily determined that the topological relationship type of the two-dimensional triangle and the closed boundary line in the two-dimensional space is that the triangle is inside the closed boundary (because it has the possibility of becoming a triangle intersecting the closed boundary); and if the three vertices in the two-dimensional space are all located outside the closed boundary line, then it can be temporarily determined that the topological relationship type of the two-dimensional triangle and the closed boundary line in the two-dimensional space is that the triangle is outside the closed boundary (because it also has the possibility of becoming a triangle intersecting the closed boundary).
[0063] S32. Include all two-dimensional triangles whose topological relationship type is represented as the intersection of a triangle and a closed boundary into a boundary triangulation set.
[0064] S33. For each two-dimensional triangle in the boundary triangulation set, determine whether the corresponding adjacent two-dimensional triangle whose adjacent edges intersect with the closed boundary line in the two-dimensional space is already in the boundary triangulation set; if not, determine that the topological relationship type of the adjacent two-dimensional triangle and the closed boundary line in the two-dimensional space is the intersection of a triangle and a closed boundary, and include the adjacent two-dimensional triangle in the boundary triangulation set, wherein the adjacent edges refer to the common edges of the two adjacent two-dimensional triangles.
[0065] In step S33, since the corresponding adjacent two-dimensional triangles are searched based on the two-dimensional triangles in the boundary triangulation set, it is necessary to construct the adjacent relationship between any two two-dimensional triangles in the multiple two-dimensional triangles in advance, that is, before step S33, based on the necessary and sufficient condition that two triangles are adjacent, there are two identical vertices, the method also includes but is not limited to the following triangle adjacent topological relationship construction step: traverse each of the multiple two-dimensional triangles, and store the corresponding triangle index in the adjacent triangle array of each corresponding vertex, so as to form a topological relationship between the vertex and the triangle (that is, each vertex stores all triangle indices containing the vertex). In this way, for each two-dimensional triangle in the boundary triangulation set, the corresponding adjacent two-dimensional triangle can be found in the adjacent triangle array of each corresponding vertex, and then it is determined whether the corresponding adjacent edge intersects with the closed boundary line in the two-dimensional space. The central idea of the aforementioned triangle adjacent topological relationship construction step is: if triangles T1 and T2 are adjacent, there must be two identical vertices, so triangle T2 must be one of all triangles containing the vertex of triangle T1. As Figure 4 As shown, the three triangles adjacent to triangle A are triangle B, triangle F, and triangle I. The triangles that contain the vertices of triangle A are only triangle B, triangle C, triangle D, triangle E, triangle F, triangle G, triangle H, triangle I, triangle J, and triangle K. Since obtaining the containment relationship between vertices and triangles only requires looping through the triangle array (i.e., the multiple two-dimensional triangles) once, compared with the conventional triangle adjacency relationship construction algorithm that requires nested traversal of the triangle array, the time complexity can be reduced from O(j 2 ) is reduced to O(j), where j represents the total number of two-dimensional triangles in the plurality of two-dimensional triangles.
[0066] S34. If the boundary triangulation set has newly added adjacent two-dimensional triangles by executing step S33, then return to execute steps S33 to S34, otherwise determine that the topological relationship type of the first non-boundary triangle and the closed boundary line in the two-dimensional space is a triangle within a closed boundary, wherein the first non-boundary triangle refers to a two-dimensional triangle among the multiple two-dimensional triangles, whose three vertices are all located inside the closed boundary line in the two-dimensional space and are not in the current boundary triangulation set.
[0067] In step S34, when all three vertices are located inside or outside the closed boundary line in the two-dimensional space, the topological relationship type of the corresponding two-dimensional triangle and the closed boundary line in the two-dimensional space may also be that the triangle intersects the closed boundary line; Figure 5 As shown, the three vertices of the two dark gray triangles on the left are all located inside the closed boundary line in the two-dimensional space, and the three vertices of the single dark gray triangle on the right are all located outside the closed boundary line in the two-dimensional space (in Figure 5 In the figure, all white triangles are two-dimensional triangles determined by executing the aforementioned step S31 and whose topological relationship type is a triangle intersecting a closed boundary), but they do intersect with the closed boundary line. Therefore, by looping through the aforementioned steps S33 to S34, it is possible to avoid missing any two-dimensional triangles that intersect with the closed boundary line, and to avoid misjudging the topological relationship type of two-dimensional triangles whose real topological relationship type is a triangle within a closed boundary, thereby ensuring the correctness of subsequent clipping. In addition, if the boundary triangulation set does not have newly added adjacent two-dimensional triangles by executing step S33, it is also possible to determine a second non-boundary triangle and whose topological relationship type with the closed boundary line in the two-dimensional space is a triangle outside the closed boundary, wherein the second non-boundary triangle refers to one of the multiple two-dimensional triangles whose three vertices are all outside the closed boundary line in the two-dimensional space and are not in the current boundary triangulation set (which at this time contains Figure 5 All white triangles in and all dark grey triangles in ).
[0068] S4. For each two-dimensional triangle whose topological relationship type represents a triangle within a closed boundary, delete the corresponding triangle in the irregular triangulated network structure.
[0069] In step S4, since the triangle corresponding to the two-dimensional triangle with the topological relationship type of a triangle within a closed boundary is the circled model surface clipping target, the purpose of clipping the surface clipping center area of the real-life three-dimensional model can be achieved by deleting the triangle in the irregular triangulated network structure.
[0070] S5. For each two-dimensional triangle whose topological relationship type represents the intersection of a triangle and a closed boundary, if the number of corresponding intersection points is less than two, then when the centroid of the corresponding triangle is located inside the closed boundary line in the two-dimensional space, the corresponding triangle is deleted in the irregular triangulated network structure, otherwise the Delaunay triangulation algorithm is used to triangulate the corresponding triangle in the irregular triangulated network structure into multiple new triangles.
[0071] In step S5, according to the different numbers of intersection points of the two-dimensional triangles with the closed boundary line in the two-dimensional space, the two-dimensional triangles with a topological relationship type of triangle intersecting with the closed boundary can be divided into two categories: the number of intersection points is less than two (i.e., there is only one intersection point) and the number of intersection points is not less than two (i.e., there are two or more intersection points), such as Figure 6 For a two-dimensional triangle in the two-dimensional space that has only one intersection with the closed boundary line, it means that one vertex of the two-dimensional triangle is on the closed boundary line, as shown in FIG. Figure 6 (a) and Figure 6 As shown in (b), it is necessary to determine whether the centroid of the two-dimensional triangle is within the closed boundary line in the two-dimensional space. If so, it means that the triangle corresponding to the two-dimensional triangle is also the circled model surface clipping target and needs to be deleted in the irregular triangulated network structure, otherwise it needs to be retained. For the two-dimensional triangle that has at least two intersections with the closed boundary line in the two-dimensional space, the model surface of the intersecting part (that is, the part within the closed boundary line in the corresponding triangle) needs to be deleted. This requires reconstructing the corresponding triangle and cutting it into smaller new triangles. If the subdivided and smaller new triangle is located inside the closed boundary line, the corresponding model surface needs to be deleted (that is, the new triangle needs to be deleted). Otherwise, the corresponding model surface needs to be retained in order to achieve the purpose of accurately clipping the surface clipping boundary area of the real-life three-dimensional model.
[0072] In step S5, for a two-dimensional triangle whose topological relationship type represents the intersection of a triangle and a closed boundary, if the number of corresponding intersection points is not less than two, the three vertices of the triangle, the camera line of sight intersection point of the triangle and the closed boundary line, and the camera line of sight projection point of the starting end point of the boundary segment of the closed boundary line within the triangle can be taken as a given discrete data point, and then the Delaunay triangulation algorithm (which is the most commonly used existing triangulation algorithm in practice) is used to generate a series of triangular meshes, thereby obtaining the multiple new triangles. In order to cope with various intersection situations, this embodiment also provides a new triangle reconstruction method, that is, for each two-dimensional triangle whose topological relationship type represents the intersection of a triangle and a closed boundary, if the number of corresponding intersection points is not less than two, the Delaunay triangulation algorithm is used to decompose the corresponding triangle in the irregular triangulated network structure into multiple new triangles, including but not limited to the following steps S51 to S53.
[0073] S51. Include the three vertices of the triangle, the camera line of sight intersection point between the triangle and the closed boundary line, and the camera line of sight projection point of the starting end point of the boundary line segment of the closed boundary line within the triangle into a vertex set, wherein the camera line of sight intersection point is the intersection point of the first camera line of sight intersecting with the closed boundary line and the edge of the triangle, the camera line of sight projection point is the intersection point of the second camera line of sight passing through the starting end point of the boundary line segment and the face enclosed by the triangle, the first camera line of sight and the second camera line of sight are respectively rays with the camera viewpoint spatial position as the starting point, and the camera viewpoint spatial position refers to the viewpoint spatial coordinates of the camera used to image the real-scene three-dimensional model in three-dimensional space.
[0074] In step S51, the spatial position of the camera viewpoint may be equivalent to the spatial position of the camera. For a two-dimensional triangle whose topological relationship type represents the intersection of a triangle and a closed boundary, the coordinates of the camera viewpoint intersection point of the corresponding triangle and the closed boundary line in three-dimensional space need to be calculated first.
[0075] Assume that there are two straight lines (P0 represents the starting coordinate of the corresponding straight line, s represents the extension coefficient variable of the corresponding straight line, represents the extension vector of the corresponding straight line) and (P1 represents the starting coordinate of the corresponding straight line, t represents the extension coefficient variable of the corresponding straight line, Represents the extension vector of the corresponding straight line), the topological relationship between these two straight lines can only be intersection, parallel or coincidence. In order to facilitate the operation, define an operation of two vectors in two-dimensional space This operation is similar to the cross product in three dimensions. From the definition, we know that Assuming that the two straight lines have an intersection, we can get formula (1):
[0076]
[0077] By shifting the terms in formula (1), we can get formula (2):
[0078]
[0079] set up And on both sides of formula (2) and use Calculation, we can get formula (3):
[0080]
[0081] From this we can get the values of s and t:
[0082]
[0083] According to the above formula (4), if Then s and t can be solved, and the straight lines intersect at one point; if The two straight lines are coincident or parallel. Since the subdivision of coincidence or parallelism has no effect on the algorithm results, we will not delve into it. Therefore, the necessary and sufficient condition for the intersection of two line segments is to meet Under the premise that 0≤s≤1 and 0≤t≤1.
[0084] like Figure 7 As shown in (a), the side of a two-dimensional triangle in two-dimensional space (T a-1 ,T a-2 ) and the projection of the boundary segment (P a-1 ,P a-2 ) intersects at point I a ; and as Figure 7 (b) shows the corresponding topological relationship between triangles and closed boundary lines under different clipping perspectives (i.e., the drawing perspectives) in three-dimensional space, I b is the side of the triangle (T b-1 ,T b-2 ) and the boundary segment (P b-1 ,P b-2 ) should be the camera line of sight intersection. If the projection intersection I is directly transformed by matrix a The two-dimensional space coordinates are converted to three-dimensional space coordinates (i.e., space coordinates in the world coordinate system). The error in the conversion will cause the intersection point after the transformation to not be on the edge of the space triangle (i.e., the triangle corresponding to the two-dimensional triangle), resulting in the final clipping result changing the direction of the triangle. Therefore, when obtaining s aUnder the premise of , the camera sight intersection point I can be directly calculated according to the following formula b Coordinates:
[0085] I b =T b-1 +s a (T b-2 -T b-1 ) (5)
[0086] Where, T b-1 and T b-2 Represent the known three-dimensional space coordinates of the triangle sides at the two end points, s a Indicates that in the two-dimensional space, from the endpoint T b-1 The projection point (i.e. Figure 7 Point T in a-1 ) to the camera sight intersection I b The projection point (i.e. Figure 7 Point I a ) and the distance from the endpoint T b-1 The projection point to the endpoint T b-2 The projection point (i.e. Figure 7 Point T in a-2 ) ratio of the distance.
[0087] S52. Sort all camera sight intersection points and all camera sight projection points in the vertex set in the circumferential direction of the closed boundary line to obtain constraint conditions.
[0088] In step S52, Figure 8 A special two-dimensional intersection situation is shown, P1, P2, P3, P4, P x-1 and P x Respectively represent the intersection points of the second camera sight line passing through the endpoints of the boundary line segment of the closed boundary line and the plane where the triangle is located, and I1, I2, I3, I4, I5 and I6 respectively represent the camera sight line intersection points of the triangle and the closed boundary line. First, the multiple camera sight line intersection points are sorted in sequence according to the order of their corresponding boundary line segments in the closed boundary line, that is, the camera sight line intersection point I3 is sorted according to the index of the corresponding boundary line segment (P1, P2) in the closed boundary line, and a provision is proposed: the index of the boundary line segment (P1, P2) is 1, the index of the boundary line segment (P2, P3) is 2, and the order is from small to large, so the order of the multiple camera sight line intersection points is I3, I4, I5, I6, I1 and I2. However, it is not difficult to find that the current sorting method is wrong, because the camera sight line intersection point I6 and the camera sight line intersection point I1 should not be connected. This is because point P xIt belongs to the end of the closed boundary line, which should be connected to point P1, but the index value is not connected. In order to solve this problem, the second rule is proposed: the boundary line segment (P x-1 , P x ) and boundary segments (P x , P1) The index value of the segment at the end of the boundary line is defined as less than 1, then the boundary segment (P x , P1) is before the boundary segment (P1, P2); if the indexes of the two boundary segments are both less than 1 and are sorted in the specified way, then the boundary segment (P x-1 , P x ) is arranged on the boundary segment (P x , before P1). Combining the above provisions 1 and 2, the order of the multiple camera sight intersections should be I1, I2, I3, I4, I5 and I6. Note that I3 and I4 are on the same straight line, and the order between them cannot be determined by line segment index. It is necessary to combine the vector relationship to accurately determine, so the third provision is proposed: the intersection of the two camera sights I x and I x+1 Located on the same boundary segment (P x ,P x+1 ), if the vector and vector The same direction, that is Then I x Should be arranged in I x+1 Before, otherwise I x Should be arranged in I x+1 Then, using these three rules, we can find all camera sight intersections in the vertex set along the circular direction of the closed boundary line (such as Figure 8 The order of camera sight line intersection points is obtained by sorting them in a clockwise direction.
[0089] After obtaining the order of camera sight line intersections, the constrained edges of the triangle reconstruction can be determined based on the order of camera sight line intersections. First, the camera sight line projection point corresponding to the starting endpoint of the boundary line segment (i.e., the first endpoint along the circumference) is specified as the discrimination point, while the camera sight line projection point corresponding to the ending endpoint (i.e., the second endpoint along the circumference) is not processed. It is worth noting that in three-dimensional space, it cannot be guaranteed that the endpoint of the line segment is in the plane where the spatial triangle is located. In order to ensure that the normal of the triangle is not destroyed after cutting, it is necessary to intersect the triangle plane through the ray connected by the camera viewpoint and the line segment endpoint, and use the intersection point after intersection as the coordinate point of the cutting triangle (i.e., the camera sight line projection point of the starting endpoint of the boundary line segment of the closed boundary line in the triangle). Therefore, a fast method for finding the intersection point of a linear object and a triangle plane in three-dimensional space is as follows. Figure 9As shown in the figure: C is the spatial position of the camera viewpoint, P is the starting endpoint of the line segment, and P' is the camera sight projection point corresponding to the starting endpoint P of the line segment.
[0090] The constraint condition of the Delaunay triangulation algorithm is a set of multiple points, which are connected in sequence to form a broken line. Figure 8 As shown in the intersection situation, the judgment point of the boundary segment corresponding to the camera line of sight intersection I1 is point P x-1 , but due to point P x-1 It is not within the spatial triangle, so it is not used as a constraint condition. Only point I1 is added to the constraint condition. The judgment point of the boundary line segment corresponding to the camera line of sight intersection point I2 is point P. x , and point P x In the space triangle, point P x and point I2 are added to the constraint conditions in sequence; the judgment point of the boundary line segment corresponding to the camera sight intersection point I3 is point P1, and point P1 is not in the spatial triangle, so only point I3 is added to the constraint conditions in sequence; after all the camera sight intersection points are judged, the constraint conditions finally obtained in sequence along the circumferential direction of the closed boundary line are: I1, P x , I2, I3, I4, I5, P3 and I6, which are connected in sequence to form a broken line as shown Figure 10 The bold line segments are shown.
[0091] S53. Based on the given vertex set, use the Delaunay triangulation algorithm with the constraints to divide the triangle into multiple new triangles.
[0092] In step S53, considering that according to the normal triangulation method, there may be a situation where the new triangles divided are crossed by the constraint boundary, that is, Figure 11 (a) in the figure does not complete the segmentation of the triangle. Therefore, in the Delaunay triangulation process, a constraint boundary represented by the constraint condition is added, stipulating that the new triangle after the segmentation cannot be passed through the constraint boundary. If there is a triangle that is passed through, the triangle that is passed through needs to be re-divided, and the final result is as follows Figure 11 The new triangular mesh shown in (b).
[0093] S6. For each new triangle among the multiple new triangles, if it is determined that the corresponding topological relationship with the closed boundary line is that the triangle is within the closed boundary, then delete the new triangle from the irregular triangulated network structure.
[0094] In the step S6, after the triangulation, the new triangles need to be screened to determine whether to delete or retain them. Specifically, the screening can be performed in the manner described in the aforementioned steps S2 to S4, or the following conventional screening algorithm can be used: first find a point in the triangle to be judged (usually the center of gravity), and then determine whether the point is within the clipping boundary line. If so, the triangle is deleted, otherwise it is retained. However, the operation speed of this screening algorithm is limited by the length of the boundary line segment. To this end, this embodiment also proposes a method that can quickly screen whether a triangle is within the boundary, that is, for each new triangle among the multiple new triangles, determine whether the corresponding triangle has a topological relationship with the closed boundary line and whether the triangle is within the closed boundary, including but not limited to the following steps S61 to 64.
[0095] S61. Get the triangle centroid of the new triangle.
[0096] S62. Connect the centroid of the new triangle and any vertex of the original triangle to obtain a connecting line segment, wherein the original triangle refers to the triangle to which the new triangle belongs.
[0097] S63. Count and obtain the number of intersections between the connecting line segments and the constraint boundary line, wherein the constraint boundary line refers to a broken line formed by sequentially connecting all points in the constraint conditions along the circumferential direction of the closed boundary line.
[0098] S64. If the vertex of the two-dimensional triangle corresponding to any vertex of the original triangle is located inside the closed boundary line in the two-dimensional space and the number of intersections is zero or an even number, or if the vertex of the two-dimensional triangle corresponding to any vertex of the original triangle is located outside the closed boundary line in the two-dimensional space and the number of intersections is an odd number, then the topological relationship between the new triangle and the closed boundary line is determined to be that the triangle is inside the closed boundary.
[0099] In the aforementioned step S63, it should be noted that if the connecting line segment intersects with the constraint boundary line at any vertex of the original triangle, the intersection point will not be recorded. And if any vertex of the original triangle is located on the closed boundary line, it is necessary to change another vertex as the basis for judgment and reconstruct the connecting line segment. The improved screening algorithm described in the aforementioned steps S61 to S64 can significantly reduce the number of loops and the number of times to judge whether there is an intersection, that is, it is only related to the number of line segments in the constraint boundary line. Figure 12 As shown, the new triangle (I1, P x, I2) is the center of gravity of point C1, the vertex of the two-dimensional triangle corresponding to vertex V0 is located inside the closed boundary line in the two-dimensional space, and the number of intersections of the connecting line segment (C1, V0) and the constraint boundary line is 2, so the new triangle (I1, P x , I2) The topological relationship with the closed boundary line is that the triangle is within the closed boundary and needs to be deleted.
[0100] S7. Obtain a new real-scene 3D model after cropping based on the new irregular triangulated network structure obtained after the deletion process.
[0101] In step S7, since the model surface of the real-life 3D model is composed of the irregular triangulated network structure, after deleting triangles to achieve the purpose of cropping the center area of the model surface cropping and deleting new triangles to achieve the purpose of accurately cropping the boundary area of the model surface cropping, a new real-life 3D model with complete cropping can be obtained based on the new irregular triangulated network structure obtained after the deletion process. In addition, considering that texture coordinates specify unique texture pixels in texture space, by assigning texture coordinates to vertex coordinates, the 3D rendering program can know which part of the texture to map into space, thereby applying the texture to the 3D model. Although the camera sight line intersection point of the triangle and the closed boundary line and the camera sight line projection point of the starting end point of the boundary segment of the closed boundary line in the triangle are now obtained, these points do not have texture coordinates; since when obtaining these points, it is guaranteed that they are all in the plane where the triangle is located, their corresponding texture coordinates can be calculated by the texture coordinates of the three vertices of the triangle without causing texture distortion, that is, based on the new irregular triangulated network structure obtained by the deletion process, a new real-scene 3D model with completed cropping is obtained, including but not limited to the texture coordinates UV of each vertex in the new triangle calculated according to the following formula p :
[0102]
[0103] Wherein, UV0, UV1 and UV2 represent the known texture coordinates corresponding one-to-one to the three vertices of the original triangle, A0, A1 and A2 represent the sub-triangle areas corresponding one-to-one to the three vertices of the original triangle, A represents the area of the original triangle, and the sub-triangle area refers to the triangle area defined by the two endpoints of the original triangle side opposite to the corresponding vertices and the vertices of the new triangle. The original triangle refers to the triangle to which the new triangle belongs.
[0104] The idea of the above calculation method is to calculate the weight factors of the unknown point (i.e., each vertex in the new triangle) relative to the three vertices of the original triangle, multiply the weight factors by the corresponding texture coordinates and then sum them up to obtain the texture coordinates of the unknown point; these weight factors are the centroid coordinates of the unknown point relative to the three vertices of the original triangle, which can be obtained by Figure 13 Assume that Figure 13 The three weight factors corresponding to a vertex P in the new triangle are a, b, and c, and a+b+c=1; the texture coordinates of the three vertices of the original triangle are UV0, UV1, and UV2, respectively, then the texture coordinate UV of vertex P is p It can be obtained by the following formula: UV p =aUV0+bUV1+cUV2, that is, point P is used as the fourth vertex, and the original triangle (V0, V1, V2) can be divided into three smaller triangles. The areas of these three small triangles are proportional to the weight factor, so a can be obtained by It can be concluded that b can be obtained by It can be concluded that c can be obtained by Specifically, if the cross product of any two edge vectors of a triangle is equal to twice the area of the triangle, the values of a, b, and c can be obtained by the following formulas:
[0105]
[0106] Where, Represents the vector from point P to point V1, represents the vector from point P to point V2, represents the vector from point P to point V0, Represents the vector from point V0 to point V1, Represents the vector from point V0 to point V2.
[0107] Therefore, based on the real-life 3D model clipping method described in the aforementioned steps S1 to S7, a new scheme for clipping a face-based real-life 3D model using a curve that fits the model surface is provided, that is, after obtaining a closed boundary line drawn that fits the model surface, the irregular triangulated network structure of the real-life 3D model is projected into a two-dimensional space according to the drawing perspective of the closed boundary line, and then the topological relationship between each triangle and the closed boundary line is judged in the two-dimensional space, and based on the judgment result, the triangles within the boundary are deleted, and the new triangles within the boundary that are obtained by decomposing the triangles that intersect with the boundary are deleted. Finally, based on the new irregular triangulated network structure obtained after the deletion process, a new real-life 3D model that has been clipped is obtained. Therefore, not only can the real-life 3D model be flexibly clipped under various clipping perspectives, but the real-life 3D model can also be clipped more finely by using the closed boundary line drawn that fits the model surface, and thus can be applied to all intersection situations, facilitating practical application and promotion.
[0108] Based on the technical solution of the first aspect mentioned above, this embodiment also provides a possible design for cropping a multi-layer real-scene three-dimensional model with a detailed hierarchy structure. That is, when cropping a multi-layer real-scene three-dimensional model with a detailed hierarchy structure, the method also includes but is not limited to: traversing the real-scene three-dimensional models of each level in the detailed hierarchy structure in order from the root node downward, and using the real-scene three-dimensional model cropping method described in the first aspect to crop the real-scene three-dimensional model of the corresponding layer.
[0109] The level of detail model is mainly used to solve the problem of slow model loading caused by the large size of the model. It stores the model as multiple files of different ranges and different clarity according to a certain organizational rule. The software that loads the model needs to load models of different precisions and resolutions according to the field of view. There are many ways to divide the level of detail model. The division result generally has a tree data structure, which allows nodes to be found by model range. Each node is an independent model file. Assume that the model is divided according to the quadtree method, such as Figure 14 As shown, the node is divided into four identical child nodes, and the node contains the indexes of the four child nodes. It is worth noting that only non-empty nodes will continue to be divided downward. The detail level model has the characteristics that the deeper the model depth, the smaller the spatial range, the denser the triangulation and the higher the clarity. Since the detail level model uses files as the smallest organizational unit, a file corresponds to a local real-life three-dimensional model, and the file contains the file path of its child nodes. Therefore, starting from the real-life three-dimensional model of the root node, the real-life three-dimensional model clipping method as described in the first aspect can be applied for clipping, and after the clipping is completed, the traversal method is used to clip the real-life three-dimensional models of each of its child nodes and all the real-life three-dimensional models under the child nodes in turn, wherein the condition for the end of the traversal is that the real-life three-dimensional model to be clipped does not intersect with the closed boundary area or no longer has child nodes.
[0110] Based on the clipping method described in the aforementioned possible design 1, each level model of the multi-layered real-scene 3D model with a detailed hierarchy structure can be clipped.
[0111] This embodiment also conducts the following result verification for the technical solution of the first aspect or possible design one, namely, on a computer equipped with an Intel Core i5-3470 (3.2GHz) processor and 16GB of memory, based on the Windows 10 operating system, using C++ and the Open Scene Graph (OpenSceneGraph, OSG) three-dimensional engine to implement the cropping method of the first aspect or possible design one, and conduct experiments on it. Specifically, the Context Capture software is used to model the oblique photography images acquired by the drone, and a three-dimensional model in the binary Open Scene Graph (OpenSceneGraphBinary, OSGB) format with a detailed hierarchy is exported as the experimental object. In detail, there are real-life three-dimensional models such as Figure 15 As shown, due to the limited viewing angle of the drone, there is an obvious hole in the middle of the model. The model is cropped using the cropping method of the first aspect or the possible design. That is, first draw Figure 15 (a1, a2) and Figure 15 The red line in (b1, b2) is used as the clipping boundary curve that fits the model surface, and then the model is clipped from the camera perspective when drawing the curve. Figure 15 (c1, c2) in the figure is the model cropping result of the positive view. Figure 15 (d1, d2) in the figure is the model cropping result from the right perspective; Figure 15 (e1, e2) in is the model cropping result for the hierarchical model with higher resolution. Figure 15 The (f1, f2) in the figure is the model cropping result for the highest resolution layer model.
[0112] In order to further verify the cropping results of the model by the cropping method of the first aspect or possible design one, multiple experiments were conducted on the same model. Figure 16 This is the result of clipping the buildings in the upper part of the model and the vegetation in the middle part, where Figure 16 (a1, a2) in the figure is the cropping result of the model using the perspective of the model below the crop. Figure 16 (b1, b2) in the figure is the cropping result of the model using the perspective of the model above the cropping. Figure 16 The lower clipping boundary line of (a1, a2) is relatively smooth, while the upper clipping boundary line has greater fluctuations. Figure 16 The (b1, b2) in the figure is the opposite. This is because the two clipping boundaries are drawn using different perspectives. The clipping boundaries will be smoother when viewed from the perspective at which they are drawn. If the same model is clipped using SuperMapiDesktop 10i software, the clipping Figure 15 The hollow area of the model in the figure is for experimental purposes, and the cropping results are as follows: Figure 17 As shown in (a), the cropping effect is not good, that is, many models that are not within the boundary are cropped. This is because the cropping perspective is fixed and the cropping reference plane is always based on the horizontal plane. When the model's viewing angle is adjusted to a vertical perspective, the cropping result can be seen as follows Figure 17 As shown in (b) in .
[0113] From the above Figure 15 and Figure 16 The clipping results show that the clipping method of the first aspect or possible design 1 has a good clipping effect on the model. After clipping, the model boundary closely fits the clipping boundary line. After zooming in on the model, subtle changes in curvature on the clipping boundary line can also be reflected in the clipping results, indicating that this method has high clipping accuracy. Models at different levels are clipped accordingly, and this method is well adapted to models with detailed hierarchical structures. And the clipping results of the triangulated network model are compared: Figure 15 (c2) Figure 15 (e2) Figure 15 (f2) Figure 16 (a2) and Figure 16 In (b2), the triangles next to the cropping boundary line are arranged in sequence along the boundary line, fitting the boundary line well, indicating that the triangle reconstruction method can ensure that the model is cropped strictly along the boundary line.
[0114] Compare at the same time Figure 15 (a1) and Figure 17 In (a), it can be found that for the same model, the cropping boundary lines with similar range and regional positions are drawn, but the cropping results of the models are quite different; the cropping results of the aforementioned first aspect or possible design one are more correct, without the problem of over-cropping or wrong cropping; while the cropping results of the SuperMapiDesktop 10i software are wrong, and other parts of the model are cropped; this shows that from this perspective, the aforementioned first aspect or possible design one cropping method is more effective. And comparison Figure 17 (a) and Figure 17 In (b), it can be found that under the vertical perspective, the model boundary and the cropped area roughly overlap after cropping, but there are still some non-overlapping areas in some small areas; this shows that SuperMapiDesktop 10i software uses a fixed vertical perspective to crop the model, resulting in cropping errors; at the same time, the software's cropping results for small change areas are not ideal and the accuracy is not high enough; although the cropping method with a fixed vertical perspective directly discards the Z value of the model coordinate and has the characteristics of fast projection speed, it is suitable for aspects such as urban building monomers, but it is not suitable for models that focus on vertical surfaces such as rock formations. In addition, a comparison is also made Figure 16From (a1) and 16(b1), it can be found that when the same model is cropped using different cropping areas and different viewing angles, the cropping method of the first aspect or possible design one can correctly crop the model and achieve good cropping effects; however, since this cropping method requires projecting the three-dimensional coordinates into the two-dimensional space, the calculation time of the projection is increased compared to vertical cropping.
[0115] In addition, based on the above experiments, the impact of the number of triangles and the number of endpoints of closed boundary lines in the irregular triangulated network on the clipping time is analyzed for a single real-life 3D model. The experimental results are shown in Table 1 below:
[0116] Table 1. Impact of cropping time on a single real-life 3D model
[0117]
[0118] The results show that: (1) in the same model with the same number of triangles, the more endpoints of the closed boundary line, the more boundary triangles are obtained and the longer the clipping time; (2) when the number of endpoints of the closed boundary line is similar, the more triangles the model has, the longer the clipping time.
[0119] We further analyze the impact of cropping time on a multi-layered, hierarchical 3D model. The experimental results are shown in Table 2 below:
[0120] Table 2. Impact of cropping time on multi-layer photorealistic 3D models with a hierarchy of details
[0121]
[0122] The results show that: (1) the more models there are, the longer the clipping time generally takes; (2) the number of endpoints of the closed boundary line cannot determine the number of intersecting models, and the number of intersecting models is determined by the location of the model and the closed boundary line; (3) the more models intersecting with the boundary line, the longer the clipping time takes.
[0123] The above experimental results can be specifically analyzed theoretically through the following time complexity, that is, the clipping method of the first aspect or possible design one mentioned above, inputting a closed boundary curve with n endpoints and a real-life 3D model with m triangles. In the stage of constructing the triangle topology relationship, the time complexity of the algorithm is related to the number of triangles in the model, and the time complexity of establishing the topological relationship between vertices and triangles is O(m); establishing the triangulated network topology relationship based on the topological relationship between vertices and triangles only traverses the triangle array once and loops through the f triangles adjacent to the vertex once, but f and m have no relationship, and f is much smaller than m, and the time complexity is f*O(m); the time complexity of constructing the triangle topology relationship is T t (m) is: T t(m) = O(m) + f*O(m) ≈ O(m). In the triangle topology division stage, the time complexity of obtaining the bounding box of the closed boundary line is O(n); assuming that the boundary line is divided into s segments when using the ray method to determine whether the triangle vertex is within the closed boundary line, the time complexity of determining whether the point is within the boundary line is Approximately equal to O(n); while dividing all triangles requires traversing the entire triangle array, using the ray method to determine the topological relationship with the boundary line for the three vertices of the triangle array, and establishing the boundary triangle array based on the vertex situation, the time complexity is O(3mn); after establishing the boundary triangle array, the time complexity of screening the incorrectly judged triangles based on the topological relationship is O(n); the time complexity of the triangle topological relationship division is T p (n) is: T p (n)=O(n)+O(n)+O(3mn)+O(n)≈O(mn)≈O(n 2 ). As for the time complexity of boundary triangle segmentation, it is related to the number of boundary triangles and the number of points of the constraint conditions in the triangle, but has nothing to do with m and n, so it is not included in the time complexity; and the texture coordinate calculation has been completed in the boundary segmentation, so the time complexity can also be ignored. Therefore, the total time complexity of the final algorithm is T a (n) is: T a (n) = T t (m)+T p (n)=O(m)+O(n 2 )≈O(n 2 ).
[0124] Combining the factors affecting the model clipping time and algorithm time complexity in Tables 1 and 2 above, it can be found that the length of the closed boundary line is an important factor affecting the clipping time. Therefore, under the premise of giving up a certain clipping accuracy, the endpoints of the boundary line can be appropriately thinned to achieve the purpose of reducing the algorithm running time.
[0125] Based on the above results and analysis, it can be seen that the clipping method of the first aspect or possible design one proposed a method for clipping a real-life 3D model with a detailed hierarchical structure from different perspectives, and the clipping method has the following obvious advantages: (1) Compared with other clipping algorithms that use face clipping, the clipping method uses the boundary line that fits the surface of the model to clip the model, which can more flexibly select the clipping area while ensuring that the clipped model still maintains its original appearance; (2) In current software or literature, there are few clipping methods used for real-life 3D models with a detailed hierarchical structure. The cropping algorithm is a novel method for cropping oblique photogrammetry 3D models with hierarchical detail structures, and the cropping method can successfully crop the oblique photogrammetry 3D models with good results; (3) the cropping method can crop the model from different angles, can handle 3D models with different geometric shapes, and avoid mis-cropping models with overlapping viewpoints; (4) the cropping method can use the topological relationship between the reconstructed triangles and the boundary lines to quickly and accurately divide the reconstructed triangles; (5) the cropping method can provide correct and effective cropping for the detailed hierarchical real-life 3D models constructed by photogrammetry or 3D laser scanning data, which is convenient for practical application and promotion.
[0126] like Figure 18 As shown, the second aspect of this embodiment provides a virtual device for implementing the first aspect or any possible design of the real scene three-dimensional model clipping method of the first aspect, including a boundary line acquisition module, a triangle projection module, a topological relationship determination module, a first deletion module, a triangulation module, a second deletion module and a clipping completion module;
[0127] The boundary line acquisition module is used to obtain a corresponding closed boundary line drawn in accordance with the surface of the real-scene three-dimensional model having an irregular triangulated network structure;
[0128] The triangle projection module is communicatively connected to the boundary line acquisition module and is used to project the irregular triangulated network structure into a two-dimensional space according to the drawing perspective of the closed boundary line to obtain a plurality of two-dimensional triangles;
[0129] The topological relationship determination module is communicatively connected to the triangle projection module and is configured to determine, for each of the plurality of two-dimensional triangles, a corresponding topological relationship type with the closed boundary line in the two-dimensional space;
[0130] The first deletion module is communicatively connected to the topological relationship determination module and is configured to delete, for each two-dimensional triangle whose topological relationship type represents a triangle within a closed boundary, the corresponding triangle from the irregular triangulated network structure, and, for each two-dimensional triangle whose topological relationship type represents a triangle intersecting the closed boundary, delete the corresponding triangle from the irregular triangulated network structure if the number of corresponding intersection points is less than two and the centroid of the corresponding triangle is located inside the closed boundary line in the two-dimensional space;
[0131] The triangulation module is communicatively connected to the topological relationship determination module and is configured to, for each two-dimensional triangle where the topological relationship type represents the intersection of the triangle and the closed boundary, use a Delaunay triangulation algorithm to triangulate the corresponding triangle in the irregular triangulated network structure into a plurality of new triangles if the number of corresponding intersection points is not less than two.
[0132] The second deletion module is communicatively connected to the triangulation module and is configured to delete, for each of the multiple new triangles, the new triangle from the irregular triangulated network structure if it is determined that the corresponding new triangle has a topological relationship with the closed boundary line that the triangle is within the closed boundary;
[0133] The clipping completion module is communicatively connected to the first deletion module and the second deletion module, and is used to obtain a new real-scene three-dimensional model that has completed clipping based on a new irregular triangulated network structure obtained through the deletion process.
[0134] The working process, working details and technical effects of the aforementioned device provided in the second aspect of this embodiment can be referred to the method described in the first aspect or any possible design of the first aspect, and will not be repeated here.
[0135] like Figure 19As shown, the third aspect of this embodiment provides a computer device for executing the first aspect or any one of the possible designs of the real scene three-dimensional model cutting method in the first aspect, including a memory, a processor and a transceiver connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive information, and the processor is used to read the computer program and execute the real scene three-dimensional model cutting method as described in the first aspect or any one of the possible designs in the first aspect. For example, the memory may include, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a flash memory, a first-in-first-out memory (FIFO) and / or a first-in-last-out memory (FILO), etc.; the processor may include, but is not limited to, a microprocessor of the STM32F105 series. In addition, the computer device may also include, but is not limited to, a power module, a display screen and other necessary components.
[0136] The working process, working details and technical effects of the aforementioned computer device provided in the third aspect of this embodiment can be referred to the method described in the first aspect or any possible design of the first aspect, and will not be repeated here.
[0137] A fourth aspect of this embodiment provides a storage medium storing instructions for the method for clipping a real-scene three-dimensional model according to the first aspect or any possible design of the method according to the first aspect, that is, the storage medium stores instructions that, when executed on a computer, execute the method for clipping a real-scene three-dimensional model according to the first aspect or any possible design of the method according to the first aspect. The storage medium refers to a carrier for storing data, and may include, but is not limited to, a computer-readable storage medium such as a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive, and / or a memory stick. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
[0138] The working process, working details and technical effects of the aforementioned readable storage medium provided in the fourth aspect of this embodiment can be referred to the method described in the first aspect or any possible design of the first aspect, and will not be repeated here.
[0139] A fifth aspect of this embodiment provides a computer program product comprising instructions that, when executed on a computer, cause the computer to perform the method for clipping a real-life 3D model as described in the first aspect or any possible design of the first aspect. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
[0140] Finally, it should be noted that the present invention is not limited to the aforementioned optional embodiments. Anyone can derive various other product forms based on the teachings of this invention. The aforementioned specific embodiments should not be construed as limiting the scope of protection of the present invention. The scope of protection of the present invention shall be determined by the claims, and the specification may be used to interpret the claims.
Claims
1. A method for cutting a real-scene 3D model, characterized in that: include: For a real-life 3D model with an irregular triangulated network structure, obtaining a corresponding closed boundary line drawn to fit the surface of the model; Projecting the irregular triangulated network structure into a two-dimensional space according to a drawing perspective of the closed boundary line to obtain a plurality of two-dimensional triangles; For each of the plurality of two-dimensional triangles, determining a corresponding topological relationship type with the closed boundary line in the two-dimensional space; For each two-dimensional triangle whose topological relationship type represents a triangle within a closed boundary, deleting the corresponding triangle in the irregular triangulated network structure; For each two-dimensional triangle whose topological relationship type represents the intersection of a triangle and a closed boundary, if the number of corresponding intersection points is less than two, then when the centroid of the corresponding triangle is located inside the closed boundary line in the two-dimensional space, the corresponding triangle is deleted from the irregular triangulated network structure; otherwise, the corresponding triangle in the irregular triangulated network structure is triangulated into multiple new triangles using the Delaunay triangulation algorithm; For each of the multiple new triangles, if it is determined that the corresponding topological relationship with the closed boundary line is that the triangle is within the closed boundary, deleting the new triangle in the irregular triangulated network structure; According to the new irregular triangulated network structure obtained after the deletion process, a new real-scene three-dimensional model with the cropping completed is obtained.
2. The method according to claim 1, wherein For a real-life 3D model with an irregular triangulated network structure, obtain the corresponding closed boundary line drawn to fit the model surface, including: Converting the screen coordinates of a mouse moved on a display screen showing the real-scene three-dimensional model into the space coordinates of a mouse in the three-dimensional space of the real-scene three-dimensional model; Constructing a first ray based on the mouse spatial coordinates and the spatial position of the camera, wherein the starting point of the first ray is the spatial position of the camera and passes through the mouse spatial coordinates, and the spatial position of the camera refers to the spatial coordinates of the camera used to image the real-scene three-dimensional model in the three-dimensional space; Determining an intersection point between the first ray and a model surface of the real-scene three-dimensional model by using a collision detection method; A plurality of intersection points of the model surface are sequentially acquired by moving the mouse so as to form a closed boundary line along any direction.
3. The method according to claim 1, wherein For each of the plurality of two-dimensional triangles, determining a corresponding topological relationship type with the closed boundary line in the two-dimensional space includes the following steps S31 to S34: S31. For each of the plurality of two-dimensional triangles, if it is determined that the corresponding three vertices are not all located inside or outside the closed boundary line in the two-dimensional space, then determining that the corresponding topological relationship type with the closed boundary line in the two-dimensional space is that the triangle intersects the closed boundary line; S32. Add all two-dimensional triangles whose topological relationship type represents the intersection of the triangle and the closed boundary into a boundary triangulation set; S33. For each two-dimensional triangle in the boundary triangulation set, determine whether a corresponding adjacent two-dimensional triangle having an adjacent edge intersecting the closed boundary line in the two-dimensional space is already in the boundary triangulation set; if not, determine that the topological relationship type of the adjacent two-dimensional triangle and the closed boundary line in the two-dimensional space is a triangle intersecting a closed boundary, and include the adjacent two-dimensional triangle in the boundary triangulation set, wherein the adjacent edge refers to a shared edge between two adjacent two-dimensional triangles; S34. If the boundary triangulation set has newly added adjacent two-dimensional triangles by executing step S33, then return to execute steps S33 to S34, otherwise determine that the topological relationship type of the first non-boundary triangle and the closed boundary line in the two-dimensional space is a triangle within a closed boundary, wherein the first non-boundary triangle refers to a two-dimensional triangle among the multiple two-dimensional triangles, whose three vertices are all located inside the closed boundary line in the two-dimensional space and are not in the current boundary triangulation set.
4. The method according to claim 1, wherein For each two-dimensional triangle where the topological relationship type represents the intersection of a triangle and a closed boundary, if the number of corresponding intersection points is not less than two, the Delaunay triangulation algorithm is used to split the corresponding triangle in the irregular triangulated network structure into multiple new triangles, including: Include the three vertices of a triangle, the camera sight line intersection point of the triangle and the closed boundary line, and the camera sight line projection point of the starting endpoint of the boundary line segment of the closed boundary line within the triangle into a vertex set, wherein the camera sight line intersection point is the intersection point of a first camera sight line intersecting the closed boundary line and the edge of the triangle, the camera sight line projection point is the intersection point of a second camera sight line passing through the starting endpoint of the boundary line segment and the surface enclosed by the triangle, the first camera sight line and the second camera sight line are respectively rays starting from the camera viewpoint spatial position, and the camera viewpoint spatial position refers to the viewpoint spatial coordinates of the camera used to image the real-scene three-dimensional model in three-dimensional space; For all camera sight line intersection points and all camera sight line projection points in the vertex set, sort them in the circumferential direction of the closed boundary line to obtain constraint conditions; According to the given vertex set, the triangle is divided into multiple new triangles using a Delaunay triangulation algorithm with the constraints.
5. The method according to claim 4, wherein For each of the multiple new triangles, determining whether the corresponding topological relationship with the closed boundary line is that the triangle is within the closed boundary includes: Get the triangle centroid of the new triangle; Connecting the centroid of the new triangle and any vertex of the original triangle to obtain a connecting line segment, wherein the original triangle is the triangle to which the new triangle belongs; Counting the number of intersections between the connecting line segments and the constraint boundary line, wherein the constraint boundary line is a broken line formed by sequentially connecting all points in the constraint condition along the circumferential direction of the closed boundary line; If the vertex of the two-dimensional triangle corresponding to any vertex of the original triangle is located inside the closed boundary line in the two-dimensional space and the number of intersections is zero or an even number, or if the vertex of the two-dimensional triangle corresponding to any vertex of the original triangle is located outside the closed boundary line in the two-dimensional space and the number of intersections is an odd number, then the topological relationship between the new triangle and the closed boundary line is determined to be that the triangle is inside the closed boundary.
6. The method according to claim 1, wherein According to the new irregular triangulated network structure obtained after the deletion process, the new real scene 3D model after the clipping is obtained, including the texture coordinates UV of each vertex in the new triangle calculated according to the following formula p : Wherein, UV0, UV1 and UV2 represent the known texture coordinates corresponding one-to-one to the three vertices of the original triangle, A0, A1 and A2 represent the sub-triangle areas corresponding one-to-one to the three vertices of the original triangle, A represents the area of the original triangle, and the sub-triangle area refers to the triangle area defined by the two endpoints of the original triangle side opposite to the corresponding vertices and the vertices of the new triangle. The original triangle refers to the triangle to which the new triangle belongs.
7. A method for cropping a multi-layered real-scene 3D model with a detailed hierarchy, characterized in that: The method comprises: The real-scene 3D models of each level in the detail hierarchy are traversed in order from the root node downward, and the real-scene 3D models of the corresponding layers are clipped using the method according to any one of claims 1 to 6.
8. A real-scene three-dimensional model cutting device, characterized in that: It includes a boundary line acquisition module, a triangle projection module, a topological relationship determination module, a first deletion module, a triangulation module, a second deletion module and a clipping completion module; The boundary line acquisition module is used to obtain a corresponding closed boundary line drawn in accordance with the surface of the real-scene three-dimensional model having an irregular triangulated network structure; The triangle projection module is communicatively connected to the boundary line acquisition module and is used to project the irregular triangulated network structure into a two-dimensional space according to the drawing perspective of the closed boundary line to obtain a plurality of two-dimensional triangles; The topological relationship determination module is communicatively connected to the triangle projection module and is configured to determine, for each of the plurality of two-dimensional triangles, a corresponding topological relationship type with the closed boundary line in the two-dimensional space; The first deletion module is communicatively connected to the topological relationship determination module and is configured to delete, for each two-dimensional triangle whose topological relationship type represents a triangle within a closed boundary, the corresponding triangle from the irregular triangulated network structure, and, for each two-dimensional triangle whose topological relationship type represents a triangle intersecting the closed boundary, delete the corresponding triangle from the irregular triangulated network structure if the number of corresponding intersection points is less than two and the centroid of the corresponding triangle is located inside the closed boundary line in the two-dimensional space; The triangulation module is communicatively connected to the topological relationship determination module and is configured to, for each two-dimensional triangle where the topological relationship type represents the intersection of the triangle and the closed boundary, use a Delaunay triangulation algorithm to triangulate the corresponding triangle in the irregular triangulated network structure into a plurality of new triangles if the number of corresponding intersection points is not less than two. The second deletion module is communicatively connected to the triangulation module and is configured to delete, for each of the multiple new triangles, the new triangle from the irregular triangulated network structure if it is determined that the corresponding new triangle has a topological relationship with the closed boundary line that the triangle is within the closed boundary; The clipping completion module is communicatively connected to the first deletion module and the second deletion module, and is used to obtain a new real-scene three-dimensional model that has completed clipping based on a new irregular triangulated network structure obtained through the deletion process.
9. A computer device, characterized in that , comprising a memory, a processor and a transceiver that are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive information, and the processor is used to read the computer program and execute the real scene three-dimensional model clipping method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed on the computer, the real scene three-dimensional model clipping method according to any one of claims 1 to 7 is executed.