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, connect(ui_widget.clip_radioButton, &QRadioButton::toggled,
[this](bool b){ [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()), connect(actionClipPolyhedra , SIGNAL(triggered()),
this, SLOT(pop_widget())); this, SLOT(pop_widget()));
@ -235,7 +236,7 @@ public Q_SLOTS:
for(int id : scene->selectionIndices()) for(int id : scene->selectionIndices())
{ {
Scene_surface_mesh_item *sm_item = qobject_cast<Scene_surface_mesh_item*>(scene->item(id)); 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())) 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())); 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()), CGAL::Polygon_mesh_processing::clip(*(sm_item->face_graph()),
plane->plane(), plane->plane(),
CGAL::parameters::clip_volume( CGAL::parameters::clip_volume(ui_widget.close_checkBox->isChecked())
ui_widget.close_checkBox->isChecked()). .do_not_triangulate_faces(!ui_widget.triangulated_checkBox->isChecked())
throw_on_self_intersection(true). .throw_on_self_intersection(true)
use_compact_clipper( .use_compact_clipper(
!ui_widget.coplanarCheckBox->isChecked()) !ui_widget.coplanarCheckBox->isChecked())
.allow_self_intersections(ui_widget.do_not_modify_CheckBox->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()), CGAL::Polygon_mesh_processing::split(*(sm_item->face_graph()),
plane->plane(), plane->plane(),
CGAL::parameters::throw_on_self_intersection(true) 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())); .allow_self_intersections(ui_widget.do_not_modify_CheckBox->isChecked()));
} }
} }

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>386</width> <width>326</width>
<height>231</height> <height>358</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -56,33 +56,86 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout"/>
<item> </item>
<widget class="QGroupBox" name="groupBox"> <item>
<property name="sizePolicy"> <spacer name="verticalSpacer_2">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <property name="orientation">
<horstretch>0</horstretch> <enum>Qt::Vertical</enum>
<verstretch>0</verstretch> </property>
</sizepolicy> <property name="sizeHint" stdset="0">
</property> <size>
<property name="title"> <width>20</width>
<string>Behavior</string> <height>40</height>
</property> </size>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0" columnstretch="1,0"> </property>
<item row="6" column="1"> </spacer>
<spacer name="verticalSpacer"> </item>
<property name="orientation"> <item>
<enum>Qt::Vertical</enum> <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>
<property name="sizeHint" stdset="0"> <property name="checked">
<size> <bool>true</bool>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</spacer> </widget>
</item> </item>
<item row="4" column="0"> <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"> <widget class="QCheckBox" name="coplanarCheckBox">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -99,37 +152,7 @@ Only available in Split mode.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <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 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">
<widget class="QCheckBox" name="do_not_modify_CheckBox"> <widget class="QCheckBox" name="do_not_modify_CheckBox">
<property name="toolTip"> <property name="toolTip">
<string>Allow the use of a self-intersected clipper, but prevent the closing of the result.</string> <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> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> </layout>
<widget class="QPushButton" name="flip_Button"> </item>
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <layout class="QVBoxLayout" name="verticalLayout_4">
<horstretch>0</horstretch> <item>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Flip plane</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="clipButton"> <widget class="QPushButton" name="clipButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@ -165,23 +179,36 @@ Only available in Split mode.</string>
</property> </property>
</widget> </widget>
</item> </item>
<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> </layout>
</widget> </item>
</item> <item>
</layout> <spacer name="verticalSpacer">
</item> <property name="orientation">
<item> <enum>Qt::Vertical</enum>
<spacer name="verticalSpacer_2"> </property>
<property name="orientation"> <property name="sizeHint" stdset="0">
<enum>Qt::Vertical</enum> <size>
</property> <width>20</width>
<property name="sizeHint" stdset="0"> <height>40</height>
<size> </size>
<width>20</width> </property>
<height>40</height> </spacer>
</size> </item>
</property> </layout>
</spacer> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>