void Delaunay::perform() { // should call init(all_points) first // will be error if as follows, don't know why: //for(auto& vh : mesh.vertices()) //for(auto vit = mesh.vertices_begin(); vit != mesh.vertices_end(); vit++) // start triangulation for(size_t i = 0; i < total_points_count; i++) { emit signalRefreshGui(); VHandle vh = mesh.vertex_handle((unsigned int)i); FHandle fh = mesh.property(VertexToFace, vh); HHandle hh = mesh.property(VertexToHEdge, vh); VHandleVec vhs_buffer; if (hh.is_valid()) { // the incrementing vertex is mapped to an (half)edge // save the vertices mapped to the two faces incident to the edge saveVhs(hh, vhs_buffer); // split edge mesh.split(mesh.edge_handle(hh), vh); } else if (fh.is_valid()) { // save vertices mapped to this face // coz properties will be destroyed after split saveVhs(fh, vhs_buffer); // split face mesh.split(fh, vh); } else { continue; } // rebucket (caused by face_split) rebucket(vh, vhs_buffer); // legalize each triangle for(auto& hh : mesh.voh_range(vh)) { legalize(mesh.next_halfedge_handle(hh), vh); } } // delete infinite vertices deleteVertices(total_points_count); }
void QMSMFormSystemOverview::refreshGui(void) { emit signalRefreshGui(); }
void MainWindow::on_actionPerform_triggered() { if (ui->actionReal_Time->isChecked() && !isRandomized) { QToolTip::showText(QPoint(this->x() + 20, this->y() + 120), "Please click Random Generation or disable Real Time Mode first", this); return; } isRandomized = false; if (points.size() < 3) { return; } if (delay_mseconds != 0) { isDemoRealTimeFinished = false; for(auto& p : points) { demoRealTime(p); } isDemoRealTimeFinished = true; if (isStopDemoRealTime) { on_actionClear_triggered(); } return; } isSelectMannually = false; triangles.clear(); QObject::connect(delaunay, SIGNAL(signalRefreshGui()), this, SLOT(slotRefreshGui())); PointVec mesh_points; for(auto& p : points) { mesh_points.push_back(Point(p.x(), p.y(), 0)); } QTime t; t.start(); delaunay->perform(mesh_points); qDebug()<<"delaunay time: "<<t.elapsed() / 1000.0; // display 2d result for (auto& fh : delaunay->mesh.faces()) { for(auto& vh : delaunay->mesh.fv_range(fh)) { Point p = delaunay->mesh.point(vh); triangles.push_back(QPoint(p[0], p[1])); } } isTrianglated = true; update(); // display 3d result ui->viewer->setParam(delaunay, this->width(), this->height()); ui->viewer->showMesh2D(); ui->viewer->showMesh3D(); }