Automatic Generation of triangular mesh contour lines and program implementation

Source: Internet
Author: User

Triangular gridded method.

1. Area gridded and grid point numerical
1.1 area gridding divides the grid into two types based on the distribution and quantity of discrete points in the Area: Rule grid and non-Rule grid. the former refers to dividing an area into a matrix mesh based on a certain distance, which is conducive to engraving the rule boundary area. The latter mainly refers to a triangle mesh and any Quadrilateral mesh, which can be engraved into any boundary area. any Quadrilateral mesh and rectangular mesh can be simply converted into triangular mesh. Therefore, this article focuses on the contour drawing on the triangular mesh. in addition, triangular units are often used in finite element numerical calculation. Numerical Calculation can directly obtain the data values on the triangular mesh points, which saves the tedious computing effort of numerical mesh points.
1.2 gridded points: the number of grid points is estimated using the values in known discrete point columns. The main method is shown in table 1:

Table 1 Comparison of interpolation and valuation methods for various grid points

Method nature

Degree of approximation uniqueness push capability calculation speed Applicability
Distribution of distance encryption method is poor, fast, and even.
Distribution of the Azimuth Method is poor, fast, and even.
Trend Surface method is not high, strong, and fast. It is not suitable for accurate contour.
The superposition method is very high, strong, fast, and unevenly distributed.
The weighted least square method is highly efficient and slow. The calculation speed is required for uneven distribution.
High, strong, slow, and wide applicability

It can be seen that different interpolation methods have different characteristics and can be used as needed. Therefore, for a discrete dot column P1, P2 ,..., Pn, Pi = (Xi, Yi, Zi), I = 1, 2 ,..., N, N indicates the number of discrete points. The number of mesh points is G1, G2 ,..., Gnp, Gi = (Xi, Yi, Zi), I = 1, 2 ,..., Np and Np are the number of knots in the grid, so that Contour Tracking can be performed on the grid.

2 equivalent point calculation and tracking
Some general plotting software such as Sufer and Graphtools use rectangular gridded contour. on the rectangular mesh, we can use a simple mathematical formula to determine and calculate the equivalent point, but the trajectory tracking of the contour line [2] is very complicated. the contour tracing on the rectangular mesh must consider three aspects: determine the general trend of the contour line entering the mesh; and determine the outbound edge after the contour line enters the mesh. for any rectangular mesh with contour lines passing through, there are four possible contour lines: bottom-up, left-right, top-down, right-left, and 1. on a rectangular mesh, It is very complicated to judge the contour direction and the outbound edge. A comprehensive search is required to obtain the set of equivalent points. when multiple branches exist in the connected area or contour, it is more difficult to judge and determine the movement of the contour. the search of contour lines on the triangle mesh is quite simple. the following describes in detail the principle of contour generation on a triangular mesh.


Automatic Generation of triangular mesh contour lines and program implementation

Cheng Jianmei Chen Chongxi sun Honglin
(China University of Geosciences) (third part of the Fourth Survey and Design Institute of the Ministry of Railways)

Abstract various Contour generation methods and features should be summarized, and the principle and implementation method of generating Contour using triangle mesh should be elaborated in detail. A Windows-based Contour drawing package with complete functions should be developed independently, the finite element simulation software is embedded to facilitate the presentation of groundwater simulation results.
Key words: triangular mesh, interpolation and valuation, Contour Tracking, and Contour drawing package.

The isoplot is one of the most important components in many fields. creating an contour map is a process of interpolation and transformation of a graph with mathematical methods for a large number of discrete and regular geometric or physical values. grid methods are often used to draw contour lines. the steps for creating contour lines by various gridded methods are: discrete data gridding; numerical mesh points; Calculation of equivalent points; contour tracing; smooth and labeled contour lines [1]. this article compares the features of various gridded methods and grid point interpolation methods, and focuses on a method for generating contour lines in an irregular grid --

Figure 3 trend of triangular mesh contour lines
If any triangle element has an edge that meets the condition (1), its contour may be in the following three ways:
In order to conveniently determine the Equi-point position and track the contour, the three edge weights of ij, jk, and ki are respectively set to 1, 2, and 3. if an contour line passes through the corresponding edge, the weight is the allocation weight; otherwise, the value is 0. the total weight ω ijk is:
ω ijk = ω ij + ω jk + ω ki. (2)
If ω iijk <3, the contour does not pass through this unit. If ω iijk = 3, the contour passes through the IJ and JK sides. If ω iijk = 4, the contour line passes through the ki and IJ sides. If ω iijk = 5, the contour line passes through the JK and Ki sides. if an edge IJ has z0 equivalent, the linear interpolation formula is used to obtain the coordinate of the equivalent point:
(3)
3.3 contour Tracing
3.3.1 Element traversal first, z0 is used to traverse all units in a certain level (mdz) contour, and formula (1) is used to record the number of units (nelement) that the contour passes) unit number and corresponding total weight. for each element containing the contour, records the feature edges L1 (I, j), L2 (I, j) that have the contour passed through, and the coordinate of the isopoints corresponding to the respective edges.
3.3.2 determine whether all the edge in the edge set is a boundary edge. If L1 is a boundary edge, set lB1 (L1) to 1; otherwise, set it to 0. similarly, L2 is recorded in LB2 (L2.
3.3.3 contour tracing is performed in all units with contour passing (total nelement units). The tracing rule is: the contour moving through the common edge and the contour passing through the element. the procedure is as follows:
(1) Starting Point of contour search: first find the first unused cell with the edge as the boundary edge. if it is found, compare the two feature edges of the unit. If they are all boundary edges, use any side as the starting edge and the other side as the subsequent edge. Otherwise, use the edge of the feature as the boundary edge as the starting edge, and the other as the subsequent edge. If the unused edge is not found for the first time and the edge is the boundary edge unit, find any unused unit and consider any side as the starting edge and the other as the subsequent side. then, the coordinates of the start and subsequent edges are stored in the first and second points of the contour line structure. record the nodes corresponding to the subsequent edges to P1 and P2, prepare for the next tracing, and mark the Unit as "used.
(2) Finding the adjacent units of the Common Edge: Looking for the units that have not been used and shared with the edge of node P1 and P2, take the non-common edge of the Unit as the next edge and record it to P1 and P2. The corresponding coordinate of the isopoints is stored in the line structure, and the cell is marked with an edge.
(3) Repeat (2). If no common edge and unused unit are found and unused unit is still available, it indicates that there is an contour branch. therefore, the process repeats (1), (2), and (3) until all units with contour passing through are used up, indicating that all contour branches of the current level have been tracked.
4. contour software package implementation
4.1 Data Structure
Point structure: Type pointapi
X as single; X coordinate of the Record Point
Y as single; y coordinate of the Record Point
End type
Branch Line Structure: Type lineapi
Flag as integer; indicates whether the branch contour is closed
Npoint as integer; record the total number of equivalent points on the branch Contour
XY (npoint) as pointapi; records coordinates of equivalent points on the branch Contour
End type
Hierarchical contour structure: Type curveapi
Nline as integer; records the number of contour branches
Line (nlne) as lineapi; records the contour of each branch
End type
Use the above data structure to record the number of branches, closed branches, points, and coordinates of each level of contour.
4.2 software features
(1) It has windows features, menu drivers, user-friendly interfaces, and flexible and convenient operations.
(2) Any contour classification file is selected, which is applicable to the creation of equi-distance and equi-distance contour. Each contour can be automatically calculated based on the given initial value and end value.
(3) You can use various line types and colors to represent contour lines.
(4) mark the contour classification value in the selected format and font.
(5) images can be scaled and printed at any time.
(6) Strong module independence, easy value shifting, and embedded in your own software system.
4.3 The author used the above method in the development of the "Groundwater Numerical Simulation before and after processing software system", and compiled the Contour for Windows 1.0 software package to embed it into the system.

Figure 1 trend of contour lines in a single rectangular grid
3. Triangular Mesh Contour Tracking
3.1 data preparation requires the nodes and unit numbers of the triangle mesh. the physical values of knots, such as water level and concentration, can be obtained through the grid interpolation or directly provided by other computing programs. the above data is summarized as follows: (1) grid node coordinates: Xi, Yi, I = ,..., Np and Np are the total number of nodes. (2) unit IJK No.: IJK (I, j), j =, 3, I = ,..., Ne: the total number of grid units in the region. (3) Physical values of grid nodes: Zi, I = ,..., Np.


Figure 2 grid encryption Diagram
In addition, when the grid scale is large, it cannot meet the requirements for contour characterization. However, when the grid is dense, the interpolation process is relatively slow and complex. the author proposes a simple method to obtain the grid node value, that is, the automatic mesh encryption method-first, a coarse mesh is formed by Discrete Points and the node value of the coarse mesh is calculated; then, the coarse mesh is encrypted. As shown in figure 2, each triangle unit can be subdivided into four small units. the node value on the mesh can be directly obtained by interpolation of adjacent coarse network nodes.
3.2 first, the equivalent point is determined at the plane position of the equivalent point in Interpolation [3]. for an contour with a value of Z0, the condition that there is an equivalent point between the cell edge IJ Is: (Zi-Z0) * (Zj-Z0) ≤ 0. (1)
If the Zi-Z0 is equal to zero, then the equivalent point will pass through the I point, this method is not conducive to tracking the next equivalent point, so only need to do simple processing, Zi = Zi-ε, ε is a very small positive number, the contour is passed near the point of the Zi.

Figure 4 shows the water level line chart of a seepage area drawn using the Contour package.

Figure 4 level line of a seepage area drawn Using Contour
Conclusion 5
This article summarizes the methods and steps for creating contour lines. in view of the versatility and superiority of the triangle mesh, this article describes in detail the process of Contour Tracking and generation on the triangle mesh. the principle of contour tracing in the triangle mesh method is that the movement of contour lines inevitably passes through the Common Edge and has the contour line passing through the unit. compared with the rectangular grid method, it has the following notable features:
(1) discrete points with uneven distribution do not need to be transformed into regular mesh points. The original discrete points can be directly used to form a triangular network, and individual mesh points can be interpolated to improve the efficiency of contour drawing;
(2) directly use the original discrete points to insert the contour lines, and draw any small isoplot on the feature's height points, but the rectangular grid method does not;
(3) The triangular gridded method has free borders and flexibility. The contour tracing process of the triangular gridded method is simpler and clearer than that of the rectangular gridded method and is easy to implement.

References
1. Huang Xiaoyun, Zhang xuezhong, Xin donggen, et al.. computer graphics technology. Beijing: People's transportation Press, 1995.
2 Lu runmin, Yang Huiying. Computer Graphics. Beijing: Tsinghua University Press, 1988.
3. Liu Xing. contour automatically drawn by direct method. Journal of Wuhan University of water conservancy and electric power, 588 (6 ~ 593.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.