Three-dimensional model plane picking method and system based on position coding octree

By using a position-encoded octree method, the method searches and fits planes on 3D objects using an octree database, solving the problems of inaccurate picking and time consumption in existing technologies, and achieving fast and accurate 3D plane picking.

CN116188685BActive Publication Date: 2026-07-14GUILIN MEASURING & CUTTING TOOLS CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUILIN MEASURING & CUTTING TOOLS CO LTD
Filing Date
2023-01-19
Publication Date
2026-07-14

Smart Images

  • Figure CN116188685B_ABST
    Figure CN116188685B_ABST
Patent Text Reader

Abstract

The application provides a three-dimensional model plane picking method and system based on position coding octree, and relates to the technical field of three-dimensional picking; the method comprises the following steps: obtaining a target three-dimensional model corresponding to a target object and displaying the target three-dimensional model, and obtaining a two-dimensional coordinate of a target picking point of a user; obtaining a three-dimensional coordinate of the target picking point according to the two-dimensional coordinate of the target picking point; obtaining a target triangle face according to the three-dimensional coordinate of the target picking point, obtaining three-dimensional coordinates of each vertex of the target triangle face, calculating a target distance between the target picking point and the target triangle face through a plane normal vector and the three-dimensional coordinate of a center point of the target triangle face, and determining the target triangle face as a search triangle face; fitting each target triangle face and the search triangle face into a picking plane; and taking the picking plane as a target picking plane to realize a non-contact measurement function in a three-dimensional field, and finding an adjacent plane on a three-dimensional model corresponding to a coordinate point according to a point of a mouse on a two-dimensional screen.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of 3D picking technology, and more specifically, to a method and system for 3D model plane picking based on a position-encoded octree. Background Technology

[0002] Picking is a crucial function in computer graphics processing systems. In many cases, it's not enough to just draw graphics; it's also necessary to allow manipulation of objects on the screen via input devices (usually a mouse) for marking, moving, and modifying. Sometimes, it's also necessary to obtain the spatial coordinates or numerical values ​​of objects. All of these rely on picking as their foundation. Currently, picking in 3D space primarily focuses on picking the bounding box of objects in 3D space, or it can only pick points of a 3D model based on a mouse point on a 2D screen. However, there's no method to pick the corresponding plane on a 3D object based on a mouse point in 2D space. If you want to perform numerical measurements on a 3D object, the method of picking planes on the 3D object based on a mouse point is indispensable.

[0003] The paper "A Method for Picking Point Coordinates of 3D Model Based on OpenGL" proposes a method to find 3D points based on mouse points. This method involves traversing all points in the 3D model, finding the 3D point with the same coordinates as the mouse point after projection onto the screen, and then comparing the points with the same coordinates to find the point with the smallest depth. Although this method can find the 3D model point corresponding to the mouse point, it requires 3D projection of all 3D model points. When the number of triangles in the 3D model is large, it will consume a lot of time. Moreover, when performing projection calculations on points on the 3D model, it is impossible to pick accurately when the mouse point is on a triangle instead of a corner of the triangle. Summary of the Invention

[0004] The purpose of this invention is to provide a method and system for picking up planes in a 3D model based on a position-coded octree. This method enables non-contact measurement in the 3D field, picking up planar elements on a 3D object. It can find the adjacent planes on the 3D model corresponding to the coordinate point of a point on a 2D screen, thus making sufficient preparations for the field of 3D measurement.

[0005] The embodiments of the present invention are implemented as follows:

[0006] In a first aspect, embodiments of this application provide a method for picking a 3D model plane based on a position-encoded octree, comprising the following steps:

[0007] S11, Obtain and display the target 3D model corresponding to the target item. The target 3D model includes multiple triangular faces. The target item is composed of multiple triangular faces, and each triangular face includes at least one pick point.

[0008] S12, Obtain the two-dimensional coordinates of the target pick point selected by the user in each pick point;

[0009] S13, Calculate the three-dimensional coordinates of the target pickup point based on its two-dimensional coordinates;

[0010] S14. Based on the three-dimensional coordinates of the target pickup point and the preset octree database, obtain the triangle with the smallest distance to the target pickup point among the triangles in the octree database as the target triangle, and obtain the three-dimensional coordinates of each vertex of the three vertices that constitute the target triangle. The octree database includes the position information of each triangle in the multiple triangles corresponding to the target three-dimensional model, as well as the three-dimensional coordinates of each vertex of the three vertices corresponding to each triangle.

[0011] S15. Based on the target triangle, obtain the three-dimensional coordinates of each of the three vertices that constitute the target triangle. Based on the target triangle and the three-dimensional coordinates of each of the three vertices of the target triangle, calculate the plane normal vector corresponding to the target triangle and the three-dimensional coordinates of the center point of the target triangle.

[0012] S16. Calculate the target distance between the target picking point and the target triangle using the plane normal vector and the three-dimensional coordinates of the center point of the target triangle. If the target distance is not greater than the first threshold, the target triangle is determined as the search triangle. If the target distance is greater than the first threshold, the target triangle is re-determined based on the octree database until the target distance between the target picking point and the target triangle is not greater than the first threshold.

[0013] S17, Based on the search triangle, obtain a first number of target triangles from the octree database, where the planar distance between each target triangle and the search triangle is no greater than a second threshold.

[0014] S18, fit the first number of target triangles and search triangles into a picking plane, and use the picking plane as the target picking surface;

[0015] S19, based on an octree database, outputs the 3D coordinates of the center point of the target picking surface and the plane normal vector of the target picking surface.

[0016] The beneficial effects of this invention are: when displaying a target 3D model corresponding to a target item, a 2D coordinate point of the target 3D model in 2D space is obtained. Through this 2D coordinate point, the entire plane of the plane where the 2D coordinate point is located is obtained, thus achieving the purpose of picking the plane of the 3D model. That is, based on obtaining a 2D coordinate point of the 3D model, multiple triangular faces in the same plane are searched through an octree database, thereby finding the plane where the 2D coordinate point on the 3D model is located, and completing the picking of the plane on the 3D model. It has the effects of short time consumption and accurate picking.

[0017] Based on the above technical solution, the present invention can be further improved as follows.

[0018] Furthermore, the above-mentioned fitting of multiple target triangles and search triangles into a picking plane, and using the picking plane as the target picking surface, includes:

[0019] S21, fit multiple target triangles and search triangles into a picking plane, and based on the octree database, obtain the three-dimensional coordinates of the center point of the picking plane, as well as the plane normal vector corresponding to the picking plane.

[0020] S22, by using the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane, the verification distance between the target picking point and the picking plane is calculated;

[0021] S23. If the verification distance is greater than the third threshold, a new target triangle is determined based on the octree database, and steps S15 to S18 are re-executed based on the new target triangle.

[0022] The beneficial effect of adopting the above-mentioned further scheme is that by verifying the first picking plane, it can be checked whether the distance between the first picking plane and the target picking point is within the specified range, and it can be determined whether the target picking point falls within the picking plane.

[0023] Furthermore, if the verification distance is not greater than the third threshold, it also includes:

[0024] S24, the picking plane is determined as the search verification triangle;

[0025] S25, based on the search verification triangle, obtain a second number of target verification triangles from the octree database. The planar distance between each target verification triangle and the search triangle in the second number of target verification triangles is not greater than the fourth threshold. The value of the second number is greater than or equal to the first number.

[0026] S26, Fit the second number of target verification triangles and search verification triangles into a new picking plane;

[0027] S27, the new pickup plane is determined as the target pickup plane.

[0028] The beneficial effect of adopting the above-mentioned further solution is that by searching for triangular faces that meet the conditions again in the octree database, as many triangular faces as possible that meet the conditions on the same plane can be found, thereby improving the accuracy of plane picking.

[0029] Furthermore, the above-mentioned determination of the new pickup plane as the target pickup plane includes:

[0030] Repeat steps S24 to S26 multiple times. After each repetition, obtain multiple different numbers of target verification triangles. In every two consecutive repetitions of steps S24 to S26, the number of target verification triangles obtained in the later repetition is greater than or equal to the number of target verification triangles obtained in the previous repetition. When the number of repetitions equals the fifth threshold, take the new picking plane corresponding to the last repetition as the target picking plane.

[0031] Alternatively, when S24-S26 is repeated twice consecutively, if the difference between the three-dimensional coordinates of the center points of the two new picking planes is no greater than the sixth threshold, and the dot product of the plane normal vectors of the two new picking planes is no less than the seventh threshold, then the new picking plane corresponding to the last time is taken as the target picking plane.

[0032] The beneficial effect of adopting the above-mentioned further scheme is that, due to the special nature of a picking point, it cannot be guaranteed that the plane represented by the first picking plane is the same as the overall picking plane. Therefore, it is necessary to use an iterative method to obtain the best picking result. That is, the multiple target triangles and search triangles obtained in the previous step are fitted to obtain the picking plane. Then, the octree database is searched through this picking plane. The search is repeated many times to search for more triangles that meet the conditions of the plane in the octree database, so as to improve the accuracy and precision of the plane picking.

[0033] Furthermore, the above methods also include:

[0034] Based on the target 3D model, an octree database corresponding to the target 3D model is established. The octree database includes the position information of each triangle face in the target 3D model and the 3D coordinate information of each vertex of the three vertices that make up each triangle face.

[0035] The beneficial effect of adopting the above-mentioned further scheme is that, based on the different three-dimensional models corresponding to different target items, an octree database of target three-dimensional models corresponding to each target item is established, that is, one target three-dimensional model of a target item corresponds to one octree database.

[0036] Furthermore, based on the target 3D model, an octree database corresponding to the target 3D model is established, including:

[0037] Obtain the position information of each triangle face in the target 3D model, as well as the 3D coordinates of each vertex among the three vertices that make up each triangle face;

[0038] Based on the three-dimensional coordinates of each vertex of each triangle, the three maximum differences of the target three-dimensional model on the X-axis, Y-axis and Z-axis are obtained;

[0039] The number of levels in the octree database is calculated based on the three maximum differences and the preset voxel width in the octree database.

[0040] The position information of each triangle face, as well as the three-dimensional coordinates of the three vertices that make up each triangle face, are stored in the corresponding level. Each level includes the three-dimensional coordinates of the three vertices of multiple triangle faces at different positions of the target three-dimensional model, so as to establish an octree database corresponding to the target three-dimensional model.

[0041] The beneficial effect of adopting the above-mentioned further scheme is that it establishes an octree database that includes the position information of each triangle face in the target 3D model and the 3D coordinate information of each vertex of the three vertices constituting each triangle face.

[0042] Secondly, embodiments of this application provide a 3D model plane picking system based on a position-coded octree, applied to the 3D model plane picking method based on a position-coded octree according to any one of the first aspects, including:

[0043] The display module is used to acquire and display the target 3D model corresponding to the target item. The target 3D model includes multiple triangular faces, the target item is composed of multiple triangular faces, and each triangular face includes at least one pick point.

[0044] The acquisition module is used to acquire the two-dimensional coordinates of the target pick point selected by the user at each pick point;

[0045] The calculation module is used to calculate the three-dimensional coordinates of the target pickup point based on its two-dimensional coordinates.

[0046] The triangle module is used to obtain the triangle with the smallest distance to the target pick point from the various triangles in the octree database based on the 3D coordinates of the target pick point and the preset octree database. It also obtains the 3D coordinates of each of the three vertices that make up the target triangle. The octree database includes the position information of each triangle in the multiple triangles corresponding to the target 3D model, as well as the 3D coordinates of each of the three vertices corresponding to each triangle.

[0047] The vector module is used to obtain the three-dimensional coordinates of each of the three vertices that make up the target triangle face, and to calculate the plane normal vector corresponding to the target triangle face and the three-dimensional coordinates of the center point of the target triangle face based on the target triangle face and the three-dimensional coordinates of each of the three vertices of the target triangle face.

[0048] The first threshold module is used to calculate the target distance between the target picking point and the target triangle using the plane normal vector and the three-dimensional coordinates of the center point of the target triangle. If the target distance is not greater than the first threshold, the target triangle is determined as the search triangle. If the target distance is greater than the first threshold, the target triangle is re-determined based on the octree database until the target distance between the target picking point and the target triangle is not greater than the first threshold.

[0049] The second threshold module is used to obtain a first number of target triangles from the octree database based on the search triangles, wherein the planar distance between each target triangle and the search triangle is not greater than the second threshold.

[0050] The determination module is used to fit a first number of target triangles and search triangles into a picking plane, and use the picking plane as the target picking surface;

[0051] The output module is used to output the 3D coordinates of the center point of the target picking surface and the plane normal vector of the target picking surface based on the octree database.

[0052] Furthermore, the aforementioned determining module includes:

[0053] The picking plane submodule is used to fit multiple target triangles and search triangles into a picking plane, and based on the octree database, obtain the three-dimensional coordinates of the center point of the picking plane, as well as the plane normal vector corresponding to the picking plane.

[0054] The verification submodule is used to calculate the verification distance between the target picking point and the picking plane by using the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane;

[0055] The third threshold submodule is used to determine a new target triangle based on the octree database if the verification distance is greater than the third threshold, and to re-execute the processing from the vector module to the determination module based on the new target triangle.

[0056] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the methods in the first aspect.

[0057] Fourthly, embodiments of this application provide a non-transitory computer-readable storage medium that stores computer instructions that cause a computer to perform any of the methods in the first aspect. Attached Figure Description

[0058] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0059] Figure 1 This is a flowchart illustrating the process of establishing an octree database in an embodiment of the present invention;

[0060] Figure 2 This is a flowchart illustrating the encoding of octree nodes in an octree database according to an embodiment of the present invention;

[0061] Figure 3 This is a schematic diagram of an octal-encoded octree in an octree database according to an embodiment of the present invention;

[0062] Figure 4 This is a schematic diagram of ray picking for mouse points in an embodiment of the present invention;

[0063] Figure 5 This is a flowchart illustrating the mouse point picking process in an embodiment of the present invention;

[0064] Figure 6 This is a flowchart of the three-dimensional model plane picking method in an embodiment of the present invention;

[0065] Figure 7 This is a schematic diagram of the target 3D model and the final target picking surface in an embodiment of the present invention;

[0066] Figure 8 This is a flowchart of the three-dimensional model plane picking method in an embodiment of the present invention;

[0067] Figure 9 This is a connection diagram of the three-dimensional model plane picking system in an embodiment of the present invention;

[0068] Figure 10 This is a schematic diagram of the connection of an electronic device in an embodiment of the present invention. Detailed Implementation

[0069] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0070] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0071] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0072] Example

[0073] In a first aspect, embodiments of this application provide a method for picking a 3D model plane based on a position-encoded octree, comprising the following steps:

[0074] S11. Obtain and display the target 3D model corresponding to the target item. The target 3D model includes multiple triangular faces. The target item is composed of multiple triangular faces, and each triangular face includes at least one pick point.

[0075] The octree database stores the position information of each triangle face in the corresponding target 3D model, as well as the 3D coordinate information of the three vertices that make up each triangle face. The center point and normal vector of the corresponding triangle face can be calculated by using the 3D coordinates of the three vertices of each triangle face. The 3D coordinates are the coordinates in the 3D Cartesian coordinate system. Different items correspond to different 3D models, and different 3D models correspond to different octree databases.

[0076] Optionally, the above methods also include:

[0077] Based on the target 3D model, an octree database corresponding to the target 3D model is established. The octree database includes the position information of each triangle face in the target 3D model and the 3D coordinate information of each vertex of the three vertices that make up each triangle face.

[0078] Optionally, the above-mentioned process of establishing an octree database corresponding to the target 3D model may include:

[0079] The system obtains the position information of each triangular facet in the target 3D model, as well as the 3D coordinates of each vertex among the three vertices that make up each triangular facet. When obtaining the position information of each triangular facet in the target 3D model, the system can use a 3D point cloud obtained from a third-party library or scanner to triangulate the 3D point cloud, thereby obtaining the coordinates of each 3D point in the target 3D model, as well as the position of the triangular facet formed by every three 3D points and the 3D coordinates of the three points that make up the triangular facet.

[0080] Based on the three-dimensional coordinates of each vertex of each triangle, the three maximum differences of the target three-dimensional model on the X-axis, Y-axis, and Z-axis are obtained; specifically, based on the three-dimensional coordinates of the three vertices of each triangle, the three maximum differences of the target three-dimensional model on the X-axis, Y-axis, and Z-axis are obtained.

[0081] The bounding box of the target 3D model is obtained by subtracting the minimum value from the maximum value of (x, y, z) among all 3D points of the target 3D model. The maximum value is the point with the largest x, y, z values ​​among all 3D points, and the minimum value is the point with the smallest x, y, z values ​​among all 3D points. The bounding box is a cube structure, and the length, width, and height of the cube structure are equal to the maximum length, width, and height of the target 3D model, respectively. For example, if the maximum value of the target 3D model is (1, 2, 3) and the minimum value is (-1, -2, -3), subtracting the (x, y, z) values ​​of the two points sequentially gives (2, 4, 6), which are the three maximum differences of the target 3D model on the X, Y, and Z axes, respectively, resulting in a bounding box with dimensions of 2, 4, and 6.

[0082] The number of levels in the octree database is calculated based on the three maximum differences and the preset voxel width in the octree database. The length, width, and height of the bounding box of the target 3D model can be obtained by subtracting the minimum point from the maximum point. The number of levels in the octree database to be built can be determined based on the length, width, and height of the bounding box and the preset voxel width in the octree database.

[0083] Specifically, based on the preset voxel width, that is, the width value L of the smallest cube in the octree database. min And the maximum side length L of the model bounding box. model Calculate the number of levels in the octree database; specifically, it can be greater than [a certain value]. The smallest integer is the number of levels in the octree database;

[0084] As an example, if the maximum point of the target 3D model is (1,2,3) and the minimum point is (-1,-2,-3), then the bounding box of the model has dimensions (2,4,6). Taking the maximum value of 6 among the dimensions (2,4,6), we get the maximum side length L. model The minimum cube width L set when creating the octree database. min Calculate 0.2 Taking an integer greater than 5 gives the number of levels in the octree.

[0085] The preset voxel width is the width value of the smallest cube in the octree database. The octree structure is a cubic structure composed of multiple cubes. The octree database includes multiple tree nodes, each corresponding to a cube. Each tree node represents the volume of the corresponding cube. Each tree node has multiple child nodes, each corresponding to a smallest cube. Therefore, the cube corresponding to a tree node can be composed of the smallest cubes corresponding to its multiple child nodes. All the smallest cubes have the same volume, and the width value of the smallest cube is the preset voxel width in the octree database. The position of each child node is fixed, and the cubic structure of the established octree database is equivalent to the cubic structure of the model bounding box. Therefore, the position of each child node corresponds to the position of the target 3D model and is used to store the 3D coordinate information of the corresponding position of the target 3D model.

[0086] In this system, the 3D coordinate information of the 3D points stored in each octree child node can be represented by octal encoding (also known as position encoding). The number of bits in the octal encoding can be three times the number of levels. That is, each octal bit records the position of the center point (x, y, z) of the corresponding level. For example, if the number of levels in the octree database is 2 and the voxel width is set to 1, the center coordinates of the octree cube structure in the octree database, which is also the center coordinates of the model bounding box, are obtained by subtracting the minimum point from the maximum point among all 3D points and then dividing by 2. For example, if the center point coordinates of the octree in the octree database are (0,0,0), then the recorded octal encoding is 0xXX, where X represents a number from 0 to 7. The numbers stored in the computer's memory are all binary numbers, which can be yyyyyy, where y represents 0 or 1. That is, the number of bits in the octal encoding is 2*3=6 bits.

[0087] As an example, the octal code of a child node in an octree database is 0x53, which corresponds to the binary representation 110011. According to the preset rules, in the binary representation corresponding to the octal code, 1 represents positive and 0 represents negative. As shown above, the binary representation 110011 corresponds to the center point coordinates (x, y, z) of each level from left to right. The width w of the nth level in the octree database...n =L min ×2 n-1 We can obtain that the width of the first layer is 1 and the width of the second layer is 2. The code of the cube corresponding to the second layer is 110. We can calculate the coordinates of the center point of the cube as (0+(-1)×2,0+1×2,0+1×2)=(-2,2,2). So the code 110 for the second layer represents a cube with a width of 2 centered at (-2,2,2). The code of the first layer is 011. So the coordinates of the center of the first layer are (-2+1×1,2+1×1,2+(-1)×1)=(-1,3,1) based on the second layer. This means a cube with a width of 1 centered at (1,3,2).

[0088] To obtain the position code of a 3D point in an octree database, the above process needs to be reversed. For example, if the center of the octree database is (0,0,0), the number of layers is 2, and the preset voxel width is 2, and we need to find the position code of the point (-0.5,1.5,3.5) in the octree, we can start from the highest layer, whose center is the octree center (0,0,0). Then, according to the set rules, 1 is positive and 0 is negative, we subtract the highest layer center from the point to get (-0.5,1.5,3.5) - (0,0,0) = (-0.5,1.5,3.5). Based on the signs of z, y, and x (-0.5,1.5,3.5), since z = 3.5 > 0, y = 1.5 > 0, x = 3.5 > 0, then we can determine the position code of the point (-0.5,1.5,3.5). Since -0.5 < 0, the first layer's code is 110. Based on the first layer's code 110 and the preset voxel width of 2, the center point of the first layer is calculated as (0 + (-1) × 2, 0 + 1 × 2, 0 + 1 × 2) = (-2, 2, 2). Subtracting the center point of the first layer from the point (-0.5, 1.5, 3.5) gives (-0.5, 1.5, 3.5) - (-2, 2, 2) = (1.5, -0.5, 1.5). Since z = 1.5 > 0, y = -0.5 < 0, and x = 1.5 > 0, the binary code of the second layer is 101. Therefore, the binary position code of the point (-0.5, 1.5, 3.5) in the octree database is 110101, which is represented as 0x65 in octal.

[0089] The position information of each triangle face, as well as the three-dimensional coordinates of the three vertices that make up each triangle face, are stored in the child nodes of the corresponding level. Each level includes the three-dimensional coordinates of the three vertices of multiple triangle faces at different positions of the target three-dimensional model, so as to establish an octree database corresponding to the target three-dimensional model.

[0090] The process involves storing the position information of each triangle facet, along with the 3D coordinates of the three vertices constituting each triangle facet, into a corresponding hierarchy to establish an octree database corresponding to the target 3D model. Knowing the number of bits in the encoding for each 3D point, the position of each triangle facet is represented by the center point of its three points. Knowing the 3D coordinates of the three points constituting a triangle facet, the coordinates of the center point can be calculated. Using the 3D coordinates of the center point, the position code of the triangle facet's center is calculated, and the index of this triangle facet is stored in the encoding of the corresponding child node in the octree database. See also... Figure 1 The nodes and codes in the octree database are linked using a map data structure. That is, the code is used as the key and the tree node of the octree database is used as the value. According to the center coordinate position of each triangle, the code of the center coordinate is first calculated, and then it is checked whether the key with this code exists in the map. If it exists, it is directly added to the value corresponding to this key. If it does not exist, a new key is created and the triangle is put into the newly created value. This process is repeated until all triangles are put into the map, thus building the octree database.

[0091] In position-encoded octree databases, encoding and decoding nodes according to their positions not only facilitates searching for nearby nodes, but also significantly improves search efficiency by using decoding. (See [link to documentation]). Figure 2 The principle of node encoding and decoding in octree database is mainly to iteratively obtain the position encoding value based on the relationship between the preset width value and the center coordinates of the node, or to iteratively obtain the center point of the encoded node and the width of the child nodes based on the position encoding and the center of the root node (the center of the octree three-dimensional structure). The encoding method is progressively layer by layer based on the width of each layer and the position of the already encoded points.

[0092] The decoding method for the octree database is the reverse of the encoding process. That is, the center point is moved bit by bit according to the encoding until all the encoding bits are used, thus obtaining the range of child nodes at the encoded position. However, the decoding method is not used when searching for the plane; instead, the search method built into the map data structure is used. The nodes surrounding the octree are obtained based on the nodes in the map shown in the encoding. See [link to relevant documentation]. Figure 3 This establishes a complete spatial encoding structure for the octree database.

[0093] S12, Obtain the two-dimensional coordinates of the target pick point selected by the user in each pick point;

[0094] When displaying a target 3D model, an OpenGL 3D projection imaging system can be established. OpenGL displays the target 3D model on a 2D plane. The main principle is to multiply the model coordinates by the model matrix to transform them into 3D spatial coordinates, then multiply the spatial coordinates by the camera's view matrix to obtain 3D camera coordinates with the camera as the origin, and finally multiply the camera coordinates by the projection matrix. Then, based on depth testing, the point with the minimum z-value within the screen space is displayed at its corresponding position on the screen. By passing the model matrix, view matrix, and projection matrix corresponding to the target 3D model into the GPU's shader, OpenGL can display a 3D image on the screen and perform the inverse transformation. OpenGL's drawing and display uses matrix multiplication to convert the coordinates of a 3D object into screen coordinates, mainly through three 4×4 transformation matrices. These three matrices are the model matrix Mat... model Convert the model's own coordinates to spatial coordinates; view matrix Mat view This converts spatial coordinates into the camera's viewing coordinates; the projection matrix Mat... projection The observation coordinates are converted into clipping coordinates between -1.0 and 1.0 in screen space. Finally, based on the width w and height h of the actual display area, the clipping coordinates are linearized into screen coordinates (x, y, y). s ,y s The mathematical representation is as follows:

[0095]

[0096]

[0097] In the formula, Mat model For the model matrix, Mat view For the viewpoint matrix, Mat projection Let w be the projection matrix, h be the width of the actual display area, and (x) be the height of the actual display area. s ,y s (x, y, z) are the screen coordinates, and (x, y, z) are the 3D coordinates transformed from the screen coordinates.

[0098] S13, Calculate the three-dimensional coordinates of the target pickup point based on its two-dimensional coordinates;

[0099] The process involves establishing a 3D point based on the screen coordinates (two-dimensional coordinates of the target pickup point) and depth value (minimum depth within the screen space). Multiplying these by the inverses of the corresponding projection matrix, view matrix, and model matrix yields the two-dimensional coordinates of the target pickup point. After establishing the octree database of the target 3D model, the mouse point position can be picked according to OpenGL's screen space projection relationship. This is primarily achieved by using the method of intersecting rays and triangles to obtain the 3D coordinates of the mouse point. In the OpenGL projection system, mouse point pickup is mainly based on the values ​​z of the near and far planes of the projection matrix, starting from the mouse point coordinates (x, y). near z far The near plane is the plane closest to the 3D coordinates of the mouse point, and the far plane is the plane farthest from the 3D coordinates of the mouse point. These two points in 3D space can be obtained through inverse calculation using a projection system. The inverse calculation process is shown below:

[0100]

[0101]

[0102] Similarly, to find the point corresponding to the distant plane, z near Replace with z far That's all; see also Figure 4 Starting from the mouse point on the near plane obtained by inverse calculation and ending at the mouse point on the far plane, calculate all intersections of this ray with the 3D model. The point in the positive direction of the ray that is closest to the near plane is the 3D space point corresponding to the mouse point.

[0103] After obtaining the ray from the mouse point in 3D space, it is necessary to find the intersection point of this ray with each triangular face on the 3D model. The principle for determining the intersection of a ray and a triangle in 3D space is to obtain it by solving a system of equations. For example, if the starting point of the ray is p and the direction vector is d, then any point on the ray can be represented as p + d × t, where t is any non-negative integer. If the three points of the triangular face are v0, v1, and v2, then any point inside the triangle in space can be represented as (1-mn)v0 + mv1 + nv2, where m ≥ 0, n ≥ 0, and m + n ≤ 1. From this, the following equation can be established:

[0104] p+d×t=(1-mn)v0+mv1+nv2 (1);

[0105] Solving this equation yields:

[0106]

[0107] See Figure 5After solving for t, we can substitute it into p+d×t to get the coordinates of the intersection point of the ray and the triangle. Among all the solutions for t, we take the smallest t value and the coordinates of the intersection point are the coordinates of the mouse point, that is, the three-dimensional coordinates of the target picking point.

[0108] S14. Based on the three-dimensional coordinates of the target pickup point and the preset octree database, obtain the triangle with the smallest distance to the target pickup point among the triangles in the octree database as the target triangle, and obtain the three-dimensional coordinates of each vertex of the three vertices that constitute the target triangle. The octree database includes the position information of each triangle in the multiple triangles corresponding to the target three-dimensional model, as well as the three-dimensional coordinates of each vertex of the three vertices corresponding to each triangle.

[0109] After a 3D point (target pick point) is picked up by the mouse, i.e., the point clicked by the mouse cursor when the target 3D model is displayed, the position information of this 3D point in the octree database can be obtained from this 3D point based on its 3D coordinates. Based on this position information, 3D coordinates and preset voxel width, the position code corresponding to the 3D coordinates of this 3D point can be calculated. This position code is then used to search and judge in the octree database to obtain the coordinate information of the triangle face where this 3D point is located.

[0110] S15. Based on the target triangle, obtain the three-dimensional coordinates of each of the three vertices that constitute the target triangle. Based on the target triangle and the three-dimensional coordinates of each of the three vertices of the target triangle, calculate the plane normal vector corresponding to the target triangle and the three-dimensional coordinates of the center point of the target triangle.

[0111] The initial plane search parameters, namely the plane center point and plane normal vector of the target triangle, can be determined first based on the three-dimensional coordinates of the three vertices of the target triangle. The center point of the target triangle can be represented by the three-dimensional coordinates of the three vertices, and the plane normal vector of the target triangle can be obtained by subtracting the three vertices pairwise to obtain two vectors, which are then calculated by cross product.

[0112] S16. Calculate the target distance between the target picking point and the target triangle using the plane normal vector and the three-dimensional coordinates of the center point of the target triangle. If the target distance is not greater than the first threshold, the target triangle is determined as the search triangle. If the target distance is greater than the first threshold, the target triangle is re-determined based on the octree database until the target distance between the target picking point and the target triangle is not greater than the first threshold.

[0113] Specifically, based on the plane normal vector corresponding to the target triangle and the three-dimensional coordinates of the center point of the target triangle, a condition for determining whether a point is on the plane can be formed. The distance from this point to the plane is used to determine whether the point is on the plane. Based on this condition, the diffusion condition of the voxels in the octree database is obtained. If there are three triangles in the voxel nodes of the octree database that are all on the plane, then the triangles that meet the condition are saved, that is, the target triangle is determined as the search triangle.

[0114] S17, Based on the search triangle, obtain a first number of target triangles from the octree database, where the planar distance between each target triangle and the search triangle is no greater than a second threshold.

[0115] The process involves searching an octree database using the obtained search triangles. Triangles whose distance from the search triangle is no greater than a second threshold are selected as target triangles. First, the triangle data corresponding to the 2D point is obtained, along with the 3D coordinates and plane normal vector of the target triangle's center point. A distance threshold of 0.1mm is set between the target picking point and the target triangle (the first threshold is 0.1mm). If the distance meets this condition, the point is considered to be on the target triangle. Then, the voxel nodes in the octree database containing the target triangles are expanded, meaning the search triangles are used to find the target triangles in the octree database until all surrounding nodes that meet the condition are found. In other words, all target triangles that meet the condition are found in the octree database.

[0116] S18, fit the first number of target triangles and search triangles into a picking plane, and use the picking plane as the target picking surface;

[0117] S19, based on an octree database, outputs the 3D coordinates of the center point of the target picking surface and the plane normal vector of the target picking surface.

[0118] The process involves fitting multiple target triangles and search triangles into a picking plane. Based on an octree database, the three-dimensional coordinates of the center point of the target picking plane and the plane normal vector of the target picking plane can be obtained. The picking plane is the model plane picked by the mouse point.

[0119] Optionally, the above-mentioned fitting of multiple target triangles and search triangles into a picking plane, and using the picking plane as the target picking surface, includes:

[0120] S21, fit multiple target triangles and search triangles into a picking plane, and based on the octree database, obtain the three-dimensional coordinates of the center point of the picking plane, as well as the plane normal vector corresponding to the picking plane.

[0121] S22, by using the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane, the verification distance between the target picking point and the picking plane is calculated;

[0122] S23. If the verification distance is greater than the third threshold, a new target triangle is determined based on the octree database, and steps S15 to S18 are re-executed based on the new target triangle.

[0123] Optionally, if the verification distance is not greater than the third threshold, the above also includes:

[0124] S24, the picking plane is determined as the search verification triangle;

[0125] S25, based on the search verification triangle, obtain a second number of target verification triangles from the octree database. The planar distance between each target verification triangle and the search triangle in the second number of target verification triangles is not greater than the fourth threshold. The value of the second number is greater than or equal to the first number.

[0126] S26, Fit the second number of target verification triangles and search verification triangles into a new picking plane;

[0127] S27, the new pickup plane is determined as the target pickup plane.

[0128] Optionally, defining the new pickup plane as the target pickup plane as described above may include:

[0129] Repeat steps S24 to S26 multiple times. After each repetition, obtain multiple different numbers of target verification triangles. In every two consecutive repetitions of steps S24 to S26, the number of target verification triangles obtained in the later repetition is greater than or equal to the number of target verification triangles obtained in the previous repetition. When the number of repetitions equals the fifth threshold, take the new picking plane corresponding to the last repetition as the target picking plane.

[0130] Alternatively, when S24-S26 is repeated twice consecutively, if the difference between the three-dimensional coordinates of the center points of the two new picking planes is no greater than the sixth threshold, and the dot product of the plane normal vectors of the two new picking planes is no less than the seventh threshold, then the new picking plane corresponding to the last time is taken as the target picking plane.

[0131] Because of the unique nature of a single picking point, it cannot be guaranteed that the plane represented by the first triangle is the same as the overall plane. Therefore, an iterative approach is needed to obtain the optimal picking result; see [link / reference]. Figure 6The process involves fitting multiple target triangles and search triangles obtained in the previous iteration to obtain a picking plane, and then obtaining the center point and plane normal vector of the picking plane. Based on the center point and plane normal vector of the picking plane, an octree is used to expand the search from the starting point to find more triangles that meet the conditions of being on the plane. This continues until the maximum number of iterations is reached, i.e., the fifth threshold is achieved; or, the difference between the center points of two new picking planes is not greater than the sixth threshold, and the dot product of the plane normal vectors of two new picking planes is not less than the seventh threshold. That is, the 3D coordinates of the center points of two consecutive picking planes do not differ by more than the sixth threshold, and the dot product of the plane normal vectors of two consecutive picking planes is not less than the seventh threshold. During calculation, the distance between two center points is not greater than the sixth threshold, and the dot product of the plane normal vectors is not less than the seventh threshold. All triangles obtained in the last search, along with the fitted center points and plane normal vectors, are output as the plane picked by the mouse point on the 3D model (target picking plane). See also Figure 7 The figure shows a schematic diagram of the target 3D model corresponding to the target item, and the diagonal part is the plane of the target 3D model that was picked up.

[0132] To further enhance understanding of the 3D model plane picking method based on position-coded octrees provided in this application, the following specific embodiment will be used to illustrate the 3D model plane picking method based on position-coded octrees provided in this application, which includes the following steps:

[0133] S11. According to the method described above, establish an octree database corresponding to different 3D models. For each octree database, the octree database includes the position information of each triangle face and the 3D coordinate information of each vertex among the three vertices that constitute each triangle face. Each object corresponds to a 3D model, which is composed of multiple triangle faces, and each triangle face includes at least one picking point.

[0134] After obtaining the two-dimensional coordinates of the target pickup point, its three-dimensional coordinates can be calculated from these coordinates. Then, using the method described above, the three-dimensional coordinates are converted into binary position codes. In the established octree database, the number of levels, the width of the cubes of the child nodes, the center coordinates of each child node, the width of the tree nodes formed by the child nodes, the center coordinates of the tree nodes, and the position code corresponding to each coordinate point are all known quantities. Since all triangular faces in the target 3D model are composed of three child nodes, the center coordinates of the three child nodes represent the coordinates of the three vertices of the triangular face. By using the position code of the target pickup point, the position codes of the three vertices of the triangular face closest to the target pickup point can be obtained. Through the conversion of these position codes, the three-dimensional coordinates of the three vertices of the triangular face closest to the target pickup point can finally be obtained.

[0135] S12, Obtain and display the target 3D model corresponding to the target item. The target 3D model includes multiple triangular faces. The target item is composed of multiple triangular faces, and each triangular face includes at least one pick point.

[0136] S13, Obtain the two-dimensional coordinates of the target pick point selected by the user in each pick point;

[0137] S14, Calculate the three-dimensional coordinates of the target pickup point based on the two-dimensional coordinates of the target pickup point;

[0138] S15. Based on the three-dimensional coordinates of the target pickup point and the preset octree database, obtain the triangle with the smallest distance to the target pickup point among the triangles in the octree database as the target triangle, and obtain the three-dimensional coordinates of each vertex of the three vertices that constitute the target triangle. The octree database includes the position information of each triangle in the multiple triangles corresponding to the target three-dimensional model, as well as the three-dimensional coordinates of each vertex of the three vertices corresponding to each triangle.

[0139] S16. Based on the target triangle, obtain the three-dimensional coordinates of each of the three vertices that constitute the target triangle. Based on the target triangle and the three-dimensional coordinates of each of the three vertices of the target triangle, calculate the plane normal vector corresponding to the target triangle and the three-dimensional coordinates of the center point of the target triangle.

[0140] S17. Calculate the target distance between the target picking point and the target triangle using the plane normal vector and the three-dimensional coordinates of the center point of the target triangle. If the target distance is not greater than the first threshold, the target triangle is determined as the search triangle. If the target distance is greater than the first threshold, the target triangle is re-determined based on the octree database until the target distance between the target picking point and the target triangle is not greater than the first threshold.

[0141] S18, Based on the search triangle, obtain a first number of target triangles from the octree database, where the planar distance between each target triangle and the search triangle is no greater than a second threshold.

[0142] S19, Fit the first number of target triangles and search triangles into a picking plane;

[0143] S20, based on the octree database, obtains the three-dimensional coordinates of the center point of the picking plane, as well as the plane normal vector corresponding to the picking plane;

[0144] S21, by using the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane, the verification distance between the target picking point and the picking plane is calculated;

[0145] S22, if the verification distance is greater than the third threshold, then a new target triangle is determined based on the octree database, and steps S16 to S19 are re-executed based on the new target triangle.

[0146] S23, if the verification distance is not greater than the third threshold, the picking plane is determined as the search verification triangle;

[0147] S24, based on the search verification triangle, obtain a second number of target verification triangles from the octree database. The planar distance between each target verification triangle and the search triangle in the second number of target verification triangles is not greater than the fourth threshold. The value of the second number is greater than or equal to the first number.

[0148] S25, Fit the second number of target verification triangles and search verification triangles into a new picking plane;

[0149] S26, repeat steps S23 to S25 multiple times, and obtain multiple different numbers of target verification triangles after each repetition. In every two consecutive repetitions of steps S23 to S25, the number of target verification triangles obtained in the later repetition is greater than or equal to the number of target verification triangles obtained in the previous repetition. When the number of repetitions is equal to the fifth threshold, the new picking plane corresponding to the last repetition is taken as the target picking plane.

[0150] Alternatively, when S23 to S25 are repeated twice consecutively, if the difference between the three-dimensional coordinates of the center points of the two new picking planes is no greater than the sixth threshold, and the dot product of the plane normal vectors of the two new picking planes is no less than the seventh threshold, then the new picking plane corresponding to the last one is taken as the target picking plane.

[0151] S27, based on an octree database, outputs the 3D coordinates of the center point of the target picking surface and the plane normal vector of the target picking surface.

[0152] Secondly, embodiments of this application provide a 3D model plane picking system based on a position-coded octree, applicable to any of the above-mentioned 3D model plane picking methods based on position-coded octrees, characterized in that it includes:

[0153] The display module is used to acquire and display the target 3D model corresponding to the target item. The target 3D model includes multiple triangular faces, the target item is composed of multiple triangular faces, and each triangular face includes at least one pick point.

[0154] The acquisition module is used to acquire the two-dimensional coordinates of the target pick point selected by the user at each pick point;

[0155] The calculation module is used to calculate the three-dimensional coordinates of the target pickup point based on its two-dimensional coordinates.

[0156] The triangle module is used to obtain the triangle with the smallest distance to the target pick point from the various triangles in the octree database based on the 3D coordinates of the target pick point and the preset octree database. It also obtains the 3D coordinates of each of the three vertices that make up the target triangle. The octree database includes the position information of each triangle in the multiple triangles corresponding to the target 3D model, as well as the 3D coordinates of each of the three vertices corresponding to each triangle.

[0157] The vector module is used to obtain the three-dimensional coordinates of each of the three vertices that make up the target triangle face, and to calculate the plane normal vector corresponding to the target triangle face and the three-dimensional coordinates of the center point of the target triangle face based on the target triangle face and the three-dimensional coordinates of each of the three vertices of the target triangle face.

[0158] The first threshold module is used to calculate the target distance between the target picking point and the target triangle using the plane normal vector and the three-dimensional coordinates of the center point of the target triangle. If the target distance is not greater than the first threshold, the target triangle is determined as the search triangle. If the target distance is greater than the first threshold, the target triangle is re-determined based on the octree database until the target distance between the target picking point and the target triangle is not greater than the first threshold.

[0159] The second threshold module is used to obtain a first number of target triangles from the octree database based on the search triangles, wherein the planar distance between each target triangle and the search triangle is not greater than the second threshold.

[0160] The determination module is used to fit a first number of target triangles and search triangles into a picking plane, and use the picking plane as the target picking surface;

[0161] The output module is used to output the 3D coordinates of the center point of the target picking surface and the plane normal vector of the target picking surface based on the octree database.

[0162] Optionally, the above-mentioned determining module may include:

[0163] The picking plane submodule is used to fit multiple target triangles and search triangles into a picking plane, and based on the octree database, obtain the three-dimensional coordinates of the center point of the picking plane, as well as the plane normal vector corresponding to the picking plane.

[0164] The verification submodule is used to calculate the verification distance between the target picking point and the picking plane by using the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane;

[0165] The third threshold submodule is used to determine a new target triangle based on the octree database if the verification distance is greater than the third threshold, and to re-execute the processing from the vector module to the determination module based on the new target triangle.

[0166] Optionally, the aforementioned third threshold submodule may include:

[0167] The search unit is used to determine the picking plane as the search verification triangle.

[0168] The search verification unit is used to obtain a second number of target verification triangles from the octree database based on the search verification triangles. The planar distance between each target verification triangle and the search triangle in the second number of target verification triangles is not greater than a fourth threshold, and the value of the second number is greater than or equal to the first number.

[0169] A fitting unit is used to fit the second number of target verification triangles and search verification triangles into a new picking plane;

[0170] The determining unit is used to determine the new picking plane as the target picking plane.

[0171] Optionally, the determining unit mentioned above may include:

[0172] The first sub-unit is used to repeatedly process the search unit to the fitting unit. After multiple repetitions, a number of target verification triangles are obtained. In each of the two consecutive repetitions of the search unit to the fitting unit process, the number of target verification triangles obtained in the second repetition is greater than or equal to the number of target verification triangles obtained in the previous repetition. When the number of repetitions is equal to the fifth threshold, the new picking plane corresponding to the last repetition is taken as the target picking plane.

[0173] The second sub-unit is used when, during the process of repeatedly searching the unit to fitting the unit, if the difference between the three-dimensional coordinates of the center points of the two new picking planes is no greater than the sixth threshold, and the dot product of the plane normal vectors of the two new picking planes is no less than the seventh threshold, then the new picking plane corresponding to the last time is taken as the target picking plane.

[0174] Optionally, the above system may also include:

[0175] The database module is used to build an octree database corresponding to the target 3D model. The octree database includes the position information of each triangle face in the target 3D model and the 3D coordinate information of each of the three vertices that make up each triangle face.

[0176] Optionally, the above database module may include:

[0177] The acquisition submodule is used to acquire the position information of each triangle face in the target 3D model, as well as the 3D coordinates of each of the three vertices that make up each triangle face;

[0178] The difference calculation submodule is used to obtain the three maximum differences of the target 3D model on the X-axis, Y-axis and Z-axis based on the 3D coordinates of each vertex of the three vertices of each triangle face;

[0179] The level count calculation submodule is used to calculate the level count of the octree database based on the three maximum differences and the preset voxel width in the octree database.

[0180] A submodule is created to store the position information of each triangle face and the three-dimensional coordinates of the three vertices that make up each triangle face into the corresponding level. Each level includes the three-dimensional coordinates of the three vertices of multiple triangle faces at different positions of the target three-dimensional model, so as to establish an octree database corresponding to the target three-dimensional model.

[0181] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the methods in the first aspect.

[0182] Fourthly, embodiments of this application provide a non-transitory computer-readable storage medium that stores computer instructions that cause a computer to perform any of the methods in the first aspect.

[0183] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within this application. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A method for plane picking of 3D models based on position-encoded octrees, characterized in that, Includes the following steps: S11, Obtain and display the target 3D model corresponding to the target item. The target 3D model includes multiple triangular faces. The target item is composed of multiple triangular faces, and each triangular face includes at least one picking point. S12, Obtain the two-dimensional coordinates of the target pickup point selected by the user in each of the pickup points; S13, calculate the three-dimensional coordinates of the target pickup point based on the two-dimensional coordinates of the target pickup point; S14. Based on the three-dimensional coordinates of the target pickup point and the preset octree database, obtain the triangle with the smallest distance to the target pickup point among the triangles in the octree database as the target triangle, and obtain the three-dimensional coordinates of each of the three vertices constituting the target triangle. The octree database includes the position information of each triangle in the multiple triangles corresponding to the target three-dimensional model, and the three-dimensional coordinates of each of the three vertices corresponding to each triangle. S15. Based on the target triangle, obtain the three-dimensional coordinates of each of the three vertices constituting the target triangle, and calculate the plane normal vector corresponding to the target triangle and the three-dimensional coordinates of the center point of the target triangle based on the target triangle and the three-dimensional coordinates of each of the three vertices of the target triangle. S16, using the plane normal vector and the three-dimensional coordinates of the center point of the target triangle, calculate the target distance between the target pickup point and the target triangle. If the target distance is not greater than a first threshold, determine the target triangle as the search triangle. If the target distance is greater than the first threshold, redetermine the target triangle based on the octree database until the target distance between the target pickup point and the target triangle is not greater than the first threshold. S17, based on the search triangle, obtain a first number of target triangles from the octree database, wherein the planar distance between each target triangle and the search triangle is not greater than a second threshold. S18, fit the first number of target triangles and the search triangles into a picking plane, and use the picking plane as the target picking surface; S19, Based on the octree database, output the three-dimensional coordinates of the center point of the target picking surface and the plane normal vector of the target picking surface; In a position-coded octree database, the principle of node encoding and decoding is to iteratively obtain the position-coded value based on the relationship between the preset width value and the center coordinates of the node, or to iteratively obtain the center point of the encoded node and the width of the child nodes based on the position code and the center of the root node. The encoding method is progressively layer by layer based on the width of each layer and the position of the already encoded points.

2. The method for 3D model plane picking based on position-encoded octrees according to claim 1, characterized in that, The step of fitting multiple target triangles and search triangles into a picking plane, and using the picking plane as the target picking plane, includes: S21, fit the multiple target triangles and the search triangles into a picking plane, and based on the octree database, obtain the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane; S22, using the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane, calculate the verification distance between the target picking point and the picking plane; S23, if the verification distance is greater than the third threshold, then a new target triangle is determined based on the octree database, and steps S15 to S18 are re-executed based on the new target triangle.

3. The method for plane picking of a 3D model based on a position-encoded octree according to claim 2, characterized in that, If the verification distance is not greater than the third threshold, it also includes: S24, the picking plane is determined as the search verification triangle; S25, based on the search verification triangle, obtain a second number of target verification triangles from the octree database, wherein the planar distance between each target verification triangle and the search triangle in the second number of target verification triangles is not greater than a fourth threshold, and the value of the second number is greater than or equal to the first number. S26, Fit the second number of target verification triangles and the search verification triangles into a new picking plane; S27, the new pickup plane is determined as the target pickup plane.

4. The method for three-dimensional model plane picking based on position-encoded octrees according to claim 3, characterized in that, The step of determining the new pickup plane as the target pickup plane includes: Repeat steps S24 to S26 multiple times, and obtain multiple different numbers of target verification triangles after each repetition. In every two consecutive repetitions of steps S24 to S26, the number of target verification triangles obtained in the later repetition is greater than or equal to the number of target verification triangles obtained in the previous repetition. When the number of repetitions is equal to the fifth threshold, the new picking plane corresponding to the last repetition is taken as the target picking plane. Alternatively, when S24-S26 is repeated twice consecutively, if the difference between the three-dimensional coordinates of the center points of the two new picking planes is not greater than the sixth threshold, and the dot product of the plane normal vectors of the two new picking planes is not less than the seventh threshold, then the new picking plane corresponding to the last time is taken as the target picking surface.

5. The method for plane picking of a 3D model based on a position-encoded octree according to any one of claims 1-4, characterized in that, The method further includes: Based on the target 3D model, an octree database corresponding to the target 3D model is established. The octree database includes the position information of each triangle face in the target 3D model and the 3D coordinate information of each vertex of the three vertices constituting each triangle face.

6. The method for three-dimensional model plane picking based on position-encoded octrees according to claim 5, characterized in that, The step of establishing an octree database corresponding to the target 3D model includes: Obtain the position information of each triangle face in the target 3D model, as well as the 3D coordinates of each vertex among the three vertices constituting each triangle face; Based on the three-dimensional coordinates of each vertex of each triangle, the three maximum differences of the target three-dimensional model on the X-axis, Y-axis and Z-axis are obtained; The number of levels in the octree database is calculated based on the three maximum differences and the preset voxel width in the octree database. The position information of each triangle face and the three-dimensional coordinates of the three vertices constituting each triangle face are stored in the corresponding level. Each level includes the three-dimensional coordinates of the three vertices of multiple triangle faces at different positions of the target three-dimensional model, so as to establish an octree database corresponding to the target three-dimensional model.

7. A 3D model plane picking system based on a position-coded octree, applied to any of the above-described 3D model plane picking methods based on a position-coded octree, characterized in that, include: The display module is used to acquire and display the target 3D model corresponding to the target item. The target 3D model includes multiple triangular faces, the target item is composed of multiple triangular faces, and each triangular face includes at least one picking point. The acquisition module is used to acquire the two-dimensional coordinates of the target pickup point selected by the user in each of the pickup points; The calculation module is used to calculate the three-dimensional coordinates of the target pickup point based on the two-dimensional coordinates of the target pickup point; The triangular face module is used to obtain the triangular face with the smallest distance to the target pick point among all the triangular faces in the octree database based on the three-dimensional coordinates of the target pick point and the preset octree database, and to obtain the three-dimensional coordinates of each of the three vertices that constitute the target triangular face. The octree database includes the position information of each triangular face among the multiple triangular faces corresponding to the target three-dimensional model, and the three-dimensional coordinates of each of the three vertices corresponding to each triangular face. The vector module is used to obtain the three-dimensional coordinates of each of the three vertices constituting the target triangle based on the target triangle, and to calculate the plane normal vector corresponding to the target triangle and the three-dimensional coordinates of the center point of the target triangle based on the target triangle and the three-dimensional coordinates of each of the three vertices of the target triangle. The first threshold module is used to calculate the target distance between the target pickup point and the target triangle using the plane normal vector and the three-dimensional coordinates of the center point of the target triangle. If the target distance is not greater than the first threshold, the target triangle is determined as the search triangle. If the target distance is greater than the first threshold, the target triangle is re-determined based on the octree database until the target distance between the target pickup point and the target triangle is not greater than the first threshold. The second threshold module is used to obtain a first number of target triangles from the octree database based on the search triangles, wherein the planar distance between each target triangle and the search triangle is not greater than the second threshold. The determining module is used to fit the first number of target triangles and the search triangles into a picking plane, and to use the picking plane as the target picking surface; The output module is used to output the three-dimensional coordinates of the center point of the target picking surface and the plane normal vector of the target picking surface based on the octree database.

8. The 3D model plane picking system based on position-encoded octree according to claim 7, characterized in that, The determining module includes: The picking plane submodule is used to fit multiple target triangles and search triangles into a picking plane, and based on the octree database, obtain the three-dimensional coordinates of the center point of the picking plane, as well as the plane normal vector corresponding to the picking plane; The verification submodule is used to calculate the verification distance between the target picking point and the picking plane using the three-dimensional coordinates of the center point of the picking plane and the plane normal vector corresponding to the picking plane. The third threshold submodule is used to determine a new target triangle based on the octree database if the verification distance is greater than the third threshold, and to re-execute the processing from the vector module to the determination module based on the new target triangle.

9. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method of any one of claims 1-6.

10. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions that cause the computer to perform the method of any one of claims 1-6.