mirror of https://github.com/CGAL/cgal
Merge pull request #5018 from maxGimeno/Demo-Add_simply_connected_polygon_generator-maxGimeno
Polyhedron Demo: Add an option to the polyline generator
This commit is contained in:
commit
ad93ce0175
|
|
@ -5,19 +5,37 @@
|
|||
#include <QMessageBox>
|
||||
#include <QBitmap>
|
||||
#include <QTabBar>
|
||||
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
|
||||
#include <CGAL/subdivision_method_3.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/triangulate_hole.h>
|
||||
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
|
||||
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Three/Viewer_interface.h>
|
||||
#include <CGAL/Three/Polyhedron_demo_plugin_helper.h>
|
||||
#include <CGAL/Three/Three.h>
|
||||
|
||||
#include "Scene_surface_mesh_item.h"
|
||||
#include "Scene_points_with_normal_item.h"
|
||||
#include "Scene_polylines_item.h"
|
||||
#include <CGAL/subdivision_method_3.h>
|
||||
#include <CGAL/Kernel_traits.h>
|
||||
#include <CGAL/Three/Three.h>
|
||||
|
||||
#include "ui_Basic_generator_widget.h"
|
||||
|
||||
struct Face : public std::array<int,3>
|
||||
{
|
||||
Face(int i, int j, int k)
|
||||
{
|
||||
(*this)[0] = i;
|
||||
(*this)[1] = j;
|
||||
(*this)[2] = k;
|
||||
}
|
||||
};
|
||||
|
||||
class GeneratorWidget :
|
||||
public QDockWidget,
|
||||
public Ui::BasicGenerator
|
||||
|
|
@ -740,17 +758,49 @@ void Basic_generator_plugin::generateLines()
|
|||
if(ok)
|
||||
{
|
||||
dock_widget->line_textEdit->clear();
|
||||
if(dock_widget->fill_checkBox->isChecked())
|
||||
{
|
||||
CGAL::Three::Three::CursorScopeGuard guard(Qt::WaitCursor);
|
||||
QApplication::processEvents();
|
||||
if(polyline.front() != polyline.back()) {
|
||||
polyline.push_back(polyline.front());
|
||||
}
|
||||
if(polyline.size() < 4) { // no triangle, skip it (needs at least 3 + 1 repeat)
|
||||
QMessageBox::warning(mw, "Warning", "Needs at least 3 points to triangulate. Aborting.");
|
||||
return;
|
||||
}
|
||||
std::vector<Face> patch;
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(polyline,
|
||||
std::back_inserter(patch),
|
||||
CGAL::Polygon_mesh_processing::parameters::use_delaunay_triangulation(true));
|
||||
|
||||
if(patch.empty()) {
|
||||
QMessageBox::warning(mw, "Warning", "Triangulation failed.");
|
||||
return;
|
||||
}
|
||||
SMesh* poly = new SMesh;
|
||||
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(polyline,
|
||||
patch,
|
||||
*poly);
|
||||
|
||||
Scene_surface_mesh_item* poly_item = new Scene_surface_mesh_item(poly);
|
||||
poly_item->setName(dock_widget->name_lineEdit->text());
|
||||
poly_item->setRenderingMode(FlatPlusEdges);
|
||||
scene->setSelectedItem(scene->addItem(poly_item));
|
||||
}
|
||||
else
|
||||
{
|
||||
Scene_polylines_item* item = new Scene_polylines_item();
|
||||
item->polylines = polylines;
|
||||
item->invalidateOpenGLBuffers();
|
||||
item->setName(dock_widget->name_lineEdit->text());
|
||||
item->setColor(Qt::black);
|
||||
item->setProperty("polylines metadata", polylines_metadata);
|
||||
item->invalidateOpenGLBuffers();
|
||||
Scene_interface::Item_id id = scene->addItem(item);
|
||||
scene->setSelectedItem(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Point_generator
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="selector_tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="prismTab">
|
||||
<attribute name="title">
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/cgal/Polyhedron_3/resources/prism.png</pixmap>
|
||||
<pixmap resource="../../Polyhedron_3.qrc">:/cgal/Polyhedron_3/resources/prism.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
|
|
@ -223,7 +223,7 @@ QGroupBox::title {
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/cgal/Polyhedron_3/resources/icosphere.png</pixmap>
|
||||
<pixmap resource="../../Polyhedron_3.qrc">:/cgal/Polyhedron_3/resources/icosphere.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -540,7 +540,7 @@ QGroupBox::title {
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/cgal/Polyhedron_3/resources/hexahedron.png</pixmap>
|
||||
<pixmap resource="../../Polyhedron_3.qrc">:/cgal/Polyhedron_3/resources/hexahedron.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
|
|
@ -750,7 +750,7 @@ QGroupBox::title {
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/cgal/Polyhedron_3/resources/tetrahedron.png</pixmap>
|
||||
<pixmap resource="../../Polyhedron_3.qrc">:/cgal/Polyhedron_3/resources/tetrahedron.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -881,7 +881,7 @@ QGroupBox::title {
|
|||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/cgal/Polyhedron_3/resources/grid.png</pixmap>
|
||||
<pixmap resource="../../Polyhedron_3.qrc">:/cgal/Polyhedron_3/resources/grid.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -1050,7 +1050,7 @@ QGroupBox::title {
|
|||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"><br /></p></body></html></string>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="overwriteMode">
|
||||
<bool>false</bool>
|
||||
|
|
@ -1067,6 +1067,8 @@ p, li { white-space: pre-wrap; }
|
|||
<string>Polyline</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_23">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="polygon_checkBox">
|
||||
<property name="text">
|
||||
|
|
@ -1074,6 +1076,15 @@ p, li { white-space: pre-wrap; }
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="fill_checkBox">
|
||||
<property name="text">
|
||||
<string>Triangulate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="line_textEdit">
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -1087,7 +1098,7 @@ p, li { white-space: pre-wrap; }
|
|||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"><br /></p></body></html></string>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="overwriteMode">
|
||||
<bool>false</bool>
|
||||
|
|
@ -1172,6 +1183,9 @@ p, li { white-space: pre-wrap; }
|
|||
<header>CGAL_double_edit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../Polyhedron_3.qrc"/>
|
||||
<include location="../../Polyhedron_3.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
|||
Loading…
Reference in New Issue