CN112927369B - Surface normal consistency restoration method and volume calculation method for three-dimensional model - Google Patents

Surface normal consistency restoration method and volume calculation method for three-dimensional model Download PDF

Info

Publication number
CN112927369B
CN112927369B CN202110197366.2A CN202110197366A CN112927369B CN 112927369 B CN112927369 B CN 112927369B CN 202110197366 A CN202110197366 A CN 202110197366A CN 112927369 B CN112927369 B CN 112927369B
Authority
CN
China
Prior art keywords
model
triangle
normal
triangles
point
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.)
Active
Application number
CN202110197366.2A
Other languages
Chinese (zh)
Other versions
CN112927369A (en
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.)
China Railway Eryuan Engineering Group Co Ltd CREEC
Original Assignee
China Railway Eryuan Engineering Group Co Ltd CREEC
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 China Railway Eryuan Engineering Group Co Ltd CREEC filed Critical China Railway Eryuan Engineering Group Co Ltd CREEC
Priority to CN202110197366.2A priority Critical patent/CN112927369B/en
Publication of CN112927369A publication Critical patent/CN112927369A/en
Application granted granted Critical
Publication of CN112927369B publication Critical patent/CN112927369B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Geometry (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a method for quickly repairing a surface normal of a three-dimensional model, which is based on a model with a correct surface normal orientation, and can start back face elimination to improve rendering efficiency during three-dimensional visualization so as to further improve the bearing capacity of a three-dimensional rendering engine model. When the volume is calculated, the result can be quickly and accurately obtained based on the triangular pyramid volume calculation mode, and the method has extremely high application and popularization values.

Description

Surface normal consistency restoration method and volume calculation method for three-dimensional model
Technical Field
The invention relates to the technical field of three-dimensional model data processing, in particular to a surface normal consistency restoration method and a volume calculation method of a three-dimensional model.
Background
The geometric data in the three-dimensional mesh model is a triangle set, wherein the normal of the triangle is calculated by the right-hand theorem based on the triangle vertex sequence, and if the triangle vertex sequence is: (V0, V1, V2), then its Normal = (V1-V0). Cross (V2-V1), if the dot order is: (V1, V0, V2), then Normal / And (4) = -Normal. The non-uniform surface normals of the three-dimensional mesh model mean that some of the triangles forming the model have normals directed to the inside of the model and some have normals directed to the outside of the modelThe side (caused by the triangle vertex sequence), especially when the BIM solid model is discretized into the mesh model, there is a high probability that the BIM solid model is discretized into the mesh model with inconsistent surface normals. The grid model with inconsistent surface normals cannot set back culling to increase rendering efficiency when performing visual rendering. Meanwhile, the BIM lightweight model with inconsistent surface normals cannot obtain correct results when calculating the volume of the BIM lightweight model.
At present, the problem of inconsistent normal lines of a model is solved by taking any point on a triangle as an origin and taking a normal line of the triangle as a direction to construct a ray to be intersected with all triangles except the triangle in the model, and judging whether the normal line of the triangle faces towards the inner side or the outer side of the model according to the parity of the number of intersection points (a point-ray method).
Disclosure of Invention
The invention aims to: aiming at the problem of low rendering efficiency in the prior art, a surface normal consistency repairing method and a volume calculating method of a three-dimensional model are provided.
In order to achieve the purpose, the invention adopts the technical scheme that:
a method for restoring surface normal consistency of a three-dimensional model comprises the following steps:
s1: constructing a point-edge-triangle topological structure of the model according to the three-dimensional mesh model;
s2: in a point-edge-triangle topological structure, arbitrarily selecting a triangle, correcting the normals of three adjacent triangles corresponding to three edges of the triangle based on the normals of the triangle, then continuing topological traversal based on the three adjacent triangles, and enabling the finally obtained normals to face towards the inside or the outside of the model uniformly;
s3: judging the normal direction of any triangle by a point-ray method, and if the normal direction faces the outer side of the model, keeping the normal directions of all the triangles unchanged; if the normal is towards the inner side of the model, the normal directions of all adjacent triangles are repaired to be opposite directions.
Preferably, the step S1 includes:
the point-edge-triangle topology includes vertex data, triangle data, and edge data of the model.
Preferably, the step S2 includes:
assuming that the vertex sequence in the triangle is V0-V1-V2, the vertices in the triangle are the sides of V0 and V1, and the corresponding vertices of the adjacent triangle are V0, V1 and V3, the correct vertex sequence of the adjacent triangle is V0-V3-V1;
according to the right-hand theorem, the normal of the triangle is: normal = (V1-V0). Cross (V2-V1);
then, the adjoining triangle normal is: normal1= (V3-V0). Cross (V0-V3).
Preferably, in step S3, the point-ray method specifically includes:
a ray is formed by any point on the triangle and the normal direction of the triangle, the ray is intersected with other triangles in the model, and if the number of intersection points is even, the normal direction of the triangle faces the outer side of the model; if the number of the intersection points is odd, the normal direction of the triangle is towards the inner side of the model.
A volume calculation method for a three-dimensional model, which employs the surface normal consistency restoration method according to any one of the above methods, further comprising:
s4: judging whether the model is a geometrically closed three-dimensional model or not based on the point-edge-triangle topological structure;
s5: if the three-dimensional model is a geometrically closed three-dimensional model, traversing all triangles and any point in the model to form a triangular pyramid set based on a triangular pyramid volume calculation method, wherein the volume of the three-dimensional model is the volume algebraic sum of the triangular pyramid set.
Preferably, the step S4 includes:
if all edges have two adjacent triangles in the model topology, the model is a closed model.
Preferably, the step S5 includes:
any point V1 is taken, all triangles in the model are traversed, the triangles are sequentially set as V2, V3 and V4 according to the order of the middle points of the triangles, triangular pyramids V1-V2V3V4 are constructed, and then the volume of the three-dimensional model is the absolute value of the algebraic sum of all the triangular pyramid volumes; when V1 is taken as the (0,0,0) point, triangular pyramids V1-V2V3V4 volume = (x 2 (y 3z4-y4z 3) -x3 (y 2z4-y4z 2) + x4 (y 2z3-y3z 2))/6.
An electronic device comprising at least one processor, and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the above.
In summary, due to the adoption of the technical scheme, the invention has the beneficial effects that:
the invention discloses a method for rapidly repairing a surface normal of a three-dimensional model, which is based on a model with a correct surface normal orientation, and can start back rejection to improve rendering efficiency during three-dimensional visualization so as to further improve the bearing capacity of a three-dimensional rendering engine model.
When the volume is calculated, a result can be quickly and accurately obtained based on the triangular pyramid volume calculation mode, and the method has extremely high application and popularization values.
Drawings
FIG. 1 is a schematic flow diagram of the present invention.
FIG. 2 is a schematic diagram of a point-edge-triangle topology of a model.
FIG. 3 is a schematic diagram showing the sequence of the vertices of a triangle and its adjacent triangles.
Fig. 4 is a schematic diagram of the triangular pyramid volume calculation.
Fig. 5 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Example 1
A method for restoring surface normal consistency of a three-dimensional model comprises the following steps:
s1: constructing a point-edge-triangle topological structure of the model according to the three-dimensional grid model;
specifically, as shown in fig. 1 and fig. 2, the step S1 includes:
s11, traversing all vertexes in the model, judging whether the vertexes are added into the m _ vVertex array or not, if not, constructing corresponding Vertex data and setting a vertex.m _ Index to be m _ vVertex array size;
s12, traversing all triangles in the model, constructing Triangle data and adding the Triangle data into m _ vTriangles. Meanwhile, edge data is constructed according to three vertexes of the Edge data, whether the Edge is added into m _ vEdges is judged, if the Edge data does not exist, the edge.m _ pTris [0] is set as the triangle and added into the m _ vEdges, and if the edge.m _ pTris [1] is set as the triangle. To this end, a point-edge-triangle topology has been constructed that completes the three-dimensional mesh model.
S2: in the point-edge-triangle topological structure, arbitrarily selecting a triangle, correcting the normals of three adjacent triangles corresponding to three edges of the triangle based on the normals of the triangle, then continuing topological traversal based on the three adjacent triangles, and finally enabling the obtained normals to face the inner side or the outer side uniformly;
as shown in fig. 3, the step S2 includes the following steps:
s21, taking a first triangle tri in a ModeltoPology.m _ vTriangles array, setting tri.m _ bFlag as true, constructing a to-be-processed edge chain table needProcessEdgeList, and adding three edges of the tri into the chain table;
s22, traversing a linked list needProcessEdgeList, acquiring an edge to be processed and removing the linked list (if the edge only has one adjacent triangle or has two adjacent triangles, and the m _ bFlags of the two adjacent triangles are both true, ignoring the edge and continuously traversing the linked list of the edge to be processed), setting the triangle with the m _ bFlag of the two adjacent triangles of the edge being true as tri, setting the other triangle as triAdjacent, and adding two edges of the three edges of the triAdjacent, which are not edge, into the linked list of the edge to be processed;
s23, assuming that the vertex sequence in the tri is V0-V1-V2, the vertex in the edge is V0 and V1, and the vertex in the triadjacene is V0, V1 and V3, the correct vertex sequence of the triadjacene is V0-V3-V1, the vertex sequence in the triadjacene is adjusted to the sequence, and the m _ bFlag flag of the triadjacene is set to true. So far, the normal direction of the triangle in the three-dimensional mesh model is restored to be consistent with the normal direction of the first triangle.
S3: judging the normal direction of any triangle by a point-ray method, and if the normal direction faces outwards, keeping the normal directions of all the triangles unchanged; if the normal lines face towards the inner side, the normal lines of all adjacent triangles are repaired to face towards the outer side. Wherein, the point-ray method specifically comprises the following steps:
a ray is formed by any point on the triangle and the normal direction of the triangle, the ray is intersected with other triangles in the model, and if the number of intersection points is even (0 is also even), the normal direction of the triangle faces the outer side of the model; if the number of the intersection points is odd, the normal direction of the triangle is towards the inner side of the model.
After the surface normal consistency is repaired in steps S1-S3, the three-dimensional model can enable backface culling to improve rendering efficiency during three-dimensional visualization, for example, in OpenGL, the backface culling key codes are enabled as follows: glEnable (GL _ CULL _ FACE); glCullFace (GL _ BACK); glFrontFace (GL _ CCW).
Example 2
Referring to fig. 1, a volume calculation method for a three-dimensional model adopts the surface normal consistency restoration method according to embodiment 1, and further includes:
s4: judging whether the three-dimensional model is a geometrically closed three-dimensional model or not based on the edge topology; if all edges have two adjacent triangles in the model topology, the model is a closed model.
S5: if the three-dimensional model is a geometrically closed three-dimensional model, traversing all triangles and any point in the model to form a triangular pyramid set based on a triangular pyramid volume calculation method, wherein the volume of the three-dimensional model is the volume algebraic sum of the triangular pyramid set.
When calculating the model volume, as shown in fig. 4, the three-dimensional model volume calculation process of the surface normal consistency is specifically as follows: and (3) traversing all triangles in the model by taking any point V1, sequentially setting the triangles as V2, V3 and V4 according to the order of the middle points of the triangles, and constructing triangular pyramids V1-V2V3V4, wherein the volume of the three-dimensional model is the absolute value of the algebraic sum of all the triangular pyramid volumes. When V1 is taken as a (0, 0) point, triangular pyramids V1-V2V3V4 volume = (x 2 × (y 3 × z4-y4 × z 3) -x3 = (y 2 × z4-y4 × z 2) + x4 × (y 2 × z3-y3 × z 2))/6.
Example 3
As shown in fig. 5, an electronic device (e.g., a computer server with program execution functionality) according to an exemplary embodiment of the present invention includes at least one processor, a power supply, and a memory and an input-output interface communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method disclosed in any one of the preceding embodiments; the input and output interface can comprise a display, a keyboard, a mouse and a USB interface and is used for inputting and outputting data; the power supply is used for supplying electric energy to the electronic equipment.
Those skilled in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as a removable memory device, a Read Only Memory (ROM), a magnetic disk, or an optical disk.
When the integrated unit of the present invention is implemented in the form of a software functional unit and sold or used as a separate product, it may also be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present invention may be essentially implemented or a part contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: various media that can store program code, such as removable storage devices, ROMs, magnetic or optical disks, etc.
The above description is intended to be illustrative of the preferred embodiment of the present invention and should not be taken as limiting the invention, but rather, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the invention.

Claims (5)

1. A method for restoring surface normal consistency of a three-dimensional model is characterized by comprising the following steps:
s1: constructing a point-edge-triangle topological structure of the model according to the three-dimensional grid model;
the step S1 includes: the point-edge-triangle topology structure comprises vertex data, triangle data and edge data of the model;
s2: in the point-edge-triangle topological structure, arbitrarily selecting a triangle, correcting the normals of three adjacent triangles corresponding to three edges of the triangle based on the normals of the triangle, then continuing topological traversal based on the three adjacent triangles, and finally enabling the obtained normals to face the inner side or the outer side of the model uniformly;
the step S2 includes: assuming that the vertex sequence in the triangle is V0-V1-V2, the vertices in the triangle are the sides of V0 and V1, and the corresponding vertices of the adjacent triangle are V0, V1 and V3, the correct vertex sequence of the adjacent triangle is V0-V3-V1;
according to the right-hand theorem, the normal of the triangle is: normal = (V1-V0). Cross (V2-V1); then, the adjoining triangle normal is: normal1= (V3-V0). Cross (V0-V3); s3: for the normal of any triangle, judging the normal direction by a point-ray method, and if the normal is towards the outer side of the model, keeping the normal directions of all triangles unchanged; if the normal lines face the inner side of the model, the normal line directions of all adjacent triangles are repaired to be opposite directions;
in step S3, the point-ray method specifically includes: a ray is formed by any point on the triangle and the normal direction of the triangle, the ray is intersected with other triangles in the model, and if the number of intersection points is even, the normal direction of the triangle faces the outer side of the model; if the number of the intersection points is odd, the normal direction of the triangle is towards the inner side of the model.
2. A volume calculation method for a three-dimensional model, which employs the method for restoring surface normal conformity of a three-dimensional model according to claim 1, further comprising:
s4: judging whether the model is a geometrically closed three-dimensional model or not based on the point-edge-triangle topological structure;
s5: if the three-dimensional model is a geometrically closed three-dimensional model, traversing all triangles and any point in the model to form a triangular pyramid set based on a triangular pyramid volume calculation method, wherein the volume of the three-dimensional model is the volume algebraic sum of the triangular pyramid set.
3. The volume calculating method according to claim 2, wherein the step S4 includes:
if all edges have two adjacent triangles in the model topology, the model is a closed model.
4. The volume calculation method according to claim 2, wherein the step S5 includes:
any point V1 is taken, all triangles in the model are traversed, the triangles are sequentially set as V2, V3 and V4 according to the order of the middle points of the triangles, triangular pyramids V1-V2V3V4 are constructed, and then the volume of the three-dimensional model is the absolute value of the algebraic sum of all the triangular pyramid volumes; when V1 is taken as the (0,0,0) point, triangular pyramids V1-V2V3V4 volume = (x 2 (y 3z4-y4z 3) -x3 (y 2z4-y4z 2) + x4 (y 2z3-y3z 2))/6.
5. An electronic device comprising at least one processor, and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 4.
CN202110197366.2A 2021-02-22 2021-02-22 Surface normal consistency restoration method and volume calculation method for three-dimensional model Active CN112927369B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110197366.2A CN112927369B (en) 2021-02-22 2021-02-22 Surface normal consistency restoration method and volume calculation method for three-dimensional model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110197366.2A CN112927369B (en) 2021-02-22 2021-02-22 Surface normal consistency restoration method and volume calculation method for three-dimensional model

Publications (2)

Publication Number Publication Date
CN112927369A CN112927369A (en) 2021-06-08
CN112927369B true CN112927369B (en) 2023-04-18

Family

ID=76170104

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110197366.2A Active CN112927369B (en) 2021-02-22 2021-02-22 Surface normal consistency restoration method and volume calculation method for three-dimensional model

Country Status (1)

Country Link
CN (1) CN112927369B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115375754A (en) * 2022-10-21 2022-11-22 中信梧桐港供应链管理有限公司 Storage yard volume detection method and device
CN115775301B (en) * 2023-02-13 2023-05-02 山东捷瑞数字科技股份有限公司 Method, device and equipment for unifying object model normals based on three-dimensional engine

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6284381A (en) * 1985-10-09 1987-04-17 Fujitsu Ltd Face normal deciding system
US6359629B1 (en) * 1998-07-06 2002-03-19 Silicon Graphics, Inc. Backface primitives culling
CN109308735A (en) * 2018-08-20 2019-02-05 上海嘉奥信息科技发展有限公司 The method and its storage medium that data based on the rendering of Unity3D body punch

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008115534A1 (en) * 2007-03-20 2008-09-25 The University Of North Carolina At Chapel Hill Methods, systems, and computer readable media or flexible occlusion rendering
WO2018179253A1 (en) * 2017-03-30 2018-10-04 株式会社ソニー・インタラクティブエンタテインメント Polygon model generation device, polygon model generation method, and program

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6284381A (en) * 1985-10-09 1987-04-17 Fujitsu Ltd Face normal deciding system
US6359629B1 (en) * 1998-07-06 2002-03-19 Silicon Graphics, Inc. Backface primitives culling
CN109308735A (en) * 2018-08-20 2019-02-05 上海嘉奥信息科技发展有限公司 The method and its storage medium that data based on the rendering of Unity3D body punch

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
邓飞 ; 王瑞 ; 王美平 ; 周熙襄 ; .复杂三维地层建模及快速射线追踪的研究与实现.大庆石油地质与开发.2007,(第01期),第113-118页. *

Also Published As

Publication number Publication date
CN112927369A (en) 2021-06-08

Similar Documents

Publication Publication Date Title
CN112927369B (en) Surface normal consistency restoration method and volume calculation method for three-dimensional model
Greß et al. GPU‐based collision detection for deformable parameterized surfaces
Zhao et al. Mathematical morphology-based generalization of complex 3D building models incorporating semantic relationships
CN113724401B (en) Three-dimensional model cutting method and device, computer equipment and storage medium
CN114494649B (en) Finite element meshing geometric cleaning method, device and storage medium
CN111063032A (en) Model rendering method and system and electronic device
CN113742829B (en) Method for reading and processing arbitrary section of bridge structure and calculating section characteristics
CN109472744B (en) Three-dimensional model reduction method
CN109726442B (en) Three-dimensional solid model reconstruction method based on ACIS platform
JP7381198B2 (en) Systems and methods for finite element mesh repair
CN112257132A (en) Data interaction method of simulation file
de Magalhaes et al. Exact intersection of 3D geometric models
CN115222930B (en) WebGL-based 3D model arrangement and combination method
Milenkovic et al. Robust minkowski sums of polyhedra via controlled linear perturbation
Hai et al. A CAE-oriented mesh hole-filling algorithm focusing on geometry and quality
CN110021059B (en) High-efficiency Marking Cubes isosurface extraction method and system without redundant computation
CN118013770B (en) Discrete grid patch geometric topological relation reconstruction method, device, equipment and storage medium
CN115618702B (en) Method for generating two-dimensional ultrahigh volume fraction mixed rock numerical simulation model by adopting overlapping contact cutting algorithm
US10529444B1 (en) System that rapidly generates a solvent-excluded surface
Elloumi et al. Towards a Building Techniques of a BREP Model Starting From a Meshed Surface
Ma et al. An end-to-end geometric deficiencies elimination algorithm for 3D meshes
JP2006323465A (en) Apparatus, method and program for processing geometric figure data
CN117541710A (en) Image rendering method and device, electronic equipment and storage medium
CN114863058A (en) Polygonal mesh division method and system for digital twin
Luon et al. Development of improved three dimensional unstructured tetrahedral mesh generator

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
GR01 Patent grant
GR01 Patent grant