Method and device for generating area of irregular polygonal plane in geometry engine
By configuring the data input interface, edge type identification service and area calculation service in the geometry engine, and handling irregular polygonal planes with arc edges, the problem of geometry engine difficulty in achieving accurate and fast area generation is solved, and efficient and accurate area calculation is achieved.
Patent Information
- Application Number
- CN202411901820.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2044-12-23
AI Technical Summary
Geometry engines are difficult to achieve accurate and fast area generation when dealing with irregular polygonal planes with arc edges.
By configuring the data input interface, edge type identification service and area calculation service in the geometry engine, loading geometric data, identifying arc edges, performing arc string processing, generating polygons, and calculating the polygon area through the area calculation service, and finally processing the area according to the arc distribution.
It realizes accurate and fast area generation of irregular polygon planes with arc edges, avoids the computational complexity brought by arc edges, and improves the processing efficiency and accuracy of the geometry engine.
Smart Images

Figure CN119359926B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of geometric graphics modeling technology, and in particular to a method for generating the area of an irregular polygonal plane in a geometric engine, a computer device, a computer program product, and a computer-readable storage medium. Background Art
[0002] Models created in geometry engines often involve complex shapes, particularly irregular polygonal surfaces with curved edges, such as arcs. Generating the area required for processing these irregular polygonal surfaces with arcs often requires more complex geometric processing and sophisticated algorithms.
[0003] For example, in some geometry engines, the area calculation performed is further refined by detecting the distribution pattern of the arc edges, such as the starting angle, the ending angle, etc., and the area calculation is corrected according to the distribution of the arc edges.
[0004] Therefore, the processing of irregular polygonal planes by the geometry engine is affected by arc edges, which leads to complex calculations and makes it difficult to achieve accurate area processing. Summary of the Invention
[0005] One purpose of the present application is to solve the technical problem that a geometry engine cannot accurately and quickly generate the area of an irregular polygonal plane with arc edges.
[0006] According to one aspect of an embodiment of the present application, a method for generating the area of an irregular polygonal plane in a geometry engine is disclosed. The geometry engine architecture includes a data input interface, an edge type recognition service, and an area calculation service, and performs geometric operations through data transmission and collaboration between the services. The method includes:
[0007] Loading geometric data through the data input interface, wherein the geometric data is a geometric description file for constructing a geometric model, and the geometric data provides an irregular polygonal plane covering a surface for the constructed geometric model;
[0008] The edge type identification service responds to the loading of the geometric data and identifies arc edges contained in the obtained irregular polygonal plane. The geometry engine is used to perform geometric operations on the irregular polygonal plane, wherein the geometric operations include calculating geometric properties of the irregular polygonal plane.
[0009] Performing an arc chordization operation with the chord corresponding to the arc edge as an edge, and generating a polygon by using the obtained edge set to obtain a polygon of the irregular polygon plane mapping;
[0010] Calculating the area of the polygon to obtain the area of the polygon formed by the chord corresponding to the arc side;
[0011] The area of the irregular polygonal plane is obtained by processing the polygonal area according to the arc distribution on the irregular polygonal plane.
[0012] According to one aspect of the embodiments of the present application, the irregular polygonal plane includes at least one arc edge.
[0013] According to one aspect of an embodiment of the present application, performing an arc chordization operation using the chord corresponding to the arc edge as an edge, and generating a polygon by using the obtained edge set to obtain the polygon of the irregular polygon plane mapping includes:
[0014] Pulling a chord of the identified arc edge, connecting the chord and the arc edge at adjacent edge endpoints of the irregular polygonal plane;
[0015] The edges formed by the chord and the line segments on the irregular polygonal plane form a continuous edge, and the resulting edge set forms a closed interval, and the closed interval is a polygon mapped by the irregular polygonal plane.
[0016] According to one aspect of an embodiment of the present application, the calling of the area calculation service to calculate the area of the polygon to obtain the polygon area of the polygon formed by the chord corresponding to the arc side includes:
[0017] Calling an area calculation service to split the polygon into a plurality of sub-convex polygons, wherein the sub-convex polygons form the polygon without overlap or gaps;
[0018] The area of each sub-convex polygon is calculated separately and aggregated to obtain the polygon area of the polygon.
[0019] According to one aspect of an embodiment of the present application, the step of calculating the area of each sub-convex polygon and aggregating to obtain the polygon area of the polygon includes:
[0020] For each sub-convex polygon, take any vertex and construct at least one triangle with each edge of the sub-convex polygon that does not contain the vertex;
[0021] Calculate the areas of all triangles and aggregate the areas of all triangles to obtain the area of the sub-convex polygon.
[0022] According to one aspect of an embodiment of the present application, the step of processing the polygonal area according to the arc distribution on the irregular polygonal plane to obtain the area of the irregular polygonal plane includes:
[0023] Identifying the orientation of the arc edge on the irregular polygonal plane;
[0024] The area of the irregular polygonal plane is obtained by processing the arc area corresponding to the arc edge on the polygonal area according to the orientation.
[0025] According to one aspect of the embodiment of the present application, the orientation includes being concave inward and convex outward toward the polygon mapped by the irregular polygonal plane.
[0026] According to one aspect of an embodiment of the present application, a computer device is disclosed, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described above.
[0027] According to one aspect of an embodiment of the present application, a computer program product is disclosed, including a computer program, which implements the steps of the method described above when executed by a processor.
[0028] According to one aspect of an embodiment of the present application, a computer-readable storage medium is disclosed, on which a computer program is stored. When the program is executed by a processor, the steps of the method described above are implemented.
[0029] According to one aspect of an embodiment of the present application, a computer device is disclosed, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described above.
[0030] According to one aspect of an embodiment of the present application, a computer program product is disclosed, including a computer program, which implements the steps of the method described above when executed by a processor.
[0031] According to one aspect of an embodiment of the present application, a computer-readable storage medium is disclosed, on which a computer program is stored. When the program is executed by a processor, the steps of the method described above are implemented.
[0032] The embodiment of the present application is directed to the configuration of a data input interface, an edge type identification service, and an area calculation service in the architecture of the geometry engine. The data input interface, the edge type identification service, and the area calculation service perform geometric operations through data transmission and collaboration between each other. Thus, the geometry engine can be provided with geometric attribute calculation functions such as area in the modeling capability, so that the area generation of the irregular polygonal plane covered by the geometric model loaded in the geometry engine can be implemented, and the area of the irregular polygonal plane can be accurately and quickly generated in rapid modeling.
[0033] Specifically, in an embodiment of the present application, an irregular polygonal plane in the geometry engine is obtained by loading geometric data through a data input interface. For the irregular polygonal plane, the edge type recognition service will respond to the loading of the geometric data and first identify the existence of arc edges thereon to know that the irregular polygonal plane contains arc edges. The irregular polygonal plane with arc edges needs to be processed. In the process of processing the irregular polygonal plane with arc edges, an arc chordization operation is performed with the chords corresponding to the arc edges as edges, and polygons are generated by the obtained edge sets to obtain polygons mapped by the irregular polygonal plane. The area calculation service is then called to perform area calculation on this polygon to obtain the polygon area of the polygon formed by the chords corresponding to the arc edges. Finally, the polygon area can be processed according to the arc distribution on the irregular polygonal plane to finally obtain the area of the irregular polygonal plane. Therefore, the irregular polygonal plane with arc edges can be accurately processed without being restricted by the influence of the arc edges, thereby ensuring the accuracy of the generated area.
[0034] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by practice of the present application.
[0035] It should be understood that the foregoing general description and the following detailed description are merely illustrative and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The above and other objects, features and advantages of the present application will become more apparent by describing in detail example embodiments thereof with reference to the attached drawings.
[0037] Figure 1 A flowchart of a method for generating the area of an irregular polygonal plane in a geometry engine according to an embodiment of the present application is shown.
[0038] Figure 2 is based on Figure 1 The corresponding embodiment shows a flowchart of a method for performing an arc chordization operation using the chord corresponding to the arc edge as the edge, and generating a polygon through the obtained edge set to obtain a polygon step of an irregular polygonal plane mapping.
[0039] Figure 3 is based on Figure 1 The corresponding embodiment shows a method flow chart describing the steps of invoking an area calculation service to calculate the area of a polygon and obtaining the area of a polygon formed by the chords corresponding to the arc edges.
[0040] Figure 4 is based on Figure 3 A flowchart of a method for describing the steps of calculating the area of each sub-convex polygon and aggregating to obtain the polygon area of the polygon is shown in the corresponding embodiment.
[0041] Figure 5 is based on Figure 1 A flowchart of a method for describing the steps of obtaining the area of an irregular polygonal plane by processing the polygon area according to the arc distribution on the irregular polygonal plane is shown in the corresponding embodiment.
[0042] Figure 6 The diagram is a schematic diagram showing an orientation type in which a polygon mapped onto an irregular polygonal plane bulges outward according to an embodiment.
[0043] Figure 7 The diagram is a schematic diagram showing an orientation type of a concave interior of a polygon mapped toward an irregular polygonal plane according to an embodiment.
[0044] Figure 8 Yes Figure 6 A graphical diagram of determining the direction of an arc edge is shown in the corresponding embodiment.
[0045] Figure 9 Yes Figure 7 A graphical diagram of determining the direction of an arc edge is shown in the corresponding embodiment. DETAILED DESCRIPTION
[0046] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these example embodiments are provided so that the description of this application will be more comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The accompanying drawings are merely schematic illustrations of the present application and are not necessarily drawn to scale. Identical reference numerals in the figures indicate identical or similar parts, and thus repeated descriptions thereof will be omitted.
[0047] In addition, the described features, structures or characteristics may be combined in one or more example embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the example embodiments of the present application. However, those skilled in the art will appreciate that the technical solutions of the present application may be practiced while omitting one or more of the specific details, or other methods, components, steps, etc. may be adopted. In other cases, known structures, methods, implementations or operations are not shown or described in detail to avoid obscuring the main content and making various aspects of the present application vague.
[0048] Some of the blocks shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0049] The embodiment of the present application is used to realize the area generation of irregular polygonal planes on the model created by the geometry engine, so that the geometry engine can quickly and accurately generate the area of the irregular polygonal planes on the created model or the currently modified and adjusted model, and thus when the geometry engine processes a large number of complex graphics, it can efficiently generate the area and ensure the calculation accuracy.
[0050] Based on this, the processing capabilities of planes and three-dimensional models constructed from complex images in the geometry engine will be enhanced, and will no longer be limited by the interference of curved edges.
[0051] The geometry engine provides modeling capabilities and, during implementation, computes geometric properties for constructed and imported geometric models. The geometry engine architecture built for this purpose includes a data input interface, edge type identification services, and area calculation services. These services execute geometric operations through data exchange and collaboration.
[0052] See Figure 1 , Figure 1 A flowchart of a method for generating the area of an irregular polygonal plane in a geometry engine according to an embodiment of the present application is shown. The embodiment of the present application provides a method for generating the area of an irregular polygonal plane in a geometry engine, the method comprising:
[0053] Step S110, loading geometric data through a data input interface, the geometric data being a geometric description file for constructing a geometric model, and the geometric data providing an irregular polygonal plane covering the surface of the constructed geometric model;
[0054] Step S120: The edge type identification service responds to the loading of the geometric data and identifies arc edges contained in the obtained irregular polygonal plane. The geometry engine is used to perform geometric operations on the irregular polygonal plane, including calculating geometric attributes of the irregular polygonal plane.
[0055] Step S130, performing an arc chordization operation with the chord corresponding to the arc edge as the edge, and generating a polygon by using the obtained edge set to obtain a polygon of the irregular polygon plane mapping;
[0056] Step S140: Calling an area calculation service to calculate the area of a polygon and obtaining the area of a polygon formed by the chord corresponding to the arc edge;
[0057] Step S150 , processing the polygon area according to the arc distribution on the irregular polygonal plane to obtain the area of the irregular polygonal plane.
[0058] These steps are described in detail below.
[0059] As mentioned above, the geometry engine in the implementation of this application focuses on the area generation of irregular polygonal planes, especially how to accurately handle complex shapes with arc edges in the geometry engine.
[0060] When the geometric engine accurately identifies that a plane on the created model is a complex figure with arc edges, it will achieve precise calculations on the complex figure through the implementation of this application, as well as effective segmentation and aggregation to obtain the corresponding area, thereby ensuring efficient calculation and accuracy.
[0061] A geometric model is an entity or shape rendered in three-dimensional space. In an embodiment of the present application, at least one surface of the geometric model is covered by an irregular polygonal plane, and its area is generated with the help of the geometric property calculation capability of the geometry engine.
[0062] The geometric model and the irregular polygonal plane covered by its surface have corresponding geometric data. The loading of the geometric model and the irregular polygonal plane covered by its surface is achieved by creating and / or importing the geometric data in the geometry engine.
[0063] Specifically, the geometry engine loads the corresponding geometry data through the configured data input interface, as performed in step S110, thereby obtaining a geometry description file for constructing a geometric model, and then providing an irregular polygonal plane covering the surface for the constructed geometric model. The irregular polygonal plane is the object for which the area needs to be generated.
[0064] For example, the geometry engine is configured with the interface function uploadGeometry(data), where data is the geometry data to be loaded. As the interface function of the geometry engine, uploadGeometry(data) loads the corresponding geometry data in response to the initiated model import or shape editing.
[0065] That is to say, no matter whether the geometric engine performs operations such as creating a geometric model, importing a geometric model, or editing the shape on the geometric model, the generated geometric data are loaded by the data input interface function, so that the corresponding model and the shape on the model can be obtained through the loaded data, thereby generating the area of the existing irregular polygonal plane.
[0066] In order to realize the area generation of the irregular polygonal plane, the geometric properties related to the area of the irregular polygonal plane are calculated. First, in the execution of step S120, the edge type recognition service identifies the plane contained in the model in the geometry engine to recognize that the plane is a complex figure containing curved edges, that is, an irregular polygonal plane with arc edges.
[0067] In an exemplary embodiment, the edge type recognition service of the geometry engine identifies whether the plane on the model contains arc edges through curve fitting or curvature analysis, so as to identify the irregular polygonal plane containing arc edges from the model, and then generate the area of the irregular polygonal plane by executing the steps of this application.
[0068] Specifically, on an irregular polygonal plane, the curve fitting can obtain the equation of a circle by fitting the points on the edge through the least squares method, as shown in the following formula:
[0069]
[0070] in, is the center of the fitted circle, is the radius;
[0071] Calculate the fitting error:
[0072]
[0073] The fitting error is obtained by calculating on the opposite side Then, the fitting error is determined Is it less than the set threshold? If the fitting error If the value is less than the set threshold, the edge being calculated is determined to be an arc edge.
[0074] On the other hand, the edges of irregular polygonal planes can be identified by curvature analysis. For example, the curvature corresponding to the points distributed on the edge is calculated. , as shown in the following formula:
[0075]
[0076] Based on this calculation, the curvature of each point on the edge is obtained. If the curvature is close to a constant along the entire edge, the edge is directly determined to be an arc edge.
[0077] As defined in this application, an irregular polygonal plane may contain edges that are either line segments (straight lines) or arcs. An irregular polygonal plane is a closed region formed by a series of continuous edges. All edges do not intersect except at their endpoints. Therefore, an irregular polygonal plane naturally does not have overlapping areas.
[0078] In addition to determining whether an edge is an arc through curve fitting or curvature analysis, in another exemplary embodiment, the geometric properties of the edge can also be identified by describing the parameters and functions of the edge. If an edge has arc parameters, such as the center, radius, and other arc-related information, or it is described by a curve function, the edge is directly classified as an arc edge.
[0079] Of course, the type of edge on a plane is not limited to this. In other exemplary embodiments, the length of the edge can also be calculated to determine whether it is a straight line segment. Specifically, the actual length of the edge and the Euclidean distance between the endpoints are calculated. If the calculated actual length of the edge and the Euclidean distance between the endpoints are equal, the edge is a straight line. If they are not equal, the edge is an arc edge.
[0080] Exemplarily, the edge type identification service can be implemented through the identifyEdgeType(edge) function, where the input value edge is the edge input for identification and judgment, and identifyEdgeType(edge) is used to identify the type of the input edge, thereby supporting subsequent operations.
[0081] After step S120 is executed to identify that a plane in the geometry engine is an irregular polygonal plane containing arc edges, the area of the irregular polygonal plane can be generated by executing subsequent steps.
[0082] It should be understood that the geometry engine is used to process and analyze geometric data, including objects such as points, lines, and surfaces. Generating areas for the created graphics is one of the basic functions of the geometry engine. The area generation capability involved in the geometry engine must target objects including two-dimensional plane geometry, such as the irregular polygonal planes identified in this application. By generating areas for the identified irregular polygonal planes to describe their size, it can be applied to subsequent functions such as shape optimization, ultimately providing precise support for application layers, such as regional division and topographic surveying in GIS (Geographic Information System) systems.
[0083] The area generation of irregular polygonal planes implemented in this application will serve as the basic function of the constructed geometry engine, and will provide area data for the two-dimensional and three-dimensional geometric modeling. It will also be combined with other functions, such as volume calculations, center of gravity analysis, etc., and ultimately achieve real-time calculations through this application, such as the fast, efficient and accurate area calculation capabilities required in graphics rendering, which are the capabilities that a real-time geometry engine should have.
[0084] In step S130, the irregular polygonal plane identified as containing arc edges by the edge type identification service in step S120 is subjected to an arc chordization operation. Specifically, the arc edges are treated as edges by their corresponding chords, and the resulting edge set is used to construct a polygon mapped to the irregular polygonal plane. In other words, the irregular polygon identified for area generation in this application includes at least one arc edge.
[0085] Complex polygons, that is, irregular polygonal planes containing arc edges, are processed as chords on the arc edges for preliminary calculations, which can simplify the resulting calculation amount.
[0086] Step S130 is a simplification and approximate calculation of the irregular polygonal plane. Under the action of step S130, the complex boundary form is converted into an easy-to-handle polygonal form to facilitate the implementation of geometric operations such as area generation required by this application.
[0087] In the geometry engine, irregular polygonal planes containing arc edges are described by corresponding parameter information and functions. For example, the straight edges, i.e., the line segments mentioned above, and arc edges contained therein have corresponding boundary information. For example, for arc edges, the parameters used to describe the arc edges include: the arc start and end points, the center of the circle, the radius, the arc range, etc.
[0088] For each identified arc edge, a chord is drawn. The chord is a straight line segment connecting the two endpoints of the arc edge. The chord is used to replace the arc edge to construct a closed interval consisting entirely of straight edges. This closed interval is the polygon mapped to the irregular polygon plane.
[0089] The execution of step S130 will significantly reduce the computational complexity in the geometry engine, which is the foundation for the geometric operation of area generation. The significant reduction in computational complexity will be applicable to real-time applications supported by the geometry engine, such as graphics rendering and physical simulation.
[0090] Specifically, during the execution of step S130, the arc chordization operation includes constructing a straight line segment for the start and end points of each arc edge. The straight line segment is the chord drawn for the arc edge. For example, the constructed straight line segment is shown in the following formula, namely:
[0091]
[0092] in, is the constructed straight line segment, is the starting point of the arc edge, is the end point of the arc edge.
[0093] The pulled chord is used to replace the arc edge, and so on. This operation is performed one by one for multiple arc edges contained in the irregular polygonal plane. Finally, all the straight line segments after replacement, that is, the straight line edges and the newly pulled chords are combined to form an edge set, which will form a closed interval.
[0094] See also Figure 2 , Figure 2 is based on Figure 1The corresponding embodiment shows a flowchart of a method for performing an arc chordization operation using the chord corresponding to the arc edge as the edge, and generating a polygon through the obtained edge set to obtain a polygon step of an irregular polygonal plane mapping.
[0095] The embodiment of the present application provides a step S130 of performing an arc chordization operation, using the chord corresponding to the arc edge as an edge, and generating a polygon by using the obtained edge set to obtain a polygon of the irregular polygon plane mapping, including:
[0096] Step S131: Draw the chord of the identified arc edge, and connect the chord and the endpoints of the adjacent edges of the irregular polygonal plane;
[0097] In step S132 , the edges formed by the chord and the line segments on the irregular polygonal plane are used to form a continuous edge. The resulting edge set forms a closed interval, and the closed interval is a polygon mapped from the irregular polygonal plane.
[0098] As mentioned above, by drawing a corresponding chord from the identified arc edge, the chord is the straight line segment between the two endpoints of the arc edge, that is, the starting point and the end point of the arc edge.
[0099] Therefore, for the irregular polygonal plane, the continuous edges thereon are replaced by the pulled chords along with the arc edges, and the replaced chords are connected to the endpoints of the adjacent edges, thereby forming a closed area.
[0100] After obtaining the polygons of the irregular polygonal plane mapping through the execution of step S130 , the corresponding polygon areas can be calculated in step S140 .
[0101] In step S140, it should be made clear first that the initial polygon, that is, the aforementioned irregular polygonal plane, is composed of continuous edges of straight line segments and circular arcs, but all arc edges have been pulled and replaced with corresponding chords through step S130. Therefore, the new polygon obtained, that is, the polygon mapped by the aforementioned irregular polygonal plane, only contains straight line segment edges.
[0102] Graphics in the geometry engine are described by parameters and / or functions. Based on this, for example, the polygon obtained by mapping the irregular polygon to the plane is described by its vertex coordinate set, so that each straight line segment edge is also defined by the coordinates of its two vertices, i.e., the endpoints.
[0103] Based on the vertex coordinates, the area calculation service can be called to perform a geometric algorithm to calculate the area of the polygon. For example, the area calculation service can be implemented using the calculatePolygonArea(vertices) function, where vertices are the vertices in the vertex coordinates set. The calculatePolygonArea function will perform the area calculation based on the coordinates of each vertex.
[0104] The area calculation service first splits a polygon into multiple convex sub-polygons, performing a convex decomposition of the polygon. This outputs multiple sub-polygons, each of which is convex. The sum of the areas of all these sub-polygons equals the polygonal area of the polygon mapped to the irregular polygonal plane.
[0105] After the polygon of the irregular polygonal plane mapping is split into multiple sub-convex polygons, the area of each sub-convex polygon can be calculated and finally aggregated to obtain the polygon area.
[0106] For example, the rule for determining a convex polygon composed of straight line segments is that for any edge, all other polygon vertices (excluding the vertices on this edge) are on the same side of this edge (including the extension line). In this case, the polygon is a convex polygon.
[0107] The geometry engine implemented in the embodiment of the present application will use this rule to split polygons. To further illustrate, the polygons of the irregular polygonal plane mapping are split into multiple sub-convex polygons using the rule that all vertices are on the same side of any edge.
[0108] Specifically, first mark the concave points of the vertex coordinate set describing the polygon, and then find a feasible diagonal line for each marked concave point, so as to divide the polygon by the found diagonal line, and so on, repeat this process until all sub-polygons are convex. The polygon mapped from the irregular polygon plane can be split into multiple sub-convex polygons, and the sub-convex polygons form a polygon without overlap and gaps.
[0109] See also Figure 3 , Figure 3 is based on Figure 1 The corresponding embodiment shows a method flow chart describing the steps of invoking an area calculation service to calculate the area of a polygon and obtaining the area of a polygon formed by the chords corresponding to the arc edges.
[0110] The step S140 of calculating the area of a polygon to obtain the area of a polygon formed by the chords corresponding to the arc sides provided in the embodiment of the present application includes:
[0111] Step S141: Calling the area calculation service to split the polygon into multiple sub-convex polygons, where the sub-convex polygons have no overlap or gaps and form a polygon;
[0112] Step S142 , calculating the area of each sub-convex polygon separately and aggregating them to obtain the polygon area of the polygon.
[0113] This step is described in detail below.
[0114] In step S141, as the polygon is obtained, the area calculation service is called. The called area calculation service splits a complex polygon into multiple sub-convex polygons. Sub-convex polygons refer to multiple sub-polygons obtained by splitting the complex polygon, which are convex, and each sub-polygon is a convex polygon.
[0115] All vertices of a convex polygon must lie on the same side of any line that forms an edge. In other words, the vertices of a convex polygon have "same side" properties. If all vertices are on the same side of an edge, then that edge will not split the polygon, and these vertices will form a sub-convex polygon.
[0116] The geometry engine first uses a cross product to mark concave points in a polygon—vertices with interior angles greater than 180 degrees. Specifically, for each vertex, the vectors between it and its two adjacent vertices are calculated. The cross product is then computed. If the resulting cross product is negative, the vertex is concave; otherwise, it is convex. This process marks concave points in a polygon.
[0117] Then, for each marked concave point, find a feasible diagonal line. Specifically, for each marked concave point, select a vertex in the polygon that is not adjacent to it, and the line segment formed by the concave point and the selected vertex cannot cross the edge of the polygon; verify whether all other vertices are on the same side of the line segment formed by the concave point and the selected vertex. If so, the concave point and the selected vertex form a valid diagonal line.
[0118] The polygon is divided into two sub-polygons along the found valid diagonal line, and the above execution process is repeated on this basis until all the existing sub-polygons are convex polygons.
[0119] In step S142 , the geometry engine calculates the area of each sub-convex polygon, and finally aggregates the areas of all sub-convex polygons to obtain the polygon area of the polygon mapped by the irregular polygonal plane.
[0120] Each sub-convex polygon is an independent convex polygon, which does not overlap with each other and has no gaps. Therefore, the area calculation of the polygon can be performed through its vertices to obtain the area of each sub-convex polygon.
[0121] In an exemplary embodiment, the area calculations performed on the sub-convex polygons can be implemented by traversing the vertex coordinates on the sub-convex polygons and using a directed area formula based on the vertex coordinates.
[0122] In another exemplary embodiment, at least one triangle may be constructed for each sub-convex polygon, and the area of each triangle may be calculated and aggregated to obtain the area of the sub-convex polygon.
[0123] For details, please refer to Figure 4 , Figure 4 is based on Figure 3 A flowchart of a method for describing the steps of calculating the area of each sub-convex polygon and aggregating to obtain the polygon area of the polygon is shown in the corresponding embodiment.
[0124] The step S142 of calculating the area of each sub-convex polygon and aggregating to obtain the polygon area provided in the embodiment of the present application includes:
[0125] Step S1421: For each sub-convex polygon, take any vertex and construct at least one triangle with each edge of the sub-convex polygon that does not contain the vertex.
[0126] Step S1422, calculate the areas of all triangles, and aggregate the areas of all triangles to obtain the area of the sub-convex polygon.
[0127] The following describes these two steps in detail.
[0128] Specifically, any vertex of each sub-convex polygon forms a triangle with two vertices on an edge that does not contain the vertex, and so on, so that at least one triangle can be obtained by dividing the sub-convex polygon.
[0129] The area of the triangles obtained by division is calculated by vertex coordinates. For example, for a triangle ABC, the vertex coordinates corresponding to its three vertices A, B and C are known to be , B and , first calculate the length of each side, and obtain the length a of side BC, the length b of side AC, and the length c of side AB in triangle ABC.
[0130]
[0131]
[0132]
[0133] After calculating the length of each side of the triangle, the area of the triangle can be directly calculated as shown in the following formula:
[0134]
[0135] Where S is the area of the calculated triangle, is the semiperimeter of the triangle .
[0136] The area of each triangle in the sub-convex polygon is calculated, and then the area of all triangles in the sub-convex polygon is accumulated to obtain the area of the sub-convex polygon.
[0137] Similarly, after obtaining the areas of all sub-convex polygons, aggregate all areas to obtain the polygon area.
[0138] The polygon area calculated in step S140 is a rough expression of the area of the irregular polygonal plane. The polygon area needs to be processed by executing step S150 to ensure that the final area can be infinitely close to the true value, thereby obtaining higher accuracy.
[0139] As mentioned above, the corresponding chords of the arc edges distributed on the irregular polygonal plane are pulled, and then the arc edges are replaced by the corresponding chords to construct the polygon for area calculation. This is a simplified processing process for complex polygons. However, after the polygon area is obtained by calculation, it is necessary to restore the influence of the distributed arc edges on the area, and then obtain the area of the irregular polygonal plane.
[0140] Therefore, during the execution of step S150, the orientation of the arc edge on the irregular polygonal plane is identified, and the polygon area is processed to obtain the arc area corresponding to the arc edge according to the identified orientation, thereby obtaining the area of the irregular polygonal plane.
[0141] See also Figure 5 , Figure 5 is based on Figure 1 A flowchart of a method for describing the steps of obtaining the area of an irregular polygonal plane by processing the polygon area according to the arc distribution on the irregular polygonal plane is shown in the corresponding embodiment.
[0142] The step S140 of obtaining the area of the irregular polygonal plane by processing the polygonal area according to the arc distribution on the irregular polygonal plane provided in the embodiment of the present application includes:
[0143] Step S151, identifying the orientation of the arc edge on the irregular polygonal plane;
[0144] Step S152 , processing the polygon area according to the direction and the arc area corresponding to the arc edge to obtain the area of the irregular polygon plane.
[0145] The following describes these two steps in detail.
[0146] First of all, it should be clearly defined that the direction of the arc edge includes two types: concave into the interior of the polygon mapped by the irregular polygon plane and convex outward.
[0147] For example, Figure 6 is a schematic diagram showing an orientation type in which a polygon mapped toward an irregular polygonal plane bulges outward according to an embodiment;
[0148] Figure 7 The diagram is a schematic diagram showing an orientation type of a concave interior of a polygon mapped toward an irregular polygonal plane according to an embodiment.
[0149] Identify the direction of each arc edge on the irregular polygonal plane. Specifically, as mentioned above, each arc edge has a corresponding chord. Therefore, for each arc edge, the midpoint on the chord corresponding to the chord is , connect a point on the edge of the arc Construct a ray and calculate whether there is an intersection between the ray and other edges of the polygon. If there is an intersection, the direction of the arc edge is determined to be concave toward the interior of the polygon. If there is no intersection, the direction of the arc edge is determined to be convex outward.
[0150] Calculating the intersection of rays and polygon edges is a basic operation in the geometry engine. It can obtain the support of the existing algorithms of the geometry engine, avoiding the need to design additional complex convexity and concavity calculations. Direction judgment can be achieved based on only a small amount of logical judgment, reducing the risk of local errors and enhancing robustness.
[0151] Furthermore, even if the edge intersecting the ray is an arc edge, it can be applied to the currently performed orientation recognition. Therefore, the performed orientation recognition is applicable to complex polygons with high reliability.
[0152] To facilitate intersection calculations, the chords of the replaced arc edges can also be directly replaced to further reduce the amount of calculation. The algorithm is easy to implement and has low computational cost, and can be supported by existing geometry engines.
[0153] Figure 8 Yes Figure 6 The corresponding embodiment shows a schematic diagram of the direction judgment of the arc edge. Figure 8 On the arc edge shown, take the midpoint of the corresponding chord to construct a ray toward the point on the arc edge. At this time, the ray does not intersect with other edges of the polygon. Therefore, it can be determined that the direction of the arc edge is convex outward toward the irregular polygon.
[0154] Figure 9 Yes Figure 7 The corresponding embodiment shows a schematic diagram of the direction judgment of the arc edge. Figure 9On the arc edge shown, take the midpoint of the corresponding chord and construct a ray toward the point on the arc edge. At this time, the ray intersects with other edges of the polygon. Therefore, it can be determined that the direction of the arc edge is concave inward toward the irregular polygon.
[0155] Furthermore, the geometry engine performs intersection calculations on the ray to determine if there is a point that is both on the ray and on a polygon edge, and then determines that the ray intersects with the other edges of the polygon.
[0156] Specifically, first calculate the chord midpoint D for the two endpoints of the arc side, A and B, which can be calculated as follows:
[0157]
[0158]
[0159] The coordinates of the chord midpoint D are .
[0160] For any point on the arc edge, the ray constructed by points D and C intersects the line where the polygon edge EF is located at Q, that is, the coordinates of the intersection point are , the calculation process involved is as follows, namely
[0161] First calculate the required parameters 、 、 、 、 and ,in:
[0162]
[0163]
[0164]
[0165]
[0166]
[0167]
[0168] Then the coordinates of point Q are:
[0169]
[0170]
[0171] At this time, if If true, then the two lines are parallel and have no intersection.
[0172] After calculating the coordinates of point Q, that is, Afterwards, to determine whether the intersection point Q is within the line segment EF, it is only necessary to determine whether the coordinates of point Q are between the coordinates of points EF. To confirm whether the intersection point Q is on the ray DC, it is only necessary to determine whether point D is on the line segment QC.
[0173] Through this calculation process, the geometry engine calculates whether the ray DC intersects with other edges of the polygon to identify the direction of the arc edge, and then can adapt the direction to process the polygon area.
[0174] The polygon area processing includes the calculation of arc areas. It should be clear that the arc area referred to is the area enclosed by the arc side and the corresponding chord. In other words, for arc sides on an irregular polygonal plane, the corresponding arc area will also be calculated for each arc side.
[0175] Exemplarily, the arc edge is represented by its two endpoints and a point on the arc edge.
[0176] For example, an arc edge has two endpoints: and , a point on the edge of the arc .
[0177] The figure corresponding to the arc is actually a part of the circumcircle corresponding to the triangle composed of three points. The center of the circumcircle is , calculate the area of triangle OAB using the following formula ,Right now:
[0178] First calculate the length of each side to obtain the length of side OA, the length of side OB, and the length of side AB in triangle OAB.
[0179]
[0180]
[0181]
[0182] After calculating the length of each side of the triangle, the area of the triangle can be directly calculated as shown in the following formula:
[0183]
[0184] in, To calculate the area of the resulting triangle, is the semiperimeter of the triangle .
[0185] In addition to calculating the area of triangle OAB , it is also necessary to calculate the center of the circumscribed circle, that is, first calculate the required parameters, namely:
[0186]
[0187]
[0188]
[0189]
[0190]
[0191]
[0192] The coordinates of the circle center are: ;
[0193]
[0194] Calculate the radius of the circumscribed circle R= , calculate ∠ACB= , then the arc angle α=2π-2∠ACB, and the sector area corresponding to the arc side is:
[0195] S 扇形 =
[0196] If ∠ACB is an acute angle, then the area of the arc is S 圆弧 =S 扇形 +S ∆OAB ;
[0197] If ∠ACB is an obtuse angle, then the area of the arc is S 圆弧 =S 扇形 -S ∆OAB ;
[0198] If ∠ACB is a right angle, then the area of the arc is S 圆弧 =S 扇形 = .
[0199] For arc sides that are convex outward, when processing the polygon area, the polygon area is added to the arc area to obtain the area of the irregular polygon plane; for arc sides that are concave inward, the polygon area is subtracted from the arc area to obtain the area of the irregular polygon plane.
[0200] Therefore, by identifying the orientation of the arc edge to process the obtained polygon area, the true area of the irregular polygon plane can be accurately obtained. Compared with algorithms that approximate the true value through segmentation, the area calculation capability of the geometry engine is greatly enhanced.
[0201] Furthermore, the orientation identification of arc edges on irregular polygonal planes, with the help of the geometric characteristics of polygons, avoids judgment only by local parameters such as the center, starting point, end point, radius, etc., which will effectively avoid the occurrence of individual local misjudgments and reduce the probability of misjudgment.
[0202] As a result, it will become difficult to determine the orientation of the arc edges of irregular polygonal planes. The orientation can be identified by judging whether the constructed rays intersect with other edges. This effectively utilizes the existing basic operations of the geometry engine, obtains efficient algorithm support in the geometry engine, and avoids the need for additional complex convexity and concavity calculations.
[0203] Furthermore, in an exemplary embodiment, during the arc edge orientation identification process, multiple rays can be constructed from the midpoint of the chord to the arc to determine whether the number of rays intersecting with other edges exceeds a set threshold. If it exceeds the set threshold, it is confirmed that there is an intersection, thereby performing intersection detection to enhance the reliability of the results, improve the orientation determination and stability, and avoid misjudgment due to the presence of complex polygons.
[0204] Furthermore, in another exemplary embodiment, in order to realize large-scale real-time processing of a large number of complex polygons in a geometry engine, for the intersection detection of the constructed rays and edges, a spatial index is used to filter out edges that are impossible to intersect with the rays, and then calculations are performed in the possible intersection areas to finally determine whether the constructed rays and edges intersect.
[0205] Since calculations only need to be performed within possible intersecting areas, the complexity can be significantly reduced. For cases with a large number of polygon edges, the time complexity is significantly reduced, making it suitable for real-time processing of large-scale irregular polygonal planes in geometry engines.
[0206] In summary, in the area calculation performed by the geometry engine, the area of each sub-convex polygon is obtained by aggregating the areas of all triangles in the sub-convex polygon, and then the polygon area of the polygon mapped by the irregular polygon plane can be obtained by aggregating the areas of all sub-convex polygons. The polygon area is equivalent to the approximate area obtained after simplifying the irregular polygon plane. Therefore, the polygon area is processed by identifying the orientation of each arc edge on the irregular polygon plane to obtain the arc area corresponding to the arc edge, so as to obtain the precise area of the irregular polygon plane.
[0207] Through this process, the area generation capability in the real-time geometry engine is provided, which can quickly process dynamic complex polygon shapes, thereby realizing complex graphics analysis and efficiently and reliably completing the geometric analysis tasks of complex graphics.
[0208] In an exemplary embodiment, the present application further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above-mentioned method.
[0209] In an exemplary embodiment, the present application further provides a computer program product, including a computer program, wherein the computer program implements the steps of the above method when executed by a processor.
[0210] In an exemplary embodiment, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above-described method when executed by a processor.
[0211] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present application.
[0212] In an exemplary embodiment of the present application, a computer program medium is further provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method described in the above method embodiment.
[0213] According to one embodiment of the present application, a program product for implementing the method in the above method embodiment is also provided. The program product may be a portable compact disc read-only memory (CD-ROM) and includes program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0214] The program product may utilize any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0215] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0216] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0217] Program code for performing the operations of the present invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0218] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the application, the features and functions of two or more modules or units described above can be concretized in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.
[0219] Furthermore, although the steps of the method of the present application are described in a particular order in the accompanying drawings, this does not require or imply that the steps must be performed in this particular order, or that all steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0220] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
[0221] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered merely as exemplary, and the true scope and spirit of the present application are indicated by the appended claims.
Claims
1. A method for generating the area of an irregular polygonal plane in a geometry engine, characterized in that: The framework of the geometry engine includes a data input interface, an edge type identification service, and an area calculation service, and performs geometry operations through data transmission and collaboration between each other. The method includes: Loading geometric data through the data input interface, the geometric data is a geometric description file for constructing a geometric model, and the geometric data provides an irregular polygonal plane covering a surface for the constructed geometric model; The edge type identification service responds to the loading of the geometric data, identifies the arc edges contained in the obtained irregular polygonal plane, and the geometric engine is used to perform geometric operations on the irregular polygonal plane, and the geometric operations include calculating geometric properties of the irregular polygonal plane; Performing an arc chordization operation with the chord corresponding to the arc edge as an edge, and generating a polygon through the obtained edge set to obtain a polygon of the irregular polygon plane mapping; Calling an area calculation service to calculate the area of the polygon to obtain the area of the polygon formed by the chord corresponding to the arc edge; Identifying the orientation of the arc edge on the irregular polygonal plane; The area of the irregular polygonal plane is obtained by processing the arc area corresponding to the arc edge of the polygonal area according to the orientation.
2. The method according to claim 1, characterized in that The irregular polygonal plane includes at least one arc edge.
3. The method according to claim 1, characterized in that The performing of the arc chordization operation uses the chord corresponding to the arc edge as an edge, and generates a polygon through the obtained edge set to obtain the polygon of the irregular polygon plane mapping, including: Pulling a chord of the identified arc edge, wherein the chord is connected to adjacent edge endpoints of the arc edge on the irregular polygonal plane; The edges formed by the chord and the line segments on the irregular polygonal plane form a continuous edge, and the obtained edge set forms a closed interval, and the closed interval is a polygon mapped by the irregular polygonal plane.
4. The method according to claim 1, characterized in that: The calling of the area calculation service to calculate the area of the polygon to obtain the polygon area of the polygon formed by the chord corresponding to the arc edge includes: Calling an area calculation service to split the polygon into a plurality of sub-convex polygons, wherein the sub-convex polygons form the polygon without overlap or gap; The area of each sub-convex polygon is calculated separately and aggregated to obtain the polygon area of the polygon.
5. The method according to claim 4, characterized in that The step of calculating the area of each sub-convex polygon and aggregating to obtain the polygon area of the polygon comprises: For each sub-convex polygon, take any vertex and construct at least one triangle with each edge of the sub-convex polygon that does not contain the vertex; The areas of all triangles are calculated, and the areas of all triangles are aggregated to obtain the area of the sub-convex polygon.
6. The method according to claim 1, characterized in that The orientation includes being concave toward the inside of the polygon mapped by the irregular polygonal plane and being convex toward the outside.
7. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.
8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
A construction method of a digital file map
CN109712235A
Template area calculation method and device based on geometric model processing and electronic equipment
CN110990925A