From bc6b6b67c534373b5686983f4323fe35af8122db Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 5 Nov 2021 15:51:39 +0100 Subject: [PATCH] filter ao and geodesic python rename --- src/meshlabplugins/filter_ao/filter_ao.cpp | 17 ++- src/meshlabplugins/filter_ao/filter_ao.h | 133 +++++++++--------- .../filter_geodesic/filter_geodesic.cpp | 26 +++- .../filter_geodesic/filter_geodesic.h | 1 + 4 files changed, 96 insertions(+), 81 deletions(-) diff --git a/src/meshlabplugins/filter_ao/filter_ao.cpp b/src/meshlabplugins/filter_ao/filter_ao.cpp index 3d6c6fea7..d94f9cd4a 100644 --- a/src/meshlabplugins/filter_ao/filter_ao.cpp +++ b/src/meshlabplugins/filter_ao/filter_ao.cpp @@ -74,13 +74,18 @@ QString AmbientOcclusionPlugin::pluginName() const QString AmbientOcclusionPlugin::filterName(ActionIDType filterId) const { - switch(filterId) - { - case FP_AMBIENT_OCCLUSION : return QString("Ambient Occlusion"); - default : assert(0); - } + switch (filterId) { + case FP_AMBIENT_OCCLUSION: return QString("Ambient Occlusion"); + default: assert(0); return QString(); + } +} - return QString(""); +QString AmbientOcclusionPlugin::pythonFilterName(ActionIDType f) const +{ + switch (f) { + case FP_AMBIENT_OCCLUSION: return QString("compute_scalar_ambient_occlusion"); + default: assert(0); return QString(); + } } QString AmbientOcclusionPlugin::filterInfo(ActionIDType filterId) const diff --git a/src/meshlabplugins/filter_ao/filter_ao.h b/src/meshlabplugins/filter_ao/filter_ao.h index 48beeae25..e7da7f5ca 100644 --- a/src/meshlabplugins/filter_ao/filter_ao.h +++ b/src/meshlabplugins/filter_ao/filter_ao.h @@ -1,25 +1,25 @@ /**************************************************************************** -* MeshLab o o * -* A versatile mesh processing toolbox o o * -* _ O _ * -* Copyright(C) 2005 \/)\/ * -* Visual Computing Lab /\/| * -* ISTI - Italian National Research Council | * -* \ * -* All rights reserved. * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program 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 General Public License (http://www.gnu.org/licenses/gpl.txt) * -* for more details. * -* * -****************************************************************************/ + * MeshLab o o * + * A versatile mesh processing toolbox o o * + * _ O _ * + * Copyright(C) 2005 \/)\/ * + * Visual Computing Lab /\/| * + * ISTI - Italian National Research Council | * + * \ * + * All rights reserved. * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program 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 General Public License (http://www.gnu.org/licenses/gpl.txt) * + * for more details. * + * * + ****************************************************************************/ #ifndef AMBIENT_OCCLUSION_H #define AMBIENT_OCCLUSION_H @@ -35,72 +35,69 @@ class AmbientOcclusionPlugin : public QObject, public FilterPlugin MESHLAB_PLUGIN_IID_EXPORTER(FILTER_PLUGIN_IID) Q_INTERFACES(FilterPlugin) - // Attributes + // Attributes protected: - std::vector viewDirVec; - vcg::Point3f cameraDir; - GLuint fboDepth, - fboResult, - depthBufferTex, - vertexCoordTex, - vertexNormalsTex, - *resultBufferTex; + std::vector viewDirVec; + vcg::Point3f cameraDir; + GLuint fboDepth, fboResult, depthBufferTex, vertexCoordTex, vertexNormalsTex, *resultBufferTex; - GLenum *resultBufferMRT, - colorFormat, - dataTypeFP; + GLenum *resultBufferMRT, colorFormat, dataTypeFP; - unsigned int numViews, - depthTexArea, - numTexPages; + unsigned int numViews, depthTexArea, numTexPages; + + bool useGPU, errInit; + bool perFace; - bool useGPU, - errInit; - bool perFace; public: - unsigned int depthTexSize, - maxTexSize; + unsigned int depthTexSize, maxTexSize; - // Methods + // Methods public: - enum { FP_AMBIENT_OCCLUSION } ; + enum { FP_AMBIENT_OCCLUSION }; - AmbientOcclusionPlugin(); - ~AmbientOcclusionPlugin(); + AmbientOcclusionPlugin(); + ~AmbientOcclusionPlugin(); - QString pluginName() const; - QString filterName(ActionIDType filter) const; - QString filterInfo(ActionIDType filterId) const; - FilterArity filterArity(const QAction*) const; - int getRequirements (const QAction* action); - bool requiresGLContext(const QAction* action) const; - FilterClass getClass(const QAction* filter) const; + QString pluginName() const; + QString filterName(ActionIDType filter) const; + QString pythonFilterName(ActionIDType f) const; + QString filterInfo(ActionIDType filterId) const; + FilterArity filterArity(const QAction*) const; + int getRequirements(const QAction* action); + bool requiresGLContext(const QAction* action) const; + FilterClass getClass(const QAction* filter) const; + + RichParameterList initParameterList(const QAction*, const MeshModel& /*m*/); + + std::map applyFilter( + const QAction* action, + const RichParameterList& /*parent*/, + MeshDocument& md, + unsigned int& postConditionMask, + vcg::CallBackPos* cb); - RichParameterList initParameterList(const QAction*, const MeshModel &/*m*/); - std::map applyFilter(const QAction* action, const RichParameterList & /*parent*/, MeshDocument &md, unsigned int& postConditionMask, vcg::CallBackPos * cb); void initTextures(void); - void initGL(vcg::CallBackPos *cb,unsigned int numVertices); - bool processGL(MeshModel &m, std::vector &posVect); - bool checkFramebuffer(); + void initGL(vcg::CallBackPos* cb, unsigned int numVertices); + bool processGL(MeshModel& m, std::vector& posVect); + bool checkFramebuffer(); - void vertexCoordsToTexture(MeshModel &m); + void vertexCoordsToTexture(MeshModel& m); - void setCamera(vcg::Point3f camDir,Box3m &meshBBox); + void setCamera(vcg::Point3f camDir, Box3m& meshBBox); - void generateOcclusionHW(); - void generateOcclusionSW(MeshModel &m); - void generateFaceOcclusionSW(MeshModel &m, std::vector & faceCenterVec); + void generateOcclusionHW(); + void generateOcclusionSW(MeshModel& m); + void generateFaceOcclusionSW(MeshModel& m, std::vector& faceCenterVec); + void applyOcclusionHW(MeshModel& m); + void applyOcclusionSW(MeshModel& m, GLfloat* aoValues); - void applyOcclusionHW(MeshModel &m); - void applyOcclusionSW(MeshModel &m,GLfloat *aoValues); + void set_shaders(char* shaderName, GLuint& vs, GLuint& fs, GLuint& pr); - void set_shaders(char *shaderName,GLuint &vs,GLuint &fs,GLuint &pr); + void dumpFloatTexture(QString filename, float* texdata, int elems); - void dumpFloatTexture(QString filename, float *texdata, int elems); private: - bool init; - + bool init; }; #endif diff --git a/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp b/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp index 8336c0066..47e2ff04f 100644 --- a/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp +++ b/src/meshlabplugins/filter_geodesic/filter_geodesic.cpp @@ -61,14 +61,26 @@ QString FilterGeodesic::pluginName() const QString FilterGeodesic::filterName(ActionIDType filter) const { - switch(filter) - { - case FP_QUALITY_BORDER_GEODESIC : return QString("Colorize by border distance"); - case FP_QUALITY_POINT_GEODESIC : return QString("Colorize by geodesic distance from a given point"); - case FP_QUALITY_SELECTED_GEODESIC : return QString("Colorize by geodesic distance from the selected points"); - default : assert(0); + switch (filter) { + case FP_QUALITY_BORDER_GEODESIC: return QString("Colorize by border distance"); + case FP_QUALITY_POINT_GEODESIC: + return QString("Colorize by geodesic distance from a given point"); + case FP_QUALITY_SELECTED_GEODESIC: + return QString("Colorize by geodesic distance from the selected points"); + default: assert(0); return QString(); + } +} + +QString FilterGeodesic::pythonFilterName(ActionIDType f) const +{ + switch (f) { + case FP_QUALITY_BORDER_GEODESIC: return QString("compute_scalar_by_border_distance_per_vertex"); + case FP_QUALITY_POINT_GEODESIC: + return QString("compute_scalar_by_geodesic_distance_from_given_point_per_vertex"); + case FP_QUALITY_SELECTED_GEODESIC: + return QString("compute_scalar_by_geodesic_distance_from_selection_per_vertex"); + default: assert(0); return QString(); } - return QString("error!"); } QString FilterGeodesic::filterInfo(ActionIDType filterId) const diff --git a/src/meshlabplugins/filter_geodesic/filter_geodesic.h b/src/meshlabplugins/filter_geodesic/filter_geodesic.h index 207bc90c8..6fe6d24c2 100644 --- a/src/meshlabplugins/filter_geodesic/filter_geodesic.h +++ b/src/meshlabplugins/filter_geodesic/filter_geodesic.h @@ -52,6 +52,7 @@ class FilterGeodesic : public QObject, public FilterPlugin QString pluginName() const; QString filterName(ActionIDType filter) const; + QString pythonFilterName(ActionIDType f) const; QString filterInfo(ActionIDType filter) const; FilterClass getClass(const QAction*) const;