mirror of https://github.com/CGAL/cgal
Merge pull request #7380 from lrineau/Polyhedron_demo-fix_Mesh_3_plugin-GF
3D demo, Mesh_3 plugin: fix the protect_borders/features
This commit is contained in:
commit
d1f9ca8846
|
|
@ -57,6 +57,10 @@ const QColor default_mesh_color(45,169,70);
|
|||
#include "split_polylines.h"
|
||||
#include <CGAL/Mesh_facet_topology.h>
|
||||
|
||||
enum Protection { BORDERS = 1, FEATURES = 2 };
|
||||
using Protection_flags = QFlags<Protection>;
|
||||
Q_DECLARE_METATYPE(Protection_flags)
|
||||
|
||||
class Mesh_3_plugin :
|
||||
public QObject,
|
||||
protected Polyhedron_demo_plugin_interface
|
||||
|
|
@ -597,28 +601,32 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type,
|
|||
ui.edgeLabel->setEnabled(ui.noEdgeSizing->isChecked());
|
||||
ui.edgeSizing->setEnabled(ui.noEdgeSizing->isChecked());
|
||||
|
||||
const QString sharp_and_boundary("Sharp and Boundary edges");
|
||||
const QString boundary_only("Boundary edges only");
|
||||
const QString sharp_edges("Sharp edges");
|
||||
const QString input_polylines("Input polylines");
|
||||
const QString on_cube("Polylines on cube");
|
||||
const QString triple_lines("Triple+ lines");
|
||||
using Item = std::pair<QString, Protection_flags>;
|
||||
const Item sharp_and_boundary{"Sharp and Boundary edges", FEATURES};
|
||||
const Item boundary_only{"Boundary edges only", BORDERS};
|
||||
const Item sharp_edges{"Sharp edges", FEATURES};
|
||||
const Item input_polylines{"Input polylines only", Protection_flags{}};
|
||||
const Item on_cube{"Polylines on cube", BORDERS};
|
||||
const Item triple_lines{"Triple+ lines", FEATURES};
|
||||
if (features_protection_available) {
|
||||
if (items->which() == POLYHEDRAL_MESH_ITEMS) {
|
||||
auto v = [](Protection_flags f) { return QVariant::fromValue(f); };
|
||||
if (mesh_type == Mesh_type::SURFACE_ONLY) {
|
||||
ui.protectEdges->addItem(sharp_and_boundary);
|
||||
ui.protectEdges->addItem(boundary_only);
|
||||
ui.protectEdges->addItem(sharp_and_boundary.first, v(sharp_and_boundary.second));
|
||||
ui.protectEdges->addItem(boundary_only.first, v(boundary_only.second));
|
||||
} else
|
||||
ui.protectEdges->addItem(sharp_edges);
|
||||
ui.protectEdges->addItem(sharp_edges.first, v(sharp_edges.second));
|
||||
} else if (items->which() == IMAGE_MESH_ITEMS) {
|
||||
if (polylines_item != nullptr) {
|
||||
ui.protectEdges->addItem(QString(input_polylines).append(" only"));
|
||||
ui.protectEdges->addItem(QString(on_cube).append(" and input polylines"));
|
||||
ui.protectEdges->addItem(QString(triple_lines).append(" and input polylines"));
|
||||
ui.protectEdges->addItem(input_polylines.first, QVariant::fromValue(input_polylines.second));
|
||||
ui.protectEdges->addItem(QString(on_cube.first).append(" and input polylines"),
|
||||
QVariant::fromValue(on_cube.second));
|
||||
ui.protectEdges->addItem(QString(triple_lines.first).append(" and input polylines"),
|
||||
QVariant::fromValue(triple_lines.second));
|
||||
}
|
||||
else {
|
||||
ui.protectEdges->addItem(on_cube);
|
||||
ui.protectEdges->addItem(triple_lines);
|
||||
ui.protectEdges->addItem(on_cube.first, QVariant::fromValue(on_cube.second));
|
||||
ui.protectEdges->addItem(triple_lines.first, QVariant::fromValue(triple_lines.second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -666,13 +674,9 @@ void Mesh_3_plugin::mesh_3(const Mesh_type mesh_type,
|
|||
tets_shape = !ui.noTetShape->isChecked() ? 0 : ui.tetShape->value();
|
||||
tets_sizing = !ui.noTetSizing->isChecked() ? 0 : ui.tetSizing->value();
|
||||
|
||||
const int pe_ci = ui.protectEdges->currentIndex();
|
||||
protect_borders = ui.protect->isChecked()
|
||||
&& ( pe_ci == ui.protectEdges->findText(on_cube, Qt::MatchContains)
|
||||
|| pe_ci == ui.protectEdges->findText(boundary_only, Qt::MatchContains));
|
||||
protect_features = ui.protect->isChecked()
|
||||
&& ( pe_ci == ui.protectEdges->findText(triple_lines, Qt::MatchContains)
|
||||
|| pe_ci == ui.protectEdges->findText(sharp_and_boundary, Qt::MatchContains));
|
||||
const auto pe_flags = ui.protectEdges->currentData().value<Protection_flags>();
|
||||
protect_borders = ui.protect->isChecked() && pe_flags.testFlag(BORDERS);
|
||||
protect_features = ui.protect->isChecked() && pe_flags.testFlag(FEATURES);
|
||||
|
||||
const bool detect_connected_components = ui.detectComponents->isChecked();
|
||||
const int manifold = (ui.manifoldCheckBox->isChecked() ? 1 : 0) +
|
||||
|
|
|
|||
|
|
@ -360,56 +360,55 @@ Meshing_thread* cgal_code_mesh_3(const Image* pImage,
|
|||
}
|
||||
else
|
||||
#endif
|
||||
if (protect_features)
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); },
|
||||
p::features_detector = CGAL::Mesh_3::Detect_features_in_image(),
|
||||
p::input_features = std::cref(polylines)
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (protect_borders)//protect polylines on image Bbox
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); },
|
||||
p::features_detector = CGAL::Mesh_3::Detect_features_on_image_bbox(),
|
||||
p::input_features = std::cref(polylines)
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (!polylines.empty())
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); },
|
||||
p::input_features = std::cref(polylines)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (p_domain == nullptr)
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); }
|
||||
)
|
||||
);
|
||||
}
|
||||
if (protect_features)
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); },
|
||||
p::features_detector = CGAL::Mesh_3::Detect_features_in_image(),
|
||||
p::input_features = std::cref(polylines)
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (protect_borders)//protect polylines on image Bbox
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); },
|
||||
p::features_detector = CGAL::Mesh_3::Detect_features_on_image_bbox(),
|
||||
p::input_features = std::cref(polylines)
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (!polylines.empty())
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); },
|
||||
p::input_features = std::cref(polylines)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (p_domain == nullptr)
|
||||
{
|
||||
p_domain = new Image_mesh_domain
|
||||
(Image_mesh_domain::create_labeled_image_mesh_domain
|
||||
(p::image = *pImage,
|
||||
p::relative_error_bound = 1e-6,
|
||||
p::construct_surface_patch_index =
|
||||
[](int i, int j) { return (i * 1000 + j); }
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
typedef ::Mesh_function<Image_mesh_domain,
|
||||
Mesh_fnt::Labeled_image_domain_tag> Mesh_function;
|
||||
|
|
|
|||
Loading…
Reference in New Issue