1 INTRODUCTION
In OpenGL, to make it easier to provide fast rendering of eligible polygons, conditional limits are imposed on legitimate polygons. It is known that the division of Polygon P in space is a series of disjoint polygons that are equivalent to the original polygon p. To maximize performance, solve flicker problems that occur during rotation of concave polygons drawn in three-dimensional space. Based on the study of Cgal triangulation algorithm, the performance of the algorithm is analyzed, and the algorithm is suitable for this subject.
2 POLYGON Partitioning
There are many algorithms for polygon partitioning, in this paper random_polygon_2
, the random vertices under the specified number are generated by the function, the monotone division (monotone partitioning) and convex division (convex partitioning) are compared and analyzed. Algorithm performance, while supporting graphical display in OpenGL environments.
template<class OutputIterator , class PointGenerator , class Traits >OutputIterator CGAL::random_polygon_2 ( std::size_t n,OutputIterator result,const PointGenerator & pg,Traits t = Default_traits )
The function generates n unique random vertices through the PG, which form a simple polygon in a counterclockwise order and write the results into result.
2.1 Monotone Division (monotone partitioning)
The Y-valued monotone polygon (Y-monotone polygon) divides the vertex v1,v2,..., vn into V1,v2,..., VK and VK,..., vn,v1 two parts. So that any horizontal line intersects at least once. In order to create a monotone division of Y values for a given polygon, y_monotone_partition_2()
a scanning line algorithm is used in the function. Its time complexity is O (Nlogn), and the spatial complexity is O (n). The number of polygon constraints produced by this algorithm does not ensure consistency with the optimal number. By using is_y_monotone_2()
y_monotone_partition_2()
the detection function to divide the validity.
template<class InputIterator , class OutputIterator , class Traits >OutputIterator CGAL::y_monotone_partition_2 ( InputIterator first,InputIterator beyond,OutputIterator result,const Traits & traits = Default_traits )
premise: the polygons defined by the point set [First,beyond] are simple polygons, and the nodes are stored in a counter-clockwise order.
2.2 Convex division (convex partitioning)
Polygon convex partitioning can be generated using the three functions provided. The first is used to produce an optimal number. The other two are used to produce similar optimal convex divisions. Both of these functions decompose polygons into simple polygons.
2.2.1 Optimal convex division (optimal convex partition)
The optimal convex division uses Green's dynamic programming algorithm, the time complexity is O (n 4), the space complexity is O (n 3)
template<class InputIterator , class OutputIterator , class Traits >OutputIteratorCGAL::optimal_convex_partition_2 ( InputIterator first,InputIterator beyond,OutputIterator result,const Traits & traits=Default_traits)
2.2.2 Approximate convex division (approx convex partition)
The function approx_convex_partition_2()
uses a simple approximate algorithm of Hertel and Mehlhorn. For a given triangle, this requires the convex partitioning algorithm O (n) Time and space complexity to construct an optimal decomposition of the number of bumps up to four times.
template<class InputIterator , class OutputIterator , class Traits >OutputIterator CGAL::approx_convex_partition_2 ( InputIterator first,InputIterator beyond,OutputIterator result,const Traits & traits = Default_traits )
2.2.3 Scan line approximation algorithm (Sweep-line approximation algorithm)
greene_approx_convex_partition_2()
The time complexity required for a function is O (n log?). N) spatial complexity of O (n)
template<class InputIterator , class OutputIterator , class Traits >OutputIterator CGAL::greene_approx_convex_partition_2 ( InputIterator first,InputIterator beyond,OutputIterator result,const Traits & traits = Default_traits )
3 Case STUDY
In the program by specifying the function Cgal::randompolygon2 (std::backInserter (Polygon),Point Generator (500)); A simple polygon that produces 50 random vertices. The polygons are divided under each algorithm as shown. The execution time of the above algorithm is shown in the following table:
From the above analysis results, the time efficiency of Y-valued monotone polygons is highest. However, when the algorithm is used in the rotating three-dimensional space, the phenomenon of flicker occurs.
By selecting the approximate convex partitioning algorithm, it will not happen, and the operation efficiency is higher than other algorithms. For code performance analysis, the main time of the algorithm is in the chunking section.
Perform the approximate convex partitioning algorithm, select 13 samples, the CPU operation efficiency is as follows:
The function details, as shown in the program running convex_partion_is_valid_2函数
most resource-intensive, can improve the program performance by improving the function.
Sample hundreds of points as shown:
The function percent details are as follows:
The function call Relationship library looks like this:
4 Conclusion
In the subject, the number of structural surface is less, generally not more than 10 structural surface, after the arc differential, the number of vertices generated is generally not more than 100, the use of approximate convex division can be a good solution to the geometric plane rotation in three-dimensional space occurs when the flicker problem, and the performance of the algorithm is higher than other algorithms. From this algorithm, it can be found that the time spent in the program is in the function convex_partion_is_valid_2
section, so you can further analyze the research to improve the efficiency of the algorithm.
5 Acknowledgment
This experiment is mainly based on the Cgal Computational Geometry algorithm Library, because of my limited ability, the algorithm understanding analysis inevitably have negligence place, in this thank the teacher to my patient guidance, please criticize correct.
6 REFERENCES
[1] Jianyong Li,jian Xue,jun Xiao. Three dimensional Sphere analysis Method of Block theory[c]//computer application and System Modeling (iccasm), Inter National Conference on, 2010:1-578.
[2] Cgal 4.7-2d Polygon partitioning:http://doc.cgal.org/latest/partition2/group_ Pkgpolygonpartitioning2.html
[3] Installation of Cgal under Windows environment: http://www.cnblogs.com/ucas/p/5264609.html
Two-dimensional triangular division of plane