Mesh model data shell extraction method and system based on OpenGL
By setting observation points around the mesh model, simulating spatial scanning and recording the visible parts, the problems of misjudgment and low efficiency in existing mesh model shell extraction are solved, and shell extraction with higher accuracy and efficiency is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2026-03-24
AI Technical Summary
Existing methods for extracting the shell of a mesh model suffer from misjudgment and omissions, and are computationally inefficient, especially in the ray tracing method where the efficiency decreases as the ray density increases.
A Mesh model data shell extraction method based on OpenGL is adopted. By setting different observation points around the model, spatial scanning is simulated, the visible part of each observation point is recorded, and the visibility judgment of all observation points is summarized to form a new visible shell model.
It improves the accuracy and computational efficiency of mesh model shell extraction by increasing the position of observation points to adjust the precision, using pixel values to determine object visibility, and merging model data to reduce the number of interactions between memory and video memory.
Smart Images

Figure CN116341333B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of CAD software development technology, specifically to a method and system for extracting shell data from Mesh models based on OpenGL. Background Technology
[0002] The statements in this section are merely background information relating to this disclosure and do not necessarily constitute prior art.
[0003] To protect the confidentiality of a model's internal structure, sometimes only the visible parts of a 3D model are shown to clients. Extracting the outer shell data from an assembly model typically involves two methods: manual and automatic. Manual extraction requires operators to delete internal structures or extract the outer shell model. However, when the model structure is complex or there are many internal models, manual extraction is time-consuming and prone to omissions and errors. Automatic extraction uses programming to extract the visible parts of the model. Information on methods for extracting the outer shell is scarce. Some methods use ray casting for shell extraction. The core idea is to emanate a cluster of vectors evenly distributed in space from the object's center and determine occlusion by whether the vector cluster intersects with other objects. Figure 1 As shown, Figure 1 (a) shows a regular pentagon contained within a circle. If rays emanating from the midpoint of the pentagon along all its vertices intersect the circle, then the pentagon is considered invisible. If there is a gap in the circle and rays pass through that gap, then the pentagon is considered visible from a certain angle, as shown in (a). Figure 1 As shown in (b); however, the accuracy of this method is related to the ray density. When the ray density is low or the objects are spaced far apart, this method is prone to misjudgment, such as... Figure 1 As shown in (c), no notch was detected by the radiation, so the radiation density was increased to reduce the occurrence of this type of situation, such as... Figure 1 As shown in (d), increasing the ray density leads to a decrease in algorithm efficiency. Furthermore, since the ray originates from the object's center, the algorithm's correctness is also related to the shape of the detected object and occlusions. Sometimes, the ray emitted from the center point cannot cover all observation angles in space. When blind spots appear, the method fails, such as... Figure 2 As shown, no matter how much the ray density is increased, the rays emanating from the center of the red polygon will intersect with the blue occlusion, thus making the internal objects invisible. However, the blue occlusion is actually at the gap, so part of the red polygon is visible.
[0004] Therefore, the inventors discovered that the current automatic extraction of model shells still has the following problems:
[0005] 1) The existing methods for extracting the outer shell do not have sufficient coverage, which can easily lead to misjudgment or omission;
[0006] 2) Existing shell extraction methods are computationally inefficient. In the process of extracting the shell using ray casting, existing methods require increasing the density of rays to reduce the false positive rate. When the object is not visible, the intersection of each ray with other models is calculated, which seriously affects the computational efficiency. Summary of the Invention
[0007] To address the aforementioned issues, this disclosure proposes a method and system for extracting shell data from a Mesh model based on OpenGL. It provides a shell extraction method that simulates spatial scanning, sets different observation points around the model, records the visible parts of the model through each observation point, and finally summarizes the visibility judgments obtained from all observation points to extract the visible shells from the model and form a new visible shell model.
[0008] According to some embodiments, the present disclosure adopts the following technical solutions:
[0009] OpenGL-based methods for extracting the shell of mesh model data include:
[0010] Simulate spatial scanning of objects to obtain the shell object model to be extracted, and mark all objects in the model as invisible;
[0011] Different observation points are generated around the model. The setting of the observation points ensures that the observation range includes all models. Pixel values of the object are extracted at each observation point. Occlusion is traversed for each observation point to obtain the visible model part of each model. It is determined whether it is the last observation point of the last model. When the occlusion is traversed and the last observation point is found, all visible model parts are extracted to form a new shell model.
[0012] According to some embodiments, the present disclosure adopts the following technical solutions:
[0013] An OpenGL-based mesh model data shell extraction system includes:
[0014] The model mesh data merging module is used to simulate spatial scanning of objects, obtain the shell object model to be extracted, and mark all objects in the model as invisible;
[0015] The spatial observation point setting module is used to generate different observation points around the model. The setting of the observation points ensures that the observation range includes all models, and the pixel values of the objects are extracted at each observation point.
[0016] The Mesh data occlusion query module and query result statistics module are used to perform occlusion query for each observation point, obtain the visible model part of each model, and determine whether it is the last observation point of the last model. When the occlusion query reaches the last observation point, all visible model parts are extracted to form a new shell model.
[0017] Compared with the prior art, the beneficial effects of this disclosure are as follows:
[0018] This disclosure provides a method for extracting the outer shell of a simulated spatial scan. Different observation points are set around the model, and the visible parts of the model are recorded at each observation point. Finally, the visibility judgments obtained from all observation points are summarized, and the visible outer shell is extracted from the model to form a new visible outer shell model. This method adjusts the accuracy by increasing the position of the observation points; it uses pixel values appearing on the screen to determine the visibility of objects; and multiple models can be merged into one before calculation, improving computational efficiency. Attached Figure Description
[0019] The accompanying drawings, which form part of this disclosure, are used to provide a further understanding of this disclosure. The illustrative embodiments of this disclosure and their descriptions are used to explain this disclosure and do not constitute an undue limitation of this disclosure.
[0020] Figure 1 This is a schematic diagram illustrating the principle of the X-ray method for determining the background technology disclosed herein.
[0021] Specifically, Figure 1 (a) in the diagram is a schematic diagram showing the invisible part of the pentagon inside the model; Figure 1 (b) in the diagram is a schematic diagram for determining the visibility of the pentagon; Figure 1 (c) in the diagram is a schematic diagram of the failure of the ray detection. Figure 1 (d) in the diagram is a schematic diagram after increasing the ray density;
[0022] Figure 2 This is a schematic diagram of the failure determination method using the X-ray method in the background art of this disclosure;
[0023] Figure 3 This is a flowchart of the model shell extraction method in the embodiments of this disclosure;
[0024] Figure 4 This is a schematic diagram illustrating the uniform generation of observation points in space according to an embodiment of this disclosure;
[0025] Figure 5 This is a schematic diagram showing the distance between the observation point and the model in an embodiment of this disclosure;
[0026] Figure 6 This is a schematic diagram illustrating the generation of observation points based on the convex hull of the model in an embodiment of this disclosure;
[0027] Figure 7 This is a schematic diagram of the merged Mesh data structure in an embodiment of this disclosure. Detailed Implementation
[0028] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.
[0029] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains.
[0030] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this disclosure. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms “comprising” and / or “including” are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0031] Example 1
[0032] One embodiment of this disclosure provides a method for extracting the shell of a Mesh model data based on OpenGL, such as... Figure 3 As shown, it includes:
[0033] Step 1: Simulate spatial scanning of objects to obtain the shell object model to be extracted, and mark all objects in the model as invisible;
[0034] Step 2: Generate different observation points around the model. The setting of the observation points ensures that the observation range includes all models. Extract the pixel values of the objects at each observation point.
[0035] Step 3: Perform an occlusion query for each observation point to obtain the visible model part of each model. Determine if it is the last observation point of the last model. When the occlusion query finds the last observation point, extract all visible model parts to form a new shell model.
[0036] Specifically, the shell extraction process simulates spatial scanning. Different observation points are set around the model, and the visible parts of the model are recorded at each observation point. Finally, the visibility judgments from all observation points are summarized, and the visible shells are selected from the model to form a new visible shell model. The accuracy can be adjusted by increasing the position of the observation points; when the model is visible, the marker is changed to visible.
[0037] As one embodiment, this disclosure is primarily implemented using the C++ language and the OpenGL graphics programming interface.
[0038] The simulation scans objects in space to obtain the shell object model to be extracted. All objects in the model are marked as invisible. First, the model data is merged, treating all models as a whole, essentially putting all model data together and submitting it to the GPU at once. Merging the model mesh data reduces the number of data interactions between memory and video memory, significantly improving efficiency when the model data volume is large. Mesh data consists of a vertex array PointArray and an index array IndexArray. During model rendering, PointArray and IndexArray are passed to the GPU, where the model data is reconstructed based on the vertices and their index values to complete the model rendering. The mesh data in this invention uses triangle data. In IndexArray, starting from the starting position, every three consecutive values form a vertex index of a triangle, and the corresponding specific vertex value can be found in PointArray. The data structure used in this disclosure during merging is as follows:
[0039] struct MergedData
[0040] {
[0041] vector <vector3>m_PositionArray;
[0042] vector <int>m_IndexArray;
[0043] std::map <Model*,pair<offest,length> >m_ModelIndex;
[0044] }
[0045] in:
[0046] m_PositionArray stores the vertex data of all models, and Vector3 represents the coordinates of a three-dimensional point.
[0047] The m_IndexArray stores the index values of all models;
[0048] m_ModelIndex stores each model and its index range. Model* is a pointer to the model data. The second parameter, offset, indicates the starting position of the model's index value in m_IndexArray, and length indicates the length occupied by the model's index value.
[0049] After merging, the data in m_PositionArray and m_IndexArray are copied to video memory. This process can be accomplished through the OpenGL interface, which is as follows:
[0050] void glBufferSubData(GLenum target,GLint offset,GLsizei size,void*data);
[0051] When copying m_PositionArray, the target value is GL_ARRAY_BUFFER; when copying m_IndexArray, the target value is GL_ELEMENT_ARRAY_BUFFER. The merged Mesh data only needs to be submitted to the display once, reducing the number of interactions between memory and video memory.
[0052] As one embodiment, observation points are set in space. The setting of observation points prepares for the next step of pixel extraction. Pixel values are extracted from the object at each observation point, and the setting of observation points must ensure that the observation range includes the entire model. This disclosure provides two methods for setting observation points: uniformly generating observation points in space and generating observation points according to the convex hull of the model.
[0053] 1) Spatially uniformly generated observation points
[0054] The method of uniformly generating observation points in space involves generating a bounding sphere of the model in space, distributing observation points evenly around the bounding sphere, and ensuring that all view cones emitted from the observation points can cover the entire bounding sphere. Figure 4 Using a two-dimensional planar diagram as an example, the distribution of observation points is explained as follows:
[0055] Given the center O of the enclosing circle, the viewing direction P1O, and the viewing cone angle α, and setting the central angle β corresponding to the arc covered by the viewing cone each time, the position of the observation point P1 in space can be calculated in this case. The calculation formula is as follows:
[0056]
[0057] in:
[0058]
[0059] After calculating the first observation point P1, O can be used as the rotation center. By rotating P1 by a certain angle θ, the second observation point P2 can be obtained. In order to ensure that there is no gap between the coverage areas of the two observation points, the rotation angle θ must be less than the central angle β. In this disclosure, θ = 0.9 · β is set to ensure that there is an overlap between the coverage areas of the observation points.
[0060] In this process, to prevent the observation point from being too far from the object and causing pixel loss, the central angle corresponding to the point where the view cone is tangent to the enclosing circle is considered as the maximum settable central angle. At this time, the central angle β is equal to the supplementary angle of the view cone angle α, and L reaches the maximum value L=R / sin(α / 2).
[0061] 2) Generating observation points from the convex hull of the model
[0062] When the model is not concentrated, or when the model distribution has a main direction in space, uniformly arranging observation points will cause some observation points to be far from the actual distance of the model. When observing the model in a distant direction, pixel loss may occur, such as... Figure 5 As shown, the observation point P1 is far from the model.
[0063] For this model distribution method, observation points can be generated based on the convex hull of the overall model. The point cloud data `m_PositionArray` of the entire model can be obtained from the merged Mesh in Module 1. The convex hull of the point cloud data can be generated based on these point clouds using existing methods. Taking a two-dimensional graphic as an example, the generated convex hull data is as follows: Figure 6 As shown:
[0064] The method for generating observation points by the model convex hull is to acquire the point cloud data of the entire model, generate the convex hull of the point cloud data based on the point cloud data, and generate observation points on each polygon face of the convex hull according to the principle. The final generated observation positions can cover the entire model.
[0065] The formula for calculating observation point P1 is as follows:
[0066]
[0067] In three-dimensional space, S is the diameter of the circumcircle of the polygonal face on the convex hull, C is the center of the circumcircle, and L is perpendicular to the polygonal face. Based on this principle, observation points are generated on each polygonal face of the convex hull, and the final generated observation positions can cover the entire model.
[0068] The method for obtaining the visible part of each model is to determine the visibility of the object model by the pixel values that appear on the screen. When the pixel value of the object exists on the screen, the object is visible; when the pixel value of the object does not exist, the object is determined to be invisible at the current observation point.
[0069] As one example, such as Figure 3 As shown, for each observation point, an occlusion query is performed to obtain the visible model part of each model. It is then determined whether it is the last observation point of the last model. When the occlusion query reaches the last observation point, all visible model parts are extracted to form a new shell model.
[0070] Specifically, the process of traversing and querying the observation points is as follows:
[0071] i. Mark all models in the space as invisible models;
[0072] ii. Observe object j at the i-th observation point and use OpenGL to determine occlusion. When the pixel value of object j appears on the screen, mark j as visible, and do not perform visibility determination for j again in the next determination. Continue to determine whether the next object j+1 is visible, until all objects have been determined, then switch to the next observation point i+1 and repeat this step;
[0073] iii. After traversing all observation points, the objects marked as visible are the outer shell objects, thus completing the extraction of the outer shell.
[0074] When rendering mesh data using OpenGL, the visibility of objects to be rendered can be determined through an occlusion query interface. During model occlusion querying, other models besides the model being queried should be treated as obstacles, and occluders should be rendered first before the model being queried.
[0075] When performing a single occlusion query on a certain model, a maximum of three index data submissions are required to complete the single occlusion query. Figure 7 This is a schematic diagram of the merged model;
[0076] Taking the query of the occlusion status of model 3 at the current position as an example, when checking model 3, models 1, 2, and 4 are first drawn as occlusion objects. Since the index values of the merged Mesh are stored continuously, only the index values (0, offset) and (offset + length, maximum index value) need to be submitted to complete the drawing of all occlusion objects, reducing the number of interactions between memory and video memory. When drawing the detected model, only the index values (offset, offset + length) need to be submitted.
[0077] The occlusion query-related interfaces used in OpenGL are as follows:
[0078] glBeginQuery(GLenum target,GLuint id);
[0079] glEndQuery(GLenum target);
[0080] The glBeginQuery interface indicates the start of an occlusion query, and glEndQuery indicates the end of the occlusion query. By calling the model's drawing function between the two interfaces, you can check whether the model is occluded while drawing the model. The parameter target is set to GL_SAMPLES_PASSED, and the parameter id is the name of the query object, which is used for subsequent search operations.
[0081] The visible models for each observation point are counted, resulting in a complete list of all visible models. During this process, all models are initially marked as invisible. When a model is found to be visible at an observation point, its visibility is set to visible. Models set to visible are no longer required to participate in visibility queries for subsequent observation points. The relevant result statistics interface is as follows:
[0082] glGetQueryObjectuiv(GLuint id,GLenum pname,GLuint*params);
[0083] Here, `id` represents the name of the queried object, corresponding one-to-one with the `id` in the query operation. While waiting for the query results, the value of `pname` is set to `GL_QUERY_RESULT_AVAILABLE`, and the value of `params` is checked. If the value of `params` is not 0, it means that the query results have appeared. After the results appear, the value of `pname` is set back to `GL_QUERY_RESULT` to obtain the query results. If the value of `params` is not 0 at this time, it means that the model is visible, and the model's visibility flag is modified.
[0084] Finally, extracting all visible models to form a new model generates the shell model of the original assembly.
[0085] Example 2
[0086] One embodiment of this disclosure provides an OpenGL-based Mesh model data shell extraction system, comprising:
[0087] The model mesh data merging module is used to simulate spatial scanning of objects, obtain the shell object model to be extracted, and mark all objects in the model as invisible;
[0088] The spatial observation point setting module is used to generate different observation points around the model. The setting of the observation points ensures that the observation range includes all models, and the pixel values of the objects are extracted at each observation point.
[0089] The Mesh data occlusion query module and query result statistics module are used to perform occlusion query for each observation point, obtain the visible model part of each model, and determine whether it is the last observation point of the last model. When the occlusion query reaches the last observation point, all visible model parts are extracted to form a new shell model.
[0090] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0091] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0092] While the specific embodiments of this disclosure have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of this disclosure. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of this disclosure are still within the scope of protection of this disclosure.< / int>
Claims
1. A method for extracting the outer shell of a mesh model data based on OpenGL, characterized in that, include: Simulate spatial scanning of objects to obtain the shell object model to be extracted. Mark all objects in the model as invisible. First, merge the model data, treat all models as a whole, put all the model data together, and submit them to the GPU at once. Different observation points are generated around the model. The setting of the observation points ensures that the observation range includes all models. Pixel values of the object are extracted at each observation point. Occlusion is traversed and queried at each observation point to obtain the visible model part of each model. It is determined whether it is the last observation point of the last model. When the occlusion is traversed and the last observation point is found, all visible model parts are extracted to form a new shell model. The process involves generating different observation points around the model, ensuring that the observation range encompasses the entire model. The methods for setting these observation points include spatially uniform observation point generation and model convex hull generation. The method for generating observation points using the model convex hull involves acquiring point cloud data of the entire model, generating a convex hull based on the point cloud data, and generating observation points on each polygonal face of the convex hull according to a set principle. The final generated observation position can cover the entire model. The formula for calculating observation point P1 is: In three-dimensional space, S is the diameter of the circumcircle of the polygonal face on the convex hull, and C is the center of the circumcircle. Based on this principle, observation points are generated on each polygonal face of the convex hull, and the final generated observation positions can cover the entire model.
2. The method for extracting the shell of a Mesh model based on OpenGL as described in claim 1, characterized in that, The method for obtaining the visible model portion of each model is to determine the visibility of the object model by the pixel values that appear on the screen.
3. The method for extracting the shell of a Mesh model based on OpenGL as described in claim 2, characterized in that, The specific method for determining the visibility of an object model is to identify the visible part of the object model as having a high pixel value, and the invisible part as having a low pixel value.
4. The method for extracting the shell of a Mesh model based on OpenGL as described in claim 1, characterized in that, The method of uniformly generating observation points in space involves generating a bounding sphere of the object model in space, distributing observation points evenly around the bounding sphere, ensuring that all view cones emitted from the observation points cover the entire bounding sphere, and calculating the first observation point.
5. The method for extracting the shell of a Mesh model based on OpenGL as described in claim 1, characterized in that, When the distribution of object models is not concentrated or there is a main direction in the distribution of models, uniformly arranging observation points will cause some observation points to be far away from the object model. When observing the model in a far direction, the problem of pixel loss will occur. Therefore, the observation points are generated and set according to the convex hull of the overall object model.
6. A Mesh model data shell extraction system based on OpenGL, employing the OpenGL-based Mesh model data shell extraction method as described in any one of claims 1-5, characterized in that, include: The model mesh data merging module is used to simulate spatial scanning of objects, obtain the shell object model to be extracted, and mark all objects in the model as invisible; The spatial observation point setting module is used to generate different observation points around the model. The setting of the observation points ensures that the observation range includes all models, and the pixel values of the objects are extracted at each observation point. The Mesh data occlusion query module and query result statistics module are used to perform occlusion query for each observation point, obtain the visible model part of each model, and determine whether it is the last observation point of the last model. When the occlusion query reaches the last observation point, all visible model parts are extracted to form a new shell model.
7. The OpenGL-based Mesh model data shell extraction system as described in claim 6, characterized in that, Mesh data consists of vertex arrays and index arrays. During model scanning, the vertex arrays and index arrays are passed to the GPU, where the model data is reconstructed based on the vertices and their index values to complete the model scan.
8. The OpenGL-based Mesh model data shell extraction system as described in claim 6, characterized in that, The Mesh data uses triangular data. In the index array, starting from the starting position, every three consecutive values form the vertex index of a triangle, and the corresponding specific vertex value can be found in the vertex array.
Citation Information
Patent Citations
Building information model-based shell extraction method
CN108460832A
Shell extraction method for three-dimensional model
CN114926605A