diff --git a/src/sampleplugins/sample_pclfilter/sample_pclfilter.cpp b/src/sampleplugins/sample_pclfilter/sample_pclfilter.cpp new file mode 100644 index 000000000..1a9049d0a --- /dev/null +++ b/src/sampleplugins/sample_pclfilter/sample_pclfilter.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +* 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 "sample_pclfilter.h" +#include +#include + +// 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 + +SamplePCLFilterPlugin::SamplePCLFilterPlugin() +:MeshFilterInterface() +{ + typeList << FP_PCL_SAMPLE; + + foreach(FilterIDType tt , types()) + actionList << new QAction(filterName(tt), this); +} + +// ST() must return the very short string describing each filtering action +// (this string is used also to define the menu entry) +QString SamplePCLFilterPlugin::filterName(FilterIDType filterId) const +{ + switch(filterId) { + case FP_PCL_SAMPLE : return QString("Point Cloud Library Filter Example"); + default : assert(0); + } + return QString(); +} + +// Info() must return the longer string describing each filtering action +// (this string is used in the About plugin dialog) +QString SamplePCLFilterPlugin::filterInfo(FilterIDType filterId) const +{ + switch(filterId) { + case FP_PCL_SAMPLE : return QString("Small useless filter added only to show how to work with a Point Cloud Library with MeshLab."); + default : assert(0); + } + return QString("Unknown Filter"); +} + +// The FilterClass describes in which generic class of filters it fits. +// This choice affect the submenu in which each filter will be placed +// More than a single class can be choosen. +SamplePCLFilterPlugin::FilterClass SamplePCLFilterPlugin::getClass(QAction *a) +{ + switch(ID(a)) + { + case FP_PCL_SAMPLE : return MeshFilterInterface::Generic; + default : assert(0); + } + return MeshFilterInterface::Generic; +} + +// This function define the needed parameters for each filter. Return true if the filter has some parameters +// it is called every time, so you can set the default value of parameters according to the mesh +// For each parameter you need to define, +// - the name of the parameter, +// - the string shown in the dialog +// - the default value +// - a possibly long string describing the meaning of that parameter (shown as a popup help in the dialog) +void SamplePCLFilterPlugin::initParameterSet(QAction * action, MeshModel & m, RichParameterSet & parlst) +{ + (void)m; + + switch(ID(action)) + { + case FP_PCL_SAMPLE : + { + break; + } + default : assert(0); + } +} + +// The Real Core Function doing the actual mesh processing. +// Move Vertex of a random quantity +bool SamplePCLFilterPlugin::applyFilter(QAction * a, MeshDocument & md , RichParameterSet & par, vcg::CallBackPos * /*cb*/) +{ + switch(ID(a)) + { + case FP_PCL_SAMPLE: + { + pcl::PointCloud cloud; + + // Fill in the cloud data + cloud.width = 5; + cloud.height = 1; + cloud.is_dense = false; + cloud.points.resize (cloud.width * cloud.height); + + for (size_t i = 0; i < cloud.points.size (); ++i) + { + cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f); + cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f); + cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f); + } + + pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud); + std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl; + + for (size_t i = 0; i < cloud.points.size (); ++i) + std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl; + break; + } + } + return true; +} + +Q_EXPORT_PLUGIN(SamplePCLFilterPlugin) diff --git a/src/sampleplugins/sample_pclfilter/sample_pclfilter.h b/src/sampleplugins/sample_pclfilter/sample_pclfilter.h new file mode 100644 index 000000000..777ca2e93 --- /dev/null +++ b/src/sampleplugins/sample_pclfilter/sample_pclfilter.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 SAMPLEPCLFILTERPLUGIN_H +#define SAMPLEPCLFILTERPLUGIN_H + +#include + +#include + +class SamplePCLFilterPlugin : public QObject, public MeshFilterInterface +{ + Q_OBJECT + Q_INTERFACES(MeshFilterInterface) + +public: + enum { FP_PCL_SAMPLE } ; + + SamplePCLFilterPlugin(); + + QString pluginName(void) const { return "SamplePCLFilterPlugin"; } + void initParameterSet(QAction *action,MeshModel &m, RichParameterSet & parlst); + QString filterName(FilterIDType filter) const; + QString filterInfo(FilterIDType filter) const; + bool applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & /*parent*/, vcg::CallBackPos * cb) ; + FilterClass getClass(QAction *a); +}; + + +#endif \ No newline at end of file diff --git a/src/sampleplugins/sample_pclfilter/sample_pclfilter.pro b/src/sampleplugins/sample_pclfilter/sample_pclfilter.pro new file mode 100644 index 000000000..17b1f14b2 --- /dev/null +++ b/src/sampleplugins/sample_pclfilter/sample_pclfilter.pro @@ -0,0 +1,14 @@ +include (../../shared.pri) + +HEADERS += sample_pclfilter.h + +SOURCES += sample_pclfilter.cpp + +TARGET = sample_pclfilter + +INCLUDEPATH += $(PCL_ROOT)/3rdParty/Boost/include/ $(PCL_ROOT)/3rdParty/Eigen/include $(PCL_ROOT)/3rdParty/Flann/include $(PCL_ROOT)/include/pcl-1.5 +QMAKE_LIBDIR += $(PCL_ROOT)/lib +LIBS += pcl_common_debug.lib pcl_io_debug.lib + + +