add do_not_triangulate_faces option in the plugin + fixes

This commit is contained in:
Sébastien Loriot 2025-03-25 23:25:34 +01:00
parent 546f823b48
commit 9f98b28eff
2 changed files with 122 additions and 93 deletions

View File

@ -122,7 +122,8 @@ public :
connect(ui_widget.clip_radioButton, &QRadioButton::toggled,
[this](bool b){
ui_widget.close_checkBox->setEnabled(!ui_widget.do_not_modify_CheckBox->isChecked() &&b);
ui_widget.close_checkBox->setEnabled(!ui_widget.do_not_modify_CheckBox->isChecked() && b);
ui_widget.coplanarCheckBox->setEnabled(ui_widget.clip_radioButton->isChecked());
});
connect(actionClipPolyhedra , SIGNAL(triggered()),
this, SLOT(pop_widget()));
@ -235,7 +236,7 @@ public Q_SLOTS:
for(int id : scene->selectionIndices())
{
Scene_surface_mesh_item *sm_item = qobject_cast<Scene_surface_mesh_item*>(scene->item(id));
if(sm_item && CGAL::is_triangle_mesh(*sm_item->polyhedron()))
if(sm_item)
{
if(!ui_widget.do_not_modify_CheckBox->isChecked() && CGAL::Polygon_mesh_processing::does_self_intersect(*sm_item->face_graph()))
CGAL::Three::Three::warning(tr("%1 has not been clipped because it has self intersections.").arg(sm_item->name()));
@ -255,10 +256,10 @@ public Q_SLOTS:
{
CGAL::Polygon_mesh_processing::clip(*(sm_item->face_graph()),
plane->plane(),
CGAL::parameters::clip_volume(
ui_widget.close_checkBox->isChecked()).
throw_on_self_intersection(true).
use_compact_clipper(
CGAL::parameters::clip_volume(ui_widget.close_checkBox->isChecked())
.do_not_triangulate_faces(!ui_widget.triangulated_checkBox->isChecked())
.throw_on_self_intersection(true)
.use_compact_clipper(
!ui_widget.coplanarCheckBox->isChecked())
.allow_self_intersections(ui_widget.do_not_modify_CheckBox->isChecked()));
}
@ -280,6 +281,7 @@ public Q_SLOTS:
CGAL::Polygon_mesh_processing::split(*(sm_item->face_graph()),
plane->plane(),
CGAL::parameters::throw_on_self_intersection(true)
.do_not_triangulate_faces(!ui_widget.triangulated_checkBox->isChecked())
.allow_self_intersections(ui_widget.do_not_modify_CheckBox->isChecked()));
}
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>386</width>
<height>231</height>
<width>326</width>
<height>358</height>
</rect>
</property>
<property name="sizePolicy">
@ -56,21 +56,10 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Behavior</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0" columnstretch="1,0">
<item row="6" column="1">
<spacer name="verticalSpacer">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -82,7 +71,71 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Behavior</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="clip_radioButton">
<property name="text">
<string>Clip</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="split_radioButton">
<property name="text">
<string>Split</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="close_checkBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Keep Closed</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="triangulated_checkBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Keep Triangulated</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="coplanarCheckBox">
<property name="enabled">
<bool>true</bool>
@ -99,37 +152,7 @@ Only available in Split mode.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="close_checkBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Keep Closed</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="split_radioButton">
<property name="text">
<string>Split</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="clip_radioButton">
<property name="text">
<string>Clip</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<item>
<widget class="QCheckBox" name="do_not_modify_CheckBox">
<property name="toolTip">
<string>Allow the use of a self-intersected clipper, but prevent the closing of the result.</string>
@ -139,20 +162,11 @@ Only available in Split mode.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="flip_Button">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Flip plane</string>
</property>
</widget>
</layout>
</item>
<item row="4" column="1">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QPushButton" name="clipButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@ -165,13 +179,23 @@ Only available in Split mode.</string>
</property>
</widget>
</item>
</layout>
<item>
<widget class="QPushButton" name="flip_Button">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Flip plane</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -185,6 +209,9 @@ Only available in Split mode.</string>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../../CGALlab.qrc"/>