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 <vector>
#include <algorithm>
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: "
<< 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");
ofs.precision(17);
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
{
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);
}
if(!is) return is;
c.face_id[li] = i;
c->ccdt_3_data().set_face_constraint_index(li, i);
}
return is;
}

View File

@ -1795,8 +1795,8 @@ bool MainWindow::loadScript(QFileInfo info)
QString program;
QString filename = info.absoluteFilePath();
QFile script_file(filename);
script_file.open(QIODevice::ReadOnly);
if(!script_file.isReadable()) {
bool success = script_file.open(QIODevice::ReadOnly);
if((! success) || (!script_file.isReadable())) {
throw std::ios_base::failure(script_file.errorString().toStdString());
}
program = script_file.readAll();
@ -2747,9 +2747,9 @@ void MainWindow::exportStatistics()
if(filename.isEmpty())
return;
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";
}
QTextStream outStream(&output);

View File

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