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

Scripting interface for gauss curvature plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13594 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6588b858
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include <QtGui>
#include "GaussCurvature.hh"
#include <iostream>
#include <ACG/GL/GLState.hh>
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
......@@ -18,14 +58,24 @@
#endif
GaussCurvaturePlugin::GaussCurvaturePlugin()
{
}
GaussCurvaturePlugin::~GaussCurvaturePlugin()
{
}
void GaussCurvaturePlugin::pluginsInitialized()
{
emit addTexture( "Gaussian Curvature" , "gauss_curvature.png" , 1 );
emit setTextureMode("Gaussian Curvature","clamp=true,clamp_min=-1,clamp_max=1,center=true");
}
void GaussCurvaturePlugin::exit()
{
emit setSlotDescription(tr("computeGaussCurvature(int)"), tr("Compute the gaussian curvature on a mesh. The curvature will be stored on the mesh on the vertex property called \"Gaussian Curvature\""),
QStringList(tr("ObjectId")), QStringList(tr("Id of the mesh")));
}
void GaussCurvaturePlugin::slotUpdateTexture( QString _textureName , int _identifier )
......@@ -46,12 +96,34 @@ void GaussCurvaturePlugin::slotUpdateTexture( QString _textureName , int _identi
if ( object->dataType( DATA_POLY_MESH ) ) {
PolyMesh* mesh = PluginFunctions::polyMesh(object);
computeGaussianCurvature(mesh);
// std::cerr << "Gauss : PolyMeshes not supported" << std::endl;
}
emit updatedTextures("Gaussian Curvature",_identifier);
}
bool GaussCurvaturePlugin::computeGaussCurvature(int _objectId) {
BaseObjectData* object;
if (! PluginFunctions::getObject( _objectId , object ) ) {
return false;
}
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh* mesh = PluginFunctions::triMesh(object);
computeGaussianCurvature(mesh);
return true;
}
if ( object->dataType( DATA_POLY_MESH ) ) {
PolyMesh* mesh = PluginFunctions::polyMesh(object);
computeGaussianCurvature(mesh);
return true;
}
return false;
}
template< typename MeshT >
void GaussCurvaturePlugin::computeGaussianCurvature( MeshT* _mesh) {
OpenMesh::VPropHandleT< double > gauss;
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef GAUSSCURVATUREPLUGIN_HH
#define GAUSSCURVATUREPLUGIN_HH
......@@ -16,29 +58,41 @@ class GaussCurvaturePlugin : public QObject, BaseInterface, TextureInterface
signals:
// Texture Interface
void addTexture( QString _textureName , QString _filename , uint dimension );
void updatedTextures( QString , int );
void setTextureMode(QString _textureName ,QString _mode);
// Base Interface
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
private slots:
void slotUpdateTexture( QString _textureName , int _identifier);
void pluginsInitialized();
void exit();
public :
~GaussCurvaturePlugin() {};
template< typename MeshT >
void computeGaussianCurvature( MeshT* _mesh);
GaussCurvaturePlugin();
~GaussCurvaturePlugin();
QString name() { return (QString("GaussCurvature")); };
QString description( ) { return (QString("Generates Gauss Curvature information")); };
public slots:
/** \brief Scripting slot to trigger computation of gaussian curvature
*
* The curvature will be stored on the mesh on the vertex property called "Mean Curvature"
*/
bool computeGaussCurvature(int _objectId);
QString version() { return QString("1.0"); };
private:
template< typename MeshT >
void computeGaussianCurvature( MeshT* _mesh);
};
#endif //GAUSSCURVATUREPLUGIN_HH
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