Lab - fix "save as" for a `c3t3` that was loaded (#8940)

## Summary of Changes

Load a `.mesh` file, remesh it or do nothing, and "save as..." fails
because the `c3t3` has its `is_valid` field set to `false`.

This PR fixes that issue : now only `.binary.cgal` requires being
certainly valid, i.e. generated by Mesh_3

thanks @IasonManolas for the report

## Release Management

* Affected package(s): Lab
* License and copyright ownership: unchanged
This commit is contained in:
Sebastien Loriot 2025-06-26 21:49:19 +02:00 committed by GitHub
commit 50fe8040ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 8 deletions

View File

@ -196,14 +196,8 @@ CGAL_Lab_c3t3_binary_io_plugin::
save(QFileInfo fileinfo, QList<Scene_item *> &items)
{
Scene_item* item = items.front();
if(!qobject_cast<Scene_c3t3_item*>(item)->is_valid())
{
QMessageBox::warning(CGAL::Three::Three::mainWindow(), "", "The c3t3_item is not valid. You cannot save it.");
return false;
}
const Scene_c3t3_item* c3t3_item = qobject_cast<const Scene_c3t3_item*>(item);
if ( NULL == c3t3_item )
{
if(nullptr == c3t3_item) {
return false;
}
@ -211,9 +205,14 @@ save(QFileInfo fileinfo, QList<Scene_item *> &items)
if(path.endsWith(".cgal"))
{
if(!c3t3_item->is_valid())
{
QMessageBox::warning(CGAL::Three::Three::mainWindow(), "",
"The c3t3_item is not valid. You cannot save it in binary cgal format.");
return false;
}
std::ofstream out(fileinfo.filePath().toUtf8(),
std::ios_base::out|std::ios_base::binary);
bool ok = out && c3t3_item->save_binary(out);
if(!ok)
return false;