mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-17 01:54:42 +00:00
FilterCreateIso uses new applyFilter call
This commit is contained in:
parent
d4e98ebe3e
commit
1cdc3ccb15
@ -130,7 +130,7 @@ else()
|
||||
# Filter plugins
|
||||
meshlabplugins/filter_sample
|
||||
meshlabplugins/filter_sample_dyn
|
||||
# meshlabplugins/filter_createiso
|
||||
meshlabplugins/filter_createiso
|
||||
# meshlabplugins/filter_geodesic
|
||||
# meshlabplugins/filter_sample_gpu
|
||||
# meshlabplugins/filter_ao
|
||||
|
||||
@ -41,101 +41,101 @@ using namespace vcg;
|
||||
|
||||
FilterCreateIso::FilterCreateIso()
|
||||
{
|
||||
typeList << FP_CREATEISO;
|
||||
typeList << FP_CREATEISO;
|
||||
|
||||
ActionIDType tt;
|
||||
foreach(tt , types())
|
||||
actionList << new QAction(filterName(tt), this);
|
||||
ActionIDType tt;
|
||||
foreach(tt , types())
|
||||
actionList << new QAction(filterName(tt), this);
|
||||
|
||||
}
|
||||
|
||||
FilterCreateIso::~FilterCreateIso() {
|
||||
for (int i = 0; i < actionList.count() ; i++ )
|
||||
delete actionList.at(i);
|
||||
for (int i = 0; i < actionList.count() ; i++ )
|
||||
delete actionList.at(i);
|
||||
}
|
||||
|
||||
QString FilterCreateIso::pluginName() const
|
||||
{
|
||||
return "FilterCreateIso";
|
||||
return "FilterCreateIso";
|
||||
}
|
||||
|
||||
QString FilterCreateIso::filterName(ActionIDType filter) const
|
||||
QString FilterCreateIso::filterName(ActionIDType filter) const
|
||||
{
|
||||
switch(filter)
|
||||
{
|
||||
case FP_CREATEISO : return QString("Noisy Isosurface");
|
||||
default: assert(0);
|
||||
}
|
||||
return QString("error!");
|
||||
switch(filter)
|
||||
{
|
||||
case FP_CREATEISO : return QString("Noisy Isosurface");
|
||||
default: assert(0);
|
||||
}
|
||||
return QString("error!");
|
||||
}
|
||||
|
||||
QString FilterCreateIso::filterInfo(ActionIDType filterId) const
|
||||
QString FilterCreateIso::filterInfo(ActionIDType filterId) const
|
||||
{
|
||||
switch(filterId)
|
||||
{
|
||||
case FP_CREATEISO: return tr("Create a isosurface perturbed by a noisy isosurface.");
|
||||
default: assert(0);
|
||||
}
|
||||
return QString("error!");
|
||||
switch(filterId)
|
||||
{
|
||||
case FP_CREATEISO: return tr("Create a isosurface perturbed by a noisy isosurface.");
|
||||
default: assert(0);
|
||||
}
|
||||
return QString("error!");
|
||||
}
|
||||
|
||||
FilterCreateIso::FilterClass FilterCreateIso::getClass(const QAction *a) const
|
||||
FilterCreateIso::FilterClass FilterCreateIso::getClass(const QAction *a) const
|
||||
{
|
||||
switch(ID(a))
|
||||
{
|
||||
case FP_CREATEISO : return FilterPlugin::MeshCreation;
|
||||
default : return FilterPlugin::Generic;
|
||||
}
|
||||
switch(ID(a))
|
||||
{
|
||||
case FP_CREATEISO : return FilterPlugin::MeshCreation;
|
||||
default : return FilterPlugin::Generic;
|
||||
}
|
||||
}
|
||||
|
||||
int FilterCreateIso::getRequirements(const QAction *action)
|
||||
int FilterCreateIso::getRequirements(const QAction *action)
|
||||
{
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_CREATEISO : return MeshModel::MM_NONE;
|
||||
default: assert(0);
|
||||
}
|
||||
return 0;
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_CREATEISO : return MeshModel::MM_NONE;
|
||||
default: assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool FilterCreateIso::applyFilter(const QAction *filter, MeshDocument &md, std::map<std::string, QVariant>&, unsigned int& /*postConditionMask*/, const RichParameterList & par, vcg::CallBackPos * cb)
|
||||
{
|
||||
md.addNewMesh("",this->filterName(ID(filter)));
|
||||
MeshModel &m=*(md.mm());
|
||||
if(filter->text() == filterName(FP_CREATEISO) )
|
||||
{
|
||||
|
||||
SimpleVolume<SimpleVoxel<Scalarm> > volume;
|
||||
|
||||
typedef vcg::tri::TrivialWalker<CMeshO, SimpleVolume<SimpleVoxel<Scalarm> > > MyWalker;
|
||||
typedef vcg::tri::MarchingCubes<CMeshO, MyWalker> MyMarchingCubes;
|
||||
MyWalker walker;
|
||||
|
||||
const int gridSize=par.getInt("Resolution");
|
||||
// Simple initialization of the volume with some cool perlin noise
|
||||
volume.Init(Point3i(gridSize,gridSize,gridSize), Box3m(Point3m(0,0,0),Point3m(1,1,1)));
|
||||
for(int i=0;i<gridSize;i++)
|
||||
for(int j=0;j<gridSize;j++)
|
||||
for(int k=0;k<gridSize;k++)
|
||||
volume.Val(i,j,k)=(j-gridSize/2)*(j-gridSize/2)+(k-gridSize/2)*(k-gridSize/2) + i*gridSize/5*(float)math::Perlin::Noise(i*.2,j*.2,k*.2);
|
||||
|
||||
printf("[MARCHING CUBES] Building mesh...");
|
||||
MyMarchingCubes mc(m.cm, walker);
|
||||
walker.BuildMesh<MyMarchingCubes>(m.cm, volume, mc, (gridSize*gridSize)/10,cb);
|
||||
m.UpdateBoxAndNormals();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void FilterCreateIso::initParameterList(const QAction *action,MeshModel & /*m*/, RichParameterList & parlst)
|
||||
std::map<std::string, QVariant> FilterCreateIso::applyFilter(const QAction *filter, const RichParameterList & par, MeshDocument &md, unsigned int& /*postConditionMask*/, vcg::CallBackPos * cb)
|
||||
{
|
||||
pair<float,float> qualityRange;
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_CREATEISO :
|
||||
parlst.addParam(RichInt("Resolution",64,"Grid Resolution","Resolution of the side of the cubic grid used for the volume creation"));
|
||||
break;
|
||||
default: break; // do not add any parameter for the other filters
|
||||
}
|
||||
if (ID(filter) == FP_CREATEISO) {
|
||||
md.addNewMesh("",this->filterName(ID(filter)));
|
||||
MeshModel &m=*(md.mm());
|
||||
SimpleVolume<SimpleVoxel<Scalarm> > volume;
|
||||
|
||||
typedef vcg::tri::TrivialWalker<CMeshO, SimpleVolume<SimpleVoxel<Scalarm> > > MyWalker;
|
||||
typedef vcg::tri::MarchingCubes<CMeshO, MyWalker> MyMarchingCubes;
|
||||
MyWalker walker;
|
||||
|
||||
const int gridSize=par.getInt("Resolution");
|
||||
// Simple initialization of the volume with some cool perlin noise
|
||||
volume.Init(Point3i(gridSize,gridSize,gridSize), Box3m(Point3m(0,0,0),Point3m(1,1,1)));
|
||||
for(int i=0;i<gridSize;i++)
|
||||
for(int j=0;j<gridSize;j++)
|
||||
for(int k=0;k<gridSize;k++)
|
||||
volume.Val(i,j,k)=(j-gridSize/2)*(j-gridSize/2)+(k-gridSize/2)*(k-gridSize/2) + i*gridSize/5*(float)math::Perlin::Noise(i*.2,j*.2,k*.2);
|
||||
|
||||
printf("[MARCHING CUBES] Building mesh...");
|
||||
MyMarchingCubes mc(m.cm, walker);
|
||||
walker.BuildMesh<MyMarchingCubes>(m.cm, volume, mc, (gridSize*gridSize)/10,cb);
|
||||
m.UpdateBoxAndNormals();
|
||||
}
|
||||
else {
|
||||
wrongActionCalled(filter);
|
||||
}
|
||||
return std::map<std::string, QVariant>();
|
||||
}
|
||||
void FilterCreateIso::initParameterList(const QAction *action,MeshModel & /*m*/, RichParameterList & parlst)
|
||||
{
|
||||
switch(ID(action))
|
||||
{
|
||||
case FP_CREATEISO :
|
||||
parlst.addParam(RichInt("Resolution",64,"Grid Resolution","Resolution of the side of the cubic grid used for the volume creation"));
|
||||
break;
|
||||
default: break; // do not add any parameter for the other filters
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,29 +42,29 @@ class FilterCreateIso : public QObject, public FilterPlugin
|
||||
MESHLAB_PLUGIN_IID_EXPORTER(FILTER_PLUGIN_IID)
|
||||
Q_INTERFACES(FilterPlugin)
|
||||
|
||||
public:
|
||||
/* naming convention :
|
||||
- FP -> Filter Plugin
|
||||
- name of the plugin separated by _
|
||||
*/
|
||||
enum {
|
||||
FP_CREATEISO,
|
||||
} ;
|
||||
public:
|
||||
/* naming convention :
|
||||
- FP -> Filter Plugin
|
||||
- name of the plugin separated by _
|
||||
*/
|
||||
enum {
|
||||
FP_CREATEISO,
|
||||
} ;
|
||||
|
||||
/* default values for standard parameters' values of the plugin actions */
|
||||
FilterCreateIso();
|
||||
~FilterCreateIso();
|
||||
/* default values for standard parameters' values of the plugin actions */
|
||||
FilterCreateIso();
|
||||
~FilterCreateIso();
|
||||
|
||||
QString pluginName() const;
|
||||
virtual QString filterName(ActionIDType filter) const;
|
||||
virtual QString filterInfo(ActionIDType filter) const;
|
||||
QString pluginName() const;
|
||||
virtual QString filterName(ActionIDType filter) const;
|
||||
virtual QString filterInfo(ActionIDType filter) const;
|
||||
|
||||
virtual FilterClass getClass(const QAction*) const;
|
||||
virtual int getRequirements(const QAction*);
|
||||
virtual void initParameterList(const QAction*, MeshModel &/*m*/, RichParameterList & /*parent*/);
|
||||
virtual FilterClass getClass(const QAction*) const;
|
||||
virtual int getRequirements(const QAction*);
|
||||
virtual void initParameterList(const QAction*, MeshModel &/*m*/, RichParameterList & /*parent*/);
|
||||
|
||||
virtual bool applyFilter(const QAction* filter, MeshDocument &md, std::map<std::string, QVariant>& outputValues, unsigned int& postConditionMask, const RichParameterList & /*parent*/, vcg::CallBackPos * cb) ;
|
||||
FILTER_ARITY filterArity(const QAction*) const {return NONE;}
|
||||
std::map<std::string, QVariant> applyFilter(const QAction* action, const RichParameterList & /*parent*/, MeshDocument &md, unsigned int& postConditionMask, vcg::CallBackPos * cb);
|
||||
FILTER_ARITY filterArity(const QAction*) const {return NONE;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user