本文整理汇总了C++中Triangulation::finite_edges_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Triangulation::finite_edges_begin方法的具体用法?C++ Triangulation::finite_edges_begin怎么用?C++ Triangulation::finite_edges_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Triangulation
的用法示例。
在下文中一共展示了Triangulation::finite_edges_begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
void solve(Triangulation DT, Segment rect[],vector<Point> points)
{
map<TP,double> vertex_dist;
for (vertex_iterator vit = DT.finite_vertices_begin();vit!=DT.finite_vertices_end();vit++)
{
TP vertex_p = vit->point();
double min_dist = min_segment(rect, vertex_p);
vertex_dist[vertex_p] = min_dist;
}
for(Edge_iterator eit= DT.finite_edges_begin(); eit!=DT.finite_edges_end();eit++)
{
double min_dist = CGAL::to_double(DT.segment(eit).squared_length()/4);
TP vertex_p1 = eit->first->vertex(DT.cw(eit->second))->point();
TP vertex_p2 = eit->first->vertex(DT.ccw(eit->second))->point();
vertex_dist[vertex_p1] = std::min(vertex_dist[vertex_p1], min_dist);
vertex_dist[vertex_p2] = std::min(vertex_dist[vertex_p2], min_dist);
}
vector<double> dist;
for (std::map<TP,double>::iterator it = vertex_dist.begin();it!= vertex_dist.end(); it++)
{
dist.push_back(it->second);
}
sort(dist.begin(),dist.end());
int f,m,l;
f = time(dist[0]);
m = time(dist[points.size()/2]);
l = time(dist[points.size() - 1]);
cout<<f<<" "<<m<<" "<<l<<endl;
}
示例2:
void R_s_k_2::draw_mesh_footpoints(const Triangulation& mesh,
const float line_width,
const float red,
const float green,
const float blue)
{
viewer->glLineWidth(line_width);
for (Finite_edges_iterator ei = mesh.finite_edges_begin(); ei != mesh.finite_edges_end(); ei++)
{
Edge edge = *ei;
draw_edge_footpoints(mesh, edge, red, green, blue);
draw_edge_footpoints(mesh, mesh.twin_edge(edge), red, green, blue);
}
}
示例3: test_case
void test_case(int n) {
// cout << "---- " << n << " ----" << endl;
Triangulation t;
std::vector<K::Point_2> pts;
pts.reserve(n);
// vector<int> x = vector<int>(n, 0);
// vector<int> y = vector<int>(n, 0);
for(int i=0; i<n; i++) {
// cin >> x[i] >> y[i];
K::Point_2 p;
cin >> p;
pts.push_back(p);
}
// Construct Delauney triangulation
t.insert(pts.begin(), pts.end());
long long min_sqd = -1;
// Find shortest edge in triangulation
for (Edge_iterator ei = t.finite_edges_begin(); ei != t.finite_edges_end(); ++ei) {
Edge e = *ei;
Triangulation::Vertex_handle v1 = e.first->vertex((e.second + 1) % 3);
Triangulation::Vertex_handle v2 = e.first->vertex((e.second + 2) % 3);
long dx = v1->point().x() - v2->point().x();
long dy = v1->point().y() - v2->point().y();
long long sqd = dx * dx + dy * dy;
if(min_sqd == -1 || sqd < min_sqd)
min_sqd = sqd;
//std::cout << "e = " << v1->point() << " <-> " << v2->point() << std::endl;
//std::cout << t.segment(e) << endl;
}
std::cout << ceil(sqrt(min_sqd) * 50) << endl;
}
示例4: main
int main() {
while(true) {
int bacteria_count;
cin >> bacteria_count;
// kill switch for application
if(bacteria_count == 0) {
break;
}
// read in boundaries of the dish
double left_border, right_border, bottom_border, top_border;
cin >> left_border >> bottom_border >> right_border >> top_border;
// collect bacteria's center information
vector<K::Point_2> bacteria_centers;
bacteria_centers.reserve(bacteria_count);
for(int i = 0; i < bacteria_count; i++) {
double bacteria_x, bacteria_y;
cin >> bacteria_x >> bacteria_y;
bacteria_centers.push_back(K::Point_2(bacteria_x, bacteria_y));
}
// create triangulation
Triangulation triang;
triang.insert(bacteria_centers.begin(), bacteria_centers.end());
// keep track of the distances for each bacteria
map<Triangulation::Point, double> distances;
//distances.reserve(bacteria_count);
// calculate initial distance: distance between the bacteria and the nearest dish boundary
for(Triangulation::Finite_vertices_iterator vertex_iter = triang.finite_vertices_begin(); vertex_iter != triang.finite_vertices_end(); ++vertex_iter) {
Triangulation::Point vertex = vertex_iter->point();
distances[vertex] = min(
min(vertex.x() - left_border, right_border - vertex.x()), // left/right minimum
min(vertex.y() - bottom_border, top_border - vertex.y()) // top/bottom minimum
);
distances[vertex] *= distances[vertex]; // square distance as we work with squared ones
}
// compute distance to other two neighbours and update distance if it is smaller
for(Triangulation::Finite_edges_iterator edge_iter = triang.finite_edges_begin(); edge_iter != triang.finite_edges_end(); ++edge_iter) {
Triangulation::Vertex_handle vertex1 = edge_iter->first->vertex(triang.cw(edge_iter->second));
Triangulation::Vertex_handle vertex2 = edge_iter->first->vertex(triang.ccw(edge_iter->second));
Triangulation::Point vertex1_point = vertex1->point();
Triangulation::Point vertex2_point = vertex2->point();
// calculate distance of the points of both vertex and half them (divide by 4 as distance is squared and 4 = 2^2)
double vertex_distance = CGAL::to_double(CGAL::squared_distance(vertex1_point, vertex2_point)) / 4;
// update distances to minimum
distances[vertex1_point] = min(distances[vertex1_point], vertex_distance);
distances[vertex2_point] = min(distances[vertex2_point], vertex_distance);
}
// now we know the minimum distance for each bacteria to another one or the borders of the dish
// extract distances into a vector and sort it
vector<double> only_distances;
only_distances.reserve(bacteria_count);
for(map<Triangulation::Point, double>::iterator iter = distances.begin(); iter != distances.end(); ++iter) {
only_distances.push_back(iter->second);
}
// sort distances
sort(only_distances.begin(), only_distances.end());
// print out information
cout << hours(only_distances[0]) << " " << hours(only_distances[bacteria_count/2]) << " " << hours(only_distances[bacteria_count - 1]) << endl;
}
}