CN116912457A - Topology reconstruction method and system based on external memory octree STL model - Google Patents

Topology reconstruction method and system based on external memory octree STL model Download PDF

Info

Publication number
CN116912457A
CN116912457A CN202311047216.9A CN202311047216A CN116912457A CN 116912457 A CN116912457 A CN 116912457A CN 202311047216 A CN202311047216 A CN 202311047216A CN 116912457 A CN116912457 A CN 116912457A
Authority
CN
China
Prior art keywords
dimensional
grid
model
octree
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311047216.9A
Other languages
Chinese (zh)
Inventor
贺可太
翟晨龙
孟晓伟
李岩席
朱冬梅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
University of Science and Technology Beijing USTB
Original Assignee
University of Science and Technology Beijing USTB
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by University of Science and Technology Beijing USTB filed Critical University of Science and Technology Beijing USTB
Priority to CN202311047216.9A priority Critical patent/CN116912457A/en
Publication of CN116912457A publication Critical patent/CN116912457A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/20Finite element generation, e.g. wire-frame surface description, tesselation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • G06T9/40Tree coding, e.g. quadtree, octree
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2200/00Indexing scheme for image data processing or generation, in general
    • G06T2200/04Indexing scheme for image data processing or generation, in general involving 3D image data

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Geometry (AREA)
  • Software Systems (AREA)
  • Multimedia (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a topology reconstruction method and a topology reconstruction system based on an external memory octree STL model, which relate to the technical field of data processing, and the method comprises the following steps: performing segmentation processing and projection processing on the three-dimensional STL model to be processed to obtain two-dimensional plane data of a plurality of sub-final parts; performing grid segmentation on the two-dimensional plane data by adopting an octree algorithm, and determining the vertex of each grid after segmentation; constructing a color quadtree; traversing the color quadtree by adopting a breadth-first algorithm to determine a grid to be thinned; performing grid segmentation on each grid to be refined, constructing an octree based on the segmented grids, and storing the octree into corresponding nodes in the color quadtree; determining three-dimensional coordinates of a reconstruction point based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model; and reconstructing the three-dimensional grid model with the topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree. The invention realizes multi-resolution display of the three-dimensional grid model and improves the model opening efficiency.

Description

Topology reconstruction method and system based on external memory octree STL model
Technical Field
The invention relates to the technical field of data processing, in particular to a topology reconstruction method and system based on an external memory octree STL model.
Background
Model engineering files of tens or even hundreds of millions of geometric primitives exist in additive manufacturing, computer aided design, three-dimensional model scanning and finite element simulation, and the phenomena of blocking and slow loading exist when application software is opened. A complex large model rapid parameterization modeling control method and different hierarchy parameterization modeling strategies are researched, and the model multi-resolution display is realized to improve the model running speed. In the field of additive manufacturing, an STL file is a commonly used model file format, the outer surface of a model is scanned, the original surface is approximately replaced by a mode of splicing a plurality of triangular patches, however, after a three-dimensional CAD file is stored into the STL file, the original topological relation is lost, so that the same vertex repeatedly appears, the read data of the increased data quantity can only be fully loaded, and the model operation efficiency is low.
The grid of the STL file belongs to unstructured, the unstructured grid has better geometric adaptability, the density control can be realized more conveniently, and the corresponding grid generation algorithm has higher automation degree. In the surface grid, the grid cells commonly used by the unstructured grid are triangles, and the grid cells commonly used by the structured grid are quadrilaterals. Three-dimensional models often contain many complex geometric features that require a grid with good geometric adaptation that would otherwise degrade the quality of the grid.
Disclosure of Invention
The invention aims to provide a topology reconstruction method and a topology reconstruction system based on an external memory octree STL model, which realize multi-resolution display of a three-dimensional grid model and improve the model opening efficiency.
In order to achieve the above object, the present invention provides the following solutions:
a topology reconstruction method based on a memory octree STL model comprises the following steps:
performing segmentation processing and projection processing on the three-dimensional STL model to be processed to obtain model two-dimensional plane data; the model two-dimensional plane data comprises two-dimensional plane data of a plurality of final sub-parts;
for the two-dimensional plane data of each final subsection, performing grid segmentation on the two-dimensional plane data by adopting an octree algorithm, and determining the vertex of each grid after segmentation;
constructing a color quadtree based on the vertexes of each grid after segmentation; the color information stored in the color quadtree represents the position of the vertex of the grid;
traversing the color quadtree by adopting a breadth-first algorithm to determine a grid to be thinned;
performing grid segmentation on each grid to be refined, constructing an octree based on the segmented grids, and storing the octree into corresponding nodes in the color quadtree;
determining three-dimensional coordinates of a reconstruction point based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model;
and reconstructing to obtain a three-dimensional grid model with a topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree.
Optionally, the three-dimensional STL model to be processed includes a plurality of triangular patches and normal vector data of each triangular patch;
the method comprises the steps of carrying out segmentation processing and projection processing on a three-dimensional STL model to be processed to obtain model two-dimensional plane data, and specifically comprises the following steps:
selecting a triangular patch from the three-dimensional STL model to be processed, taking the selected triangular patch as an initial subsection, and taking normal vector data of the initial subsection as a reference normal vector;
calculating a vector angle based on the reference normal vector and normal vector data of the adjacent triangular patches; the adjacent triangular patches are any triangular patch adjacent to the initial subsection;
when the normal vector included angle is within a preset included angle range, combining the adjacent triangular patches with the initial sub-part to obtain an updated initial sub-part, and returning to the normal vector data based on the reference normal vector and the adjacent triangular patches to calculate a normal vector included angle;
when the normal vector included angle is not in the preset included angle range, determining the initial sub-part as a final sub-part;
wrapping the final subsection with an AABB bounding box to obtain a box-like section;
projecting the box-shaped part to obtain two-dimensional plane data of the final subsection; the two-dimensional plane data of the plurality of final sub-portions constitutes model two-dimensional plane data.
Optionally, projecting the box-like portion to obtain two-dimensional plane data of the final subsection, including:
projecting the box-shaped part to obtain bounding box projection point data and sub-part boundary projection point data respectively;
storing the bounding box projection point data and the sub-part boundary projection point data into a preset data table;
invoking the preset data table, connecting the bounding box projection point data on a two-dimensional plane to obtain a bounding box frame, and connecting the sub-part boundary projection point data to obtain a sub-part bounding box; the bounding box border and the sub-portion bounding box form two-dimensional plane data of the final sub-portion.
Optionally, an octree algorithm is adopted to segment the two-dimensional plane data and determine the vertex of each segmented grid, which specifically comprises:
based on an octree algorithm, carrying out grid segmentation on the bounding box frame so as to determine three vertexes of each grid after segmentation;
based on the vertexes of each grid after segmentation, constructing a color quadtree specifically comprises:
if three vertexes of each grid are all in the sub-part surrounding frame after the division, determining the marking color of the grid as a first color;
if the three vertexes of each grid are outside the subsection bounding box after the division, determining the marking color of the grid as a second color;
if any one of the three vertexes of each grid after the segmentation is positioned in the sub-part bounding box and any one vertex is positioned outside the sub-part bounding box, determining the marking color of the grid as a third color; the grid corresponding to the third color is a grid to be thinned;
and constructing a color quadtree based on all grids after segmentation and the marking color of each grid.
Optionally, the three-dimensional STL model to be processed further includes vertex coordinate data of each triangular patch;
determining three-dimensional coordinates of a reconstruction point based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model, specifically comprising:
projecting the vertex of each triangular patch in the three-dimensional STL model to be processed to a two-dimensional plane, and determining position data of a plurality of two-dimensional patch points according to vertex coordinate data of each triangular patch;
determining position data of two-dimensional vertexes of each grid based on the octree and the model two-dimensional plane data;
taking the two-dimensional vertexes of any grid as a starting point, and calculating to obtain a vertex patch distance set based on the position data of the starting point and the position data of any two-dimensional patch point;
selecting a minimum value from the vertex patch distance set, and marking a triangular patch corresponding to the minimum value as a standby patch;
determining a standby straight line, and then determining the intersection point coordinates of the standby straight line and the standby patch; the standby straight line is a straight line passing through the starting point and parallel to the reference normal vector of the final subsection where the starting point is located; the intersection point coordinate is the Z-axis coordinate of the starting point; the position data and the Z-axis coordinate of the starting point form a three-dimensional coordinate of a reconstruction point of the starting point; and the three-dimensional coordinates of the reconstruction points of the plurality of starting points form the three-dimensional coordinates of the reconstruction points of the three-dimensional STL model to be processed.
In order to achieve the above purpose, the present invention also provides the following technical solutions:
a topology reconstruction system based on a memory octree STL model, comprising:
the segmentation projection processing module is used for carrying out segmentation processing and projection processing on the three-dimensional STL model to be processed so as to obtain model two-dimensional plane data; the model two-dimensional plane data comprises two-dimensional plane data of a plurality of final sub-parts;
the grid segmentation module is used for carrying out grid segmentation on the two-dimensional plane data by adopting an octree algorithm aiming at the two-dimensional plane data of each final subsection, and determining the vertex of each grid after segmentation;
the quadtree construction module is used for constructing a color quadtree based on the vertexes of each grid after the segmentation; the color information stored in the color quadtree represents the position of the vertex of the grid;
the grid refinement module is used for traversing the color quadtree by adopting a breadth-first algorithm so as to determine grids to be refined;
the octree construction module is used for carrying out grid segmentation on each grid to be refined, constructing octree based on the segmented grids and storing the octree into corresponding nodes in the color quadtree;
the reconstruction coordinate determining module is used for determining three-dimensional coordinates of reconstruction points based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model;
and the three-dimensional model reconstruction module is used for reconstructing and obtaining a three-dimensional grid model with a topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree.
According to the specific embodiment provided by the invention, the invention discloses the following technical effects:
the invention discloses a topology reconstruction method and a topology reconstruction system based on an external memory octree STL model, wherein the three-dimensional STL model to be processed is subjected to segmentation processing to obtain a plurality of final sub-parts, and then projection processing is performed to obtain corresponding two-dimensional plane data; performing grid segmentation on the two-dimensional plane data by adopting an octree algorithm, determining the vertexes of each grid after segmentation, and further constructing a color quadtree; color information stored within the color quadtree characterizes the location of the vertices of the mesh. Traversing the color quadtree by adopting a breadth-first algorithm, then carrying out grid segmentation, constructing an octree based on the segmented grids, and storing the octree into corresponding nodes in the color quadtree. The storage mode of combining the octree and the quadtree can improve the grid division efficiency and the iteration efficiency, the octree is used for storing grid information, the quadtree stores grid color information and the index of the octree, and the grid color information is truly obtained by judging the boundary relation between the grid nodes and the model. In addition, the octree data storage structure is introduced to reconstruct topology, the tree structure has the advantages of high access efficiency, convenient and efficient data insertion and deletion operation and high utilization rate of ordered data space, and multi-resolution display can be realized by calling different trees. Finally, determining three-dimensional coordinates of the reconstruction points based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model; and reconstructing to obtain a three-dimensional grid model with a topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree. In summary, the method and the device for generating the three-dimensional grid model have the advantages that the grid model with the topological structure is obtained by cutting, projecting and grid mapping the existing STL model, meanwhile, multi-resolution display of the three-dimensional grid can be realized, and the model opening efficiency can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings that are needed in the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a topology reconstruction method based on a memory octree STL model of the invention;
FIG. 2 is a schematic view of triangular patch overlapping in a certain direction;
FIG. 3 is a schematic representation of three-dimensional curved surface planarization in accordance with the present invention;
FIG. 4 is a schematic diagram of the determination of the color of a mark of a grid in the present invention;
FIG. 5 is a schematic diagram of the first quadrant division of the octree according to the present invention when grid-splitting is performed;
FIG. 6 is a schematic diagram of a storage form of octree and color quadtree according to the present invention;
FIG. 7 is a schematic view of a rectangular triangular patch according to the present invention;
fig. 8 is a schematic structural diagram of a topology reconstruction system based on a memory octree STL model according to the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The three-dimensional model is divided into a plurality of sub-parts, then the sub-parts are projected onto a two-dimensional plane for grid division, grids are stored in an octree form, after division, the two-dimensional grids are projected onto the three-dimensional model, so that the three-dimensional grid model with topological relation is obtained, multi-resolution display is realized, and the method can be applied to opening large-scale complex grid model files.
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
STL is a three-dimensional model file format, a model taking STL as a storage structure is a file format which scans the outer surface of a three-dimensional model, generates a surface boundary and covers the surface boundary by triangular patches, and approximately represents the model.
Solid
Facet normal Nx Ny Nz
Outer Loop
Vertex V1x V1y V1z
Vertex V2x V2y V2z
Vertex V3x V3y V3z
EndLoop
Endfacet
……
EndSolid
Because the STL file lacks topology information between adjacent geometric elements and each element is independent, the data reading efficiency is low, inconvenience is brought to the subsequent grid traversal and operation, and the octree-based storage structure method is provided for improving the model opening efficiency and realizing the multi-resolution display requirements.
Example 1
As shown in fig. 1, the present invention provides a topology reconstruction method based on a memory octree STL model, which includes:
step 100, carrying out segmentation processing and projection processing on a three-dimensional STL model to be processed to obtain model two-dimensional plane data; the model two-dimensional plane data includes two-dimensional plane data of a plurality of final sub-portions. The three-dimensional STL model to be processed comprises a plurality of triangular patches, normal vector data of each triangular patch and vertex coordinate data of each triangular patch. The triangular grid formed by the triangular patches has good geometric adaptability, can well express planes, simple curved surfaces and complex combined surfaces, and is superior to the structured grid in terms of expressing complex models. Thus, the subsequent meshing still employs triangular meshes.
The space subdivision is an effective method for quickly searching data in space, the tree data structure is a typical search structure based on the idea of space subdivision, and is a tree search structure for selecting proper parameter construction point sets, so that the data reading efficiency can be improved, compared with the single division of four-way trees, the octree storage structure is more in grid number, the data structure is superior to the original STL model data structure, and grid-related operation is facilitated; in order to avoid the situation that a three-dimensional model is projected onto a two-dimensional plane, a plurality of vertex phenomena cannot occur in the projection direction, the model needs to be divided into sub-parts, and the sub-parts cannot generate the problems when projected onto a plane passing through a given normal vector.
The three-dimensional model is often a closed entity, more than one coordinate exists on the same coordinate system projected onto the two-dimensional plane, if the three-dimensional model is directly projected onto the two-dimensional plane, the model is overlapped, as shown in fig. 2, the two triangular patches are projected in the Z direction to generate an interference phenomenon, and the grid is divided into a partial missing phenomenon, so that the three-dimensional model STL file needs to be processed, and the problems are avoided.
Based on the above principle, step 100 specifically includes:
(1) And selecting a triangular patch from the three-dimensional STL model to be processed, taking the selected triangular patch as an initial subsection, and taking normal vector data of the initial subsection as a reference normal vector.
(2) Calculating a vector angle based on the reference normal vector and normal vector data of the adjacent triangular patches; the adjacent triangular patches are any triangular patches adjacent to the initial sub-portion, that is, the adjacent triangular patches are discriminated to the surrounding by taking a reference normal vector as a reference.
(3) And when the normal vector included angle is in a preset included angle range, combining the adjacent triangular patches with the initial sub-part to obtain an updated initial sub-part, and returning to the step of calculating a normal vector included angle based on the reference normal vector and normal vector data of the adjacent triangular patches.
(4) And when the normal vector included angle is not in the preset included angle range, determining the initial subsection as a final subsection. And stopping continuously searching the triangular surface patches when the included angle between the normal vector of the other triangular surface patches and the included angle between the normal vector of the reference triangular surface patches are larger than the limiting value.
In one embodiment, the coordinate values of the last triangular patch incorporated into the initial sub-portion are stored in a TZBList table, and the triangular patch is determined to be a feature triangular patch with one edge on the feature edge and the different final sub-portions are separated by the feature edge. Taking a typical part cam as an example, the different final sub-portions are represented using different colors.
(5) The final subsection was wrapped with an AABB bounding box to yield a box-like section.
(6) Projecting the box-shaped part to obtain two-dimensional plane data of the final subsection; the two-dimensional plane data of the plurality of final sub-portions constitutes model two-dimensional plane data. Specifically, the box-like portion is subjected to three-dimensional space coordinate transformation such that the reference normal vector coincides with the Z axis. The coordinate transformation in the space can be split into rotation and translation, and each sub-part reference normal vector can be overlapped with the Z axis of the world coordinate system only by requiring a rotation matrix and a translation matrix.
In one specific example, the projecting of the box-like portion in step (6) to obtain the two-dimensional plane data of the final subsection specifically includes:
61 The box-shaped portion is projected to obtain bounding box projection point data and sub-portion boundary projection point data, respectively. Specifically, since the STL model is composed of a triangular patch formed of points and normal vectors, zeroing the three-dimensional Z coordinate can result in a point cloud on a two-dimensional plane. Based on this, the Z coordinate value in the three-dimensional coordinates (x, y, Z) within the bounding box and the subsection is zeroed out. The calculation formula of the bounding box projection point data is as follows:
wherein x, y and z are coordinates in a reference normal vector world coordinate system, namely bounding box projection point data, and z=0; x is x 1 、y 1 、z 1 Respectively obtaining three-dimensional coordinates of a reference normal vector local coordinate system, namely three-dimensional coordinates of an AABB bounding box in the box-shaped part; r is R x 、R y 、R z Rotation of AABB bounding boxes in the box-like portion along the X-axis, Y-axis and Z-axis of the reference normal vector world coordinate system, respectivelyThe matrix of the array is transformed into a matrix,、/>and->The rotation angles of the AABB bounding box in the box-shaped part along X, Y and the Z-axis direction are respectively shown, and T is the translation matrix of the AABB bounding box in the box-shaped part,>、/>and->Is the amount of translation of the AABB bounding box in the box section in X, Y and Z-axis. In addition, the reference normal vector local coordinate system: taking the centroid of the sub-part after segmentation as an origin, taking the normal vector of the triangular patch taken during segmentation as a Z axis, namely taking the reference normal vector as the Z axis, and enabling the X axis and the Y axis to be perpendicular to the Z axis; the reference normal vector world coordinate system is a model import coordinate system, namely a coordinate system in three-dimensional drawing software.
62 And storing the bounding box projection point data and the sub-part boundary projection point data into a preset data table. Specifically, points constituting the sub-section boundary and bounding box points are stored in the TZBList table in the form of Z-coordinates of zero.
63 Calling the preset data table, connecting the bounding box projection point data to obtain a bounding box frame on a two-dimensional plane, and connecting the sub-part boundary projection point data to obtain a sub-part bounding box; the bounding box border and the sub-portion bounding box form two-dimensional plane data of the final sub-portion. Specifically, the TZBList table is called, the sub-subsection boundary points are connected on the two-dimensional plane, the outline of the model can be drawn, meanwhile, a bounding box is formed, the planarization effect of the three-dimensional model is achieved, as shown in fig. 3, and the outermost border is the projection of the AABB bounding box.
In a specific application example, when the two-dimensional plane data of one final subsection is determined, and the determination of the two-dimensional plane data of the next final subsection is performed, a triangular patch when the normal vector included angle is not within the preset included angle range can be selected as an initial subsection, and the normal vector data of the initial subsection is used as the reference normal vector of the next final subsection, so that the segmentation of the next final subsection is performed.
Step 200, for the two-dimensional plane data of each final subsection, performing grid segmentation on the two-dimensional plane data by adopting an octree algorithm, and determining the vertex of each grid after segmentation.
Step 200 specifically includes: and performing grid segmentation on the bounding box frame based on an octree algorithm to determine three vertexes of each grid after segmentation. Generally, three vertices are enough to determine a grid, and four vertices are more cumbersome and computationally intensive, so that the three vertices are determined for subsequent processing.
Step 300, constructing a color quadtree based on the vertexes of each grid after segmentation; the color information stored in the color quadtree characterizes the position of the vertex of the mesh.
Step 300, as shown in fig. 4, specifically includes:
(1) If three vertexes of each grid are all in the sub-part surrounding frame after the division, determining the marking color of the grid as a first color; in one embodiment, the first color is black, indicated at 10, indicating a fully filled color, without further grid segmentation.
(2) If the three vertexes of each grid are outside the subsection bounding box after the division, determining the marking color of the grid as a second color; in one embodiment, the second color is white, indicated by 00, indicating that there is no need for further grid segmentation.
(3) If any one of the three vertexes of each grid after the segmentation is positioned in the sub-part bounding box and any one vertex is positioned outside the sub-part bounding box, determining the marking color of the grid as a third color; the grid corresponding to the third color is a grid to be thinned; in one embodiment, the third color is gray, indicated by 01, indicating that an incompletely filled color is required for further grid segmentation.
(4) And constructing a color quadtree based on all grids after segmentation and the marking color of each grid. Specifically, after the filling judgment is performed on the grid, the data of the recorded color is stored in a color quadtree, each sub-node in the color quadtree represents a quadrant, and each quadrant has three possibilities, namely 10, 00 and 01.
In other words, by judging the relationship between three points forming the mesh and the sub-partial bounding box, it is possible to judge what color the mesh should be marked with, and the first quadrant mesh division is taken as an example, as shown in fig. 5: by calculating P 0 And P 3 Is the midpoint P of (2) 9 And sum P 0 In comparison, the band division region is determined to be in a quadrant and comprises P 0 P 3 Two triangles on a side may appear in several distribution cases black and white, grey and both grey; according to P 2 P 3 、P 0 P 2 、P 0 P 4 And P 3 P 4 Calculating the midpoint P of each edge 10 、 P 11 、 P 12 、 P 13 Connection P 2 P 4 、P 10 P 12 、P 11 P 13 A new local mesh is formed.
And 400, traversing the color quadtree by adopting a breadth-first algorithm to determine a grid to be refined.
It should be appreciated that there are multiple ways of traversing the tree, such as a binary tree with a preamble traversal, a middle-order traversal, and a subsequent traversal, where the three read nodes are in different orders. The preamble traversal reads data information according to the left-right order of the root, namely, the root node is accessed first, and then sub-nodes are sequentially read according to the left-right order; the middle sequence traversal reads data according to the left-to-right sequence, reads the leftmost sub-node first, and reads the root node and the right sub-node; the subsequent traversal is to read the sub-nodes according to the left-to-right sequence and finally access the root node, but the method is applicable to binary trees, and if the tree is larger than the binary tree, the tree can be converted into the binary tree, but the calculation amount is required to be increased. Therefore, the tree traversal method adopts breadth-first and depth-first algorithms to carry out tree traversal, and can also be called as a layer sequence traversal and preamble traversal method of the n-ary tree.
Specifically, the data storage form of the invention is a quadtree, a plane is divided into four quadrants, the division discrimination and the division operation are carried out according to the sequence from one quadrant to the four quadrants, the data are popped out according to the sequence of the quadrants, after each division, a local four quadrant appears locally, the grid division judgement is carried out on each newly appearing quadrant, the stack is popped out at the quadrant point of the top of the stack, and meanwhile, the quadrants needing to be divided are popped into the stack.
And 500, carrying out grid segmentation on each grid to be refined, constructing an octree based on the segmented grids, and storing the octree into corresponding nodes in the color quadtree. That is, the midpoint calculation of each side is performed on the divided surrounding boundary, the midpoint and diagonal line of each side are connected, and the coordinates of each point are stored in the form of an octree. For example, after the first meshing, there are 9 points, as shown in FIG. 5, with the rectangular midpoint P 0 As father node, other eight points P 1 、P 2 、P 3 、P 4 、P 5 、P 6 、P 7 And P 8 Is a sub-node formed with P 0 The octree is used as the parent node and the other eight points are used as child nodes, and then the octree is stored in the quadtree nodes, and the data storage form is shown in fig. 6. If one quadrant in the quadtree is subjected to grid judgment and needs to be subjected to grid division, a new octree is formed in the one quadrant, the octree is stored in one sub-node of the quadtree, and after the new grid is divided, the first quadrant forms a local four-quadrant, so that the four nodes are further separated to represent the local four-quadrant under the sub-node representing the one quadrant.
The grid density of the three-dimensional model can be controlled by calling different sub-nodes of the quadtree, the storage mode can achieve a multi-resolution display effect, the purpose of rapidly opening the model is achieved, and grids with low layers can be used at positions which cannot be seen in the view cone range when the model is opened. The grid is coarse and has poor quality, and the dense grid which is displayed by using the high-level grid, namely reading terminal sub-nodes in the view cone range has good quality.
And 600, determining three-dimensional coordinates of a reconstruction point based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model.
It should be noted that, the two-dimensional plane and the three-dimensional model sub-part have the corresponding relationship, the same reference normal vector is used, if the point of the two-dimensional grid on the three-dimensional model is to be found, the direct method is to make a straight line through a certain grid node, and traverse all triangular patches to obtain the intersection point, but the calculation amount is definitely too large.
In order to solve the above problem of large calculation amount, step 600 of the present invention specifically includes:
(1) And projecting the vertex of each triangular patch in the three-dimensional STL model to be processed to a two-dimensional plane, and determining the position data of a plurality of two-dimensional patch points according to the vertex coordinate data of each triangular patch. The Z coordinate in the position data of each two-dimensional patch point is 0.
(2) Position data of two-dimensional vertices of each mesh is determined based on the octree and the model two-dimensional plane data.
(3) And taking the two-dimensional vertexes of any grid as a starting point, and calculating to obtain a vertex patch distance set based on the position data of the starting point and the position data of any two-dimensional patch point.
(4) And screening a minimum value from the vertex patch distance set, and marking the triangular patch corresponding to the minimum value as a standby patch.
(5) Determining a standby straight line, and then determining the intersection point coordinates of the standby straight line and the standby patch; the standby straight line is a straight line passing through the starting point and parallel to the reference normal vector of the final subsection where the starting point is located; the intersection point coordinate is the Z-axis coordinate of the starting point; the position data and the Z-axis coordinate of the starting point form a three-dimensional coordinate of a reconstruction point of the starting point; and the three-dimensional coordinates of the reconstruction points of the plurality of starting points form the three-dimensional coordinates of the reconstruction points of the three-dimensional STL model to be processed.
In another specific application example, step 600 specifically includes:
(1) And projecting the vertex of each triangular patch in the three-dimensional STL model to be processed to a two-dimensional plane, and determining an STL model vertex list SPointList according to vertex coordinate data of each triangular patch as shown in the following table 1.
TABLE 1 STL model vertex List SPointList
(2) Determining a node linear table based on the octree and the model two-dimensional plane data; in practical applications, the node linear table WPointList may be created by scanning two-dimensional plane mesh nodes, as shown in table 2 below.
Table 2 node Linear Table WPointList
(3) Establishing a triangular patch linear table PlanList; the triangular patch linear table is used for storing triangular patches in each final subsection in the three-dimensional STL model to be processed; triangular patch linearity table PlaneList may be shown in conjunction with fig. 7 and table 3.
TABLE 3 triangular patch Linear Table PlanList
(4) Traversing the node linear table, and expanding the two-dimensional coordinates of the grid vertexes stored in the node linear table to three dimensions to obtain a standby node coordinate table; and the Z axes of the coordinates in the standby node coordinate table are all zero.
(5) And calculating the distance between any Q point in the node linear table and any value in the STL model vertex list to obtain a distance set. The node linear table WPointList is internally provided with a plurality of Q values which are arranged in sequence, and when the distance set is calculated, the Q values can be calculated in sequence from front to back according to the arrangement sequence.
(6) And screening the minimum value from the distance set, and marking the vertex of the triangular patch corresponding to the minimum value as a point A.
(7) Traversing the triangular patch linear table, determining the triangular patch containing the point A, and then storing the triangular patch containing the point A into a Z value table ZLIST.
(8) A straight line that crosses the Q point and is parallel to the reference normal vector of the final subsection where the Q point is located is determined.
(9) Calling a triangular patch containing an A point from the Z value table ZLIST, and then determining the intersection point coordinates of the straight line and the triangular patch containing the A point; and the intersection point coordinate is the Z-axis coordinate of the Q point.
(10) And storing Z-axis coordinates of all the Q points into the standby node coordinate table to obtain three-dimensional coordinates of the reconstruction points of the three-dimensional STL model to be processed.
And 700, reconstructing to obtain a three-dimensional grid model with topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree. That is, after all final subsections complete the grid mapping, each final subsection is restored to the original position through coordinate inversion and a complete model is formed by combining the color quadtree composition model forest containing each final subsection.
In summary, the invention adopts the method of carrying out topology reconstruction on the STL model based on the octree storage structure, firstly, the three-dimensional model is projected to a two-dimensional plane, grid division is carried out on the two-dimensional plane, the divided grids are mapped to the three-dimensional model, and the multi-resolution display of the three-dimensional grid model is realized by a method of combining two storage modes of octree and quadtree, so that the model opening efficiency is improved; the grid division mode is simpler by adopting a two-dimensional plane grid division mode. In practical application, the scheme of the invention can be used for three-dimensional modeling direction in the intelligent manufacturing field, improves the STL model opening efficiency and realizes the multi-resolution display requirement.
Example two
As shown in fig. 8, in order to implement the technical solution in the first embodiment to achieve the corresponding functions and technical effects, this embodiment further provides a topology reconstruction system based on an external octree STL model, including:
the segmentation projection processing module 101 is used for carrying out segmentation processing and projection processing on the three-dimensional STL model to be processed so as to obtain model two-dimensional plane data; the model two-dimensional plane data includes two-dimensional plane data of a plurality of final sub-portions.
The grid segmentation module 201 is configured to perform grid segmentation on the two-dimensional plane data of each final subsection by adopting an octree algorithm, and determine vertices of each segmented grid.
A quadtree construction module 301, configured to construct a color quadtree based on the vertices of each mesh after segmentation; the color information stored in the color quadtree characterizes the position of the vertex of the mesh.
The grid refinement module 401 is configured to traverse the color quadtree by using a breadth-first algorithm to determine a grid to be refined.
And the octree construction module 501 is configured to perform grid segmentation on each grid to be refined, construct octree based on the segmented grids, and store the octree into corresponding nodes in the color quadtree.
And the reconstruction coordinate determining module 601 is configured to determine three-dimensional coordinates of a reconstruction point based on the octree, the two-dimensional plane data of the model, and the three-dimensional STL model to be processed.
The three-dimensional model reconstruction module 701 is configured to reconstruct a three-dimensional grid model with a topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree.
Example III
The present embodiment provides an electronic device, including a memory and a processor, where the memory is configured to store a computer program, and the processor is configured to execute the computer program to cause the electronic device to execute the topology reconstruction method based on the external octree STL model of the first embodiment. Alternatively, the electronic device may be a server.
In addition, the embodiment of the invention also provides a computer readable storage medium, which stores a computer program, and the computer program realizes the topology reconstruction method based on the external octree STL model in the first embodiment when being executed by a processor.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to assist in understanding the methods of the present invention and the core ideas thereof; also, it is within the scope of the present invention to be modified by those of ordinary skill in the art in light of the present teachings. In view of the foregoing, this description should not be construed as limiting the invention.

Claims (8)

1. A topology reconstruction method based on an external octree STL model is characterized by comprising the following steps:
performing segmentation processing and projection processing on the three-dimensional STL model to be processed to obtain model two-dimensional plane data; the model two-dimensional plane data comprises two-dimensional plane data of a plurality of final sub-parts;
for the two-dimensional plane data of each final subsection, performing grid segmentation on the two-dimensional plane data by adopting an octree algorithm, and determining the vertex of each grid after segmentation;
constructing a color quadtree based on the vertexes of each grid after segmentation; the color information stored in the color quadtree represents the position of the vertex of the grid;
traversing the color quadtree by adopting a breadth-first algorithm to determine a grid to be thinned;
performing grid segmentation on each grid to be refined, constructing an octree based on the segmented grids, and storing the octree into corresponding nodes in the color quadtree;
determining three-dimensional coordinates of a reconstruction point based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model;
and reconstructing to obtain a three-dimensional grid model with a topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree.
2. The topology reconstruction method based on the external octree STL model according to claim 1, wherein the three-dimensional STL model to be processed includes a plurality of triangular patches and normal vector data of each triangular patch;
the method comprises the steps of carrying out segmentation processing and projection processing on a three-dimensional STL model to be processed to obtain model two-dimensional plane data, and specifically comprises the following steps:
selecting a triangular patch from the three-dimensional STL model to be processed, taking the selected triangular patch as an initial subsection, and taking normal vector data of the initial subsection as a reference normal vector;
calculating a vector angle based on the reference normal vector and normal vector data of the adjacent triangular patches; the adjacent triangular patches are any triangular patch adjacent to the initial subsection;
when the normal vector included angle is within a preset included angle range, combining the adjacent triangular patches with the initial sub-part to obtain an updated initial sub-part, and returning to the normal vector data based on the reference normal vector and the adjacent triangular patches to calculate a normal vector included angle;
when the normal vector included angle is not in the preset included angle range, determining the initial sub-part as a final sub-part;
wrapping the final subsection with an AABB bounding box to obtain a box-like section;
projecting the box-shaped part to obtain two-dimensional plane data of the final subsection; the two-dimensional plane data of the plurality of final sub-portions constitutes model two-dimensional plane data.
3. Topology reconstruction method based on the external octree STL model according to claim 2, characterized in that the box-like part is projected to obtain two-dimensional plane data of the final sub-part, comprising in particular:
projecting the box-shaped part to obtain bounding box projection point data and sub-part boundary projection point data respectively;
storing the bounding box projection point data and the sub-part boundary projection point data into a preset data table;
invoking the preset data table, connecting the bounding box projection point data on a two-dimensional plane to obtain a bounding box frame, and connecting the sub-part boundary projection point data to obtain a sub-part bounding box; the bounding box border and the sub-portion bounding box form two-dimensional plane data of the final sub-portion.
4. The topology reconstruction method based on the external octree STL model according to claim 3, wherein the calculation formula of the bounding box projection point data is:
wherein x, y and z are coordinates in a reference normal vector world coordinate system respectively, and z=0; x is x 1 、y 1 、z 1 Respectively obtaining three-dimensional coordinates of a reference normal vector local coordinate system; r is R x 、R y 、R z Respectively the rotation matrix of AABB bounding box along X axis, Y axis and Z axis of reference normal vector world coordinate system in box-shaped portion,、/>and->The rotation angles of the AABB bounding box in the box-shaped part along X, Y and the Z-axis direction are respectively shown, and T is the translation matrix of the AABB bounding box in the box-shaped part,>、/>and->Is the amount of translation of the AABB bounding box in the box section in X, Y and Z-axis.
5. The topology reconstruction method based on the external octree STL model of claim 3, wherein the two-dimensional plane data is subjected to mesh segmentation by adopting an octree algorithm, and vertices of each mesh after segmentation are determined, comprising the following steps:
based on an octree algorithm, carrying out grid segmentation on the bounding box frame so as to determine three vertexes of each grid after segmentation;
based on the vertexes of each grid after segmentation, constructing a color quadtree specifically comprises:
if three vertexes of each grid are all in the sub-part surrounding frame after the division, determining the marking color of the grid as a first color;
if the three vertexes of each grid are outside the subsection bounding box after the division, determining the marking color of the grid as a second color;
if any one of the three vertexes of each grid after the segmentation is positioned in the sub-part bounding box and any one vertex is positioned outside the sub-part bounding box, determining the marking color of the grid as a third color; the grid corresponding to the third color is a grid to be thinned;
and constructing a color quadtree based on all grids after segmentation and the marking color of each grid.
6. The topology reconstruction method based on the external octree STL model according to claim 2, wherein the three-dimensional STL model to be processed further includes vertex coordinate data of each triangular patch;
determining three-dimensional coordinates of a reconstruction point based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model, specifically comprising:
projecting the vertex of each triangular patch in the three-dimensional STL model to be processed to a two-dimensional plane, and determining position data of a plurality of two-dimensional patch points according to vertex coordinate data of each triangular patch;
determining position data of two-dimensional vertexes of each grid based on the octree and the model two-dimensional plane data;
taking the two-dimensional vertexes of any grid as a starting point, and calculating to obtain a vertex patch distance set based on the position data of the starting point and the position data of any two-dimensional patch point;
selecting a minimum value from the vertex patch distance set, and marking a triangular patch corresponding to the minimum value as a standby patch;
determining a standby straight line, and then determining the intersection point coordinates of the standby straight line and the standby patch; the standby straight line is a straight line passing through the starting point and parallel to the reference normal vector of the final subsection where the starting point is located; the intersection point coordinate is the Z-axis coordinate of the starting point; the position data and the Z-axis coordinate of the starting point form a three-dimensional coordinate of a reconstruction point of the starting point; and the three-dimensional coordinates of the reconstruction points of the plurality of starting points form the three-dimensional coordinates of the reconstruction points of the three-dimensional STL model to be processed.
7. The topology reconstruction method based on the external octree STL model according to claim 2, wherein the three-dimensional STL model to be processed further includes vertex coordinate data of each triangular patch;
determining three-dimensional coordinates of a reconstruction point based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model, specifically comprising:
projecting the vertex of each triangular patch in the three-dimensional STL model to be processed to a two-dimensional plane, and determining a STL model vertex list according to vertex coordinate data of each triangular patch;
determining a node linear table based on the octree and the model two-dimensional plane data;
establishing a triangular patch linear table; the triangular patch linear table is used for storing triangular patches in each final subsection in the three-dimensional STL model to be processed;
traversing the node linear table, and expanding the two-dimensional coordinates of the grid vertexes stored in the node linear table to three dimensions to obtain a standby node coordinate table; the Z axes of the coordinates in the standby node coordinate table are all zero;
calculating the distance between any Q point in the node linear table and any value in the STL model vertex list to obtain a distance set;
screening a minimum value from the distance set, and marking the vertex of the triangular patch corresponding to the minimum value as a point A;
traversing the triangular patch linear table, determining a triangular patch containing an A point, and then storing the triangular patch containing the A point into a Z value table;
determining a straight line passing through the Q point and parallel to a reference normal vector of a final subsection where the Q point is located;
calling a triangular patch containing an A point from the Z value table, and then determining the intersection point coordinates of the straight line and the triangular patch containing the A point; the intersection point coordinate is the Z-axis coordinate of the Q point;
and storing Z-axis coordinates of all the Q points into the standby node coordinate table to obtain three-dimensional coordinates of the reconstruction points of the three-dimensional STL model to be processed.
8. A topology reconstruction system based on a memory octree STL model, the system comprising:
the segmentation projection processing module is used for carrying out segmentation processing and projection processing on the three-dimensional STL model to be processed so as to obtain model two-dimensional plane data; the model two-dimensional plane data comprises two-dimensional plane data of a plurality of final sub-parts;
the grid segmentation module is used for carrying out grid segmentation on the two-dimensional plane data by adopting an octree algorithm aiming at the two-dimensional plane data of each final subsection, and determining the vertex of each grid after segmentation;
the quadtree construction module is used for constructing a color quadtree based on the vertexes of each grid after the segmentation; the color information stored in the color quadtree represents the position of the vertex of the grid;
the grid refinement module is used for traversing the color quadtree by adopting a breadth-first algorithm so as to determine grids to be refined;
the octree construction module is used for carrying out grid segmentation on each grid to be refined, constructing octree based on the segmented grids and storing the octree into corresponding nodes in the color quadtree;
the reconstruction coordinate determining module is used for determining three-dimensional coordinates of reconstruction points based on the octree, the model two-dimensional plane data and the to-be-processed three-dimensional STL model;
and the three-dimensional model reconstruction module is used for reconstructing and obtaining a three-dimensional grid model with a topological relation based on the three-dimensional coordinates of the reconstruction points and the color quadtree.
CN202311047216.9A 2023-08-21 2023-08-21 Topology reconstruction method and system based on external memory octree STL model Pending CN116912457A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311047216.9A CN116912457A (en) 2023-08-21 2023-08-21 Topology reconstruction method and system based on external memory octree STL model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311047216.9A CN116912457A (en) 2023-08-21 2023-08-21 Topology reconstruction method and system based on external memory octree STL model

Publications (1)

Publication Number Publication Date
CN116912457A true CN116912457A (en) 2023-10-20

Family

ID=88366824

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311047216.9A Pending CN116912457A (en) 2023-08-21 2023-08-21 Topology reconstruction method and system based on external memory octree STL model

Country Status (1)

Country Link
CN (1) CN116912457A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117272914A (en) * 2023-10-31 2023-12-22 北京智芯仿真科技有限公司 Method and device for quickly determining copper-clad shape to form topological structure based on quadtree

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117272914A (en) * 2023-10-31 2023-12-22 北京智芯仿真科技有限公司 Method and device for quickly determining copper-clad shape to form topological structure based on quadtree
CN117272914B (en) * 2023-10-31 2024-03-12 北京智芯仿真科技有限公司 Method and device for quickly determining copper-clad shape to form topological structure based on quadtree

Similar Documents

Publication Publication Date Title
JP4494597B2 (en) Representing color gradation as a detail-oriented hierarchical distance field
JP4563554B2 (en) How to sculpt objects represented as models
US6396492B1 (en) Detail-directed hierarchical distance fields
JP2002501640A (en) Adaptive mesh refinement method and apparatus
CN113593051B (en) Live-action visualization method, dam visualization method and computer equipment
KR100503789B1 (en) A rendering system, rendering method, and recording medium therefor
CN116912457A (en) Topology reconstruction method and system based on external memory octree STL model
CN111243094B (en) Three-dimensional model accurate voxelization method based on lighting method
Yu et al. HexDom: polycube-based hexahedral-dominant mesh generation
JPH08153214A (en) Method for generating three-dimensional orthogonal grating data
Santos et al. Integration of CAD Models into Game Engines.
CN114633850B (en) Virtual visual reconstruction method for finite element model of ship structure
Amiri et al. Connectivity maps for subdivision surfaces
CN114590366B (en) Virtual visualization system for finite element analysis result of ship structure
CN112967396A (en) Mirror reflection-based 3D model spherical surface area-preserving parameterization method and system
CN117437378B (en) Quadrilateral-based grid generation method, system, equipment and medium
Tang et al. Improved fast 3D reconstruction algorithm based on laser scanning point cloud
Lee et al. Constant-time navigation in four-dimensional nested simplicial meshes
CN117036567A (en) Three-dimensional scene model rendering method
CN117292096A (en) Virtual model generation method and device, storage medium and electronic equipment
Liu et al. Research on Triangular Surface Reconstruction Algorithm Based on Point Cloud of Large Power Scene
CN115994976A (en) Construction method and system of AASDF based on GPU
CN114648622A (en) T spline surface rapid reconstruction algorithm based on mesh sharing control vertex
CN112989458A (en) Method for converting BIM (building information modeling) model into 3DTiles file
CN118037992A (en) Triangular network local reconstruction method, system, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination