mirror of https://github.com/CGAL/cgal
refactor the CDT_3 plugin
This commit is contained in:
parent
398df2bf2a
commit
9d791ce3ec
|
|
@ -383,21 +383,19 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
target_link_libraries(cgal_lab PRIVATE Qt6::WebSockets)
|
||||
endif()
|
||||
cgal_add_compilation_test(cgal_lab)
|
||||
|
||||
#
|
||||
# the `CGALlab` executable
|
||||
# required as a dependency by all plugins
|
||||
#
|
||||
add_executable(CGALlab CGALlab.cpp)
|
||||
target_link_libraries(CGALlab PRIVATE cgal_lab)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGALlab)
|
||||
cgal_add_compilation_test(CGALlab)
|
||||
|
||||
target_link_libraries(CGALlab PRIVATE demo_framework)
|
||||
|
||||
# Link with CGAL
|
||||
target_link_libraries(CGALlab PRIVATE CGAL::CGAL_Qt6)
|
||||
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGALlab)
|
||||
|
||||
###########
|
||||
# PLUGINS #
|
||||
###########
|
||||
#
|
||||
# PLUGINS
|
||||
#
|
||||
|
||||
file(
|
||||
GLOB DEMO_PLUGINS
|
||||
|
|
@ -409,11 +407,14 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
|
||||
add_subdirectory(implicit_functions)
|
||||
|
||||
add_dependencies(CDT_3 IO_surface_meshes detect_sharp_edges_plugin)
|
||||
add_dependencies(Mesh_3 IO_surface_meshes)
|
||||
|
||||
#
|
||||
# EXECUTABLES
|
||||
#
|
||||
add_executable(CGAL_Mesh_3 Mesh_3.cpp)
|
||||
add_dependencies(CGAL_Mesh_3 Mesh_3)
|
||||
add_dependencies(CGAL_Mesh_3 Mesh_3 IO_surface_meshes)
|
||||
target_link_libraries(CGAL_Mesh_3 PRIVATE cgal_lab)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGAL_Mesh_3)
|
||||
|
||||
|
|
|
|||
|
|
@ -58,62 +58,59 @@ class CDT_3_plugin : public QObject, public CGAL_Lab_plugin_interface
|
|||
|
||||
void cdt_3()
|
||||
{
|
||||
for(CGAL::Three::Scene_interface::Item_id index : scene->selectionIndices())
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
Scene_surface_mesh_item* mesh_item =
|
||||
qobject_cast<Scene_surface_mesh_item*>(scene->item(scene->mainSelectionIndex()));
|
||||
Scene_polygon_soup_item* soup_item =
|
||||
qobject_cast<Scene_polygon_soup_item*>(scene->item(index));
|
||||
if(mesh_item)
|
||||
{
|
||||
auto* mesh = mesh_item->face_graph();
|
||||
if(!mesh)
|
||||
return;
|
||||
auto patch_id_pmap = mesh->property_map<SMesh::Face_index, int>("f:patch_id");
|
||||
auto cdt = patch_id_pmap
|
||||
? CGAL::make_conforming_constrained_Delaunay_triangulation_3(*mesh, CGAL::parameters::face_patch_map(*patch_id_pmap))
|
||||
: CGAL::make_conforming_constrained_Delaunay_triangulation_3(*mesh);
|
||||
auto triangulation_item = std::make_unique<Scene_c3t3_item>();
|
||||
auto& item_tr = triangulation_item->triangulation();
|
||||
CGAL::Three::OverrideCursorScopeGuard guard(Qt::WaitCursor);
|
||||
Scene_item* item = scene->item(scene->mainSelectionIndex());
|
||||
Scene_surface_mesh_item* mesh_item = qobject_cast<Scene_surface_mesh_item*>(item);
|
||||
Scene_polygon_soup_item* soup_item = qobject_cast<Scene_polygon_soup_item*>(item);
|
||||
if(mesh_item)
|
||||
item = mesh_item;
|
||||
else if(soup_item)
|
||||
item = soup_item;
|
||||
else
|
||||
item = nullptr;
|
||||
|
||||
const auto cdt_tr = CGAL::convert_to_triangulation_3(cdt);
|
||||
auto inf_v = item_tr.tds().copy_tds(cdt_tr.tds(), cdt_tr.infinite_vertex(), Vertex_converter(), Cell_converter());
|
||||
item_tr.set_infinite_vertex(inf_v);
|
||||
triangulation_item->triangulation_changed();
|
||||
|
||||
triangulation_item->setParent(mesh_item->parent());
|
||||
triangulation_item->setName("CDT of " + mesh_item->name());
|
||||
triangulation_item->show_intersection(false);
|
||||
scene->addItem(triangulation_item.release());
|
||||
mesh_item->setVisible(false);
|
||||
}
|
||||
else if(soup_item)
|
||||
{
|
||||
auto cdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(
|
||||
soup_item->points(), soup_item->polygons());
|
||||
|
||||
auto triangulation_item = std::make_unique<Scene_c3t3_item>();
|
||||
auto& item_tr = triangulation_item->triangulation();
|
||||
|
||||
const auto cdt_tr = CGAL::convert_to_triangulation_3(cdt);
|
||||
auto inf_v =
|
||||
item_tr.tds().copy_tds(cdt_tr.tds(), cdt_tr.infinite_vertex(), Vertex_converter(), Cell_converter());
|
||||
item_tr.set_infinite_vertex(inf_v);
|
||||
triangulation_item->triangulation_changed();
|
||||
|
||||
triangulation_item->setParent(soup_item->parent());
|
||||
triangulation_item->setName("CDT of " + soup_item->name());
|
||||
triangulation_item->show_intersection(false);
|
||||
scene->addItem(triangulation_item.release());
|
||||
soup_item->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CGAL::Three::Three::warning(tr("This function is only applicable on PLCs and polygon soups."));
|
||||
}
|
||||
if(item == nullptr) {
|
||||
CGAL::Three::Three::warning(tr("This function is only applicable on PLCs and polygon soups."));
|
||||
return;
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
auto* const mesh = mesh_item ? mesh_item->face_graph() : nullptr;
|
||||
if(!mesh) return;
|
||||
|
||||
using CDT = CGAL::Conforming_constrained_Delaunay_triangulation_3<EPICK>;
|
||||
CDT cdt = std::invoke([&] {
|
||||
CDT cdt;
|
||||
if(mesh_item) {
|
||||
auto patch_id_pmap_opt = mesh->property_map<SMesh::Face_index, int>("f:patch_id");
|
||||
|
||||
if(patch_id_pmap_opt.has_value()) {
|
||||
cdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(
|
||||
*mesh, CGAL::parameters::face_patch_map(*patch_id_pmap_opt));
|
||||
}
|
||||
else {
|
||||
cdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(*mesh);
|
||||
}
|
||||
}
|
||||
else if(soup_item) {
|
||||
cdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(
|
||||
soup_item->points(), soup_item->polygons());
|
||||
|
||||
}
|
||||
return cdt;
|
||||
});
|
||||
auto triangulation_item = std::make_unique<Scene_c3t3_item>();
|
||||
auto& item_tr = triangulation_item->triangulation();
|
||||
|
||||
const auto cdt_tr = CGAL::convert_to_triangulation_3(std::move(cdt));
|
||||
auto inf_v = item_tr.tds().copy_tds(cdt_tr.tds(), cdt_tr.infinite_vertex(), Vertex_converter(), Cell_converter());
|
||||
item_tr.set_infinite_vertex(inf_v);
|
||||
triangulation_item->triangulation_changed();
|
||||
|
||||
triangulation_item->setParent(item->parent());
|
||||
triangulation_item->setName("CDT of " + item->name());
|
||||
triangulation_item->show_intersection(false);
|
||||
scene->addItem(triangulation_item.release());
|
||||
item->setVisible(false);
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ target_link_libraries(lcc_io_plugin PRIVATE scene_lcc_item)
|
|||
find_package(OpenMesh QUIET)
|
||||
if(OpenMesh_FOUND)
|
||||
include(CGAL_OpenMesh_support)
|
||||
cgal_lab_plugin(om_plugin OM_io_plugin KEYWORDS Viewer PMP)
|
||||
cgal_lab_plugin(om_plugin OM_io_plugin KEYWORDS Viewer PMP IO_surface_meshes)
|
||||
target_link_libraries(om_plugin PUBLIC scene_surface_mesh_item scene_polygon_soup_item scene_selection_item)
|
||||
target_link_libraries(om_plugin PRIVATE CGAL::OpenMesh_support)
|
||||
else()
|
||||
|
|
@ -71,7 +71,7 @@ endif()
|
|||
|
||||
if(VTK_FOUND AND VTK_LIBRARIES)
|
||||
message(STATUS "VTK ${VTK_VERSION} found ${VTK_LIBRARIES}")
|
||||
cgal_lab_plugin(vtk_plugin VTK_io_plugin KEYWORDS Viewer Mesh_3)
|
||||
cgal_lab_plugin(vtk_plugin VTK_io_plugin KEYWORDS Viewer IO_surface_meshes)
|
||||
target_link_libraries(vtk_plugin
|
||||
PRIVATE
|
||||
scene_surface_mesh_item
|
||||
|
|
@ -119,7 +119,7 @@ if(3MF_LIBRARIES
|
|||
AND 3MF_INCLUDE_DIR
|
||||
AND EXISTS "${3MF_INCLUDE_DIR}/Model/COM/NMR_DLLInterfaces.h")
|
||||
include_directories(${3MF_INCLUDE_DIR})
|
||||
cgal_lab_plugin(io_3mf_plugin 3mf_io_plugin KEYWORDS Viewer PMP)
|
||||
cgal_lab_plugin(io_3mf_plugin 3mf_io_plugin KEYWORDS Viewer PMP IO_surface_meshes)
|
||||
target_link_libraries(io_3mf_plugin PRIVATE scene_surface_mesh_item scene_points_with_normal_item scene_polylines_item ${3MF_LIBRARIES})
|
||||
target_compile_definitions(io_3mf_plugin PRIVATE -DCGAL_LINKED_WITH_3MF)
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -35,11 +35,19 @@
|
|||
|
||||
namespace CGAL{
|
||||
namespace Three{
|
||||
//define enum depending on Qt version
|
||||
|
||||
struct OverrideCursorScopeGuard
|
||||
{
|
||||
OverrideCursorScopeGuard(QCursor cursor) { QApplication::setOverrideCursor(cursor); }
|
||||
~OverrideCursorScopeGuard() { QApplication::restoreOverrideCursor(); }
|
||||
};
|
||||
|
||||
class CGAL_Lab_plugin_interface;
|
||||
class THREE_EXPORT Three{
|
||||
public:
|
||||
|
||||
using CursorScopeGuard = CGAL::Three::OverrideCursorScopeGuard; // for compatibility
|
||||
|
||||
Three();
|
||||
virtual ~Three(){}
|
||||
static QMainWindow* mainWindow();
|
||||
|
|
@ -122,19 +130,6 @@ protected:
|
|||
static QMutex* s_mutex;
|
||||
static QWaitCondition* s_wait_condition;
|
||||
static bool s_is_locked;
|
||||
|
||||
public:
|
||||
struct CursorScopeGuard
|
||||
{
|
||||
CursorScopeGuard(QCursor cursor)
|
||||
{
|
||||
QApplication::setOverrideCursor(cursor);
|
||||
}
|
||||
~CursorScopeGuard()
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue