refactor directional geom preserv filter, and add two more filters to add custom point attributes

This commit is contained in:
alemuntoni 2021-10-07 14:52:48 +02:00
parent 45cc5398cc
commit 0361b30844
6 changed files with 2218 additions and 1546 deletions

View File

@ -740,47 +740,47 @@ void LayerDialog::adaptLayout(QTreeWidgetItem * item)
//Add default annotations for each mesh about faces and vertices number
void LayerDialog::addDefaultNotes(QTreeWidgetItem * parent, MeshModel *meshModel)
{
QTreeWidgetItem *fileItem = new QTreeWidgetItem();
QTreeWidgetItem* fileItem = new QTreeWidgetItem();
fileItem->setText(1, QString("File"));
if(!meshModel->fullName().isEmpty())
if (!meshModel->fullName().isEmpty())
fileItem->setText(2, meshModel->shortName());
parent->addChild(fileItem);
updateColumnNumber(fileItem);
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
vertItem->setText(1, QString("Vertices"));
vertItem->setText(2, QString::number(meshModel->cm.vn));
parent->addChild(vertItem);
updateColumnNumber(vertItem);
if(meshModel->cm.en>0){
QTreeWidgetItem *edgeItem = new QTreeWidgetItem();
if (meshModel->cm.en > 0) {
QTreeWidgetItem* edgeItem = new QTreeWidgetItem();
edgeItem->setText(1, QString("Edges"));
edgeItem->setText(2, QString::number(meshModel->cm.en));
parent->addChild(edgeItem);
updateColumnNumber(edgeItem);
}
QTreeWidgetItem *faceItem = new QTreeWidgetItem();
QTreeWidgetItem* faceItem = new QTreeWidgetItem();
faceItem->setText(1, QString("Faces"));
faceItem->setText(2, QString::number(meshModel->cm.fn));
parent->addChild(faceItem);
updateColumnNumber(faceItem);
std::vector<std::string> vertScalarNames;
vcg::tri::Allocator<CMeshO>::GetAllPerVertexAttribute< Scalarm >(meshModel->cm,vertScalarNames);
vcg::tri::Allocator<CMeshO>::GetAllPerVertexAttribute<Scalarm>(meshModel->cm, vertScalarNames);
std::vector<std::string> vertPointNames;
vcg::tri::Allocator<CMeshO>::GetAllPerVertexAttribute< Point3m >(meshModel->cm,vertPointNames);
vcg::tri::Allocator<CMeshO>::GetAllPerVertexAttribute<Point3m>(meshModel->cm, vertPointNames);
std::vector<std::string> faceScalarNames;
vcg::tri::Allocator<CMeshO>::GetAllPerFaceAttribute< Scalarm >(meshModel->cm,faceScalarNames);
vcg::tri::Allocator<CMeshO>::GetAllPerFaceAttribute<Scalarm>(meshModel->cm, faceScalarNames);
std::vector<std::string> facePointNames;
vcg::tri::Allocator<CMeshO>::GetAllPerFaceAttribute< Point3m >(meshModel->cm,facePointNames);
vcg::tri::Allocator<CMeshO>::GetAllPerFaceAttribute<Point3m>(meshModel->cm, facePointNames);
unsigned int totAttributes = vertScalarNames.size() + vertPointNames.size() +
faceScalarNames.size() + facePointNames.size();
if (totAttributes > 0){
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
QFont f;
faceScalarNames.size() + facePointNames.size();
if (totAttributes > 0) {
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
QFont f;
f.setBold(true);
vertItem->setFont(1, f);
vertItem->setText(1, QString("Custom Attrs:"));
@ -788,41 +788,41 @@ void LayerDialog::addDefaultNotes(QTreeWidgetItem * parent, MeshModel *meshModel
updateColumnNumber(vertItem);
}
for(const std::string& name: vertScalarNames) {
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
for (const std::string& name : vertScalarNames) {
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
vertItem->setText(2, QString("Vert (scalar):"));
vertItem->setText(3, QString(name.c_str()));
parent->addChild(vertItem);
updateColumnNumber(vertItem);
}
for(const std::string& name: vertPointNames) {
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
vertItem->setText(2, QString("Vert (vec3):"));
for (const std::string& name : vertPointNames) {
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
vertItem->setText(2, QString("Vert (point):"));
vertItem->setText(3, QString(name.c_str()));
parent->addChild(vertItem);
updateColumnNumber(vertItem);
}
for(const std::string& name: faceScalarNames) {
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
for (const std::string& name : faceScalarNames) {
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
vertItem->setText(2, QString("Face (scalar):"));
vertItem->setText(3, QString(name.c_str()));
parent->addChild(vertItem);
updateColumnNumber(vertItem);
}
for(const std::string& name: facePointNames) {
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
vertItem->setText(2, QString("Face (vec3):"));
for (const std::string& name : facePointNames) {
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
vertItem->setText(2, QString("Face (point):"));
vertItem->setText(3, QString(name.c_str()));
parent->addChild(vertItem);
updateColumnNumber(vertItem);
}
if (meshModel->cm.textures.size() > 0){
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
QFont f;
if (meshModel->cm.textures.size() > 0) {
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
QFont f;
f.setBold(true);
vertItem->setFont(1, f);
vertItem->setText(1, QString("Textures:"));
@ -830,16 +830,15 @@ void LayerDialog::addDefaultNotes(QTreeWidgetItem * parent, MeshModel *meshModel
updateColumnNumber(vertItem);
}
for(const std::string& name: meshModel->cm.textures) {
QTreeWidgetItem *vertItem = new QTreeWidgetItem();
for (const std::string& name : meshModel->cm.textures) {
QTreeWidgetItem* vertItem = new QTreeWidgetItem();
vertItem->setText(2, QString(name.c_str()));
const QImage& img = meshModel->getTexture(name);
QString size = QString::number(img.width()) + "x" + QString::number(img.height());
const QImage& img = meshModel->getTexture(name);
QString size = QString::number(img.width()) + "x" + QString::number(img.height());
vertItem->setText(3, QString(size));
parent->addChild(vertItem);
updateColumnNumber(vertItem);
}
}
//Add, if necessary, columns to the treeWidget.

File diff suppressed because it is too large Load Diff

View File

@ -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-2021 \/)\/ *
* 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 FILTER_FUNC_PLUGIN_H
#define FILTER_FUNC_PLUGIN_H
@ -28,7 +28,6 @@
#include <common/plugins/interfaces/filter_plugin.h>
#include "muParser.h"
#include "filter_refine.h"
class FilterFunctionPlugin : public QObject, public FilterPlugin
@ -38,65 +37,69 @@ class FilterFunctionPlugin : public QObject, public FilterPlugin
Q_INTERFACES(FilterPlugin)
protected:
double x,y,z,nx,ny,nz,r,g,b,a,q,rad,vtu,vtv,vsel;
double x0,y0,z0,x1,y1,z1,x2,y2,z2,nx0,ny0,nz0,nx1,ny1,nz1,nx2,ny2,nz2,r0,g0,b0,a0,r1,g1,b1,a1,r2,g2,b2,a2,q0,q1,q2,wtu0,wtv0,wtu1,wtv1,wtu2,wtv2,vsel0,vsel1,vsel2;
double fr,fg,fb,fa,fnx,fny,fnz,fq,fsel;
double v,f,v0i,v1i,v2i,ti;
double x, y, z, nx, ny, nz, r, g, b, a, q, rad, vtu, vtv, vsel;
double x0, y0, z0, x1, y1, z1, x2, y2, z2, nx0, ny0, nz0, nx1, ny1, nz1, nx2, ny2, nz2, r0, g0,
b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, q0, q1, q2, wtu0, wtv0, wtu1, wtv1, wtu2, wtv2,
vsel0, vsel1, vsel2;
double fr, fg, fb, fa, fnx, fny, fnz, fq, fsel;
double v, f, v0i, v1i, v2i, ti;
std::vector<std::string> v_attrNames; // names of the <float> per vertex attributes
std::vector<double> v_attrValue; // values of the <Scalarm> per vertex attributes
std::vector<std::string> v3_attrNames; // names of the <Point3f> per vertex attributes There are 3x (one foreach coord _x, _y, _z)
std::vector<double> v3_attrValue; // values of the <Point3m> per vertex attributes. There are 3x (one foreach coord _x, _y, _z)
std::vector<std::string> f_attrNames;
std::vector<double> f_attrValue;
std::vector<CMeshO::PerVertexAttributeHandle<Scalarm> > v_handlers;
std::vector<CMeshO::PerVertexAttributeHandle<Point3m> > v3_handlers;
std::vector<CMeshO::PerFaceAttributeHandle<Scalarm> > f_handlers;
QString errorMsg;
std::vector<std::string> v3_attrNames; // names of the <Point3f> per vertex attributes There are
// 3x (one foreach coord _x, _y, _z)
std::vector<double> v3_attrValue; // values of the <Point3m> per vertex attributes. There are 3x
// (one foreach coord _x, _y, _z)
std::vector<std::string> f_attrNames;
std::vector<double> f_attrValue;
std::vector<CMeshO::PerVertexAttributeHandle<Scalarm>> v_handlers;
std::vector<CMeshO::PerVertexAttributeHandle<Point3m>> v3_handlers;
std::vector<CMeshO::PerFaceAttributeHandle<Scalarm>> f_handlers;
QString errorMsg;
public:
enum {
FF_VERT_SELECTION,
FF_FACE_SELECTION,
FF_GEOM_FUNC,
FF_VERT_TEXTURE_FUNC,
FF_WEDGE_TEXTURE_FUNC,
FF_FACE_COLOR,
FF_VERT_COLOR,
FF_VERT_NORMAL,
FF_VERT_QUALITY,
FF_FACE_QUALITY,
FF_DEF_VERT_ATTRIB,
FF_DEF_FACE_ATTRIB,
FF_GRID,
FF_ISOSURFACE,
FF_REFINE
} ;
FF_VERT_SELECTION,
FF_FACE_SELECTION,
FF_GEOM_FUNC,
FF_VERT_TEXTURE_FUNC,
FF_WEDGE_TEXTURE_FUNC,
FF_FACE_COLOR,
FF_VERT_COLOR,
FF_VERT_NORMAL,
FF_VERT_QUALITY,
FF_FACE_QUALITY,
FF_DEF_VERT_SCALAR_ATTRIB,
FF_DEF_FACE_SCALAR_ATTRIB,
FF_DEF_VERT_POINT_ATTRIB,
FF_DEF_FACE_POINT_ATTRIB,
FF_GRID,
FF_ISOSURFACE,
FF_REFINE
};
FilterFunctionPlugin();
~FilterFunctionPlugin();
QString pluginName() const;
QString filterName(ActionIDType filter) const;
QString filterInfo(ActionIDType filter) const;
FilterClass getClass(const QAction*) const;
int postCondition(const QAction *action) const;
RichParameterList initParameterList(const QAction*, const MeshModel &/*m*/);
virtual int getRequirements(const QAction*);
QString pluginName() const;
QString filterName(ActionIDType filter) const;
QString filterInfo(ActionIDType filter) const;
FilterClass getClass(const QAction*) const;
int postCondition(const QAction* action) const;
RichParameterList initParameterList(const QAction*, const MeshModel& /*m*/);
virtual int getRequirements(const QAction*);
std::map<std::string, QVariant> applyFilter(
const QAction* action,
const RichParameterList & parameters,
MeshDocument &md,
unsigned int& postConditionMask,
vcg::CallBackPos * cb);
const QAction* action,
const RichParameterList& parameters,
MeshDocument& md,
unsigned int& postConditionMask,
vcg::CallBackPos* cb);
FilterArity filterArity(const QAction* filter) const;
void showParserError(const QString &s, mu::Parser::exception_type &e);
void setAttributes(CMeshO::VertexIterator &vi,CMeshO &m);
void setAttributes(CMeshO::FaceIterator &fi,CMeshO &m);
void setPerVertexVariables(mu::Parser &p, CMeshO &m);
void setPerFaceVariables(mu::Parser &p, CMeshO &m);
void showParserError(const QString& s, mu::Parser::exception_type& e);
void setAttributes(CMeshO::VertexIterator& vi, CMeshO& m);
void setAttributes(CMeshO::FaceIterator& fi, CMeshO& m);
void setPerVertexVariables(mu::Parser& p, CMeshO& m);
void setPerFaceVariables(mu::Parser& p, CMeshO& m);
};
#endif

View File

@ -23,6 +23,7 @@
#include <common/ml_document/mesh_model.h>
#include "string_conversion.h"
#include "muParser.h"
using namespace vcg;
using namespace mu;

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +1,31 @@
/****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2007 \/)\/ *
* 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 FilterUnsharp_PLUGIN_H
#define FilterUnsharp_PLUGIN_H
/*****************************************************************************
* MeshLab o o *
* A versatile mesh processing toolbox o o *
* _ O _ *
* Copyright(C) 2007-2021 \/)\/ *
* 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 FILTER_UNSHARP_PLUGIN_H
#define FILTER_UNSHARP_PLUGIN_H
#include <QObject>
#include <common/plugins/interfaces/filter_plugin.h>
class FilterUnsharp : public QObject, public FilterPlugin
{
Q_OBJECT
@ -34,14 +33,11 @@ class FilterUnsharp : public QObject, public FilterPlugin
Q_INTERFACES(FilterPlugin)
public:
/* naming convention :
- FP -> Filter Plugin
- name of the plugin separated by _
*/
enum {
FP_CREASE_CUT,
FP_LAPLACIAN_SMOOTH,
FP_DIRECTIONAL_PRESERVATION,
//FP_DIRECTIONAL_PRESERVATION_STORE,
FP_DIRECTIONAL_PRESERVATION_BLEND,
FP_DEPTH_SMOOTH,
FP_HC_LAPLACIAN_SMOOTH,
FP_SD_LAPLACIAN_SMOOTH,
@ -61,29 +57,26 @@ public:
FP_RECOMPUTE_QUADFACE_NORMAL,
FP_LINEAR_MORPH,
FP_SCALAR_HARMONIC_FIELD
} ;
/* default values for standard parameters' values of the plugin actions */
};
FilterUnsharp();
~FilterUnsharp();
QString pluginName() const;
QString filterName(ActionIDType filter) const;
QString filterInfo(ActionIDType filter) const;
FilterClass getClass(const QAction*) const;
int getRequirements(const QAction*);
QString pluginName() const;
QString filterName(ActionIDType filter) const;
QString filterInfo(ActionIDType filter) const;
FilterClass getClass(const QAction*) const;
int getRequirements(const QAction*);
std::map<std::string, QVariant> applyFilter(
const QAction* action,
const RichParameterList & parameters,
MeshDocument &md,
unsigned int& postConditionMask,
vcg::CallBackPos * cb);
RichParameterList initParameterList(const QAction* action, const MeshDocument &/*m*/);
int postCondition(const QAction* ) const;
int getPreConditions(const QAction*) const;
FilterArity filterArity(const QAction* filter) const;
const QAction* action,
const RichParameterList& parameters,
MeshDocument& md,
unsigned int& postConditionMask,
vcg::CallBackPos* cb);
RichParameterList initParameterList(const QAction* action, const MeshDocument& /*m*/);
int postCondition(const QAction*) const;
int getPreConditions(const QAction*) const;
FilterArity filterArity(const QAction* filter) const;
};
#endif
#endif // FILTER_UNSHARP_PLUGIN_H