Commit e76bf976 authored by Jan Möbius's avatar Jan Möbius
Browse files

Interface for maximal edge length algorithm

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13463 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 63e91ab5
......@@ -57,6 +57,7 @@
#include <OpenMesh/Tools/Subdivider/Uniform/Sqrt3T.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/Sqrt3InterpolatingSubdividerLabsikGreinerT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/ModifiedButterFlyT.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/LongestEdgeT.hh>
SubdividerPlugin::SubdividerPlugin() :
......@@ -75,6 +76,9 @@ void SubdividerPlugin::initializePlugin()
tool_->resize(size);
connect(tool_->subdivide_uniform_toolButton, SIGNAL( clicked() ), this, SLOT( slotSubdivideUniform() ) );
connect(tool_->simpleButton, SIGNAL( clicked() ), this, SLOT( slotSimpleSubdivide() ) );
toolIcon_ = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"subdivider.png");
emit addToolbox( tr("Subdivider") , tool_, toolIcon_ );
......@@ -120,6 +124,60 @@ void SubdividerPlugin::slotSubdivideUniform()
//-----------------------------------------------------------------------------
void SubdividerPlugin::slotSimpleSubdivide()
{
std::vector< int > ids;
if ( PluginFunctions::getTargetIdentifiers( ids ) )
{
for (unsigned int i = 0; i < ids.size(); ++i)
{
if(tool_->longestEdgeSplit->isChecked())
{
simpleSubdivide(ids[i],"longest",tool_->subdivision_steps_spinBox->value(), tool_->maximalEdgeLength->value());
}
}
}
emit updateView();
}
//-----------------------------------------------------------------------------
void SubdividerPlugin::simpleSubdivide(int _objectId, QString _algorithm , int _steps, double _parameter) {
std::cerr << "Simple" << std::endl;
BaseObjectData* object;
if (!test_trimesh_object(_objectId, object))
return;
TriMesh* mesh = PluginFunctions::triMesh(object);
if (_algorithm.contains("longest", Qt::CaseInsensitive)) {
OpenMesh::Subdivider::Uniform::LongestEdgeT<TriMesh, double> subdivider;
std::cerr << "Simple1" << std::endl;
subdivider.attach(*mesh);
subdivider.set_max_edge_length(_parameter);
subdivider(*mesh, _steps, tool_->updatePoints->isChecked());
subdivider.detach();
}
mesh->garbage_collection();
mesh->update_face_normals();
mesh->update_vertex_normals();
TriMeshObject* tmo = PluginFunctions::triMeshObject(object);
tmo->update();
// Create backup
emit createBackup(object->id(), "Subdivider", UPDATE_TOPOLOGY);
// Geometry and topology changed!
emit updatedObject(object->id(), UPDATE_TOPOLOGY);
}
//-----------------------------------------------------------------------------
void SubdividerPlugin::subdivide(int _objectId, QString _algorithm , int _steps) {
BaseObjectData* object;
......@@ -162,6 +220,7 @@ void SubdividerPlugin::subdivide(int _objectId, QString _algorithm , int _steps)
subdivider.detach();
}
mesh->garbage_collection();
mesh->update_face_normals();
mesh->update_vertex_normals();
......
......@@ -103,11 +103,16 @@ private slots:
void slotSubdivideUniform();
void slotSimpleSubdivide();
public slots:
/// Scripting slot for subdivision
void subdivide(int _objectId, QString _algorithm , int _steps);
/// Scripting slot for the simple subdivision algorithms
void simpleSubdivide(int _objectId, QString _algorithm , int _steps, double _parameter);
public :
SubdividerPlugin();
......
......@@ -6,13 +6,23 @@
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<width>410</width>
<height>646</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="Uniform">
<attribute name="title">
<string>Uniform</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
......@@ -162,6 +172,97 @@ of SIGGRAPH 1996, ACM SIGGRAPH, 1996, pp. 189-192.</string>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="Simple">
<attribute name="title">
<string>Simple</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QRadioButton" name="longestEdgeSplit">
<property name="toolTip">
<string>This algorithm splits edges longer than the given maximal length. For each split, the longest edge is split at its midpoint.</string>
</property>
<property name="text">
<string>Longest Edge </string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Max Edge Length</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="maximalEdgeLength">
<property name="toolTip">
<string>Maximal edge length after the algorithm</string>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="simpleButton">
<property name="text">
<string>Subdivide</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment