Boolean operation method, device, computer equipment and storage medium

By triangulating the model's intersection segment set and deleting preset triangles, the problem of poor model quality in traditional Boolean operations is solved, and high-quality model generation without breaking surfaces and errors is achieved.

CN113902870BActive Publication Date: 2025-09-02SHENZHEN SHUMA ELECTRONICS TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111061661.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-10
Publication Date
2025-09-02
Estimated Expiration
2041-09-10

AI Technical Summary

Technical Problem

Traditional Boolean operation methods are prone to surface breaking or erroneous results in graphics processing, resulting in poor model quality.

Method used

By obtaining the model's intersecting line segment set for triangulation, the divided triangle is performed for Boolean operation, and deleting triangles of preset types are deleted to obtain the manifold model.

Benefits of technology

The quality of Boolean calculation results is improved, ensuring that the model has no broken surfaces and no error results, and the model is of good quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113902870B_ABST
    Figure CN113902870B_ABST
Patent Text Reader

Abstract

This application relates to a Boolean operation method, apparatus, computer device, and storage medium. The method comprises: obtaining a first model and a second model; obtaining a set of intersecting line segments resulting from the intersection of the first and second models; performing triangulation based on the set of intersecting line segments to obtain triangular segments; performing a Boolean operation on the triangular segments to obtain a Boolean operation result; and deleting triangles of a preset type obtained from the Boolean operation result to obtain a manifold model. The method of this application can improve the quality of the model obtained after the Boolean operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer computing, and in particular to a Boolean operation method, device, computer equipment and storage medium. Background Art

[0002] Boolean operations are digitally symbolized logical deduction methods. These operations are used in graphics processing to create new shapes by combining simple basic shapes. They have evolved from two-dimensional Boolean operations to three-dimensional Boolean operations. Traditional Boolean operations generate new shapes by performing intersection, difference, and union operations on two or more objects. However, these methods can produce fragmented or erroneous results, resulting in poor quality models. Summary of the Invention

[0003] Based on this, it is necessary to provide a Boolean operation method, device, computer equipment and storage medium to address the above technical problems.

[0004] A Boolean operation method, comprising:

[0005] Obtain a first model and a second model;

[0006] Obtaining a set of intersecting line segments resulting from the intersection of the first model and the second model;

[0007] Perform triangulation according to the set of intersecting line segments to obtain triangulated triangles;

[0008] Performing a Boolean operation on the subdivided triangles to obtain a Boolean operation result;

[0009] Triangles of a preset type obtained according to the Boolean operation result are deleted to obtain a manifold model.

[0010] A Boolean operation device, comprising:

[0011] A model acquisition module, configured to acquire a first model and a second model;

[0012] A line segment set acquisition module, configured to acquire an intersecting line segment set obtained by intersecting the first model and the second model;

[0013] A triangulation module, configured to perform triangulation according to the set of intersecting line segments to obtain triangulated triangles;

[0014] An operation module, configured to perform a Boolean operation on the subdivided triangles to obtain a Boolean operation result;

[0015] The processing module is used to delete the triangles of the preset type obtained according to the Boolean operation result to obtain a manifold model.

[0016] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of various method embodiments when executing the computer program.

[0017] A computer-readable storage medium stores a computer program, which implements the steps of various method embodiments when executed by a processor.

[0018] The above-mentioned Boolean operation method, device, computer equipment and storage medium obtain the first model and the second model and the set of intersecting line segments obtained by the intersection, perform triangulation based on the set of intersecting line segments to obtain the triangular triangles after triangulation, perform Boolean operation based on the triangular triangles after triangulation to obtain the Boolean operation result. Since the quality of the Boolean operation result obtained at this time is poor, the preset type of triangles in the Boolean operation result are deleted, that is, after obtaining the Boolean operation result, post-processing is performed to obtain a manifold model, so that the model obtained after the Boolean operation has no broken surfaces, no erroneous results, and good model quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 1 is a flow chart of a Boolean operation method in one embodiment;

[0020] Figure 2 A schematic diagram of obtaining intersecting fallback triangles in one embodiment;

[0021] Figure 3 is a schematic diagram of overlapping triangles in one embodiment;

[0022] Figure 4 A schematic diagram of a process for obtaining a set of intersecting line segments obtained by intersecting a first model and a second model in one embodiment;

[0023] Figure 5 is a structural block diagram of a Boolean operation device in one embodiment;

[0024] Figure 6 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0025] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0026] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0027] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.

[0028] In addition, in the present invention, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. Except for the specific descriptions of the present invention, "first" and "second" are used to represent different things. For example, although the first model and the second model are both models, the first model and the second model are not the same model. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0029] The Boolean operation method provided in this application can be applied to a computer device. The computer device may be, but is not limited to, various personal computers, laptop computers, smartphones, tablet computers, and portable wearable devices. The computer device may also be a server. The server may be implemented as a standalone server or a server cluster consisting of multiple servers.

[0030] In one embodiment, Figure 1 As shown, a Boolean operation method is provided, which is described by taking the application of the method on a computer device as an example, and includes the following steps:

[0031] Step 102: Acquire a first model and a second model.

[0032] The first model and the second model are not the same model. Both the first model and the second model can be in STL (StereoLithography) format. STL (StereoLithography) is a file format used in stereolithography computer-aided design software. It is used to describe the surface geometry of three-dimensional objects.

[0033] Specifically, the first model and the second model are independent models. The first model and the second model can be models of any shape, such as, but not limited to, spherical, square, or animal shapes. The first model and the second model are specifically pre-completed models. The first model and the second model are specifically three-dimensional models. Before the computer device acquires the first model and the second model, the first model and the second model can be precision-controlled.

[0034] Step 104: Obtain a set of intersecting line segments resulting from the intersection of the first model and the second model.

[0035] The intersecting line segment set may include multiple intersecting rings. Each intersecting ring includes at least three intersecting line segments. An intersecting line segment refers to a line segment where the first model and the second model intersect. It is understood that the intersecting line segment set may also directly include multiple intersecting line segments.

[0036] Specifically, the computer device may construct a BSP tree or a KD tree based on the triangle set in the first model and the triangles in the second model, and determine intersecting triangle pairs using the BSP tree or KD tree with the triangle information. The computer device determines a set of intersecting line segments resulting from the intersection of the first model and the second model based on the intersecting triangle pairs.

[0037] Step 106: perform triangulation based on the set of intersecting line segments to obtain triangulated triangles.

[0038] Specifically, the triangulation can be performed using a (Delaunay) triangulation algorithm.

[0039] Specifically, the computer device triangulates the triangle containing the intersecting line segments in the set of intersecting line segments to obtain a triangulated triangle, and replaces the original triangle with the triangulated triangle.

[0040] Step 108: Perform a Boolean operation on the divided triangles to obtain a Boolean operation result.

[0041] The Boolean operation result refers to a combination of the first model and the second model after at least one of an intersection operation, a union operation, and a difference operation. The Boolean operation result may retain triangles of the first model and the second model.

[0042] Specifically, since the triangles after the meshing can be derived from triangles in the first model or from triangles in the second model, the computer device needs to update the triangle set of the first model and the triangle set of the second model based on the meshed triangles. The computer device can use the ray method to determine the internal and external states of each triangle in the first and second models. The computer device obtains the type of Boolean operation and performs the Boolean operation based on the type of Boolean operation and the internal and external states of each triangle to obtain a Boolean operation result.

[0043] Step 110 , deleting triangles of a preset type obtained according to the Boolean operation result to obtain a manifold model.

[0044] The manifold model refers to a model in which any edge corresponds to only two triangles and there are no overlapping triangles.

[0045] Specifically, the computer device deletes triangles of a preset type obtained based on the Boolean operation results to obtain a manifold model. The preset triangle types include at least one of a first type of triangle and a second type of triangle. The first type of triangle refers to a triangle directly obtained based on the Boolean operation results, such as at least one of a repeated triangle and a free triangle. The second type of triangle refers to a triangle obtained by merging based on the Boolean operation results, such as at least one of an intersecting degenerate triangle and an overlapping degenerate triangle.

[0046] A degenerate triangle is one with an area of ​​zero. An intersecting degenerate triangle is one created by moving the vertices of a triangle on the target intersecting segment to the endpoints of the target intersecting segment. An overlapping degenerate triangle is one created by moving one vertex of an overlapping triangle to a vertex of another triangle, resulting in an area of ​​zero.

[0047] Repeating triangles refer to at least two identical triangles. Identical triangles refer to triangles whose three vertices correspond one to one, and the distance between the corresponding vertices is less than a preset distance.

[0048] A free triangle is a triangle in which at least two sides correspond to only one triangle of the model itself. The above-mentioned Boolean operation method obtains the first model and the second model and the set of intersecting line segments obtained by their intersection, performs triangulation based on the set of intersecting line segments to obtain the triangular triangles after triangulation, and performs Boolean operation on the triangular triangles after triangulation to obtain the Boolean operation result. Since the quality of the Boolean operation result obtained at this time is poor, the triangles of the preset type obtained according to the Boolean operation result are deleted. That is, after obtaining the Boolean operation result, post-processing is performed to obtain a manifold model, so that the model obtained after the Boolean operation has no broken surfaces, no erroneous results, and good model quality. In addition, by deleting the triangles of the preset type obtained according to the Boolean operation result, the model can still obtain a manifold model after multiple consecutive Boolean operations.

[0049] In one embodiment, triangles of a preset type obtained according to the result of a Boolean operation are deleted, including: determining a target intersecting line segment corresponding to at least three triangles from a set of intersecting line segments according to the result of the Boolean operation; moving the vertices of the triangles on the target intersecting line segment to the endpoints of the target intersecting line segment to obtain intersecting degenerate triangles; and deleting the intersecting degenerate triangles.

[0050] The Boolean operation result retains the triangle set of the first model and the triangle set of the second model. The target intersecting line segment refers to a line that serves as the edge of at least three triangles. The endpoints of the target intersecting line segment refer to the endpoints of the line.

[0051] Specifically, the computer device determines a target intersecting line segment corresponding to at least three triangles from the set of intersecting line segments based on the triangles in the Boolean operation result. The computer device moves the vertices of the triangles on the target intersecting line segment, along with the corresponding triangles, to the endpoints of the target intersecting line segment to obtain an intersecting degenerate triangle. The vertices of the triangles on the target intersecting line segment can specifically be moved toward the endpoint of the target intersecting line segment closest to the vertices of the triangle. In the process of moving the vertices of the triangles, the triangles associated with the vertices of the triangles also move with the vertices of the triangles.

[0052] In this embodiment, Figure 2 FIG. 1 is a schematic diagram of obtaining intersecting fallback triangles in one embodiment. Figure 2 (a) contains three triangles, and the target intersection line segment is AE. There is a vertex C of the triangle on AE. Then move point C to point E, and we get Figure 2 Point C' in (b) coincides with point E. Figure 2 (b) Triangle ABC now becomes triangle AB'E (C'). Triangle C'DE is an intersecting degenerate triangle. Delete triangle C'DE, leaving triangle AB'E. This means that one edge corresponds to two triangles, resulting in a manifold model.

[0053] In this embodiment, since the manifold model refers to a model in which one edge corresponds to only two triangles, when a target intersecting line segment corresponding to at least three triangles appears, it indicates that the Boolean operation result is wrong. Therefore, by determining the target intersecting line segment corresponding to at least three triangles from the intersecting line segment set based on the Boolean operation result, moving the vertices of the triangles on the target intersecting line segment to the end points of the target intersecting line segment, obtaining intersecting degenerate triangles, and deleting the intersecting degenerate triangles, the redundant triangles can be deduplicated, thereby improving the quality of the model after the Boolean operation obtained by the Boolean operation.

[0054] In one embodiment, triangles of a preset type obtained according to a Boolean operation result are deleted, including: obtaining the normal vector of each triangle in the Boolean operation result; determining overlapping triangles that meet a preset normal vector condition based on the normal vector of each triangle; offsetting the vertex of one of the overlapping triangles toward the remaining vertices to obtain overlapping degenerate triangles; and deleting the overlapping degenerate triangles.

[0055] Overlapping triangles are defined as triangles that are coplanar, have a common edge, and have overlapping areas (i.e., the overlapping area is greater than 0). Overlapping degenerate triangles are defined as triangles with an area of ​​0.

[0056] The pre-set normal vector condition means that at least two triangles have the same normal vector or opposite normal vectors. The same or opposite normal vectors depend on how the normal vector is calculated.

[0057] Specifically, the computer device obtains the normal vectors of each triangle in the Boolean operation result. Based on the normal vectors of each triangle, the computer device determines overlapping triangles that meet a preset normal vector condition. Because other errors may occur during vertex movement, the computer device may attempt to shift the vertex of one of the overlapping triangles toward the vertices of the remaining triangles multiple times until an overlapping degenerate triangle is obtained.

[0058] In this embodiment, Figure 3 FIG. 1 is a schematic diagram of overlapping triangles in one embodiment. Figure 3 In (a), triangles ABC and BCD are located in the same plane. Furthermore, triangles ABC and BCD overlap. By shifting point D toward point C or toward point B, the overlapping degenerate triangle BCD' can be obtained. Figure 3 In the figure, point D is shifted to point C, and the overlapping degenerate triangle BCD' is deleted to obtain Figure 3 (b), namely triangle ABC. The computer device can specifically enumerate the results of all point offsets and ultimately adopt a method that can obtain overlapping degenerate triangles.

[0059] In this embodiment, since there may be coplanar parts with overlapping areas in the Boolean operation result, the normal vector of each triangle in the Boolean operation result is obtained, and the overlapping triangles that meet the preset normal vector conditions are determined based on the normal vector of each triangle. The vertex of one triangle in the overlapping triangles is offset toward the other vertices to obtain overlapping degenerate triangles, and the overlapping degenerate triangles are deleted. This can effectively remove the overlapping triangles and improve the accuracy of the model obtained by the Boolean operation.

[0060] In one embodiment, triangles of a preset type obtained according to a Boolean operation result are deleted, including: when identical repeated triangles exist in the Boolean operation result, one of the repeated triangles is retained and the remaining triangles are deleted.

[0061] The repeated triangles refer to at least two identical triangles. The identical triangles refer to triangles whose three vertices correspond one to one and the distance between the corresponding vertices is less than a preset distance.

[0062] Specifically, when the computer device detects that there are identical repeated triangles in the Boolean operation result, any one of the repeated triangles is retained and the remaining triangles in the repeated triangles are deleted.

[0063] In this embodiment, duplicate triangles may appear in the Boolean operation result. By retaining one of the duplicate triangles and deleting the remaining triangles, the triangles in the Boolean operation result can be deduplicated, thereby improving the quality of the model obtained after the Boolean operation.

[0064] In one embodiment, triangles of a preset type obtained according to a Boolean operation result are deleted, including: determining the number of triangles corresponding to the sides of each triangle in the Boolean operation result; determining free triangles in which at least two sides correspond to only one triangle according to the number of triangles corresponding to the sides of each triangle; and deleting the free triangles.

[0065] Among them, a free triangle is a triangle whose two sides or three sides only correspond to one triangle of itself.

[0066] Specifically, the computer device determines the number of triangles corresponding to the edges of each triangle in the Boolean operation result. Based on the number of triangles corresponding to the edges of each triangle, the computer device determines free triangles in which at least two edges of the same triangle correspond to only one triangle. The computer device deletes the free triangles.

[0067] For example, a computer device determines the number of triangles corresponding to AB, AC, and BC in triangle ABC. If side AB corresponds to only one triangle, ABC, and side AC also corresponds to only one triangle, ABC, and side BC corresponds to both triangle ABC and triangle BCD, then triangle ABC is effectively a free triangle. The computer device deletes the free triangle.

[0068] In this embodiment, since the Boolean operation result is obtained from a three-dimensional model, the manifold model is that one edge corresponds to only two triangles, so the free triangle whose at least two edges only correspond to one triangle of itself is an erroneous triangle. Therefore, by determining the number of triangles corresponding to the edges of each triangle in the Boolean operation result, and according to the number of triangles corresponding to the edges of each triangle, determining the free triangle whose at least two edges each correspond to one triangle, and deleting the free triangles, it is possible to delete the redundant triangles that do not conform to the manifold model, thereby improving the quality of the model obtained after the Boolean operation.

[0069] In one embodiment, a Boolean operation is performed based on the subdivided triangles to obtain a Boolean operation result, including: updating the triangle set of the first model and the triangle set of the second model based on the subdivided triangles; determining the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model; and performing a Boolean operation based on the type of Boolean operation and the internal and external states of each triangle to obtain a Boolean operation result.

[0070] The inside-outside state of a triangle indicates whether it is located in the intersection of the first and second models. An inside-outside triangle is one that is spatially inside the space of the other model. An outside-outside triangle is one that is outside the intersecting bounding box. Boolean operations include intersection, difference, and union.

[0071] Specifically, since the triangular portion after the split may be part of the first model or the second model, the computer device updates the triangle set of the first model and the triangle set of the second model based on the split triangle. The computer device may use a ray method or other method to determine the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model. The computer device obtains the type of Boolean operation. When the type of Boolean operation is an intersection operation, the computer device saves triangles whose internal and external states are internal states. When the type of Boolean operation is a difference operation, the computer device saves triangles in the external state in the first model and triangles in the internal state in the second model. When the type of Boolean operation is a union operation, the computer device retains triangles whose internal and external states are external states. The computer device thus obtains the Boolean operation result.

[0072] In this embodiment, the triangle set of the first model and the triangle set of the second model are updated based on the split triangles, the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model are determined, and Boolean operations are performed based on the type of Boolean operation and the internal and external states of each triangle, so that the Boolean operation results can be accurately obtained.

[0073] In one embodiment, determining the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model includes:

[0074] Step (a1): performing connectivity judgment on each triangle in the triangle set of the first model and the triangle set of the second model to obtain a triangle combination with a connectivity relationship.

[0075] Specifically, the computer device uses a Union-Find algorithm to determine the connectivity of adjacent triangles in the triangle set of the first model and the triangle set of the second model, obtaining at least one connected triangle combination. For example, for two adjacent triangle IDs (such as 10 and 11) whose shared edges are non-intersecting loops, the algorithm Union(10, 11) is performed. This allows most triangles to be merged into several combinations. Finally, simply determining the internal and external state of a triangle within a combination can determine the internal and external state of the entire combination.

[0076] In this embodiment, the computer device can select any triangle in the external state to perform connectivity judgment, and then all triangle combinations are in the external state, thereby reducing the time for calculating the label of the first triangle and improving the calculation stability.

[0077] Step (a2), determine the internal and external states of the triangle combination.

[0078] Specifically, the computer device may obtain the inside-outside labels of the boundary triangles and use the inside-outside state represented by the inside-outside labels of the boundary triangles corresponding to the triangle combination as the inside-outside state of the triangle combination. Alternatively, the computer device may determine the inside-outside state of the corresponding triangle combination based on the inside-outside state of the triangles selected for connectivity determination.

[0079] Step (a3): taking the internal and external states of the triangle combination as the internal and external states of the triangles in the corresponding triangle combination.

[0080] Specifically, the computer device uses the internal and external states of the triangle combination as the internal and external states of the triangles in the triangle combination.

[0081] Step (a4), obtain the target triangle that is not in the triangle combination.

[0082] Specifically, since some triangles may still have their inside and outside states not determined after the connectivity determination, the computer device obtains a target triangle that is not in the triangle combination.

[0083] Step (a5): traverse the surrounding triangles of the target triangle until the boundary triangle is reached.

[0084] The surrounding triangles of the target triangle refer to the mutually adjacent triangles surrounding the target triangle. The boundary triangles refer to the triangles located on the inner and outer boundaries. For example, a triangle located in the intersection area of ​​the first model and the second model is a triangle in the inner state, while a triangle not located in the intersection area is a triangle in the outer state. The boundary triangle is then a triangle located at the intersection boundary of the first model and the second model. Specifically, the computer device traverses the surrounding triangles of the target triangle until it reaches the boundary triangle.

[0085] Step (a6), obtain the inside and outside triangle labels of the boundary triangle.

[0086] Among them, the inside and outside labels of the boundary triangles are manually pre-labeled.

[0087] Step (a7): determine the inside and outside states of the target triangle based on the inside and outside labels of the triangle.

[0088] Specifically, the computer uses the inside-outside state represented by the inside-outside label of the triangle as the inside-outside state of the target triangle.

[0089] In this embodiment, connectivity judgment is performed on each triangle in the triangle set of the first model and the triangle set of the second triangle, and each triangle combination with connectivity is obtained. The internal and external states of each triangle combination are determined, and the internal and external states of the triangle combination are used as the internal and external states of the triangles in the triangle combination. The internal and external states of most triangles can be quickly obtained through connectivity judgment; by obtaining a target triangle that is not in the triangle combination, traversing the surrounding triangles of the target triangle until the boundary triangle is traversed, obtaining the triangle internal and external labels of the boundary triangle, and determining the triangle internal and external states of the target triangle according to the triangle internal and external labels, the speed of internal and external state judgment can be improved, while ensuring that the internal and external states of the triangles in the first model and the second model are judged, thereby improving the accuracy of Boolean operations.

[0090] In one embodiment, Figure 4 FIG. 1 is a flow chart of obtaining a set of intersecting line segments obtained by intersecting a first model and a second model in one embodiment, including:

[0091] Step 402: Obtain a first bounding box of the first model and a second bounding box of the second model.

[0092] The bounding box algorithm is an algorithm for finding the optimal bounding space. The basic idea is to approximate a complex set of objects with a slightly larger geometric object with simpler properties. The bounding box can be any shape, including square and circular.

[0093] Specifically, the first bounding box is the bounding box corresponding to the first model, and the second bounding box is the bounding box corresponding to the second model.

[0094] Step 404: determine an intersecting bounding box obtained by intersecting the first bounding box and the second bounding box.

[0095] Specifically, the intersecting bounding box refers to the bounding box of the intersection area of ​​the first bounding box and the second bounding box. For example, the first bounding box is boxA, the second bounding box is boxB, and the intersecting bounding box is BoxIntersect.

[0096] Step 406 : Determine a first triangle bounding box for each triangle in the first model, and determine a second triangle bounding box for each triangle in the second model.

[0097] Specifically, the first model includes a plurality of first triangles. The computer device obtains a first triangle bounding box for each triangle in the first model. The second model includes a plurality of second triangles. The computer device obtains a second triangle bounding box for each triangle in the second model.

[0098] Step 408: Obtain a first triangle index corresponding to the first triangle bounding box that intersects with the intersecting bounding box.

[0099] The first triangle index and the second triangle index may both be stored in an array, which can make the reading speed faster.

[0100] Specifically, the first triangle index refers to the index of the triangle corresponding to the first triangle bounding box that intersects with the intersecting bounding box. The first triangle bounding box that intersects with the intersecting bounding box can be regarded as a bounding box that may intersect with the second triangle bounding box.

[0101] For example, the computer device obtains a first triangle index taList corresponding to the first triangle bounding box intersected with BoxIntersect.

[0102] Step 410: Obtain a second triangle index corresponding to a second triangle bounding box that intersects with the intersecting bounding box.

[0103] Specifically, the second triangle index refers to the index of the triangle corresponding to the second triangle bounding box that intersects the intersecting bounding box. The second triangle bounding box that intersects the intersecting bounding box can be regarded as a bounding box that may intersect with the second triangle bounding box.

[0104] For example, the computer device obtains a second triangle index tbList corresponding to the second triangle bounding box intersected with BoxIntersect.

[0105] Step 412 : Determine a triangle bounding box pair where a first triangle bounding box corresponding to the first triangle index intersects with a second triangle bounding box corresponding to the second triangle index.

[0106] One of the triangle bounding boxes is the first triangle bounding box corresponding to the first triangle index, and the other is the second triangle bounding box corresponding to the second triangle index. The first triangle index can be used to indicate the position of the first triangle, or the position of the first triangle bounding box. The second triangle index can be used to indicate the position of the second triangle, or the position of the second triangle bounding box.

[0107] Specifically, the computer device determines a pair of triangle bounding boxes where a first triangle bounding box corresponding to a first triangle index intersects a second triangle bounding box corresponding to a second triangle index. For example, if the first triangle indices are 1 and 2, the triangle bounding box corresponding to 1 is a, and the bounding box corresponding to 2 is b; and if the second triangle indices are 8 and 9, the triangle bounding box corresponding to 8 is h, and the triangle bounding box corresponding to 9 is i, then the computer performs intersection determinations on a and h, a and i, b and h, and b and i to obtain the triangle bounding box pairs ai and bh.

[0108] In this embodiment, when the number of first triangle indices and second triangle indices is less than a preset number, an intersection judgment is performed on the first triangle bounding box corresponding to the first triangle index and the second triangle bounding box corresponding to the second triangle index to obtain an intersecting triangle bounding box pair.

[0109] Step 414: Obtain the intersecting triangle pairs corresponding to each triangle bounding box pair.

[0110] For example, all bounding boxes in taList and tbList are intersected. If the bounding box of a triangle in taList intersects with the bounding box of a triangle in tbList, the intersecting triangle pair IntersectSet is recorded.

[0111] Step 416: Obtain the intersecting line segments of each intersecting triangle pair, and obtain a set of intersecting line segments obtained by intersecting the first model and the second model.

[0112] Specifically, the computer device obtains intersecting line segments of each intersecting triangle pair among a plurality of intersecting triangle pairs, and obtains an intersecting line segment set obtained by the intersection of the first model and the second model.

[0113] In this embodiment, the intersecting bounding box obtained by the intersection of the first bounding box and the second bounding box is first determined, the first triangle index and the second triangle index that may be located in the intersection area of ​​the model are filtered out through the intersecting bounding box, and then the triangles corresponding to these indexes are used to filter out the triangle bounding box pairs, thereby obtaining a set of intersecting line segments. Through multiple screening, the complexity of the calculation can be reduced and the efficiency of Boolean operations can be improved.

[0114] In one embodiment, the intersecting triangle pair includes a first intersecting triangle and a second intersecting triangle;

[0115] Get the intersecting line segments of each intersecting triangle pair, including:

[0116] For each intersecting triangle pair, determine if the three sides of the first intersecting triangle intersect with the second intersecting triangle, and determine if the three sides of the second intersecting triangle intersect with the first intersecting triangle;

[0117] When the number of at least one of the first intersection point coordinates and the second intersection point coordinates meets the preset number condition, the intersection line segment obtained by the intersection of the first model and the second model is obtained according to at least one of the first intersection point coordinates and the second intersection point coordinates; the first intersection point coordinates are obtained by judging the intersection of the three sides of the first intersection triangle with the second intersection triangle; the second intersection point coordinates are obtained by judging the intersection of the three sides of the second intersection triangle with the first intersection triangle.

[0118] The first intersection point coordinates and the second intersection point coordinates do not necessarily exist at the same time. For example, if triangle ABC and triangle DEF are not coplanar, and triangle DEF passes through triangle ABC, then only the first intersection point coordinates or the second intersection point coordinates exist.

[0119] Specifically, for each intersecting triangle pair, the computer device determines whether the three sides of the first intersecting triangle intersect with the second intersecting triangle, and determines whether the three sides of the second intersecting triangle intersect with the first intersecting triangle.

[0120] The intersection determination results for the three sides of the first intersecting triangle and the second intersecting triangle may be 0, 1, or 2 first intersection point coordinates. Similarly, the intersection determination results for the three sides of the second intersecting triangle and the first intersecting triangle may be 0, 1, or 2 second intersection point coordinates. Therefore, in this embodiment, there may be cases where there are no first intersection point coordinates or no second intersection point coordinates.

[0121] The preset number condition may be that the number of intersection point coordinates is 2. The number of at least one of the first intersection point coordinates and the second intersection point coordinates satisfying the preset number condition includes the number of the first intersection point coordinates being 2, the number of the second intersection point coordinates being two, or the number of the first intersection point coordinates and the number of the second intersection point coordinates being two.

[0122] For example, extract a triangle pair from the IntersectSet, and then obtain the three vertex information of the two triangles from the first model and the second model respectively. Use the three edges of the first triangle in the first model and the second triangle in the second model to intersect and calculate the intersection point, and then use the three edges of the second triangle in the second model and the first triangle in the first model to intersect and calculate the intersection point. The following situation will occur:

[0123] ① If there is no intersection, it means the two triangles do not intersect.

[0124] ② If there is only one intersection point, ignore it. (Duplicates need to be removed. That is, if two intersection points are calculated six times above, but their coordinates are the same, they are considered to be one intersection point. Two triangles can have at most two intersection points if they are not coplanar.)

[0125] ③ If there are two unique intersection points, record the line segment in the line segment set. Add the line segment information to the two triangles for subsequent triangulation.

[0126] In this embodiment, since in the three-dimensional model, the side of the first intersecting triangle intersects with the second intersecting triangle, which is different from the side of the second intersecting triangle intersecting with the first intersecting triangle, it is necessary to make judgments separately to obtain a set of intersecting line segments and improve the accuracy of the Boolean operation results.

[0127] In one embodiment, when it is detected that the intersecting line segment of a pair of intersecting triangles is located on a triangle edge, the triangle edge is used as the intersecting line segment. That is, for a pair of intersecting triangles, if the intersecting line segment of the pair of intersecting triangles is not located on a triangle edge, the three edges of the first intersecting triangle are judged to intersect with the second intersecting triangle, and the three edges of the second intersecting triangle are judged to intersect with the first intersecting triangle.

[0128] In one embodiment, the intersecting triangle pairs include a first intersecting triangle and a second intersecting triangle. The Boolean operation method further includes: when the first intersecting triangle and the second intersecting triangle are coplanar, moving the first model or the second model by a preset distance; and performing the steps of obtaining intersecting line segments of each intersecting triangle pair to obtain an intersecting line segment set resulting from the intersection of the first model and the second model.

[0129] The preset distance is specifically a value pre-configured in the computer device. The preset distance can be a relatively small value. The specific value of the preset distance can be less than the accuracy of the model, such as 0.001.

[0130] Specifically, when the first intersecting triangle and the second intersecting triangle are coplanar, the computer device moves the first model or the second model by a preset distance. After moving the preset distance, the intersecting triangle pairs of the first model and the second model do not change significantly, so the intersecting triangle pairs can be retained. However, since the intersecting line segments undergo certain transformations due to the movement of the models, the previously obtained intersecting line segment set and the information recorded within the triangles are deleted, and the step of obtaining the intersecting line segments of each intersecting triangle pair is re-executed to obtain the intersecting line segment set resulting from the intersection of the first model and the second model.

[0131] In this embodiment, when there is a situation where the triangles are coplanar, that is, when the first intersecting triangle and the second intersecting triangle are coplanar, moving the first model or the second model by a preset distance can effectively avoid the situation where the triangles are coplanar, and there is no need to redetermine the intersecting triangle pairs. It is sufficient to re-execute the step of determining the intersecting line segments obtained by the intersection of the first model and the second model according to each intersecting triangle pair to obtain the intersecting line segment set. This can reduce the Boolean operation time while ensuring the accuracy of the model.

[0132] In one embodiment, determining a triangle bounding box pair where a first triangle bounding box corresponding to a first triangle index and a second triangle bounding box corresponding to a second triangle index intersect includes:

[0133] When at least one of the number of the first triangle indexes and the number of the second triangle indexes is greater than or equal to a preset number, dividing the bounding box corresponding to the first triangle index into a first preset number of first triangle bounding box sets;

[0134] Divide the bounding box corresponding to the second triangle index into a second preset number of second triangle bounding box sets;

[0135] Performing intersection determination on each first triangular bounding box set and each second triangular bounding box set to obtain intersecting triangular bounding box set pairs;

[0136] For each intersecting triangle bounding box set pair, an intersection determination is performed on the bounding boxes of each first triangle and each second triangle in the intersecting triangle bounding box set pair to obtain an intersecting triangle bounding box pair.

[0137] The preset number refers to the number pre-set on the computer device.

[0138] The bounding box corresponding to the first triangle index can be considered as a large bounding box corresponding to multiple first triangles. Similarly, the bounding box corresponding to the second triangle index can be considered as a large bounding box corresponding to multiple second triangles. The first preset number and the second preset number can be the same or different.

[0139] The first triangle bounding box set includes the first triangle bounding boxes corresponding to the first triangle indices in the plurality of first triangle indices. The second triangle bounding box set includes the second triangle bounding boxes corresponding to the second triangle indices in the plurality of second triangle indices. The first triangle bounding box set can be considered as a single bounding box, and the second triangle bounding box set can also be considered as a single bounding box.

[0140] Specifically, when at least one of the number of first triangle indices and the number of second triangle indices is greater than a preset number, the computer device divides the bounding box corresponding to the first triangle index into a first preset number of portions based on the position of the bounding box, thereby obtaining a first preset number of first triangle bounding box sets. The position of the bounding box can refer to at least one of the x-axis, y-axis, and z-axis of the bounding box. For example, if the x-axis of the bounding box corresponding to the first triangle index ranges from 0 to 100, then the bounding box can be divided into 10 portions, resulting in 0-10, 10-20, ..., 90-100, and a total of 10 portions.

[0141] The computer device divides the bounding box corresponding to the second triangle index into a second preset number of parts according to the position of the bounding box, and obtains a second number of second triangle bounding box sets.

[0142] The computer device performs an intersection check on each set of first triangular bounding boxes and each set of second triangular bounding boxes to obtain intersecting triangular bounding box pairs. For example, if the first set of triangular bounding boxes is A, B, and C, and the second set of triangular bounding boxes is D, E, and F, then A is intersected with D, E, and F, respectively; B is intersected with D, E, and F, respectively; and C is intersected with D, E, and F, respectively, to obtain intersecting triangular bounding box pairs AD, EB, and CF.

[0143] For each intersecting triangle bounding box set pair, the computer device obtains the bounding box of each first triangle and the bounding box of each second triangle in the intersecting triangle bounding box set pair. The computer device performs an intersection determination on the bounding boxes of each first triangle and each second triangle in the intersecting triangle bounding box set pair to obtain the intersecting triangle bounding box pair. For example, the computer device performs an intersection determination on the triangle bounding boxes in the intersecting triangle bounding box set pairs AD to obtain the intersecting triangle bounding box pair.

[0144] In this embodiment, when the number of triangle bounding boxes in each intersecting triangle bounding box set pair is still greater than the preset number, the first triangle bounding box in the triangle bounding box set pair is divided into a third preset number of parts, and the second triangle bounding box in the triangle bounding box set pair is divided into a fourth preset number of parts, and then an intersection judgment is performed on each first triangle bounding box and the second triangle bounding box until an intersecting triangle bounding box pair is obtained.

[0145] For example, if the number of triangles in taList and tbList is less than the preset number (for example, 30), then the triangle bounding boxes corresponding to taList and tbList are directly intersected. If a triangle bounding box corresponding to a taList intersects with a triangle bounding box corresponding to tbList, then the intersecting triangle pair IntersecSet is recorded. If it is greater than or equal to the preset number, taking the value range of the bounding boxes corresponding to taList and tbList as 0-100, then the bounding box corresponding to taList is divided into 10 parts along the x-axis to obtain the first triangle bounding box set with ten ranges such as 0-10, 10-20...90-100. The bounding box corresponding to tbList is divided into 10 parts along the x-axis to obtain the second triangle bounding box set with ten ranges such as 0-10, 10-20...90-100. Then, the 10 first triangle bounding box sets and the 10 second triangle bounding box sets are intersected to obtain intersecting triangle bounding box set pairs. The taList_subx and tbList_subx values ​​in the triangle bounding box set are then further evaluated. The next evaluation treats taList_subx as taList and tbList_subx as tbList. If the number of taList and tbList values ​​is still high, the tree is split again along the y-axis. If the number of indices after splitting along the y-axis is still high, the tree is split again along the z-axis. To prevent splitting too deep, the deepest node is currently limited to three layers, meaning no further splitting is performed after splitting along the z-axis.

[0146] In this embodiment, when at least one of the number of first triangle indices and the number of second triangle indices is greater than a preset number, it indicates that the number of triangle indices is large. Therefore, it is necessary to divide the bounding box into a triangle bounding box set, perform an intersection judgment on the triangle bounding box set, and then perform an intersection judgment on the triangle bounding boxes in the triangle bounding box set, which can improve the speed of Boolean operations.

[0147] In one embodiment, traditional Boolean operations may have one or more problems, such as being unable to handle situations where the model is partially coplanar, requiring the two entities to be strict manifold models, obtaining broken or erroneous results when performing Boolean operations on certain models, requiring large memory and having slow calculation speed.

[0148] Therefore, a Boolean operation method in an embodiment of the present invention is proposed, including:

[0149] Step (b1): obtaining a first model and a second model.

[0150] Step (b2): obtaining a first bounding box of the first model and a second bounding box of the second model.

[0151] Step (b3): ​​determining an intersecting bounding box obtained by intersecting the first bounding box and the second bounding box.

[0152] Step (b4): determining a first triangle bounding box for each triangle in the first model, and determining a second triangle bounding box for each triangle in the second model.

[0153] Step (b5): obtaining a first triangle index corresponding to the first triangle bounding box that intersects with the intersecting bounding box.

[0154] Step (b6): obtaining a second triangle index corresponding to the second triangle bounding box that intersects with the intersecting bounding box.

[0155] Step (b7): when at least one of the number of the first triangle indexes and the number of the second triangle indexes is greater than or equal to a preset number, dividing the bounding box corresponding to the first triangle index into a first preset number of first triangle bounding box sets.

[0156] Step (b8): dividing the bounding box corresponding to the second triangle index into a second preset number of second triangle bounding box sets.

[0157] Step (b9): performing intersection determination on each first triangular bounding box set and each second triangular bounding box set to obtain intersecting triangular bounding box set pairs.

[0158] Step (b10): for each intersecting triangle bounding box set pair, performing intersection determination on the bounding boxes of each first triangle and each second triangle in the intersecting triangle bounding box set pair to obtain an intersecting triangle bounding box pair.

[0159] Step (b11): when at least one of the number of first triangle indices and the number of second triangle indices is less than a preset number, performing an intersection determination on a first triangle bounding box corresponding to the first triangle index and a second triangle bounding box corresponding to the second triangle index to obtain a pair of intersecting triangle bounding boxes.

[0160] Step (b12): Obtain the intersecting triangle pairs corresponding to each triangle bounding box pair. The intersecting triangle pairs include a first intersecting triangle and a second intersecting triangle.

[0161] Step (b13): for each intersecting triangle pair, determine whether the three sides of the first intersecting triangle intersect with the second intersecting triangle, and determine whether the three sides of the second intersecting triangle intersect with the first intersecting triangle.

[0162] Step (b14): when the number of at least one of the first intersection point coordinates and the second intersection point coordinates meets the preset number condition, the intersection line segments obtained by the intersection of the first model and the second model are obtained according to at least one of the first intersection point coordinates and the second intersection point coordinates, and the intersection line segment set obtained by the intersection of the first model and the second model is obtained; the first intersection point coordinates are obtained by judging the intersection of the three sides of the first intersection triangle with the second intersection triangle; the second intersection point coordinates are obtained by judging the intersection of the three sides of the second intersection triangle with the first intersection triangle.

[0163] Step (b15): when the first intersecting triangle and the second intersecting triangle are coplanar, moving the first model or the second model by a preset distance.

[0164] Step (b16) returns to the step of executing, for each intersecting triangle pair, determining whether the three sides of the first intersecting triangle intersect with the second intersecting triangle, and determining whether the three sides of the second intersecting triangle intersect with the first intersecting triangle.

[0165] Step (b17): triangulate the triangles according to the set of intersecting line segments to obtain the triangulated triangles.

[0166] Step (b18): updating the triangle set of the first model and the triangle set of the second model according to the subdivided triangles.

[0167] Step (b19): performing connectivity judgment on each triangle in the triangle set of the first model and the triangle set of the second model to obtain triangle combinations having connectivity relationships.

[0168] Step (b20), determine the internal and external states of each triangle combination.

[0169] Step (b21), taking the internal and external states of the triangle combination as the internal and external states of the triangles in the triangle combination.

[0170] Step (b22), obtain the target triangle that is not in the triangle combination.

[0171] Step (b23), traverse the surrounding triangles of the target triangle until the boundary triangle is reached.

[0172] Step (b24), obtain the inside and outside triangle labels of the boundary triangle.

[0173] Step (b25) determines the inside and outside states of the target triangle based on the inside and outside labels of the triangle.

[0174] Step (b26): performing a Boolean operation according to the type of the Boolean operation and the internal and external states of each triangle to obtain a Boolean operation result.

[0175] Step (b27), when the target intersecting line segments corresponding to at least three triangles are determined from the intersecting line segment set according to the Boolean operation result, the vertices of the triangles on the target intersecting line segments are moved to the endpoints of the target intersecting line segments to obtain intersecting degenerate triangles.

[0176] Step (b28), delete the intersecting degenerate triangles.

[0177] Step (b29), obtain the normal vector of each triangle in the Boolean operation result.

[0178] Step (b30), when overlapping triangles that meet the preset normal vector condition are determined based on the normal vectors of each triangle, the vertex of one of the overlapping triangles is shifted toward the other vertices to obtain overlapping degenerate triangles.

[0179] Step (b31), delete overlapping degenerate triangles.

[0180] In step (b32), when the same repeated triangles exist in the Boolean operation result, one of the repeated triangles is retained and the remaining triangles are deleted.

[0181] Step (b33), determine the number of triangles corresponding to the sides of each triangle in the Boolean operation result.

[0182] Step (b34): when a free triangle is determined in which at least two sides correspond to only one triangle based on the number of triangles corresponding to the sides of each triangle, the free triangle is deleted to obtain a manifold model.

[0183] In this embodiment, a first model and a second model, along with a set of intersecting line segments resulting from their intersection, are obtained. Triangulation is performed based on the intersecting line segment set to obtain triangular segments. Boolean operations are performed on the triangular segments to obtain Boolean operation results. Because the quality of the Boolean operation results obtained at this time is poor, at least one of intersecting degenerate triangles, overlapping degenerate triangles, duplicate triangles, and free triangles is deleted. Specifically, after obtaining the Boolean operation results, post-processing is performed to obtain a manifold model. This ensures that the model obtained after the Boolean operation has no broken surfaces, no erroneous results, and a high-quality model. Furthermore, by deleting triangles of a preset type obtained based on the Boolean operation results, the model can be subjected to multiple consecutive Boolean operations and still obtain a manifold model. Furthermore, connectivity determination and bounding boxes corresponding to indices are employed to increase the speed of Boolean operations.

[0184] It should be understood that although the above Figure 1 and Figure 4The steps in the flowchart are shown in sequence as indicated by arrows, and the steps (a1) to (a7) and (b1) to (b34) are shown in sequence as indicated by numbers. However, these steps are not necessarily performed in the order indicated by arrows or numbers. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be performed in other orders. In addition, Figure 1 and Figure 4 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0185] In one embodiment, Figure 5 FIG. 5 is a block diagram of a Boolean operation device in an embodiment, which provides a Boolean operation device including a model acquisition module 502, a line segment set acquisition module 504, a segmentation module 506, an operation module 508, and a processing module 510, wherein:

[0186] A model acquisition module 502 is used to acquire a first model and a second model;

[0187] A line segment set acquisition module 504 is used to acquire an intersection line segment set obtained by intersecting the first model and the second model;

[0188] A triangulation module 506 is configured to perform triangulation based on the set of intersecting line segments to obtain triangulated triangles;

[0189] An operation module 508 is used to perform a Boolean operation on the divided triangles to obtain a Boolean operation result;

[0190] The processing module 510 is configured to delete triangles of a preset type obtained according to the Boolean operation result to obtain a manifold model.

[0191] The Boolean operation device described above obtains a first model and a second model, along with a set of intersecting line segments resulting from their intersection, performs triangulation based on the set of intersecting line segments to obtain triangular segments, and performs a Boolean operation on the triangular segments to obtain a Boolean operation result. Because the quality of the Boolean operation result obtained at this time is poor, triangles of a preset type obtained based on the Boolean operation result are deleted. That is, after obtaining the Boolean operation result, post-processing is performed to obtain a manifold model, ensuring that the model obtained after the Boolean operation has no broken surfaces, no erroneous results, and a high-quality model. Furthermore, by deleting triangles of the preset type obtained based on the Boolean operation result, the model can be subjected to multiple consecutive Boolean operations and still obtain a manifold model.

[0192] In one embodiment, the processing module 510 is used to determine a target intersecting line segment corresponding to at least three triangles from the intersecting line segment set based on the result of the Boolean operation; move the vertices of the triangles on the target intersecting line segment to the endpoints of the target intersecting line segment to obtain intersecting degenerate triangles; and delete the intersecting degenerate triangles.

[0193] In this embodiment, since the manifold model refers to a model in which one edge corresponds to only two triangles, when a target intersecting line segment corresponding to at least three triangles appears, it indicates that the Boolean operation result is wrong. Therefore, by determining the target intersecting line segment corresponding to at least three triangles from the intersecting line segment set based on the Boolean operation result, moving the vertices of the triangles on the target intersecting line segment to the end points of the target intersecting line segment, obtaining intersecting degenerate triangles, and deleting the intersecting degenerate triangles, the redundant triangles can be deduplicated, thereby improving the quality of the model after the Boolean operation obtained by the Boolean operation.

[0194] In one embodiment, the processing module 510 is used to obtain the normal vector of each triangle in the Boolean operation result; determine the overlapping triangles that meet the preset normal vector conditions based on the normal vectors of each triangle; offset the vertex of one triangle in the overlapping triangles toward the other vertices to obtain overlapping degenerate triangles; and delete the overlapping degenerate triangles.

[0195] In this embodiment, since there may be coplanar parts with overlapping areas in the Boolean operation result, the normal vector of each triangle in the Boolean operation result is obtained, and the overlapping triangles that meet the preset normal vector conditions are determined based on the normal vector of each triangle. The vertex of one triangle in the overlapping triangles is offset toward the other vertices to obtain overlapping degenerate triangles, and the overlapping degenerate triangles are deleted. This can effectively remove the overlapping triangles and improve the accuracy of the model obtained by the Boolean operation.

[0196] In one embodiment, the processing module 510 is configured to retain one of the duplicate triangles and delete the remaining triangles when identical duplicate triangles exist in the Boolean operation result.

[0197] In this embodiment, duplicate triangles may appear in the Boolean operation result. By retaining one of the duplicate triangles and deleting the remaining triangles, the triangles in the Boolean operation result can be deduplicated, thereby improving the quality of the model obtained after the Boolean operation.

[0198] In one embodiment, the processing module 510 is used to determine the number of triangles corresponding to the sides of each triangle in the Boolean operation result; based on the number of triangles corresponding to the sides of each triangle, determine free triangles whose at least two sides each correspond to only one triangle; and delete the free triangles.

[0199] In this embodiment, since the Boolean operation result is obtained from a three-dimensional model, the manifold model is one edge corresponding to only two triangles, so a free triangle whose at least two sides correspond to only one triangle of itself is an erroneous triangle. Therefore, by determining the number of triangles corresponding to the edges of each triangle in the Boolean operation result, and according to the number of triangles corresponding to the edges of each triangle, determining the free triangles whose at least two sides correspond to one triangle, and deleting the free triangles, it is possible to delete the redundant triangles that do not conform to the manifold model, thereby improving the quality of the model obtained after the Boolean operation.

[0200] In one embodiment, the operation module 508 is used to update the triangle set of the first model and the triangle set of the second model based on the subdivided triangles; determine the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model; perform Boolean operations based on the type of Boolean operation and the internal and external states of each triangle to obtain Boolean operation results.

[0201] In this embodiment, the triangle set of the first model and the triangle set of the second model are updated based on the split triangles, the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model are determined, and Boolean operations are performed based on the type of Boolean operation and the internal and external states of each triangle, so that the Boolean operation results can be accurately obtained.

[0202] In one embodiment, the operation module 508 is used to perform connectivity judgment on each triangle in the triangle set of the first model and the triangle set of the second model to obtain triangle combinations with connectivity relationships; determine the internal and external states of each triangle combination; use the internal and external states of the triangle combination as the internal and external states of the triangle in the corresponding triangle combination; obtain the target triangle that is not in the triangle combination; traverse the surrounding triangles of the target triangle until the boundary triangle is traversed; obtain the triangle internal and external labels of the boundary triangle; and determine the internal and external states of the target triangle based on the triangle internal and external labels.

[0203] In this embodiment, connectivity judgment is performed on each triangle in the triangle set of the first model and the triangle set of the second triangle, and each triangle combination with connectivity is obtained. The internal and external states of each triangle combination are determined, and the internal and external states of the triangle combination are used as the internal and external states of the triangles in the triangle combination. The internal and external states of most triangles can be quickly obtained through connectivity judgment; by obtaining a target triangle that is not in the triangle combination, traversing the surrounding triangles of the target triangle until the boundary triangle is traversed, obtaining the triangle internal and external labels of the boundary triangle, and determining the triangle internal and external states of the target triangle according to the triangle internal and external labels, the speed of internal and external state judgment can be improved, while ensuring that the internal and external states of the triangles in the first model and the second model are judged, thereby improving the accuracy of Boolean operations.

[0204] In one embodiment, the line segment set acquisition module 504 is used to obtain a first bounding box of the first model and a second bounding box of the second model; determine an intersecting bounding box obtained by the intersection of the first bounding box and the second bounding box; determine a first triangle bounding box of each triangle in the first model, and determine a second triangle bounding box of each triangle in the second model; obtain a first triangle index corresponding to the first triangle bounding box that intersects with the intersecting bounding box; obtain a second triangle index corresponding to the second triangle bounding box that intersects with the intersecting bounding box; determine a triangle bounding box pair that intersects the first triangle bounding box corresponding to the first triangle index and the second triangle bounding box corresponding to the second triangle index; obtain an intersecting triangle pair corresponding to each triangle bounding box pair; obtain an intersecting line segment of each intersecting triangle pair, and obtain an intersecting line segment set obtained by the intersection of the first model and the second model.

[0205] In this embodiment, the intersecting bounding box obtained by the intersection of the first bounding box and the second bounding box is first determined, the first triangle index and the second triangle index that may be located in the intersection area of ​​the model are filtered out through the intersecting bounding box, and then the triangles corresponding to these indexes are used to filter out the triangle bounding box pairs, thereby obtaining a set of intersecting line segments. Through multiple screening, the complexity of the calculation can be reduced and the efficiency of Boolean operations can be improved.

[0206] In one embodiment, the intersecting triangle pairs include a first intersecting triangle and a second intersecting triangle. The line segment set acquisition module 504 is configured to, for each intersecting triangle pair, determine the intersection of the three sides of the first intersecting triangle with the second intersecting triangle, and determine the intersection of the three sides of the second intersecting triangle with the first intersecting triangle; when the number of at least one of the first intersection point coordinates and the second intersection point coordinates meets a preset number condition, obtain an intersecting line segment resulting from the intersection of the first model and the second model based on at least one of the first intersection point coordinates and the second intersection point coordinates; the first intersection point coordinates are obtained by determining the intersection of the three sides of the first intersecting triangle with the second intersecting triangle; and the second intersection point coordinates are obtained by determining the intersection of the three sides of the second intersecting triangle with the first intersecting triangle.

[0207] In this embodiment, since in the three-dimensional model, the side of the first intersecting triangle intersects with the second intersecting triangle, which is different from the side of the second intersecting triangle intersecting with the first intersecting triangle, it is necessary to make judgments separately to obtain a set of intersecting line segments and improve the accuracy of the Boolean operation results.

[0208] In one embodiment, the line segment set acquisition module 504 is also used to move the first model or the second model by a preset distance when the first intersecting triangle and the second intersecting triangle are coplanar; obtain the intersecting line segments of each intersecting triangle pair after the movement, and obtain the intersecting line segment set obtained by the intersection of the first model and the second model.

[0209] In this embodiment, when there is a situation where the triangles are coplanar, that is, when the first intersecting triangle and the second intersecting triangle are coplanar, moving the first model or the second model by a preset distance can effectively avoid the situation where the triangles are coplanar, and there is no need to redetermine the intersecting triangle pairs. It is sufficient to re-execute the step of determining the intersecting line segments obtained by the intersection of the first model and the second model according to each intersecting triangle pair to obtain the intersecting line segment set. This can reduce the Boolean operation time while ensuring the accuracy of the model.

[0210] In one embodiment, the operation module 508 is configured to divide the bounding box corresponding to the first triangle index into a first preset number of first triangle bounding box sets when at least one of the number of the first triangle index and the number of the second triangle index is greater than or equal to a preset number.

[0211] Divide the bounding box corresponding to the second triangle index into a second preset number of second triangle bounding box sets;

[0212] Performing intersection determination on each first triangular bounding box set and each second triangular bounding box set to obtain intersecting triangular bounding box set pairs;

[0213] For each intersecting triangle bounding box set pair, an intersection determination is performed on the bounding boxes of each first triangle and each second triangle in the intersecting triangle bounding box set pair to obtain an intersecting triangle bounding box pair.

[0214] In this embodiment, when at least one of the number of first triangle indices and the number of second triangle indices is greater than a preset number, it indicates that the number of triangle indices is large. Therefore, it is necessary to divide the bounding box into a triangle bounding box set, perform an intersection judgment on the triangle bounding box set, and then perform an intersection judgment on the triangle bounding boxes in the triangle bounding box set, which can improve the speed of Boolean operations.

[0215] For the specific definition of the Boolean operation device, please refer to the definition of the Boolean operation method above and will not be repeated here. The various modules in the above-mentioned Boolean operation device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.

[0216] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, memory, a communication interface, a display screen, and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal via wired or wireless communication. The wireless communication method can be achieved through Wi-Fi, a carrier network, NFC (near-field communication), or other technologies. When executed by the processor, the computer program implements a Boolean operation method. The display screen of the computer device can be a liquid crystal display or an electronic ink display. The input device of the computer device can be a touch layer covering the display screen, or keys, a trackball, or a touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse.

[0217] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0218] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps of the above-mentioned Boolean operation method embodiments when executing the computer program.

[0219] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned Boolean operation method embodiments are implemented.

[0220] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes in the above-described method embodiments. Any reference to memory, storage, database, or other media used in the embodiments provided herein may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0221] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A Boolean operation method, characterized in that: The method comprises: Obtaining a first model and a second model; the first model and the second model are used to describe the surface geometry of a three-dimensional object; the first model and the second model are three-dimensional models in STL format; the STL format is a file format used for stereolithography computer-aided design software; Obtaining a set of intersecting line segments resulting from the intersection of the first model and the second model; Perform triangulation according to the set of intersecting line segments to obtain triangulated triangles; Performing a Boolean operation on the subdivided triangles to obtain a Boolean operation result; Deleting triangles of a preset type obtained according to the Boolean operation result to obtain a manifold model; wherein deleting triangles of a preset type obtained according to the Boolean operation result includes: Determining target intersection line segments corresponding to at least three triangles from the set of intersection line segments according to the Boolean operation result; Moving the vertices of the triangle on the target intersecting line segment to the endpoints of the target intersecting line segment to obtain an intersecting degenerate triangle; Deleting the intersecting degenerate triangles; Obtaining the normal vector of each triangle in the Boolean operation result; Determining overlapping triangles that meet a preset normal vector condition based on the normal vectors of the triangles; offsetting the vertex of one of the overlapping triangles toward the remaining vertices to obtain an overlapping degenerate triangle; Deleting the overlapping degenerate triangles; When the Boolean operation result contains identical repeated triangles, retain one of the repeated triangles and delete the remaining triangles; Determining the number of triangles corresponding to the sides of each triangle in the Boolean operation result; Determine, based on the number of triangles corresponding to the sides of each triangle, a free triangle in which at least two sides correspond to only one triangle; Delete the stray triangle.

2. The method according to claim 1, characterized in that The performing a Boolean operation on the divided triangles to obtain a Boolean operation result includes: updating the triangle set of the first model and the triangle set of the second model according to the subdivided triangles; Determining the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model; A Boolean operation is performed according to the type of the Boolean operation and the internal and external states of each triangle to obtain a Boolean operation result.

3. The method according to claim 2, characterized in that The determining of the internal and external states of each triangle in the triangle set of the first model and the triangle set of the second model includes: Performing connectivity judgment on each triangle in the triangle set of the first model and the triangle set of the second model to obtain a triangle combination having a connectivity relationship; determining the internal and external states of the triangle combination; Using the internal and external states of the triangle combination as the internal and external states of the triangles in the triangle combination; Get the target triangle that is not in the triangle combination; Traverse the surrounding triangles of the target triangle until the boundary triangle is reached; Get the inside and outside triangle labels of the boundary triangle; The inside and outside states of the target triangle are determined according to the inside and outside labels of the triangle.

4. The method according to claim 1, wherein The obtaining of a set of intersecting line segments obtained by intersecting the first model and the second model includes: Obtain a first bounding box of the first model and a second bounding box of the second model; Determine an intersecting bounding box obtained by intersecting the first bounding box and the second bounding box; Determine a first triangle bounding box for each triangle in the first model, and determine a second triangle bounding box for each triangle in the second model; Obtain a first triangle index corresponding to a first triangle bounding box that intersects with the intersecting bounding box; Obtain a second triangle index corresponding to a second triangle bounding box that intersects with the intersecting bounding box; Determine a triangle bounding box pair where a first triangle bounding box corresponding to the first triangle index intersects with a second triangle bounding box corresponding to the second triangle index; Obtaining the intersecting triangle pairs corresponding to each of the triangle bounding box pairs; The intersecting line segments of each intersecting triangle pair are obtained to obtain an intersecting line segment set obtained by the intersection of the first model and the second model.

5. The method according to claim 4, characterized in that The intersecting triangle pair includes a first intersecting triangle and a second intersecting triangle; The obtaining of the intersecting line segments of each intersecting triangle pair includes: For each intersecting triangle pair, performing an intersection determination on the three sides of the first intersecting triangle and the second intersecting triangle, and performing an intersection determination on the three sides of the second intersecting triangle and the first intersecting triangle; When the number of at least one of the first intersection point coordinates and the second intersection point coordinates meets the preset number condition, the intersection line segment obtained by the intersection of the first model and the second model is obtained according to at least one of the first intersection point coordinates and the second intersection point coordinates; the first intersection point coordinates are obtained by judging the intersection of the three sides of the first intersection triangle with the second intersection triangle; the second intersection point coordinates are obtained by judging the intersection of the three sides of the second intersection triangle with the first intersection triangle.

6. The method according to claim 4, characterized in that The intersecting triangle pair includes a first intersecting triangle and a second intersecting triangle; The method further comprises: When the first intersecting triangle and the second intersecting triangle are coplanar, moving the first model or the second model by a preset distance; The step of obtaining the intersecting line segments of each intersecting triangle pair is performed to obtain a set of intersecting line segments obtained by the intersection of the first model and the second model.

7. The method according to claim 4, characterized in that The determining a triangle bounding box pair where a first triangle bounding box corresponding to the first triangle index intersects a second triangle bounding box corresponding to the second triangle index, comprising: When at least one of the number of the first triangle indices and the number of the second triangle indices is greater than or equal to a preset number, dividing the bounding box corresponding to the first triangle index into a first preset number of first triangle bounding box sets; Divide the bounding box corresponding to the second triangle index into a second preset number of second triangle bounding box sets; Performing intersection determination on each of the first triangular bounding box sets and each of the second triangular bounding box sets to obtain intersecting triangular bounding box set pairs; For each intersecting triangle bounding box set pair, an intersection determination is performed on the bounding boxes of each first triangle and each second triangle in the intersecting triangle bounding box set pair to obtain an intersecting triangle bounding box pair.

8. A Boolean operation device, characterized in that: The device comprises: A model acquisition module is configured to acquire a first model and a second model; the first model and the second model are used to describe the surface geometry of a three-dimensional object; the first model and the second model are three-dimensional models in STL format; the STL format is a file format used for stereolithography computer-aided design software; A line segment set acquisition module, configured to acquire an intersecting line segment set obtained by intersecting the first model and the second model; A triangulation module, configured to perform triangulation according to the set of intersecting line segments to obtain triangulated triangles; An operation module, configured to perform a Boolean operation on the subdivided triangles to obtain a Boolean operation result; a processing module, configured to delete triangles of a preset type obtained according to the Boolean operation result to obtain a manifold model; The device is used to implement the steps of the method according to any one of claims 1 to 7.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • STL model Boolean calculation based method for extracting inner surface model of fuel tank in airplane

    CN105022865A