Merge remote-tracking branch 'cgal/6.1.x-branch' into 'cgal/main'

This commit is contained in:
Sébastien Loriot 2025-12-03 11:54:47 +01:00
commit 26a5fc70e4
6 changed files with 55 additions and 30 deletions

View File

@ -5,6 +5,7 @@
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h> #include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
#include <vector> #include <vector>
#include <algorithm>
using K = CGAL::Exact_predicates_inexact_constructions_kernel; using K = CGAL::Exact_predicates_inexact_constructions_kernel;
@ -29,6 +30,18 @@ int main(int argc, char* argv[])
<< "Number of constrained facets in the CDT: " << "Number of constrained facets in the CDT: "
<< ccdt.number_of_constrained_facets() << '\n'; << ccdt.number_of_constrained_facets() << '\n';
// Collect constrained facets per polygon
std::vector<std::size_t> constrained_facets(polygons.size());
for(auto facet : ccdt.constrained_facets())
{
int i = ccdt.face_constraint_index(facet);
++constrained_facets[i];
}
auto it = std::max_element(constrained_facets.begin(), constrained_facets.end());
std::cout << "The polygon with the most constrained facets has index "
<< (it - constrained_facets.begin()) << " and " << *it << " facets.\n";
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh"); std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
ofs.precision(17); ofs.precision(17);
CGAL::IO::write_MEDIT(ofs, ccdt); CGAL::IO::write_MEDIT(ofs, ccdt);

View File

@ -1034,7 +1034,7 @@ public:
*/ */
CDT_3_signed_index face_constraint_index(typename Triangulation::Cell_handle ch, int i) const CDT_3_signed_index face_constraint_index(typename Triangulation::Cell_handle ch, int i) const
{ {
return ch->face_id[static_cast<unsigned>(i)]; return ch->ccdt_3_data().face_constraint_index(i);
} }
/*! /*!

View File

@ -98,7 +98,7 @@ public:
CGAL::read(is, i); CGAL::read(is, i);
} }
if(!is) return is; if(!is) return is;
c.face_id[li] = i; c->ccdt_3_data().set_face_constraint_index(li, i);
} }
return is; return is;
} }

View File

@ -1795,8 +1795,8 @@ bool MainWindow::loadScript(QFileInfo info)
QString program; QString program;
QString filename = info.absoluteFilePath(); QString filename = info.absoluteFilePath();
QFile script_file(filename); QFile script_file(filename);
script_file.open(QIODevice::ReadOnly); bool success = script_file.open(QIODevice::ReadOnly);
if(!script_file.isReadable()) { if((! success) || (!script_file.isReadable())) {
throw std::ios_base::failure(script_file.errorString().toStdString()); throw std::ios_base::failure(script_file.errorString().toStdString());
} }
program = script_file.readAll(); program = script_file.readAll();
@ -2747,9 +2747,9 @@ void MainWindow::exportStatistics()
if(filename.isEmpty()) if(filename.isEmpty())
return; return;
QFile output(filename); QFile output(filename);
output.open(QIODevice::WriteOnly | QIODevice::Text); bool success = output.open(QIODevice::WriteOnly | QIODevice::Text);
if(!output.isOpen()){ if((! success) || (!output.isOpen())){
qDebug() << "- Error, unable to open" << "outputFilename" << "for output"; qDebug() << "- Error, unable to open" << "outputFilename" << "for output";
} }
QTextStream outStream(&output); QTextStream outStream(&output);

View File

@ -93,18 +93,20 @@ bool Camera_positions_list::save(QString filename) {
if(m_model->rowCount() <1) if(m_model->rowCount() <1)
return false; return false;
QFile file(filename); QFile file(filename);
file.open(QIODevice::WriteOnly); if(file.open(QIODevice::WriteOnly)){
QTextStream out(&file); QTextStream out(&file);
for(int i = 0; i < m_model->rowCount(); ++i) for(int i = 0; i < m_model->rowCount(); ++i)
{ {
QStandardItem* item = m_model->item(i); QStandardItem* item = m_model->item(i);
out << item->data(Qt::DisplayRole).toString() out << item->data(Qt::DisplayRole).toString()
<< "\n" << "\n"
<< item->data(Qt::UserRole).toString() << item->data(Qt::UserRole).toString()
<< "\n"; << "\n";
}
file.close();
return true;
} }
file.close(); return false;
return true;
} }
void Camera_positions_list::on_saveButton_pressed() void Camera_positions_list::on_saveButton_pressed()
@ -129,19 +131,24 @@ void Camera_positions_list::on_openButton_pressed()
void Camera_positions_list::load(QString filename) { void Camera_positions_list::load(QString filename) {
QFile file(filename); QFile file(filename);
std::clog << "Loading camera positions " << qPrintable(filename) << std::endl;
file.open(QIODevice::ReadOnly); if(file.open(QIODevice::ReadOnly)){
QTextStream input(&file); std::clog << "Loading camera positions " << qPrintable(filename) << std::endl;
while(!input.atEnd()) {
QString text = input.readLine(1000); QTextStream input(&file);
QString coord = input.readLine(1000); while(!input.atEnd()) {
if(text.isNull() || coord.isNull()) return; QString text = input.readLine(1000);
CGAL::qglviewer::Frame frame; QString coord = input.readLine(1000);
if(Three::activeViewer()->readFrame(coord, frame)) if(text.isNull() || coord.isNull()) return;
{ CGAL::qglviewer::Frame frame;
addItem(text, if(Three::activeViewer()->readFrame(coord, frame))
Three::activeViewer()->dumpFrame(frame)); {
addItem(text,
Three::activeViewer()->dumpFrame(frame));
}
} }
}else {
std::clog << "Loading camera positions " << qPrintable(filename) << " failed" << std::endl;
} }
} }

View File

@ -138,7 +138,12 @@ public Q_SLOTS:
private: private:
void showFileBox(QString title, QString fileName) { void showFileBox(QString title, QString fileName) {
QFile textFile(fileName); QFile textFile(fileName);
textFile.open(QIODevice::ReadOnly); bool b = textFile.open(QIODevice::ReadOnly);
if(!b){
QMessageBox::critical(this, tr("Error"),
tr("Could not open file %1.").arg(fileName));
return;
}
QMessageBox mb(QMessageBox::NoIcon, QMessageBox mb(QMessageBox::NoIcon,
title, title,
QTextStream(&textFile).readAll(), QTextStream(&textFile).readAll(),