Method for efficiently constructing three-dimensional entity model topological relation based on spatial hash
By using a spatial hash data structure and a wide-narrow stage matching strategy, the topology of IGES format 3D CAD models can be quickly reconstructed, solving the problem of low efficiency in existing technologies and realizing efficient topology reconstruction and computer-aided manufacturing processes.
Patent Information
- Application Number
- CN202511689715.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-01-30
AI Technical Summary
Existing technologies are inefficient in reconstructing topology from 3D CAD models in IGES format, resulting in high computational complexity and severely impacting the performance of CAD systems.
A spatial hashing-based approach is adopted. By constructing a spatial hashing data structure and using endpoint coordinates to establish a fast lookup index, wide-stage candidate matching and narrow-stage accurate verification are performed to quickly reconstruct the topological relationship of the 3D solid model.
It significantly reduces the computational complexity of boundary matching, thereby greatly improving the efficiency of topology reconstruction. It can handle large and complex models, meet the needs of high-end CAD applications, and achieve a performance improvement of tens of times.
Smart Images

Figure CN121437797A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of computer-aided design (CAD), three-dimensional geometric modeling and industrial data exchange, and particularly relates to a method for efficiently constructing the topological relationship of a three-dimensional solid model based on spatial hashing. Background Technology
[0002] In modern manufacturing, the exchange of 3D CAD models across software and platforms is a common process in design, analysis, and manufacturing. IGES (Initial Graphics Exchange Specification), as a long-established and widely used neutral file format, plays an important role in this process. However, the IGES format has an inherent limitation when describing 3D solids: it typically represents the model as a collection of independent "trimmed surfaces" (such as IGES solid type 144). Each trimmed surface consists of its underlying geometric surface (such as a plane, B-spline surface, etc.) and a set of 3D curves defining its boundaries.
[0003] In this descriptive method, the individual surface patches are isolated from each other; the file itself does not store their adjacency and connection relationships, i.e., topological information. For example, two surfaces that fit closely together in space will have their shared common boundary described as two separate curves in the IGES file. To enable advanced geometric operations (such as Boolean operations, chamfering, shelling), finite element analysis (FEA), or computer-aided manufacturing (CAM) path planning in the imported model, the complete topology of the model must first be reconstructed. This process is often referred to as "stitching" or "topology reconstruction."
[0004] The core task of topology reconstruction is to identify all geometrically coincident boundary curves in the model and unify them into a single topological "edge". Traditional solutions typically employ a brute-force strategy: traversing all boundary curves in the model and comparing any two curves in pairs to determine if they are geometrically identical. Assuming the model has n boundary curves, this algorithm has a computational complexity of up to [insert value here]. For complex modern industrial product models, the number of surfaces can be in the tens of thousands, and the number of boundary curves is even greater. At this point, The computational complexity will result in an extremely long model import process, which severely restricts the efficiency of design and engineering analysis and becomes a major bottleneck in the performance of CAD systems.
[0005] Therefore, developing an algorithm that can significantly improve boundary matching efficiency and quickly complete topology reconstruction is crucial for optimizing the model import performance of CAD software. Summary of the Invention
[0006] In existing technologies, when importing models from data formats such as IGES that only contain discrete geometric surfaces, topology reconstruction is inefficient. To address this issue, this invention provides a method for efficiently constructing the topological relationships of a 3D solid model based on spatial hashing. This method can quickly and accurately reconstruct a boundary representation (B-Rep) solid model with complete topological relationships from a data format (such as IGES) that only contains discrete geometry and lacks topological information. This model can then be applied to a computer-aided manufacturing (CAM) system to generate numerical control (NC) machining path planning, thereby guiding physical machine tools to manufacture industrial parts models.
[0007] To achieve the above-mentioned objectives, the present invention specifically adopts the following technical solution: In a first aspect, the present invention provides a method for efficiently constructing the topological relationships of a three-dimensional entity model based on spatial hashing, comprising the following steps: S1. Obtain the data file of the 3D model of the industrial parts to be processed, read the model data from the data file, parse the content of the data file into a set of independent, topologically unrelated complete external surface of the industrial parts, and extract all the boundary curves of the industrial parts contained in each surface in the set. The boundary curves of the industrial parts are used to define the actual boundary of the industrial parts in 3D space. S2. Initialize a spatial hash data structure, traverse all industrial component boundary curves, extract the endpoint coordinates of each industrial component boundary curve, and insert the identification information of the industrial component boundary curve and its endpoint coordinates into the spatial hash data structure, thereby establishing a fast lookup index for the spatial location of the endpoints of the industrial component boundary curves; where the endpoint coordinates are the start coordinates and end coordinates of the industrial component boundary curve in three-dimensional space. S3. Iterate through all industrial component boundary curves again. For any industrial component boundary curve to be matched, use the endpoint coordinates of the industrial component boundary curve to query the spatial hash data structure for industrial component boundary curves that are spatially adjacent to it to form a candidate curve set. S4. A set of curve pairs is formed by an industrial component boundary curve and a candidate curve from the corresponding candidate curve set. Each set of curve pairs is subjected to precise geometric consistency verification to obtain a set of curve pairs that are geometrically coincident within a preset error range. S5. Create shared topological entities for geometrically coincident curve pairs and construct complete boundary representation topological structures. Finally, stitch the discrete sets of trimmed surfaces into a B-Rep solid model of industrial parts with complete connectivity, which is used by computer-aided manufacturing systems to generate processing paths for industrial parts.
[0008] Based on the above scheme, each step can be implemented in the following preferred manner.
[0009] As a preferred embodiment of the first aspect mentioned above, in S1, each boundary curve of an industrial component includes its geometric definition and the starting and ending coordinates in three-dimensional space.
[0010] As a preferred embodiment of the first aspect mentioned above, in S2, the spatial hash data structure internally maintains a mapping relationship, where the key is a hash value calculated based on the endpoint coordinates, and the value is a list used to store the boundary curve identification information of industrial parts.
[0011] As a preferred embodiment of the first aspect mentioned above, in S2, the specific process performed for each industrial component boundary curve is as follows: S21. Obtain the starting and ending coordinates of each industrial component boundary curve, predefine a virtual 3D mesh, and assign a unique index to each mesh cell in the virtual 3D mesh; S22. Map the starting coordinates to the unique index of the first grid cell, calculate a hash key based on the unique index of the first grid cell, and then store the data structure containing the boundary curve identification information of the industrial parts into the hash bucket corresponding to the hash key; S23. Map the endpoint coordinates to the unique index of the second grid cell, calculate a hash key based on the unique index of the second grid cell, and then store the data structure containing the boundary curve identification information of the industrial parts into the hash bucket corresponding to the recalculated hash key.
[0012] As a preferred embodiment of the first aspect mentioned above, in S3, the specific process performed for each industrial component boundary curve is as follows: S31. Obtain the starting and ending coordinates of each industrial component boundary curve; S32. Query the hash bucket corresponding to the starting coordinate of the boundary curve of the industrial component, and at the same time query the hash bucket corresponding to the neighborhood of the starting coordinate. Then, summarize the identification information of the boundary curve of the industrial component obtained from all hash buckets queried by the starting coordinate into a starting candidate list. S33. Query the hash bucket corresponding to the endpoint coordinates of the boundary curve of the industrial component, and at the same time query the hash buckets corresponding to the neighborhood of the endpoint coordinates. Then, summarize the boundary curve identification information of the industrial component obtained from all hash buckets queried by the endpoint coordinates into a candidate endpoint list. S34. Select industrial component boundary curves from the starting point candidate list and the ending point candidate list that have one endpoint adjacent to the starting point of the industrial component boundary curve and another endpoint adjacent to the ending point of the industrial component boundary curve as candidate curves, and form a candidate curve set.
[0013] As a preferred embodiment of the first aspect above, in S22, S23, S32 and S33, the identification information of the boundary curve of the industrial component is a pointer pointing to the boundary curve of the industrial component or an index of the boundary curve of the industrial component.
[0014] Secondly, this invention provides a system for efficiently constructing topological relationships of a three-dimensional entity model based on spatial hashing, comprising: The data acquisition module is used to acquire the data file storing the 3D model of the industrial parts to be processed, read the model data from the data file, parse the content of the data file into a set of independent, topologically unrelated complete external surface of the industrial parts, and extract all the boundary curves of the industrial parts contained in each surface in the set. The boundary curves of the industrial parts are used to define the actual boundary of the industrial parts in 3D space. The index building module is used to initialize a spatial hash data structure, traverse all industrial component boundary curves, extract the endpoint coordinates of each industrial component boundary curve, and insert the identification information of the industrial component boundary curve and its endpoint coordinates into the spatial hash data structure, thereby establishing a fast lookup index for the spatial location of the endpoints of the industrial component boundary curves; where the endpoint coordinates are the start coordinates and end coordinates of the industrial component boundary curve in three-dimensional space. The wide-stage candidate matching module is used to traverse all industrial component boundary curves again. For any industrial component boundary curve to be matched, the endpoint coordinates of the industrial component boundary curve are used to query the spatial hash data structure for industrial component boundary curves that are spatially adjacent to it to form a candidate curve set. The narrow-stage precision verification module is used to perform precise geometric consistency verification on each pair of curves, which consists of a boundary curve of an industrial component and a candidate curve from its corresponding set of candidate curves, to obtain geometrically coincident curve pairs within a preset error range. The topology generation module is used to create shared topological entities for geometrically overlapping curve pairs and construct complete boundary representation topological structures. Ultimately, it stitches together discrete sets of trimmed surfaces into B-Rep solid models of industrial parts with complete connectivity, which are used by computer-aided manufacturing systems to generate processing paths for industrial parts.
[0015] Thirdly, the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, enables a method for efficiently constructing the topological relationship of a three-dimensional entity model based on spatial hashing as described in any of the solutions in the first aspect above.
[0016] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a method for efficiently constructing topological relationships of a three-dimensional entity model based on spatial hashing, as described in any of the solutions of the first aspect above.
[0017] Fifthly, the present invention provides a computer electronic device, which includes a memory and a processor; The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement a method for efficiently constructing the topological relationships of a three-dimensional entity model based on spatial hashing, as described in any of the solutions of the first aspect above.
[0018] Compared with the prior art, the present invention has the following advantages: Significantly improved efficiency: This invention introduces a spatial hash structure, transforming the boundary matching search process from a global operation... The complexity is significantly reduced to near linear. Complexity. This prevents matching time from increasing dramatically with model complexity, allowing for speed improvements of tens of times or even more for importing large, complex models.
[0019] High scalability: The method of this invention exhibits good scalability and can effectively handle ultra-large-scale industrial models containing tens of thousands or even hundreds of thousands of faces, meeting the needs of high-end CAD applications.
[0020] The algorithm is robust: This invention adopts a two-step strategy of "wide-stage screening - narrow-stage verification", which not only utilizes the efficiency of spatial indexing, but also ensures the accuracy and reliability of matching through precise geometric comparison, and can robustly handle tolerance issues. Attached Figure Description
[0021] Figure 1 This is an overall flowchart of an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the principle of the spatial hash data structure in an embodiment of the present invention; Figure 3 This is a system block diagram of the present invention. Detailed Implementation
[0022] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.
[0023] In the description of this invention, it should be understood that the terms "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first" and "second" may explicitly or implicitly include at least one of those features.
[0024] like Figure 1 As shown, in a preferred embodiment of the present invention, the method for efficiently constructing the topological relationship of a three-dimensional entity model based on spatial hashing includes the following steps S1 to S5. The specific implementation process of each step will be described in detail below.
[0025] S1. Obtain the data file of the 3D model of the industrial parts to be processed, read the model data from the data file, parse the content of the data file into a set of independent, topologically unrelated complete external surface of the industrial parts, and extract all the boundary curves of the industrial parts contained in each surface of the set. The boundary curves of the industrial parts are used to define the actual boundary of the industrial parts in 3D space.
[0026] It should be noted that step S1 involves data reading and preprocessing. The data file format is IGES. By parsing the data file content, the model data is loaded into a series of independent trimmed surface objects. For each trimmed surface, all its industrial component boundary curves are extracted. Each industrial component boundary curve contains its geometric definition (such as a straight line, circular arc, or B-spline curve) and its start and end coordinates in three-dimensional space.
[0027] In this embodiment, step S1 begins by reading an IGES file. Specifically, an IGESReader class is responsible for parsing the various parts of the file. The program identifies and creates an instance of IGESEntity144 (trimmed surface). For each IGESEntity144, the program further parses the underlying surface entity (such as IGESEntity128 B-spline surface) and boundary loop entity (such as IGESEntity142) it references. Each boundary loop is composed of one or more industrial component boundary curves (such as IGESEntity110 straight line, IGESEntity100 arc, IGESEntity126 B-spline curve, etc.). At the end of this step, this embodiment obtains an in-memory object representation: a set of independent Surface objects and a set of associated TrimmedCurve (industrial component boundary curve) objects.
[0028] S2. Initialize a spatial hash data structure, traverse all industrial component boundary curves, extract the endpoint coordinates of each industrial component boundary curve, and insert the identification information of the industrial component boundary curve and its endpoint coordinates into the spatial hash data structure, thereby establishing a fast lookup index for the spatial location of the endpoints of the industrial component boundary curves; where the endpoint coordinates are the start coordinates and end coordinates of the industrial component boundary curve in three-dimensional space.
[0029] It should be noted that step S2 involves constructing a spatial hash index. To accelerate the subsequent matching process, this invention introduces a spatial hash data structure (Hash Map), such as... Figure 2 As shown, the spatial hash data structure internally maintains a mapping relationship. Its key is a hash value calculated based on the endpoint coordinates, and its value is a list (i.e., hash buckets) used to store the identification information of industrial component boundary curves. Specifically, in step S2, a three-dimensional spatial hash table is first initialized, and then all industrial component boundary curves extracted in S1 are traversed. For each industrial component boundary curve, its start and end point three-dimensional coordinates are obtained, and the pointer or unique identifier of the industrial component boundary curve is inserted into the hash bucket calculated from its start and end point coordinates, respectively. In this way, a fast lookup index from spatial location to curve is established.
[0030] It should be noted that in S2, the specific process executed for each industrial component boundary curve is as follows: S21. Obtain the starting coordinates of the boundary curve of each industrial component ( Figure 2 P1start) and endpoint coordinates ( Figure 2In P1_end), a virtual 3D mesh is predefined, and a unique index is assigned to each mesh cell in the virtual 3D mesh (e.g., ...). ).
[0031] S22. Map the starting coordinates to the unique index of the first grid cell, calculate a hash key based on the unique index of the first grid cell, and then store the data structure containing the boundary curve identification information of the industrial parts into the hash bucket corresponding to the hash key.
[0032] S23. Map the endpoint coordinates to the unique index of the second grid cell, and then calculate a hash key based on the unique index of the second grid cell (e.g., Then, the data structure containing the boundary curve identification information of industrial parts is stored in the hash bucket corresponding to the recalculated hash key.
[0033] In this embodiment S23, for the endpoint coordinates of the boundary curve of the industrial component, the same hash key calculation and storage logic as the above-mentioned starting coordinates is performed, and its identification information is also stored in the hash bucket corresponding to its endpoint coordinates.
[0034] It should be noted that in S22 and S23, the identification information of the boundary curve of the industrial component is a pointer to the boundary curve of the industrial component or an index of the boundary curve of the industrial component.
[0035] S3. Iterate through all industrial component boundary curves again. For any industrial component boundary curve to be matched, use the endpoint coordinates of the industrial component boundary curve to query the spatial hash data structure for industrial component boundary curves that are spatially adjacent to it to form a candidate curve set.
[0036] It should be noted that step S3 is a broad-phase candidate matching. This phase is performed after the hash index is built, and its purpose is to quickly filter out potentially matching industrial component boundary curve pairs, thereby narrowing the global matching range to local industrial component boundary curve pairs and avoiding global pairwise comparisons.
[0037] It should be noted that in S3, the specific process executed for each industrial component boundary curve is as follows: S31. Obtain the starting and ending coordinates of each industrial component boundary curve.
[0038] S32. Query the hash bucket corresponding to the starting point coordinate of the boundary curve of the industrial component, and at the same time query the hash bucket corresponding to the neighborhood of the starting point coordinate. Summarize the boundary curve identification information of all industrial components obtained from all hash buckets queried by the starting point coordinate into a starting point candidate list.
[0039] In this embodiment S32, for the starting coordinates of an industrial component boundary curve: query the hash bucket that precisely corresponds to its starting coordinates, and at the same time query all hash buckets corresponding to the surrounding neighborhood (e.g., the 26 neighboring grid cells) of its starting coordinates, in order to tolerate floating-point errors and model tolerances, and summarize all industrial component boundary curve identification information obtained from these hash buckets into a starting candidate list.
[0040] S33. Query the hash bucket corresponding to the endpoint coordinates of the boundary curve of the industrial component, and at the same time query the hash buckets corresponding to the neighborhood of the endpoint coordinates. Summarize the boundary curve identification information of all industrial components obtained from all hash buckets queried by the endpoint coordinates into a endpoint candidate list.
[0041] In this embodiment S33, for the endpoint coordinates of the boundary curve of the industrial component: perform the same neighborhood query operation as the above starting coordinates, and summarize the found industrial component boundary curve identification information into an endpoint candidate list.
[0042] S34. Select industrial component boundary curves from the starting point candidate list and the ending point candidate list that have one endpoint adjacent to the starting point of the industrial component boundary curve and another endpoint adjacent to the ending point of the industrial component boundary curve as candidate curves, and form a candidate curve set.
[0043] In this embodiment S34, by analyzing the query results of the start point and the end point (i.e., the candidate list of the start point and the candidate list of the end point), candidate curves that have one endpoint adjacent to the start point of the boundary curve of the industrial component to be matched, and the other endpoint adjacent to the end point of the boundary curve of the industrial component to be matched can be selected.
[0044] Therefore, steps S2 and S3 of this invention can accurately obtain the candidate curve set by traversing all industrial component boundary curves twice. Conventional methods do not use spatial hash data structures for wide-stage matching to reduce complexity; they often directly perform brute-force matching, comparing all industrial component boundary curves pairwise to find overlapping edges. In this invention, however, the spatial hash index constructed in step S2 is used to query the spatial hash table built in step S2 for each industrial component boundary curve using its start and end coordinates. The query scope includes not only the hash bucket where the endpoint is precisely located but also its neighboring hash buckets to handle accuracy errors. By querying only a small number of candidate curves in the space adjacent to its endpoint (including neighboring hash buckets), a small group of "candidate curves" that are spatially very close to the endpoint of the industrial component boundary curve can be quickly obtained. This reduces the number of industrial component boundary curve pairs requiring precise verification from the conventional approach. The level dropped sharply to Levels, among which, This represents the total number of boundary curves for industrial components. It is the average number of curves in the neighborhood. , This indicates the computational complexity.
[0045] S4. A set of curve pairs is formed by an industrial component boundary curve and a candidate curve from the corresponding candidate curve set. Each set of curve pairs is subjected to precise geometric consistency verification to obtain a set of curve pairs that are geometrically coincident within a preset error range.
[0046] It should be noted that step S4 is a narrow phase precise verification. Candidate curves selected in the wide phase only approximate each other at their endpoints and cannot be guaranteed to completely overlap. Therefore, this phase requires precise geometric consistency verification of a set of curve pairs (e.g., industrial component boundary curve A and candidate curve B from the candidate curve set of industrial component boundary curve A). The verification method used here already has relatively mature solutions in the prior art, therefore this invention does not impose limitations.
[0047] In this embodiment, the verification method is as follows: a series of points are sampled on the boundary curve of the industrial parts to be matched, these sampled points are projected onto the candidate curve, and the distance between the sampled points and the corresponding projected points in three-dimensional space is calculated. If all distances are within a preset geometric tolerance, the curve pair is determined to be geometrically coincident.
[0048] Specifically, for each curve pair (curveA, curveB) obtained from step S3, a function similar to IGESTwoCurveMatch is called for verification, where curveA represents the boundary curve of the industrial component to be matched; and curveB represents the candidate curve corresponding to curveA. Inside this function, in this embodiment, the parameter domain of curveA... Select a preset number (e.g., 5) of parameter values evenly. As the starting point of the parameter field, This is the endpoint of the parameter domain. Calculate the 3D point coordinates corresponding to the selected parameter values on curveA and store them as a point set `pointsA`. Then, project the points on pointA onto curveB sequentially to obtain the corresponding projected point set, which is stored as point set B. Compare the two point sets `pointsA` and `pointsB` to see if they match. If all corresponding points in `pointsA` and `pointsB` coincide within the tolerance range, then curveA and curveB are considered a match. Otherwise, curveA and curveB are not a match.
[0049] S5. Create a shared topological entity for geometrically coincident curve pairs and construct a complete boundary representation topological structure. Finally, stitch the discrete set of trimmed surfaces into a B-Rep solid model of industrial parts with complete connectivity, which is used by computer-aided manufacturing systems (CAM) to generate processing paths for industrial parts.
[0050] It should be noted that step S5 is for B-Rep topology generation. After matching the boundary curves of all industrial components, a standard B-Rep solid model is constructed based on the matching results, the geometric and topological information of the model, and the kernel's model representation method. The method for constructing the B-Rep solid model here already has relatively mature solutions in the existing technology; therefore, this invention does not impose any limitations.
[0051] In this embodiment, the specific process of constructing the B-Rep solid model is as follows: (1) Create a topological "face" for each original trimmed surface. (2) For each pair of curves that are confirmed to be geometrically coincident, they will share a unique topological "edge". If this "edge" has not yet been created, a new "edge" entity is created according to its geometric definition. (3) In the "loop" that constitutes each "face", create a "half-edge" for the original industrial component boundary curve. A set of matching curve pairs will correspond to two "half-edges" in opposite directions, both of which point to the same "edge" they share. (4) Associate the "edges" with their starting and ending "vertex" to complete the construction of the entire model topology.
[0052] It should be noted that in step S5, the B-Rep solid model serves as a boundary representation (B-Rep) model of the industrial part, possessing complete geometry and topology. This model can be input into a computer-aided manufacturing (CAM) system to generate numerical control (NC) machining path planning, thereby guiding the physical machine tool to manufacture the industrial part model. In this system, the CAM software utilizes the shared topological "edge" information between surfaces constructed in this invention to identify continuous machining areas, thus generating smooth and efficient finishing toolpaths. This solves the technical problem that the original IGES file lacks topological connections, causing the CAM software to misjudge the common boundary of geometrically continuous (within tolerance range) adjacent surfaces as two independent, discontinuous boundaries, leading to interrupted toolpath calculations or inability to smoothly transition between surfaces. This enables automated precision manufacturing of the industrial part.
[0053] To better demonstrate the specific implementation and technical effects of the present invention, the method for efficiently constructing the topological relationship of a three-dimensional entity model based on spatial hashing, as shown in steps S1 to S5 of the above preferred implementation, is applied to a specific example below.
[0054] Example The specific implementation process of the method for efficiently constructing the topological relationship of a three-dimensional entity model based on spatial hashing used in this embodiment is as described above and will not be repeated here.
[0055] To illustrate the technical effectiveness of the method of this invention compared to existing technologies (i.e., "traditional methods") in solving the efficiency problem of IGES file topology reconstruction, this embodiment compares the total B-Rep reconstruction time of the two methods under the same hardware and software environment. The traditional method (comparison group) employs the brute-force algorithm described in the background section, which, after preprocessing in step S1, does not construct a spatial hash index but instead... Nested loops are used to precisely verify the narrow stages of step S4 for all industrial component boundary curve pairs. The method of this invention (experimental group) employs the method described in the above embodiments for efficiently constructing the topological relationships of a 3D solid model based on spatial hashing.
[0056] This embodiment selected 12 IGES format industrial component models of varying complexity and origin as the test dataset. The experimental environment selected for the test was: Windows 11 hardware and software platform; Intel Core i5-13490F CPU; 64GB RAM. The test metric was set as: recording the time required to reconstruct the B-Rep topology after loading the IGES file (excluding the time for IGES file reading and preprocessing, i.e., the time spent in step 1). The test results are shown in Table 1: Table 1. Test Results As shown in Table 1, regarding the relationship between complexity and time consumption, the time consumption of the traditional method increases quadratically with the increase in the number of boundary curves for industrial parts. For example, when the number of curves increases from approximately 41,000 to approximately 213,000 (about 5.2 times), the time consumption increases dramatically from 15,752 ms to 483,812 ms (about 30.7 times), demonstrating a significant... The complexity of the model leads to excessive time consumption when processing complex models, constituting a serious technical bottleneck. When processing simple models, the performance of the method in this invention is comparable to that of traditional methods. This is because the construction of the spatial hash index itself incurs overhead. However, as the model complexity (number of boundary curves of industrial parts) increases, the performance advantage of this invention becomes exponential: when processing medical device models (37,957 edges), the performance improvement reaches 122.8 times; when processing ultra-large machinery models (213,427 edges), this invention reduces the reconstruction time from 483,812 ms (approximately 8 minutes) to 1,027 ms (approximately 1.0 second), a performance improvement of up to 471.1 times.
[0057] As can be seen, the method of this invention brings a leap in computational efficiency, solves the problem of "computational complexity explosion," and significantly improves the performance of computer systems. Traditional methods, without spatial hash indexes, require traversing and comparing each boundary curve with all other curves in the model to find the curves that need to be stitched together. This results in a computational complexity of O(log n). The computational complexity increases exponentially when the model is complex and the number of curves reaches thousands or even tens of thousands (which is very common in industrial parts), leading to extremely slow computer system response and even inability to complete the calculation within a reasonable time. This invention introduces a spatial hash data structure, transforming the "needle-in-a-haystack" global traversal search into a "precise positioning" query based on spatial location. Its core improvements (steps S2 and S3), namely spatial hash indexing and wide-stage matching, are essentially efficient "filters," with the average query complexity of spatial hashing approaching... This reduces the overall computational complexity of finding candidate matching curves for each boundary curve from Reduce to near This represents a leap in magnitude. Therefore, this invention achieves an exponential decrease in computational load by constructing a spatial hash index at the algorithmic level, thereby significantly saving total CPU processing time and improving efficiency.
[0058] In summary, the experimental data from this embodiment strongly demonstrates that the present invention, through the design of steps S2 (spatial hash index construction) and S3 (wide-stage candidate matching), successfully reduces the algorithmic complexity of topology reconstruction from... Reduced to near This technology greatly alleviates the problem of low efficiency in the processing of large and complex industrial models by existing technologies, and overcomes the computational efficiency bottleneck in processing complex industrial parts models with a large number of boundary curves, with significant beneficial effects.
[0059] It should also be noted that the method for efficiently constructing the topological relationships of a 3D entity model based on spatial hashing in the above embodiments can essentially be executed by a computer program or module. Therefore, similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a system for efficiently constructing the topological relationships of a 3D entity model based on spatial hashing, corresponding to the method for efficiently constructing the topological relationships of a 3D entity model based on spatial hashing provided in the above embodiments. Figure 3 As shown, it includes: The data acquisition module is used to acquire the data file storing the 3D model of the industrial parts to be processed, read the model data from the data file, parse the content of the data file into a set of independent, topologically unrelated complete external surface of the industrial parts, and extract all the boundary curves of the industrial parts contained in each surface in the set. The boundary curves of the industrial parts are used to define the actual boundary of the industrial parts in 3D space. The index building module is used to initialize a spatial hash data structure, traverse all industrial component boundary curves, extract the endpoint coordinates of each industrial component boundary curve, and insert the identification information of the industrial component boundary curve and its endpoint coordinates into the spatial hash data structure, thereby establishing a fast lookup index for the spatial location of the endpoints of the industrial component boundary curves; where the endpoint coordinates are the start coordinates and end coordinates of the industrial component boundary curve in three-dimensional space. The wide-stage candidate matching module is used to traverse all industrial component boundary curves again. For any industrial component boundary curve to be matched, the endpoint coordinates of the industrial component boundary curve are used to query the spatial hash data structure for industrial component boundary curves that are spatially adjacent to it to form a candidate curve set. The narrow-stage precision verification module is used to perform precise geometric consistency verification on each pair of curves, which consists of a boundary curve of an industrial component and a candidate curve from its corresponding set of candidate curves, to obtain geometrically coincident curve pairs within a preset error range. The topology generation module is used to create shared topological entities for geometrically overlapping curve pairs and construct complete boundary representation topologies. Ultimately, it stitches together discrete sets of trimmed surfaces into B-Rep solid models of industrial parts with complete connectivity, which are used by computer-aided manufacturing systems (CAM) to generate machining paths for industrial parts.
[0060] It is understood that the method for efficiently constructing the topological relationship of a three-dimensional solid model based on spatial hashing described in S1-S5 above can essentially be implemented by a computer program. Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer program product corresponding to the method for efficiently constructing the topological relationship of a three-dimensional solid model based on spatial hashing provided in the above embodiments. This product includes a computer program / instruction, which, when executed by a processor, can implement the method for efficiently constructing the topological relationship of a three-dimensional solid model based on spatial hashing as described in the above embodiments.
[0061] Similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer electronic device corresponding to the method for efficiently constructing the topological relationship of a three-dimensional entity model based on spatial hashing provided in the above embodiment, which includes a memory and a processor; The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement a method for efficiently constructing the topological relationships of a three-dimensional entity model based on spatial hashing, as described in the above embodiments.
[0062] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0063] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer-readable storage medium corresponding to the method for efficiently constructing the topological relationship of a three-dimensional entity model based on spatial hashing provided in the above embodiment. The storage medium stores a computer program, which, when executed by a processor, can realize the method for efficiently constructing the topological relationship of a three-dimensional entity model based on spatial hashing in the above embodiment.
[0064] Specifically, in the computer-readable storage medium of the above three embodiments, the stored computer program is executed by a processor, which can perform the aforementioned steps S1 to S5.
[0065] It is understood that the aforementioned storage media may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Furthermore, the storage media may also be various media capable of storing program code, such as USB flash drives, external hard drives, magnetic disks, or optical discs.
[0066] It is understood that the processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0067] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.
Claims
1. A method for efficiently constructing topological relations of three-dimensional solid models based on spatial hashing, characterized in that, The method comprises the following steps: S1. Obtain a data file storing a three-dimensional model of an industrial part to be processed, read model data from the data file, parse the data file content into a set of independent, non-topological associated complete shape surface set of industrial parts, and extract all industrial part boundary curves contained in each surface in the set, which are used to frame the actual boundary of the industrial part in three-dimensional space; S2. Initialize a spatial hash data structure, traverse all industrial part boundary curves, extract the endpoint coordinates of each industrial part boundary curve, and insert the identification information of the industrial part boundary curve into the spatial hash data structure together with the endpoint coordinates, thereby establishing a quick lookup index of the spatial position of the endpoint of the industrial part boundary curve; wherein the endpoint coordinates are the starting point coordinates and the ending point coordinates of the industrial part boundary curve in three-dimensional space; S3. Traverse all industrial part boundary curves again, for any industrial part boundary curve to be matched, use the endpoint coordinates of the industrial part boundary curve to query the industrial part boundary curves adjacent to its spatial position in the spatial hash data structure to form a candidate curve set; S4. Form a curve pair from an industrial part boundary curve and a candidate curve in the candidate curve set corresponding to the industrial part boundary curve, perform accurate geometric consistency verification on each curve pair, and obtain a curve pair that geometrically coincides within a preset error range; S5. Create a shared topological entity for the geometrically coinciding curve pair, and construct a complete boundary representation topological structure, finally stitch the discrete cutting surface set into an industrial part B-Rep entity model with complete connection relationship, which is used to generate a machining path of the industrial part by a computer-aided manufacturing system.
2. The method for efficiently constructing topological relations of three-dimensional solid models based on spatial hashing according to claim 1, wherein, In S1, each industrial part boundary curve contains its geometric definition and starting point coordinates and ending point coordinates in three-dimensional space.
3. The method for efficiently constructing topological relations of three-dimensional solid models based on spatial hashing according to claim 1, wherein, In S2, the spatial hash data structure internally maintains a mapping relationship, the key of which is a hash value calculated from the endpoint coordinates, and the value is a list for storing the identification information of the industrial part boundary curve.
4. The method for efficiently constructing topological relations of three-dimensional solid models based on spatial hashing according to claim 3, wherein, In S2, for each industrial part boundary curve, the specific process is as follows: S21. Obtain the starting point coordinates and ending point coordinates of each industrial part boundary curve, predefine a virtual three-dimensional grid, and assign a unique index to each grid cell in the virtual three-dimensional grid; S22. Map the starting point coordinates to the unique index of the first grid cell, and calculate a hash key according to the unique index of the first grid cell, then store the data structure containing the identification information of the industrial part boundary curve in the hash bucket corresponding to the hash key; S23. Map the ending point coordinates to the unique index of the second grid cell, and calculate another hash key according to the unique index of the second grid cell, then store the data structure containing the identification information of the industrial part boundary curve in the hash bucket corresponding to the calculated hash key.
5. The method for efficiently constructing topological relations of three-dimensional solid models based on spatial hashing according to claim 4, wherein, In S3, for each industrial part boundary curve, the specific process is as follows: S31. Obtain the starting point coordinates and ending point coordinates of each industrial part boundary curve; S32. Query the hash bucket corresponding to the starting point coordinate of the industrial part boundary curve, and query the hash bucket corresponding to the neighborhood of the starting point coordinate at the same time. All the industrial part boundary curve identification information obtained through the query of all the hash buckets of the starting point coordinate is summarized as a starting point candidate list; S33. Query the hash bucket corresponding to the ending point coordinate of the industrial part boundary curve, and query the hash bucket corresponding to the neighborhood of the ending point coordinate at the same time. All the industrial part boundary curve identification information obtained through the query of all the hash buckets of the ending point coordinate is summarized as an ending point candidate list; S34. From the starting point candidate list and the ending point candidate list, filter out the industrial part boundary curve whose one end point is adjacent to the starting point of the industrial part boundary curve and whose another end point is adjacent to the ending point of the industrial part boundary curve as a candidate curve, and form a candidate curve set.
6. The method for efficiently constructing topological relations of three-dimensional solid models based on spatial hashing according to claim 5, wherein, In S22, S23, S32 and S33, the identification information of the industrial part boundary curve is a pointer pointing to the industrial part boundary curve or an index of the industrial part boundary curve.
7. A system for efficiently constructing topological relations of three-dimensional solid models based on spatial hashing, characterized in that, Comprise: a data acquisition module, configured to acquire a data file storing a three-dimensional model of an industrial part to be processed, read model data from the data file, parse the data file content into a set of independent, topologically unassociated complete shape surface sets of the industrial part, and extract all the industrial part boundary curves contained in each surface in the set, the industrial part boundary curve being used to frame the actual boundary of the industrial part in the three-dimensional space; an index construction module, configured to initialize a spatial hash data structure, traverse all the industrial part boundary curves, extract the end point coordinates of each industrial part boundary curve, and insert the identification information of the industrial part boundary curve and its end point coordinates into the spatial hash data structure, so as to establish a fast lookup index of the spatial position of the end point of the industrial part boundary curve; wherein the end point coordinates are the starting point coordinates and the ending point coordinates of the industrial part boundary curve in the three-dimensional space; a wide-stage candidate matching module, configured to traverse all the industrial part boundary curves again, for any industrial part boundary curve to be matched, query the industrial part boundary curves adjacent to its spatial position in the spatial hash data structure to form a candidate curve set; a narrow-stage accurate verification module, configured to form a curve pair from one industrial part boundary curve and one candidate curve in the candidate curve set corresponding to the industrial part boundary curve, and perform accurate geometric consistency verification on each curve pair to obtain a curve pair geometrically coinciding within a preset error range; a topological structure generation module, configured to create a shared topological entity for the geometrically coinciding curve pair, and construct a complete boundary representation topological structure, finally stitch the discrete cutting surface set into an industrial part B-Rep entity model having complete connection relationship, for a computer-aided manufacturing system to generate a machining path of the industrial part.
8. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instructions are executed by the processor to implement the method for efficiently constructing a topological relationship of a three-dimensional entity model based on a spatial hash according to any one of claims 1-6. The computer program / instructions are executed by the processor to implement the method for efficiently constructing a topological relationship of a three-dimensional entity model based on a spatial hash according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and when the computer program is executed by a processor, a method for efficiently constructing a three-dimensional entity model topological relationship based on a space hash according to any one of claims 1-6 is implemented.
10. A computer electronic device, characterized in that, comprising a memory and a processor; The memory is configured to store a computer program. The processor is configured to implement the method for efficiently constructing a three-dimensional entity model topological relationship based on a space hash according to any one of claims 1-6 when the computer program is executed.
