4. Free函数
Arrangement_on_surface_2类模板是用曲线切分二维的面。因为它的接口设计是最简化的,这意味着它的成员函数很少执行几何操作。本章将解释怎么利用这些Free function来达到Arrangement操作。执行这些操作通常需要优秀的几何算法,而且有时会对几何traits类增加额外的要求。这些操作很多都是基于2个框架:面扫描(surface sweep)和区域构建(zone contructions)。这些操作接收一个x单调的曲线,因此几何特征类(geometry-traits class)可以被Arrangement当入参和出参,这些操作必须是ArrangementXMonotoneTraits_2概念的一个model。
4.1 区域构建算法
4.1.1 插入一对不相交的曲线
4.1.2 插入X单调的曲线
4.1.3 插入一般曲线
4.1.4 插入点集
4.1.5 插入相交的线段(code example)
文件在Arrangement_on_surface_2/incremental_insertion.cpp
代码段如下:
cpp
// Using the global incremental insertion functions.
#include <CGAL/basic.h>
#include <CGAL/Arr_naive_point_location.h>
#include "arr_exact_construction_segments.h"
#include "arr_print.h"
typedef CGAL::Arr_naive_point_location<Arrangement> Naive_pl;
typedef CGAL::Arr_point_location_result<Arrangement>::Type Pl_result_type;
int main() {
// Construct the arrangement of five intersecting segments.
Arrangement arr;
Naive_pl pl(arr);
Segment s1(Point(1, 0), Point(2, 4));
Segment s2(Point(5, 0), Point(5, 5));
Segment s3(Point(1, 0), Point(5, 3));
Segment s4(Point(0, 2), Point(6, 0));
Segment s5(Point(3, 0), Point(5, 5));
auto e = insert_non_intersecting_curve(arr, s1, pl);
insert_non_intersecting_curve(arr, s2, pl);
insert(arr, s3, Pl_result_type(e->source()));
insert(arr, s4, pl);
insert(arr, s5, pl);
print_arrangement_size(arr);
// Perform a point-location query on the resulting arrangement and print
// the boundary of the face that contains it.
Point q(4, 1);
auto obj = pl.locate(q);
auto* f = boost::get<Arrangement::Face_const_handle>(&obj);
std::cout << "The query point (" << q << ") is located in: ";
print_face<Arrangement>(*f);
return 0;
}