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

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();
......
This diff is collapsed.
Markdown is supported
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