A non-recursive method for calculating the distance from a spatial point to a given point set
Through non-recursive calculation methods and balanced binary tree structure, the problem of slow calculation speed of distance from space point to given point set in computational fluid mechanics is solved, efficient distance parameter calculation is realized, and computing performance is improved.
Patent Information
- Application Number
- CN202411935314.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-26
AI Technical Summary
In the prior art, in computational fluid mechanics, the calculation speed of the space point to a given point set distance is low, especially during the implicit assembly of overlapping grids and non-constant flow field simulation, resulting in low computational efficiency.
The non-recursive calculation method is used to initialize the geometric data of a given point set through a vector container, and generate a balanced binary tree retrieval structure. The non-recursive calculation of the distance between the spatial point and the given point set, and position the nearest point, finally freeing dynamic memory.
The time cost of automatic hole digging of overlapping grids and calculation of distance parameters in the non-constant flow field simulation is greatly reduced, and the calculation performance of computational fluid mechanics software is improved.
Smart Images

Figure CN119358462B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of computational fluid dynamics and computational geometry, and in particular to a non-recursive calculation method for the distance from a space point to a given point set. Background Art
[0002] In the process of using computational fluid dynamics methods to perform numerical simulation of physical fields, it is often necessary to calculate the distance between each discrete point in the space region and the wall point set. For example, in the implicit assembly process of overlapping grids, the spatial grid points Distance to the surface point set of the component to which it belongs And the distance to other component surface points , which is the key geometric parameter for automatic mesh hole digging. In the numerical simulation of turbulent effects, most turbulence models need to calculate the minimum distance from the center of the unit body to the element set on the solid wall surface. From the perspective of computational geometry, they can all be summarized as the calculation of the distance from a spatial point to a given point set. At present, refined flow field simulations related to complex configurations often rely on large grids, resulting in a sharp increase in the total amount of distance parameter calculations. At the same time, for the case of relative motion of components, unsteady flow field simulations need to update these distance parameters at each physical time step. They have become common efficiency hotspots, restricting the in-depth application of computational fluid dynamics software. Therefore, it is particularly important to develop high-performance methods to improve the calculation speed of distance parameters. Summary of the invention
[0003] In order to overcome the deficiencies of the prior art, the present invention provides a non-recursive calculation method for the distance from a spatial point to a given point set, which solves the problems of low calculation speed in the prior art.
[0004] The technical solution adopted by the present invention to solve the above problems is:
[0005] A non-recursive method for calculating the distance from a spatial point to a given point set comprises the following steps:
[0006] Step 1: Use a vector container to initialize and store the geometric data of a given point set;
[0007] Step 2: Generate a balanced binary tree retrieval structure in a non-recursive mode;
[0008] Step 3: Non-recursively calculate the distance from the spatial point to the given point set and locate the nearest point;
[0009] Step 4: When the positioning is completed, release the dynamic memory allocated for the internal members of the balanced binary tree.
[0010] As a preferred technical solution, in step 1, it is assumed that The given point set of point elements is , define a Vector container, sequential storage Points The address value is recorded as , where the class describing the point element information contains two basic data: ① The spatial coordinates of the point element, in the form of a double-precision floating-point array The identifier, its length and spatial dimension Same;②Point elements in The initial sequence number in the signed integer variable Identification; at a given point set In the example, any two different point elements have different value.
[0011] As a preferred technical solution, in step 2, All elements in are divided into multiple finite point subsets for storage, and each finite point subset forms a one-to-one mapping relationship with the relevant nodes on the balanced binary tree; among them, the finite point subset contained in each non-terminal node is the union of the finite point subsets contained in its left child and right child nodes, and the finite point subsets contained in the same-level brother nodes do not intersect with each other.
[0012] As a preferred technical solution, in step 2, As a binary tree node type name, The internal member variables of include: ① The finite point subset elements contained in the current node are The starting subscript in ;②The finite point subset elements contained in the current node are The end subscript in ;③The finite point subset contained in the current node is The infimum array in the directions ; ④ The finite point subset contained in the current node is The supremum array in the directions ; ⑤The left child pointer of the current node , whose initialization value is a null pointer ;⑥The right child pointer of the current node , whose initialization value is a null pointer .
[0013] As a preferred technical solution, step 2 includes the following steps:
[0014] Step 21: Set a finite point subset length threshold for a balanced binary tree and use a signed integer member variable Store; if the current node contains a finite number of point subset elements Satisfy the conditions , then the current node is identified as a non-terminal node and needs to continue non-recursive partitioning; otherwise, the current node is identified as a terminal node;
[0015] Step 22: Global root node pointer for a balanced binary tree Construct an instantiated object;
[0016] Step 23: Declare the working stack required for the non-recursive construction of a balanced binary tree: The pointer type declares a fixed length Register array , while using signed integer register variables Identifies the top position of the stack. The initial value of is set to -1;
[0017] Step 24: Combine The type of loop pattern is used to non-recursively construct the nodes at each level of a balanced binary tree.
[0018] As a preferred technical solution, in step S22, first, a pointer is created on the heap. Open up dynamic memory space and pass node type The constructor of and Assign a value of 0 and ; Then, Type declares a register pointer variable , and use The address value is initialized; among them, express The total length of
[0019] As a preferred technical solution, step 24 includes the following steps:
[0020] Step 241: Extract the current Internal member variables of the node object pointed to by the pointer and The value of Calculate the point elements contained in the node object in each coordinate axis direction The variance of the coordinate components of the Record the direction number corresponding to the maximum variance; among them, is an integer and ;
[0021] Step 242: Along the direction of maximum variance, according to the coordinate components of the point elements The rules from small to large are currently The point element address value contained in the node object pointed to by the pointer Sort by
[0022] Step 243: Calculate the current The upper and lower bounds of the space bounding box of the node object pointed to by the pointer, along coordinate axis directions, respectively calculate the current The point element contained in the node object pointed to by the pointer The coordinate components The infimum of Supremum ;in, is an integer and ;
[0023] Step 244: Construct the current The left child and right child of the node object pointed to by the pointer;
[0024] Step 245: First, set the register pointer variable point to The top member of the stack, that is , and then let the register variable The value of is reduced by 1;
[0025] When the register pointer variable When the address value of is not empty, execute steps 241 to 244, otherwise execute step 245; when When the loop terminates, the construction process of the balanced binary tree is completed.
[0026] As a preferred technical solution, step 3 includes the following steps:
[0027] Step 31: Declare a register variable of pointer type , and use Initialize the address value pointed to;
[0028] Step 32: Declare the two work stacks required for the non-recursive traversal of the binary tree: Pointer type declares a fixed length Register array , declare a register array of the same length as double-precision floating-point type ; At the same time, with a signed integer register variable Identifies the top position of the stack. The initial value of is -1;
[0029] Step 33: Combine The loop mode non-recursively calculates the square of the distance from a spatial point to a given point set and locates the nearest point.
[0030] As a preferred technical solution, step 33 includes the following steps:
[0031] Step 331: If Object and Both exist, then define and initialize two local node pointers as follows:
[0032] , ;
[0033] Calculate separately Point to the nearest node pointer Far node pointer The square value of the distance between the bounding boxes of the two subtrees of the root node and ,set up The parameters of the lower and upper bounds of the bounding box corresponding to the node are and ,at the same time Point at The projection component on Defined as: If ,So ;if ,So ;if ,So , ;Pick The corresponding bounding box infra and supremum parameters of the node are calculated The value of , then exchange and Values and swap and direction; if , then the register pointer variable The pointer is changed to the near node pointer Otherwise, it is changed to a null address value. ;if , then first make the register variable The value of is accumulated by 1, and then , ;in, Represents the square value of the distance from a spatial point to a given point set. express Any point in dimensional space The coordinate array of express No. Quantity;
[0034] Step 332: If Object and All point to empty address values , then extract the current The object contains the starting and ending range parameters of the given point subset, and stores their values in signed integer register variables and Then, traverse A fragment of a sequence with consecutive subscripts The range is , calculate successively Point to point elements The square of the distance ,if , then The value of is updated to Simultaneously balance the nearest point pointer of a binary tree Point to the current point element The address of; finally, when the traversal is completed, the register pointer variable Points to a null address ;
[0035] Step 333: If condition Established, then first point to The stored binary tree node address value, otherwise it points to an empty address , then make the register variable The value of is reduced by 1;
[0036] Step 334: Return The square root of As a point To a given point set sequence The distance, at this time the nearest point pointer of the balanced binary tree Pointing Distance point in sequence The first address of the most recent element, which can be accessed through the interface function Points to more detailed data;
[0037] When register variables When the value of is not a null address value, execute step 331 to step 332, otherwise execute step 333; when At the end of the cycle, The final value of is obtained and the position of the nearest point element is determined.
[0038] As a preferred technical solution, in step 4, for a given point set sequence The heap space occupied by each element is released according to the sequential traversal process of the vector; the heap space occupied by each layer of nodes in the balanced binary tree is released according to the pre-order traversal process of the fork tree structure.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] (1) In the implicit assembly process of super-large-scale overlapping grids with a scale of more than 100 million, the non-recursive calculation model of the distance from a spatial point to a given point set can quickly obtain the distance parameters from the spatial grid point to the grid point set on the solid wall surface, thereby greatly reducing the time cost of automatic digging holes in overlapping grids;
[0041] (2) In the unsteady simulation process of flow field based on ultra-large-scale moving grids of the order of 100 million, the non-recursive calculation model of the distance from a spatial point to a given point set can quickly update the distance parameter from the center of each volume unit to the center of the surface element of the solid wall, thereby reducing the time cost of turbulence simulation at each physical time step. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a flow chart of the non-recursive algorithm for the distance from a spatial point to a given point set of the present invention;
[0043] Figure 2 It is a given point set element data structure and its vector mapping relationship diagram of the present invention;
[0044] Figure 3 It is a mapping diagram of the internal members of the binary tree node of the present invention and its corresponding given point subset;
[0045] Figure 4 It is a schematic diagram of the non-recursive construction process of nodes at each layer of the binary tree of the present invention;
[0046] Figure 5 This is a diagram showing the effect of the overlapping grids digging holes in the three-body delivery model of the present invention (section x=5.2). DETAILED DESCRIPTION
[0047] The present invention will be further described in detail below in conjunction with embodiments and drawings, but the embodiments of the present invention are not limited thereto.
[0048] Example 1
[0049] like Figures 1 to 5 As shown, in view of the problems of the prior art, the present invention provides a non-recursive calculation method for the distance from a spatial point to a given point set. In a standard C++ programming environment, Figure 1 As shown in the figure, its implementation process includes the following 4 basic steps.
[0050] Step 1: Use a vector container to initialize and store the geometric data of a given point set. In the initial stage, assume that The given point set of point elements is , the present invention allows There are point elements with the same spatial coordinates in . Figure 2 As shown, calling the C++ standard template library, the present invention defines a A vector container ( ), sequential storage Points The address value is recorded as , where the description point element ( ) The class composed of information contains two basic data: ① The spatial coordinates of the point element, in the form of a double-precision floating-point array The identifier, its length and spatial dimension The same. ② The point element is The initial sequence number in the signed integer variable Identification. In a given point set In the example, any two different point elements have different value.
[0051] Step 2: Generate a balanced binary tree retrieval structure in non-recursive mode. In the current step, you need to All elements in are divided into multiple finite point subsets for storage, and each finite point subset forms a one-to-one mapping relationship with the relevant nodes on the balanced binary tree. Among them, the finite point subset contained in each non-terminal node is the union of the finite point subsets contained in its left and right child nodes, and the finite point subsets contained in the same-level brother nodes do not intersect with each other. In the present invention, is the name of the binary tree node type, such as Figure 3 As shown, its internal member variables are: ① The finite point subset elements contained in the current node are in The starting subscript in ;②The finite point subset elements contained in the current node are The end subscript in ;③The finite point subset contained in the current node is The infimum array in the directions ; ④ The finite point subset contained in the current node is The supremum array in the directions ; ⑤The left child pointer of the current node , whose initialization value is a null pointer ;⑥The right child pointer of the current node , whose initialization value is a null pointer . Figure 4The figure shows the non-recursive construction process of nodes at each level of a binary tree, where each ellipse corresponds to a node of the binary tree, and the two solid arrows extending to the lower left and lower right point to the left child and right child of the current node respectively; the number in the ellipse indicates the start of the binary tree node instantiation (i.e. The order of calculation of the first, second, fifth, and sixth internal member variables of the binary tree is shown in Figure 1. The dashed arrow indicates that the instantiation of the binary tree node is completed (i.e. The order of calculation of the ③ and ④ internal member variables).
[0052] Furthermore, step 2 can be divided into the following 4 steps:
[0053] Step 21: Set a finite point subset length threshold for a balanced binary tree and use a signed integer member variable If the current node contains a finite number of point subset elements Satisfy the conditions , then the current node is identified as a non-terminal node and needs to continue to perform non-recursive partitioning; otherwise, the current node is identified as a terminal node. In the embodiment of the present invention, based on the comprehensive consideration of the binary tree height control factor and the local nearest point fast search factor, the setting The value of is 24.
[0054] Step 22: Global root node pointer for a balanced binary tree Construct an instantiated object. First, create a pointer on the heap Open up dynamic memory space and pass node type The constructor of and Assign a value of 0 and ( That is Then, Type declares a register pointer variable , and use Initialize it with the address value.
[0055] Step 23: Declare the working stack required for the non-recursive construction of a balanced binary tree. The pointer type declares a fixed length Register array , while using signed integer register variables Identifies the top position of the stack. The initial value is set to -1 (that is, the initial stack is an empty stack). In an embodiment of the present invention, The value of is a constant 32. Combined with the subsequent non-recursive construction steps, we can see that the working stack The length of is not less than the depth of the balanced binary tree. The value of is 32, then the maximum total number of nodes in a balanced binary tree on a single processor is , which exceeds the upper limit of the value of the computer's signed integer variable, so The length is sufficient.
[0056] Step 24: Combine The type of loop pattern is non-recursive to construct the nodes at each level of the balanced binary tree. Here The logical condition for the execution of the loop is the register pointer variable The address value pointed to is not empty or a register variable The value is not equal to -1 (that is, the working stack Non-empty stack). Under this premise, according to the variance analysis and sorting algorithm of the coordinate components of the given point subset, the instantiation of the node objects at each level of the balanced binary tree is performed, and the calculation of related parameters is completed. The process can be described as follows: when the register pointer variable When the address value of is not empty, execute steps 241 to 244, otherwise execute step 245. When the loop terminates, the construction process of the balanced binary tree is completed.
[0057] Step 241: Extract the current Internal member variables of the node object pointed to by the pointer and The value of Calculate the point elements contained in the node object in each coordinate axis direction (Continuous subscript The range is ) and use signed integer register variables Record the direction number corresponding to the maximum variance.
[0058] Step 242: Along the direction of maximum variance, according to the coordinate components of the point elements The rules from small to large are currently The point element address value contained in the node object pointed to by the pointer (Continuous subscript The range is ) to sort. The present invention directly calls the C++ standard template library The generic algorithm completes this sorting process to achieve the optimal combination of quick sort, heap sort and insertion sort, thereby reducing the time cost of non-recursive construction of a balanced binary tree.
[0059] Step 243: Calculate the current The upper and lower bounds of the spatial bounding box of the node object pointed to by the pointer. coordinate axis directions, respectively calculate the current The point element contained in the node object pointed to by the pointer (Continuous subscript The range is ) The infimum of Supremum , (continuous subscript The range is ). The present invention directly calls the C++ standard template library and The generic algorithm completes this calculation process.
[0060] Step 244: Construct the current The left and right children of the node object pointed to by the pointer. In steps 241 to 243, the internal member variables and Identifies the current subtree at a given point sequence The starting and ending range of the point subset involved in . Since in step 242, along the sequence number The maximum variance direction of the subscript The range is The subset elements are reordered, so the signed integer register variable is defined For use in sequence Mark the median element on the . Established, then first The right child member of the object being referred to Instantiate, it contains a given subset of points in The start and end numbers in are set to and , then register variable The value is accumulated by 1 (stack operation), and then used Store the right child member The address value of . Established, then first The left child member of the object being referred to Instantiate, it contains a given subset of points in The start and end numbers in are set to and , then Pointer to the left child member The address value of Points to a null address value .
[0061] Step 245: First, set the register pointer variable point to The top member of the stack, that is , and then let the register variable The value of is reduced by 1 (stack pop operation).
[0062] Step 3: Non-recursively calculate the distance from the spatial point to the given point set and locate the nearest point. Any point in dimensional space The coordinate array is , To a given set of points The square value of the distance uses a double-precision floating-point register variable Storage, whose initial value is a sufficiently large floating-point constant (In the embodiment of the present invention, ). A non-recursive search function with no return type and its parameter list is declared as , where the double-precision floating-point parameter for The first address of the point coordinates (constant pointer transfer), double-precision floating-point parameter That is To a given set of points The square value of the distance (reference transfer). After the parameter transfer is completed, the distance from the spatial point to the given point set can be calculated according to steps 31 to 34 and the nearest point can be located.
[0063] Step 31: Declare a register variable of pointer type , and use Initializes the value of the address pointed to.
[0064] Step 32: Declare the two work stacks required for the non-recursive traversal of the binary tree. Pointer type declares a fixed length Register array , declare a register array of the same length as double-precision floating-point type ; At the same time, with a signed integer register variable Identifies the top position of the stack. The initial value of is -1. In the embodiment of the present invention, consistent with step 23, The value in the current function scope is still the constant 32.
[0065] Step 33: Combine The type of loop pattern non-recursively calculates the square value of the distance from a spatial point to a given point set And locate the nearest point. The logical condition of the loop execution is a register variable The value is a non-empty address value, or a register variable The value of is not equal to -1. The process can be described as follows: when the register variable When the value of is not a null address value, execute steps 331 to 332, otherwise execute step 333. At the end of the cycle, The final value of is obtained and the position of the nearest point element is determined.
[0066] Step 331: If the current subtree root node is a non-terminal node, that is The left child pointer of the object and the right child pointer Both exist, then define and initialize two local node pointers as follows:
[0067] , Calculate separately Point to Near Node Pointer (To a known point The node pointer variable to which the nearer subtree bounding box belongs) and the far node pointer (To a known point The node pointer variable to which the bounding box of the farther subtree belongs) is the square value of the distance between the bounding boxes of the two subtrees of the root node and .set up The parameters of the lower and upper bounds of the bounding box corresponding to the node are and ,at the same time Point at dimension( ) on the projection component Defined as: If ,So ;if ,So ;if ,So . Further, Similarly, take The corresponding bounding box infra and supremum parameters of the node, by analogy The calculation process can be obtained If , then exchange and Values and swap and If , then the register pointer variable The direction of Otherwise, it is changed to a null address value. .if , then first make the register variable The value of is accumulated by 1, and then , (Push operation).
[0068] Step 332: If the current subtree root node is a terminal node, that is The left child pointer of the object and the right child pointer All point to empty address values , then extract the current The object contains the starting and ending range parameters of the given point subset, and stores their values in signed integer register variables and Next, traverse A fragment of a sequence with consecutive subscripts The range is , calculate successively Point to point elements The square of the distance ,if , then The value of is updated to Simultaneously balance the nearest point pointer of a binary tree Point to the current point element Finally, when the traversal is completed, the register pointer variable Points to a null address .
[0069] Step 333: If condition Established, then first point to The stored binary tree node address value, otherwise it points to an empty address , then make the register variable The value of is reduced by 1 (pop operation).
[0070] Step 34: Return The square root of As a point To a given point set sequence The distance, at this time the nearest point pointer of the balanced binary tree Pointing Distance point in sequence The first address of the most recent element, which can be accessed through the interface function It is pointed to more detailed data. It is explained that, in the implementation step 3 of the present invention, only the square value of the relevant distance parameter is stored to avoid the influence of frequent square root operations on the computing performance.
[0071] Step 4: When the positioning is completed, release the dynamic memory opened by the internal members of the balanced binary tree, which are: ① Given point set sequence ② The heap space occupied by each element of the tree is released according to the sequential traversal process of the vector. ② The heap space occupied by each layer of the nodes in the balanced binary tree is released according to the pre-order traversal process of the fork tree structure.
[0072] Example 2
[0073] like Figures 1 to 5 As shown, as a further optimization of Example 1, based on Example 1, this embodiment also includes the following technical features:
[0074] In order to enable ordinary technicians in this field to better understand the technical solution of the present invention, the following takes the high-speed flow CFD simulation software HyFLOW in the national numerical wind tunnel project as an example to further describe the technical solution of the present invention. The original HyFLOW software relies on the implicit assembly module of the structural overlapping grid and combines the turbulence model to have the unsteady heat flow simulation function based on the moving grid. Among them, in the implicit assembly module of the overlapping grid, the wall distance parameter of the spatial grid point is obtained by the classic cyclic box algorithm; in the unsteady heat flow simulation process, the wall distance parameter of the volume unit cell center in the turbulence model is obtained by the classic multidimensional digital tree algorithm. With the increase of the grid scale, the time consumption generated by the above two algorithms in the calculation of the wall distance parameter increases rapidly. In order to improve the computing performance of the HyFLOW software as a whole, the technical solution of the present invention is applied to the new version of the HyFLOW software, and the cyclic box algorithm and the multidimensional digital tree algorithm are replaced in the implicit assembly module of the overlapping grid and the unsteady heat flow simulation module, respectively, and the time cost is compared.
[0075] like Figure 4 As shown, each node of the balanced binary tree is constructed in sequence in the order of pre-order traversal. Figure 4 In the figure, the ellipse represents a node, and the number inside the ellipse represents the pre-order traversal number of the current node (that is, the construction order number of the current node). For example, the number 0 represents the pre-order traversal number of the current node is 0, the number 6 represents the pre-order traversal number of the current node is 6, and the number 14 represents the pre-order traversal number of the current node is 14.
[0076] Figure 5The embodiment model selected by the present invention is shown, which is a wing with three missile bodies mounted under it. Independent structural grids are generated around these four components, so that the total number of spatial grid points reaches 632011834 and the total number of volume units reaches 615807000. On a domestic high-performance cluster, 240 core computing resources are called. At the initial moment, the wall distance parameters of the spatial grid points are calculated using the cyclic box algorithm and the algorithm of the present invention respectively. The corresponding wall time consumption is 615.36s and 29.74s respectively. It can be seen that the algorithm of the present invention reduces the time cost by 95.2%; similarly, at the initial moment, the multidimensional digital tree method and the algorithm of the present invention are used to calculate the wall distance parameters of the volume unit center in the turbulence model respectively. The corresponding wall time is 29.43s and 10.82s respectively. It can be seen that the algorithm of the present invention reduces the time cost by 63.2%. The embodiment shows that the application of the present invention greatly reduces the time consumed in the motion overlapping grid assembly and the wall distance parameter update during the unsteady heat flow simulation, and improves the computing performance of the simulation software.
[0077] As described above, the present invention can be preferably implemented.
[0078] All features disclosed in all embodiments in this specification, or steps in all methods or processes implicitly disclosed, except for mutually exclusive features and / or steps, can be combined and / or expanded or replaced in any manner.
[0079] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. According to the technical essence of the present invention, within the spirit and principles of the present invention, any simple modification, equivalent replacement and improvement made to the above embodiment still falls within the protection scope of the technical solution of the present invention.
Claims
1. A non-recursive method for calculating the distance from a spatial point to a given point set, characterized in that: The following steps are involved: Step 1: Use a vector container to initialize and store the geometric data of a given point set; Step 2: Generate a balanced binary tree retrieval structure in a non-recursive mode; Step 3: Non-recursively calculate the distance from the spatial point to the given point set and locate the nearest point; Step 4: After the positioning is completed, the dynamic memory allocated for the internal members of the balanced binary tree is released; In step 1, let The given point set of point elements is , define a Vector container, sequential storage Points The address value is recorded as , where the class describing the point element information contains two basic data: ① The spatial coordinates of the point element, in the form of a double-precision floating-point array The identifier, its length and spatial dimension Same;②Point elements in The initial sequence number in the signed integer variable Identification; at a given point set In the example, any two different point elements have different value; In step 2, All elements in are divided into multiple finite point subsets for storage, and each finite point subset forms a one-to-one mapping relationship with the relevant nodes on the balanced binary tree; the finite point subset contained in each non-terminal node is the union of the finite point subsets contained in its left child and right child nodes, and the finite point subsets contained in the same-level brother nodes do not intersect with each other; In step 2, As a binary tree node type name, The internal member variables of include: ① The finite point subset elements contained in the current node are The starting subscript in ;②The finite point subset elements contained in the current node are The end subscript in ;③The finite point subset contained in the current node is The infimum array in the directions ; ④ The finite point subset contained in the current node is The supremum array in the directions ; ⑤The left child pointer of the current node , whose initialization value is a null pointer ;⑥The right child pointer of the current node , whose initialization value is a null pointer ; Step 2 includes the following steps: Step 21: Set a finite point subset length threshold for a balanced binary tree and use a signed integer member variable Store; if the current node contains a finite number of point subset elements Satisfy the conditions , then the current node is identified as a non-terminal node and needs to continue non-recursive partitioning; otherwise, the current node is identified as a terminal node; Step 22: Global root node pointer for a balanced binary tree Construct an instantiated object; Step 23: Declare the working stack required for the non-recursive construction of a balanced binary tree: The pointer type declares a fixed length Register array , while using signed integer register variables Identifies the top position of the stack. The initial value of is set to -1; Step 24: Combine The type of loop pattern non-recursively constructs the nodes at each level of the balanced binary tree; In step S22, first, a pointer is created on the heap. Open up dynamic memory space and pass node type The constructor of and Assign a value of 0 and ; Then, Type declares a register pointer variable , and use The address value is initialized; among them, express Total length; Step 24 includes the following steps: Step 241: Extract the current Internal member variables of the node object pointed to by the pointer and The value of Calculate the point elements contained in the node object in the directions of the coordinate axes The variance of the coordinate components of the Record the direction number corresponding to the maximum variance; among them, is an integer and ; Step 242: Along the direction of maximum variance, according to the coordinate components of the point elements The rules from small to large are currently The point element address value contained in the node object pointed to by the pointer Sort by Step 243: Calculate the current The upper and lower bounds of the space bounding box of the node object pointed to by the pointer, along coordinate axis directions, respectively calculate the current The point element contained in the node object pointed to by the pointer The coordinate components The infimum of Supremum ;in, is an integer and ; Step 244: Construct the current The left child and right child of the node object pointed to by the pointer; Step 245: First, set the register pointer variable point to The top member of the stack, that is , and then let the register variable The value of is reduced by 1; When the register pointer variable When the address value of is not empty, execute steps 241 to 244, otherwise execute step 245; when When the loop terminates, the construction process of the balanced binary tree is completed.
2. A non-recursive calculation method for the distance from a spatial point to a given point set according to claim 1, characterized in that: Step 3 includes the following steps: Step 31: Declare a register variable of pointer type , and use Initialize the address value pointed to; Step 32: Declare the two work stacks required for the non-recursive traversal of the binary tree: Pointer type declares a fixed length Register array , declare a register array of the same length as double-precision floating-point type ; At the same time, with a signed integer register variable Identifies the top position of the stack. The initial value of is -1; Step 33: Combine The loop mode non-recursively calculates the square of the distance from a spatial point to a given point set and locates the nearest point.
3. The non-recursive calculation method of the distance from a spatial point to a given point set according to claim 2, characterized in that: Step 33 includes the following steps: Step 331: If Object and Both exist, then define and initialize two local node pointers as follows: , ; Calculate separately Point to the nearest node pointer Far node pointer The square value of the distance between the bounding boxes of the two subtrees of the root node and ,set up The parameters of the lower and upper bounds of the bounding box corresponding to the node are and ,at the same time Point at The projection component on Defined as: If ,So ;if ,So ;if ,So , ;Pick The corresponding bounding box infra and supremum parameters of the node are calculated The value of , then exchange and Values and swap and direction; if , then the register pointer variable The pointer is changed to the near node pointer Otherwise, it is changed to a null address value. ;if , then first make the register variable The value of is accumulated by 1, and then , ;in, Represents the square value of the distance from a spatial point to a given point set. express Any point in dimensional space The coordinate array of express No. Quantity; Step 332: If The left child pointer of the object and All point to empty address values , then extract the current The object contains the starting and ending range parameters of the given point subset, and stores their values in signed integer register variables and Then, traverse A fragment of a sequence with consecutive subscripts The range is , calculate successively Point to point elements The square of the distance ,if , then The value of is updated to Simultaneously balance the nearest point pointer of a binary tree Point to the current point element The address of; finally, when the traversal is completed, the register pointer variable Points to a null address ; Step 333: If condition Established, then first point to The stored binary tree node address value, otherwise it points to an empty address , then make the register variable The value of is reduced by 1; Step 334: Return The square root of As a point To a given point set sequence The distance, at this time the nearest point pointer of the balanced binary tree Pointing Distance point in sequence The first address of the most recent element, which can be accessed through the interface function Points to more detailed data; When register variables When the value of is not a null address value, execute step 331 to step 332, otherwise execute step 333; when At the end of the cycle, The final value of is obtained and the position of the nearest point element is determined.
4. A non-recursive calculation method for the distance from a spatial point to a given point set according to any one of claims 1 to 3, characterized in that: In step 4, for a given point set sequence The heap space occupied by each element is released according to the sequential traversal process of the vector; the heap space occupied by each layer of nodes in the balanced binary tree is released according to the pre-order traversal process of the fork tree structure.
Citation Information
Patent Citations
A curved surface non-iterative re-gridding method represented by triangular grids
CN109671154A
Web end real-time hybrid rendering method and device combined with ray tracing and computer equipment
CN111340928A