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

Added vsi metadata for subdividers, added scripting slot

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10249 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8e6ed7b4
include (plugin)
openflipper_plugin ()
openflipper_plugin (INSTALLDATA VsiMetadata)
......@@ -31,6 +31,9 @@ void SubdividerPlugin::initializePlugin()
void SubdividerPlugin::pluginsInitialized()
{
emit setSlotDescription("subdivide(int,QString,int)", "Smooth a triangular mesh",
QString("object_id,algorithm,iterations").split(","),
QString("id of an object, algorithm to use (loop | sqrt3 | interpolating_sqrt(3) | modifiedButterfly ), number of iterations").split(","));
}
//-----------------------------------------------------------------------------
......@@ -42,58 +45,83 @@ void SubdividerPlugin::slotSubdivideUniform()
{
for (unsigned int i = 0; i < ids.size(); ++i)
{
BaseObjectData* object;
if(!test_trimesh_object(ids[i], object))
return;
int steps = tool_->subdivision_steps_spinBox->value();
TriMesh* mesh = PluginFunctions::triMesh(object);
if(tool_->loop_radioButton->isChecked())
{
OpenMesh::Subdivider::Uniform::LoopT<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(steps);
subdivider.detach();
subdivide(ids[i],"loop",tool_->subdivision_steps_spinBox->value());
}
else if ( tool_->sqrt3_radioButton->isChecked() )
{
OpenMesh::Subdivider::Uniform::Sqrt3T<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(steps);
subdivider.detach();
subdivide(ids[i],"sqrt3",tool_->subdivision_steps_spinBox->value());
}
else if ( tool_->LabsikGreiner_radioButton->isChecked() )
{
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(steps);
subdivider.detach();
subdivide(ids[i],"interpolating_sqrt(3)",tool_->subdivision_steps_spinBox->value());
}
else if ( tool_->modifiedButterfly_radioButton->isChecked() )
{
OpenMesh::Subdivider::Uniform::ModifiedButterflyT<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(steps);
subdivider.detach();
subdivide(ids[i],"modifiedButterfly",tool_->subdivision_steps_spinBox->value());
}
}
}
emit updateView();
}
//-----------------------------------------------------------------------------
mesh->update_face_normals();
mesh->update_vertex_normals();
TriMeshObject* tmo = PluginFunctions::triMeshObject(object);
tmo->update();
void SubdividerPlugin::subdivide(int _objectId, QString _algorithm , int _steps) {
BaseObjectData* object;
if(!test_trimesh_object(_objectId , object))
return;
TriMesh* mesh = PluginFunctions::triMesh(object);
if(_algorithm.contains("loop",Qt::CaseInsensitive))
{
OpenMesh::Subdivider::Uniform::LoopT<TriMesh,double> subdivider;
// Create backup
emit createBackup(object->id(), "Subdivider");
emit updatedObject(object->id(), UPDATE_TOPOLOGY);
}
subdivider.attach(*mesh);
subdivider(_steps);
subdivider.detach();
}
emit updateView();
else if ( _algorithm.contains("sqrt3",Qt::CaseInsensitive) )
{
OpenMesh::Subdivider::Uniform::Sqrt3T<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(_steps);
subdivider.detach();
}
else if ( _algorithm.contains("interpolating_sqrt(3)",Qt::CaseInsensitive) )
{
OpenMesh::Subdivider::Uniform::InterpolatingSqrt3LGT<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(_steps);
subdivider.detach();
}
else if ( _algorithm.contains("modifiedButterfly",Qt::CaseInsensitive) )
{
OpenMesh::Subdivider::Uniform::ModifiedButterflyT<TriMesh,double> subdivider;
subdivider.attach(*mesh);
subdivider(_steps);
subdivider.detach();
}
mesh->update_face_normals();
mesh->update_vertex_normals();
TriMeshObject* tmo = PluginFunctions::triMeshObject(object);
tmo->update();
// Create backup
emit createBackup(object->id(), "Subdivider");
// Geometry and topology changed!
emit updatedObject(object->id(), UPDATE_ALL);
}
......
......@@ -45,13 +45,15 @@ signals:
void defineViewMode(QString _mode, QStringList _usedWidgets);
void scriptInfo( QString _functionName );
// ToolboxInterface
void addToolbox( QString _name , QWidget* _widget );
// BackupInterface
void createBackup( int _id , QString _name );
// ScriptInterface
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
private slots:
......@@ -61,10 +63,14 @@ private slots:
/// Make plugin available in no-GUI mode
void noguiSupported( ) {} ;
void slotSubdivideUniform();
public slots:
void slotSubdivideUniform();
/// Scripting slot for subdivision
void subdivide(int _objectId, QString _algorithm , int _steps);
public :
~SubdividerPlugin() {};
......
<OpenFlipper>
<element name="loop_subdivider">
<category>Algorithms</category>
<short>Subdivider(Loop)</short>
<long>Loop subdivision algorithm: C. T. Loop, Smooth Subdivision Surfaces Based on Triangles, M.S. Thesis, Department of Mathematics, University of Utah, August 1987.</long>
<dataflow>true</dataflow>
<inputs>
<input name="obj" type="ObjectId">
<short>ID of an Object</short>
<long>ID of an Object</long>
</input>
<input name="steps" type="Number" external="false">
<short>Number of iterations</short>
<long>Desired number of subdivision steps</long>
<default>1</default>
<min>1</min>
<max>1000</max>
<precision>1</precision>
</input>
</inputs>
<code>
subdivider.subdivide([input="obj"],"loop",[input="steps"]);
</code>
</element>
<element name="sqrt3_subdivider">
<category>Algorithms</category>
<short>Subdivider(Sqrt(3) )</short>
<long>Sqrt(3): L. Kobbelt, Sqrt(3) subdivision, Proceedings of SIGGRAPH 2000.</long>
<dataflow>true</dataflow>
<inputs>
<input name="obj" type="ObjectId">
<short>ID of an Object</short>
<long>ID of an Object</long>
</input>
<input name="steps" type="Number" external="false">
<short>Number of iterations</short>
<long>Desired number of subdivision steps</long>
<default>1</default>
<min>1</min>
<max>1000</max>
<precision>1</precision>
</input>
</inputs>
<code>
subdivider.subdivide([input="obj"],"sqrt3",[input="steps"]);
</code>
</element>
<element name="interpolating_sqrt3_subdivider">
<category>Algorithms</category>
<short>Subdivider(Interpolating Sqrt(3) )</short>
<long>Interpolating Labsik Greiner Subdivider as described in Interpolating sqrt(3) subdivision Labsik and Greiner, 2000</long>
<dataflow>true</dataflow>
<inputs>
<input name="obj" type="ObjectId">
<short>ID of an Object</short>
<long>ID of an Object</long>
</input>
<input name="steps" type="Number" external="false">
<short>Number of iterations</short>
<long>Desired number of subdivision steps</long>
<default>1</default>
<min>1</min>
<max>1000</max>
<precision>1</precision>
</input>
</inputs>
<code>
subdivider.subdivide([input="obj"],"interpolating_sqrt3",[input="steps"]);
</code>
</element>
<element name="modifiedButterfly_subdivider">
<category>Algorithms</category>
<short>Subdivider(Modified Butterfly)</short>
<long>Modified butterfly scheme of Denis Zorin, Peter Schröder and Wim Sweldens, Interpolating subdivision for meshes with arbitrary topology, in Proceedings of SIGGRAPH 1996, ACM SIGGRAPH, 1996, pp. 189-192.</long>
<dataflow>true</dataflow>
<inputs>
<input name="obj" type="ObjectId">
<short>ID of an Object</short>
<long>ID of an Object</long>
</input>
<input name="steps" type="Number" external="false">
<short>Number of iterations</short>
<long>Desired number of subdivision steps</long>
<default>1</default>
<min>1</min>
<max>1000</max>
<precision>1</precision>
</input>
</inputs>
<code>
subdivider.subdivide([input="obj"],"modifiedButterfly",[input="steps"]);
</code>
</element>
</OpenFlipper>
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