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)
|
target_link_libraries(cgal_lab PRIVATE Qt6::WebSockets)
|
||||||
endif()
|
endif()
|
||||||
cgal_add_compilation_test(cgal_lab)
|
cgal_add_compilation_test(cgal_lab)
|
||||||
|
|
||||||
|
#
|
||||||
|
# the `CGALlab` executable
|
||||||
|
# required as a dependency by all plugins
|
||||||
|
#
|
||||||
add_executable(CGALlab CGALlab.cpp)
|
add_executable(CGALlab CGALlab.cpp)
|
||||||
target_link_libraries(CGALlab PRIVATE cgal_lab)
|
target_link_libraries(CGALlab PRIVATE cgal_lab)
|
||||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGALlab)
|
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGALlab)
|
||||||
cgal_add_compilation_test(CGALlab)
|
cgal_add_compilation_test(CGALlab)
|
||||||
|
|
||||||
target_link_libraries(CGALlab PRIVATE demo_framework)
|
#
|
||||||
|
# PLUGINS
|
||||||
# Link with CGAL
|
#
|
||||||
target_link_libraries(CGALlab PRIVATE CGAL::CGAL_Qt6)
|
|
||||||
|
|
||||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGALlab)
|
|
||||||
|
|
||||||
###########
|
|
||||||
# PLUGINS #
|
|
||||||
###########
|
|
||||||
|
|
||||||
file(
|
file(
|
||||||
GLOB DEMO_PLUGINS
|
GLOB DEMO_PLUGINS
|
||||||
|
|
@ -409,11 +407,14 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
||||||
|
|
||||||
add_subdirectory(implicit_functions)
|
add_subdirectory(implicit_functions)
|
||||||
|
|
||||||
|
add_dependencies(CDT_3 IO_surface_meshes detect_sharp_edges_plugin)
|
||||||
|
add_dependencies(Mesh_3 IO_surface_meshes)
|
||||||
|
|
||||||
#
|
#
|
||||||
# EXECUTABLES
|
# EXECUTABLES
|
||||||
#
|
#
|
||||||
add_executable(CGAL_Mesh_3 Mesh_3.cpp)
|
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)
|
target_link_libraries(CGAL_Mesh_3 PRIVATE cgal_lab)
|
||||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGAL_Mesh_3)
|
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()
|
void cdt_3()
|
||||||
{
|
{
|
||||||
for(CGAL::Three::Scene_interface::Item_id index : scene->selectionIndices())
|
CGAL::Three::OverrideCursorScopeGuard guard(Qt::WaitCursor);
|
||||||
{
|
Scene_item* item = scene->item(scene->mainSelectionIndex());
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
Scene_surface_mesh_item* mesh_item = qobject_cast<Scene_surface_mesh_item*>(item);
|
||||||
Scene_surface_mesh_item* mesh_item =
|
Scene_polygon_soup_item* soup_item = qobject_cast<Scene_polygon_soup_item*>(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)
|
if(mesh_item)
|
||||||
{
|
item = mesh_item;
|
||||||
auto* mesh = mesh_item->face_graph();
|
else if(soup_item)
|
||||||
if(!mesh)
|
item = soup_item;
|
||||||
|
else
|
||||||
|
item = nullptr;
|
||||||
|
|
||||||
|
if(item == nullptr) {
|
||||||
|
CGAL::Three::Three::warning(tr("This function is only applicable on PLCs and polygon soups."));
|
||||||
return;
|
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))
|
auto* const mesh = mesh_item ? mesh_item->face_graph() : nullptr;
|
||||||
: CGAL::make_conforming_constrained_Delaunay_triangulation_3(*mesh);
|
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 triangulation_item = std::make_unique<Scene_c3t3_item>();
|
||||||
auto& item_tr = triangulation_item->triangulation();
|
auto& item_tr = triangulation_item->triangulation();
|
||||||
|
|
||||||
const auto cdt_tr = CGAL::convert_to_triangulation_3(cdt);
|
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());
|
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);
|
item_tr.set_infinite_vertex(inf_v);
|
||||||
triangulation_item->triangulation_changed();
|
triangulation_item->triangulation_changed();
|
||||||
|
|
||||||
triangulation_item->setParent(mesh_item->parent());
|
triangulation_item->setParent(item->parent());
|
||||||
triangulation_item->setName("CDT of " + mesh_item->name());
|
triangulation_item->setName("CDT of " + item->name());
|
||||||
triangulation_item->show_intersection(false);
|
triangulation_item->show_intersection(false);
|
||||||
scene->addItem(triangulation_item.release());
|
scene->addItem(triangulation_item.release());
|
||||||
mesh_item->setVisible(false);
|
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."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ target_link_libraries(lcc_io_plugin PRIVATE scene_lcc_item)
|
||||||
find_package(OpenMesh QUIET)
|
find_package(OpenMesh QUIET)
|
||||||
if(OpenMesh_FOUND)
|
if(OpenMesh_FOUND)
|
||||||
include(CGAL_OpenMesh_support)
|
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 PUBLIC scene_surface_mesh_item scene_polygon_soup_item scene_selection_item)
|
||||||
target_link_libraries(om_plugin PRIVATE CGAL::OpenMesh_support)
|
target_link_libraries(om_plugin PRIVATE CGAL::OpenMesh_support)
|
||||||
else()
|
else()
|
||||||
|
|
@ -71,7 +71,7 @@ endif()
|
||||||
|
|
||||||
if(VTK_FOUND AND VTK_LIBRARIES)
|
if(VTK_FOUND AND VTK_LIBRARIES)
|
||||||
message(STATUS "VTK ${VTK_VERSION} found ${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
|
target_link_libraries(vtk_plugin
|
||||||
PRIVATE
|
PRIVATE
|
||||||
scene_surface_mesh_item
|
scene_surface_mesh_item
|
||||||
|
|
@ -119,7 +119,7 @@ if(3MF_LIBRARIES
|
||||||
AND 3MF_INCLUDE_DIR
|
AND 3MF_INCLUDE_DIR
|
||||||
AND EXISTS "${3MF_INCLUDE_DIR}/Model/COM/NMR_DLLInterfaces.h")
|
AND EXISTS "${3MF_INCLUDE_DIR}/Model/COM/NMR_DLLInterfaces.h")
|
||||||
include_directories(${3MF_INCLUDE_DIR})
|
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_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)
|
target_compile_definitions(io_3mf_plugin PRIVATE -DCGAL_LINKED_WITH_3MF)
|
||||||
else()
|
else()
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,19 @@
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
namespace Three{
|
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 CGAL_Lab_plugin_interface;
|
||||||
class THREE_EXPORT Three{
|
class THREE_EXPORT Three{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
using CursorScopeGuard = CGAL::Three::OverrideCursorScopeGuard; // for compatibility
|
||||||
|
|
||||||
Three();
|
Three();
|
||||||
virtual ~Three(){}
|
virtual ~Three(){}
|
||||||
static QMainWindow* mainWindow();
|
static QMainWindow* mainWindow();
|
||||||
|
|
@ -122,19 +130,6 @@ protected:
|
||||||
static QMutex* s_mutex;
|
static QMutex* s_mutex;
|
||||||
static QWaitCondition* s_wait_condition;
|
static QWaitCondition* s_wait_condition;
|
||||||
static bool s_is_locked;
|
static bool s_is_locked;
|
||||||
|
|
||||||
public:
|
|
||||||
struct CursorScopeGuard
|
|
||||||
{
|
|
||||||
CursorScopeGuard(QCursor cursor)
|
|
||||||
{
|
|
||||||
QApplication::setOverrideCursor(cursor);
|
|
||||||
}
|
|
||||||
~CursorScopeGuard()
|
|
||||||
{
|
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue