Commit 6588b858 authored by Jan Möbius's avatar Jan Möbius
parents
include (plugin)
openflipper_plugin ()
#include <QtGui>
#include "GaussCurvature.hh"
#include <iostream>
#include <ACG/GL/GLState.hh>
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
#include <MeshTools/Curvature.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#ifdef USE_OPENMP
#include <omp.h>
#endif
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()
{
}
void GaussCurvaturePlugin::slotUpdateTexture( QString _textureName , int _identifier )
{
if ( _textureName != "Gaussian Curvature")
return;
BaseObjectData* object;
if (! PluginFunctions::getObject( _identifier , object ) ) {
return;
}
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMesh* mesh = PluginFunctions::triMesh(object);
computeGaussianCurvature(mesh);
}
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);
}
template< typename MeshT >
void GaussCurvaturePlugin::computeGaussianCurvature( MeshT* _mesh) {
OpenMesh::VPropHandleT< double > gauss;
if(!_mesh->get_property_handle( gauss, "Gaussian Curvature"))
_mesh->add_property( gauss, "Gaussian Curvature" );
#ifdef USE_OPENMP
std::vector< typename MeshT::VertexHandle > handles;
handles.reserve(_mesh->n_vertices());
for ( typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
handles.push_back( v_it.handle() );
#pragma omp parallel for
for ( int i = 0 ; i < (int)handles.size(); ++i )
_mesh->property(gauss,handles[i]) = curvature::gauss_curvature(*_mesh,handles[i]);
#else
for ( typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
_mesh->property(gauss,v_it) = curvature::gauss_curvature(*_mesh,v_it);
#endif
}
Q_EXPORT_PLUGIN2( gausscurvatureplugin , GaussCurvaturePlugin );
#ifndef GAUSSCURVATUREPLUGIN_HH
#define GAUSSCURVATUREPLUGIN_HH
#include <QObject>
#include <QMenuBar>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/TextureInterface.hh>
#include <OpenFlipper/common/Types.hh>
class GaussCurvaturePlugin : public QObject, BaseInterface, TextureInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(TextureInterface)
signals:
void addTexture( QString _textureName , QString _filename , uint dimension );
void updatedTextures( QString , int );
void setTextureMode(QString _textureName ,QString _mode);
private slots:
void slotUpdateTexture( QString _textureName , int _identifier);
void pluginsInitialized();
void exit();
public :
~GaussCurvaturePlugin() {};
template< typename MeshT >
void computeGaussianCurvature( MeshT* _mesh);
QString name() { return (QString("GaussCurvature")); };
QString description( ) { return (QString("Generates Gauss Curvature information")); };
public slots:
QString version() { return QString("1.0"); };
};
#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