diff --git a/src/meshlabplugins/filter_create/filter_create.cpp b/src/meshlabplugins/filter_create/filter_create.cpp new file mode 100644 index 000000000..c97968723 --- /dev/null +++ b/src/meshlabplugins/filter_create/filter_create.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +* 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. * +* * +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include "filter_create.h" + +// Constructor usually performs only two simple tasks of filling the two lists +// - typeList: with all the possible id of the filtering actions +// - actionList with the corresponding actions. If you want to add icons to your filtering actions you can do here by construction the QActions accordingly + +FilterCreate::FilterCreate() +{ + typeList <(m.cm); + break; + case CR_ICOSAHEDRON: + vcg::tri::Icosahedron(m.cm); + break; + case CR_OCTAHEDRON: + vcg::tri::Octahedron(m.cm); + break; + case CR_SPHERE: + vcg::tri::Sphere(m.cm); + break; + case CR_BOX: + float sz=par.getFloat("size"); + vcg::Box3f b(vcg::Point3f(1,1,1)*(sz/2),vcg::Point3f(1,1,1)*(-sz/2)); + vcg::tri::Box(m.cm,b); + break; + } + vcg::tri::UpdateNormals::PerFace(m.cm); + return true; +} + +const MeshFilterInterface::FilterClass FilterCreate::getClass(QAction *a) +{ + switch(ID(a)) + { + + case CR_BOX: + case CR_TETRAHEDRON: + case CR_ICOSAHEDRON: + case CR_SPHERE: + case CR_OCTAHEDRON: + return MeshFilterInterface::MeshCreation; + break; + default: assert(0); + return MeshFilterInterface::Generic; + } +} +const int FilterCreate::getRequirements(QAction *action) +{ + switch(ID(action)) + { + case CR_SPHERE: + return MeshModel::MM_FACEFACETOPO; + } + return MeshModel::MM_NONE; +} +Q_EXPORT_PLUGIN(FilterCreate) diff --git a/src/meshlabplugins/filter_create/filter_create.h b/src/meshlabplugins/filter_create/filter_create.h new file mode 100644 index 000000000..4a3a95cb0 --- /dev/null +++ b/src/meshlabplugins/filter_create/filter_create.h @@ -0,0 +1,51 @@ +/**************************************************************************** +* 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 FILTER_CREATE_H +#define FILTER_CREATE_H + +#include + +#include +#include + +class FilterCreate : public QObject, public MeshFilterInterface +{ + Q_OBJECT + Q_INTERFACES(MeshFilterInterface) + +public: + enum { CR_BOX, CR_SPHERE, CR_ICOSAHEDRON, CR_TETRAHEDRON, CR_OCTAHEDRON } ; + + FilterCreate(); + + virtual const QString filterName(FilterIDType filter); + virtual const QString filterInfo(FilterIDType filter); + virtual const FilterClass getClass(QAction *); + virtual bool autoDialog(QAction *) {return true;} + virtual void initParameterSet(QAction *,MeshModel &/*m*/, FilterParameterSet & /*parent*/); + virtual bool applyFilter(QAction *filter, MeshModel &m, FilterParameterSet & /*parent*/, vcg::CallBackPos * cb) ; + virtual const int getRequirements(QAction *action); +}; + +#endif diff --git a/src/meshlabplugins/filter_create/filter_create.pro b/src/meshlabplugins/filter_create/filter_create.pro new file mode 100644 index 000000000..abb3bbb66 --- /dev/null +++ b/src/meshlabplugins/filter_create/filter_create.pro @@ -0,0 +1,7 @@ +include (../../shared.pri) + +HEADERS = filter_create.h + +SOURCES = filter_create.cpp \ + ../../meshlab/filterparameter.cpp +TARGET = filter_create