Exemple #1
0
// The Real Core Function doing the actual mesh processing.
// Move Vertex of a random quantity
bool ExtraSamplePlugin::applyFilter(QAction */*filter*/, MeshDocument &md, RichParameterSet & par, vcg::CallBackPos *cb)
{
	CMeshO &m = md.mm()->cm;
	srand(time(NULL)); 
	const float max_displacement =par.getAbsPerc("Displacement");

	for(unsigned int i = 0; i< m.vert.size(); i++){
		 // Typical usage of the callback for showing a nice progress bar in the bottom. 
		 // First parameter is a 0..100 number indicating percentage of completion, the second is an info string.
		  cb(100*i/m.vert.size(), "Randomly Displacing...");

		float rndax = (float(2.0f*rand())/RAND_MAX - 1.0f ) *max_displacement;
		float rnday = (float(2.0f*rand())/RAND_MAX - 1.0f ) *max_displacement;
		float rndaz = (float(2.0f*rand())/RAND_MAX - 1.0f ) *max_displacement;
		m.vert[i].P() += vcg::Point3f(rndax,rnday,rndaz);
	}
	
	// Log function dump textual info in the lower part of the MeshLab screen. 
	Log("Successfully displaced %i vertices",m.vn);
	
	// to access to the parameters of the filter dialog simply use the getXXXX function of the FilterParameter Class
	if(par.getBool("UpdateNormals"))	
			vcg::tri::UpdateNormal<CMeshO>::PerVertexNormalizedPerFace(m);
	
	vcg::tri::UpdateBounding<CMeshO>::Box(m);
  
	return true;
}
//
// Apply filter
//
bool FilterTopoPlugin::applyFilter(QAction *filter, MeshModel &m, RichParameterSet & par, vcg::CallBackPos *cb)
{
	// To run the retopology algorithm an istance of RetopoMeshBuilder is needed
	RetopMeshBuilder rm;

	// Load topology mesh
	MeshModel *userMesh = par.getMesh("userMesh");
	// Load (input) original mesh
	MeshModel *inMesh = par.getMesh("inMesh");
	// Load iterations value
	int it = par.getInt("it");
	// Load distance value
	float dist = par.getAbsPerc("dist");

	// Destination meshmodel: retopology mesh will replace flat topology mesh
	MeshModel * outM = par.getMesh("userMesh");

	// Prepare mesh
	inMesh->updateDataMask(MeshModel::MM_FACEMARK);
	tri::UpdateNormals<CMeshO>::PerFaceNormalized(inMesh->cm);
	tri::UpdateFlags<CMeshO>::FaceProjection(inMesh->cm);

	// Init the retopology builder with original input mesh and distance value
	rm.init(inMesh, dist);
	// Apply the algorithm
	return rm.applyTopoMesh(*userMesh, *inMesh, it, dist, *outM);
}
Exemple #3
0
void FilterSSynth::initParameterSet(QAction* filter,MeshDocument &md, RichParameterSet &par)
{
   par.addParam(new RichString("grammar","set maxdepth 40 R1 R2 rule R1 { { x 1 rz 6 ry 6 s 0.99 } R1 { s 2 } sphere } rule R2 {{ x -1 rz 6 ry 6 s 0.99 } R2 { s 2 } sphere} ","Eisen Script grammar","Write a grammar according to Eisen Script specification and using the primitives box, sphere, mesh, dot and triangle "));
   par.addParam(new RichInt("seed",1,"seed for random construction","Seed needed to build the mesh"));
   par.addParam(new RichInt("sphereres",1,"set maximum resolution of sphere primitves, it must be included between 1 and 4","increasing the resolution of the spheres will improve the quality of the mesh "));
   return;
}
//
// Filter interface start up
//
void FilterTopoPlugin::initParameterSet(QAction *action, MeshDocument & md, RichParameterSet & parlst) 
{
	MeshModel *target= md.mm();
	foreach (target, md.meshList) 
		if (target != md.mm())  break;

	doc = &md;

	 switch(ID(action))	 {
		case FP_RE_TOPO :  
			// Iterations editbox
			parlst.addParam(new RichInt(	"it", 
							4,
							"Number of refinement iterations used to build the new mesh", 
							"As higher is this value, as well defined will be the new mesh. Consider that more than 5 iterations may slow down your system"));
			// Distance editbox
			parlst.addParam(new RichAbsPerc(	"dist", 0.3f, 0.01f, 0.99f, 
								"Incremental distance %", 
								"This param represents the % distance for the local search algorithm used for new vertices allocation. Generally, 0.25-0.30 is a good value"));
			// Topology mesh list
			parlst.addParam(new RichMesh(	"userMesh", md.mm(), 
							"Topology mesh",
							"This mesh will be used as the new base topology, and will be replaced by the new mesh"));
			// Original mesh list
			parlst.addParam(new RichMesh( "inMesh", target,
							"Original mesh",
							"The new mesh will be elaborated using this model"));
		break;
											
		default : assert(0); 
	}
}
Exemple #5
0
void DecorateShadowPlugin::initGlobalParameterSet(QAction *action, RichParameterSet &parset)
{
    switch(ID(action)){
        case DP_SHOW_SHADOW : {
            assert(!(parset.hasParameter(this->DecorateShadowMethod())));
            int method = SH_MAP_VSM_BLUR;
            parset.addParam(
                    new RichEnum(
                        this->DecorateShadowMethod(),
                        method,
                        getSHMethods(),
                        "Shader used to perform shadow mapping decoration",
                        "Shadow mapping method")
                    );
            break;
        }

        case DP_SHOW_SSAO : {
            assert(!(parset.hasParameter(this->DecorateShadowSSAORadius())));
            float radius = 0.25f;
            parset.addParam(
                    new RichFloat(this->DecorateShadowSSAORadius(),
                    radius,
                    "Uniform parameter for SSAO shader",
                    "SSAO radius"));
            break;
        }

        default: assert(0);
    }
}		
Exemple #6
0
 bool FilterSSynth::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet & par, CallBackPos *cb, QWidget *parent)
{
        this->seed=par.findParameter("seed")->val->getInt();
        int maxrec=par.findParameter("maxrec")->val->getInt();
        int sphereres=par.findParameter("sphereres")->val->getInt();
        int maxobj=par.findParameter("maxobj")->val->getInt();
        this->renderTemplate=GetTemplate(sphereres);
        if(this->renderTemplate!=QString::Null()){
        QFile grammar(fileName);
                grammar.open(QFile::ReadOnly|QFile::Text);
        QString gcontent(grammar.readAll());
        grammar.close();
                if(maxrec>0)ParseGram(&gcontent,maxrec,tr("set maxdepth"));
                if(maxobj>0)ParseGram(&gcontent,maxobj,tr("set maxobjects"));
        QString x3dfile(FilterSSynth::ssynth(gcontent,maxrec,this->seed,cb));
        if(QFile::exists(x3dfile)){
        openX3D(x3dfile,m,mask,cb);
        QFile x3df(x3dfile);
        x3df.remove();
        return true;
        }
        else{
            QMessageBox::critical(parent,tr("Error"),tr("An error occurred during the mesh generation: ").append(x3dfile));
                return false;
        }
    }
        else{ QMessageBox::critical(parent,"Error","Sphere resolution must be between 1 and 4"); return false;}
 }
Exemple #7
0
bool FilterSSynth::applyFilter(QAction*  filter, MeshDocument &md, RichParameterSet & par, vcg::CallBackPos *cb)
{
    QWidget *  parent=(QWidget*)this->parent();
    RichParameter* grammar=par.findParameter(QString("grammar"));
    RichParameter* seed=par.findParameter(QString("seed"));
    int sphereres=par.findParameter("sphereres")->val->getInt();
    this->renderTemplate=GetTemplate(sphereres);
    if(this->renderTemplate!=QString::Null()){
    QString path=ssynth(grammar->val->getString(),-50,seed->val->getInt(),cb);
    if(QFile::exists(path)){
    QFile file(path);
    int mask;
     QString name(file.fileName());
        openX3D(name,*(md.mm()),mask,cb);
    file.remove();
    return true;
        }
        else{
            QString message=QString("An error occurred during the mesh generation:" ).append(path);
            QMessageBox::critical(parent,"Error",message);
                return false;
        }
    }
    else{
        QMessageBox::critical(parent,"Error","Sphere resolution must be between 1 and 4"); return false;
    }
}
Exemple #8
0
void MeshSubFilter::initParameterSet(QAction*, MeshDocument&, RichParameterSet & par){
    par.addParam(new RichInt("fps", 100, "Frames per second", "The number of times per second the physics simulation is updated"));
    par.addParam(new RichInt("iterations", 20, "Physics method iterations", "The number of iterations of the iterative physics equation solver method"));
    par.addParam(new RichInt("contacts", 20, "Max contacts", "Maximum number of contact points to generate per object pair"));
    par.addParam(new RichFloat("bounciness", 0.1f, "Bounciness", "The amount of bounciness of a collision: 0 means the surfaces are not bouncy at all, 1 is the maximum bounciness"));
    par.addParam(new RichFloat("friction", 10, "Friction", "The coulomb friction coefficient of a collision"));
}
Exemple #9
0
void SdfGpuPlugin::initParameterSet(QAction *action, MeshModel &/*m*/, RichParameterSet &par)
{

    qDebug() << "called here!";
     mAction = ID(action);
    QStringList onPrimitive; onPrimitive.push_back("On vertices"); onPrimitive.push_back("On Faces");
   par.addParam( new RichEnum("onPrimitive", 0, onPrimitive, "Metric:",
                    "Choose whether to trace rays from faces or from vertices. " ));
   par.addParam(  new RichInt("numberRays",128, "Number of rays: ",
                    "The number of rays that will be casted around "
                    "the normals."));
   par.addParam(new RichInt("DepthTextureSize", 512, "Depth texture size",
                    "Size of the depth texture for depth peeling. Higher resolutions provide better sampling of the mesh, with a small performance penalty."));
   par.addParam(new RichInt("peelingIteration", 10, "Peeling Iteration",
                                "Number of depth peeling iteration. Actually is the maximum number of layers that a ray can hit while traversing the mesh. "
                                "For example, in the case of a sphere, you should specify 2 in this parameter. For a torus, specify 4. "
                                "<b>For more complex geometry you should run the depth complexity filter to know the exact value</b>."));
   par.addParam(new RichFloat("peelingTolerance", 0.0000001f, "Peeling Tolerance",
                            "Depth tolerance used during depth peeling. This is the threshold used to differentiate layers between each others."
                            "Two elements whose distance is below this value will be considered as belonging to the same layer."));

   if(mAction != SDF_DEPTH_COMPLEXITY)
        par.addParam(new RichFloat("coneAngle",120,"Cone amplitude", "Cone amplitude around normals in degrees. Rays are traced within this cone."));



   switch(mAction)
    {
            case SDF_OBSCURANCE:
                 par.addParam(new RichFloat("obscuranceExponent", 0.1f, "Obscurance Exponent",
                                          "This parameter controls the spatial decay term in the obscurance formula. "
                                          "The greater the exponent, the greater the influence of distance; that is: "
                                          "even if a ray is blocked by an occluder its contribution to the obscurance term is non zero, but proportional to this parameter. "
                                          "It turs out that if you choose a value of zero, you get the standard ambient occlusion term. "
                                          "<b>(In this case, only a value of two, in the peeling iteration parameter, has a sense)</b>"));
                 break;

            default:
                {
                    break;
                }
    }

   par.addParam(new RichBool("useVBO",USEVBO_BY_DEFAULT,"Use VBO if supported","By using VBO, Meshlab loads all the vertex structure in the VRam, greatly increasing rendering speed (for both CPU and GPU mode). Disable it if problem occurs"));

   if(mAction == SDF_SDF)
   {
        par.addParam(new RichBool("removeFalse",true,"Remove false intersections","For each"
                                  "ray we check the normal at the point of intersection,"
                                  "and ignore intersections where the normal at the intersection"
                                  "points is in the same direction as the point-of-origin"
                                  "(the same direction is defined as an angle difference less"
                                  "than 90) "));

        par.addParam(new RichBool("removeOutliers",false,"Remove outliers","The outliers removal is made on the fly with a supersampling of the depth buffer. "
                                  "For each ray that we trace, we take multiple depth values near the point of intersection and we output only the median of these values. "
                                  "Some mesh can benefit from this additional calculation. "));
   }
}
Exemple #10
0
QScriptValue IRichParameterSet_prototype_setBool(QScriptContext* c,QScriptEngine* e)
{
	RichParameterSet* rset = qscriptvalue_cast<RichParameterSet*>(c->thisObject());
	QString varname = c->argument(0).toString();
	bool val = c->argument(1).toBool();
	rset->setValue(varname,BoolValue(val));
	return e->undefinedValue();
}
Exemple #11
0
QScriptValue IRichParameterSet_prototype_setFloat( QScriptContext* c,QScriptEngine* e )
{
	RichParameterSet* rset = qscriptvalue_cast<RichParameterSet*>(c->thisObject());
	QString varname = c->argument(0).toString();
	float val = (float) c->argument(1).toNumber();
	rset->setValue(varname,FloatValue(val));
	return e->undefinedValue();
}
Exemple #12
0
// 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 parmeter 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 TriOptimizePlugin::initParameterSet(QAction *action, MeshModel &m, RichParameterSet & parlst)
{
	if (ID(action) == FP_CURVATURE_EDGE_FLIP) {
		parlst.addParam(new RichBool("selection", m.cm.sfn > 0, tr("Update selection"), tr("Apply edge flip optimization on selected faces only")));
		parlst.addParam(new RichFloat("pthreshold", 1.0f,
											tr("Angle Thr (deg)"),
											tr("To avoid excessive flipping/swapping we consider only couple of faces with a significant diedral angle (e.g. greater than the indicated threshold). ")));
		
		QStringList cmetrics;
		cmetrics.push_back("mean");
		cmetrics.push_back("norm squared");
		cmetrics.push_back("absolute");
		
		parlst.addParam(new RichEnum("curvtype", 0, cmetrics, tr("Curvature metric"),
		        tr("<p style=\'white-space:pre\'>"
			        "Choose a metric to compute surface curvature on vertices<br>"
			        "H = mean curv, K = gaussian curv, A = area per vertex<br><br>"
			        "1: Mean curvature = H<br>"
			        "2: Norm squared mean curvature = (H * H) / A<br>"
			        "3: Absolute curvature:<br>"
			        "     if(K >= 0) return 2 * H<br>"
			        "     else return 2 * sqrt(H ^ 2 - A * K)")));
		}
	
		if (ID(action) == FP_PLANAR_EDGE_FLIP) {
			parlst.addParam(new RichBool("selection", m.cm.sfn > 0, tr("Update selection"), tr("Apply edge flip optimization on selected faces only")));

		parlst.addParam(new RichFloat("pthreshold", 1.0f,
											tr("Planar threshold (deg)"),
											tr("angle threshold for planar faces (degrees)")));
			
		QStringList pmetrics;
		pmetrics.push_back("area/max side");
		pmetrics.push_back("inradius/circumradius");
		pmetrics.push_back("mean ratio");
		pmetrics.push_back("delaunay");
		pmetrics.push_back("topology");
		parlst.addParam(new RichEnum("planartype", 0, pmetrics, tr("Planar metric"),
		        tr("<p style=\'white-space:pre\'>"
			        "Choose a metric to define the planar flip operation<br><br>"
			        "Triangle quality based<br>"
			        "1: minimum ratio height/edge among the edges<br>"
			        "2: ratio between radii of incenter and circumcenter<br>"
			        "3: 2*sqrt(a, b)/(a+b), a, b the eigenvalues of M^tM,<br>"
			        "     M transform triangle into equilateral<br><br>"
			        "Others<br>"
			        "4: Fix the Delaunay condition between two faces<br>"
			        "5: Do the flip to improve local topology<br>")));
		parlst.addParam(new RichInt("iterations", 1, "Post optimization relax iter", tr("number of a planar laplacian smooth iterations that have to be performed after every run")));

	}
	
	if (ID(action) == FP_NEAR_LAPLACIAN_SMOOTH) {
		parlst.addParam(new RichBool("selection", false, tr("Update selection"),	tr("Apply laplacian smooth on selected faces only")));
		parlst.addParam(new RichFloat("AngleDeg", 0.5f,	tr("Max Normal Dev (deg)"),	tr("maximum mean normal angle displacement (degrees) from old to new faces")));
		parlst.addParam(new RichInt("iterations", 1, "Iterations", tr("number of laplacian smooth iterations in every run")));
	}
}
Exemple #13
0
// The Real Core Function doing the actual mesh processing.
bool FilterAutoalign::applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & par, vcg::CallBackPos *cb)
{
  vcg::tri::FourPCS<CMeshO> *fpcs ;
  switch(ID(filter)) {
    case FP_AUTOALIGN :
    {

      MeshModel *firstMesh= par.getMesh("FirstMesh");
      MeshModel *secondMesh= par.getMesh("SecondMesh");
      vcg::tri::FourPCS<CMeshO> fpcs;
      fpcs.par.Default();
      fpcs.par.f =  par.getFloat("overlapping");
      firstMesh->updateDataMask(MeshModel::MM_VERTMARK);
      secondMesh->updateDataMask(MeshModel::MM_VERTMARK);
      fpcs.Init(firstMesh->cm,secondMesh->cm);
      bool res = fpcs.Align(0,firstMesh->cm.Tr,cb);
      firstMesh->clearDataMask(MeshModel::MM_VERTMARK);
      secondMesh->clearDataMask(MeshModel::MM_VERTMARK);

      if(res) Log("Automatic Rough Alignment Done");
         else Log("Automatic Rough Alignment Failed");
    } break;



    case FP_BEST_ROTATION :
    {
      MeshModel *firstMesh= par.getMesh("FirstMesh");
      MeshModel *secondMesh= par.getMesh("SecondMesh");
      tri::Guess GG;
      GG.pp.MatrixNum = 100;
      GG.GenRotMatrix();
      GG.Init<CMeshO>(firstMesh->cm, secondMesh->cm);
      static int counterMV=0;
      static int step=0;
      //for(int i=0;i<GG.MV.size();++i)
      int i=counterMV;
      step = (step +1)%4;
//			if(step==0) counterMV++;

      qDebug("Counter %i step %i",counterMV,step);
        {
            Point3f baseTran =  GG.InitBaseTranslation(GG.MV[i]);
            Point3f bestTran;

            int res = GG.SearchBestTranslation(GG.u[0],GG.MV[i],4,1,baseTran,bestTran);
            if(step==0) firstMesh->cm.Tr.SetIdentity();
            if(step==1) firstMesh->cm.Tr = GG.MV[i];
            if(step==2) firstMesh->cm.Tr = GG.BuildTransformation(GG.MV[i],baseTran);
            if(step==3) firstMesh->cm.Tr = GG.BuildTransformation(GG.MV[i],bestTran);
        }
      //Log(0,(res)?" Automatic Rough Alignment Done":"Automatic Rough Alignment Failed");
    } break;
    default: assert (0);
  }
  return true;
}
void FilterGeodesic::initParameterSet(QAction *action,MeshModel &m, RichParameterSet & parlst)
{
    switch(ID(action))
        {
            case FP_QUALITY_POINT_GEODESIC :
                    parlst.addParam(new RichPoint3f("startPoint",m.cm.bbox.min,"Starting point","The starting point from which geodesic distance has to be computed. If it is not a surface vertex, the closest vertex to the specified point is used as starting seed point."));
          parlst.addParam(new RichAbsPerc("maxDistance",m.cm.bbox.Diag(),0,m.cm.bbox.Diag()*2,"Max Distance","If not zero it indicates a cut off value to be used during geodesic distance computation."));
                    break;
    default: break; // do not add any parameter for the other filters
    }
    return;
}
Exemple #15
0
void U3DIOPlugin::saveParameters(const RichParameterSet &par)
{
        vcg::Point3f from_target_to_camera = vcg::Point3f(par.getPoint3f(QString("position_val")) - par.getPoint3f(QString("target_val")));
	vcg::tri::io::u3dparametersclasses::Movie15Parameters::CameraParameters* sw = _param._campar;
	//vcg::Point3f p = avoidExponentialNotation(sw->_obj_pos,_param._campar->_obj_bbox_diag);
	vcg::Point3f p = sw->_obj_pos;
	_param._campar = new vcg::tri::io::u3dparametersclasses::Movie15Parameters::CameraParameters(
		par.getFloat(QString("fov_val")),0.0f,from_target_to_camera,from_target_to_camera.Norm(),sw->_obj_bbox_diag,p);
	_param.positionQuality = par.getInt(QString("compression_val"));

	delete sw;
}
void Application::executeFilter(Model* model, QString filterName) {
    // qDebug() << "StarlabApplication::executeFilter()";
    FilterPlugin* filter = pluginManager()->getFilter(filterName);
    if(!filter->isApplicable(model))
        throw StarlabException("Filter not applicable");

    /// Filter is applied on the *selected* model
    document()->setSelectedModel(model);
    RichParameterSet* pars = new RichParameterSet();
    filter->initParameters(pars);
    filter->applyFilter(pars);
    pars->deleteLater();
}
Exemple #17
0
// 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 parmeter 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 FilterAutoalign::initParameterSet(QAction *action,MeshDocument & md/*m*/, RichParameterSet & parlst)
{
   MeshModel *target;
   switch(ID(action))	 {
    case FP_AUTOALIGN :
        target= md.mm();
        foreach (target, md.meshList)
            if (target != md.mm())  break;

        parlst.addParam(new RichMesh ("FirstMesh", md.mm(),&md, "First Mesh",
                        "The mesh were the coplanar bases are sampled (it will contain the trasformation)"));
        parlst.addParam(new RichMesh ("SecondMesh", target,&md, "Second Mesh",
                        "The mesh were similar coplanar based are searched."));
        parlst.addParam(new RichFloat("overlapping",0.5f,"Estimated fraction of the\n first mesh overlapped by the second"));
        parlst.addParam(new RichFloat("tolerance [0.0,1.0]",0.3f,"Error tolerance"));
     break;
       case FP_BEST_ROTATION :
       target= md.mm();
       foreach (target, md.meshList)
       if (target != md.mm())  break;

       parlst.addParam(new RichMesh ("FirstMesh", md.mm(),&md, "First Mesh",
                       "The mesh that will be moved"));
       parlst.addParam(new RichMesh ("SecondMesh", target,&md, "Second Mesh",
                       "The mesh that will be kept fixed."));
       parlst.addParam(new RichInt("GridSize",10,"Grid Size", "The size of the uniform grid that is used for searching the best translation for a given rotation"));
       parlst.addParam(new RichInt("Rotation Num",64,"RotationNumber", "sss"));
       break;

   default: break; // do not add any parameter for the other filters
  }
}
Exemple #18
0
void U3DIOPlugin::initSaveParameter(const QString &format, MeshModel &m, RichParameterSet &par) 
{
	_param._campar = new vcg::tri::io::u3dparametersclasses::Movie15Parameters::CameraParameters(m.cm.bbox.Center(),m.cm.bbox.Diag());
	//vcg::Point3f pos = avoidExponentialNotation(_param._campar->_obj_pos,_param._campar->_obj_bbox_diag);
	vcg::Point3f pos = _param._campar->_obj_pos;
	vcg::Point3f dir(0.0f,0.0f,-1.0f * _param._campar->_obj_bbox_diag);
	par.addParam(new RichPoint3f("position_val",dir, "Camera Position",
		"The position in which the camera is set. The default value is derived by the 3d mesh's bounding box."));		
	//vcg::Point3f dir(0.0f,0.0f,avoidExponentialNotation(-1.0f * _param._campar->_obj_bbox_diag,_param._campar->_obj_bbox_diag));
	par.addParam(new RichPoint3f("target_val",pos, "Camera target point",
		"The point towards the camera is seeing. The default value is derived by the 3d mesh's bounding box."));
	par.addParam(new RichFloat("fov_val",60.0f,"Camera's FOV Angle 0..180","Camera's FOV Angle. The values' range is between 0-180 degree. The default value is 60."));
	par.addParam(new RichInt("compression_val",500,"U3D quality 0..1000","U3D mesh's compression ratio. The values' range is between 0-1000 degree. The default value is 500."));
}
void FilterHarmonicPlugin::initParameterSet(QAction * action, MeshModel & m, RichParameterSet & parlst)
{
	switch(ID(action))
	{
	case FP_SCALAR_HARMONIC_FIELD :
		parlst.addParam(new RichPoint3f("point1", m.cm.bbox.min,"Point 1","A vertex on the mesh that represent one harmonic field boundary condition."));
		parlst.addParam(new RichPoint3f("point2", m.cm.bbox.min,"Point 2","A vertex on the mesh that represent one harmonic field boundary condition."));
		parlst.addParam(new RichDynamicFloat("value1", 0.0f, 0.0f, 1.0f,"value for the 1st point","Harmonic field value for the vertex."));
		parlst.addParam(new RichDynamicFloat("value2", 1.0f, 0.0f, 1.0f,"value for the 2nd point","Harmonic field value for the vertex."));
		parlst.addParam(new RichBool("colorize", true, "Colorize", "Colorize the mesh to provide an indication of the obtained harmonic field."));
		break;
	default : assert(0);
	}
}
Exemple #20
0
// This function define the needed parameters for each filter. 
void FilterMeasurePlugin::initParameterSet(QAction *action, MeshDocument &m, RichParameterSet & par)
{
	 switch(ID(action))	 
	 {
   case FP_MEASURE_FACE_QUALITY_HISTOGRAM :
   case FP_MEASURE_VERTEX_QUALITY_HISTOGRAM:
         {
         pair<float,float> minmax = tri::Stat<CMeshO>::ComputePerVertexQualityMinMax(m.mm()->cm);
         par.addParam(new RichFloat("minVal",minmax.first,"Min","The value that is used as a lower bound for the set of bins (all the value smaller this one will be put in the first bin)"));
         par.addParam(new RichFloat("maxVal",minmax.second,"Max","The value that is used as a upper bound for the set of bins (all the value over this one will be put in the last bin)"));
         par.addParam(new RichInt("binNum",20,"Number of bins","Number of bins in which the range of values is subdivided"));
        } break;
	}
}
Exemple #21
0
void AlgoDemoPlugin::initParameterSet(QAction *action, MeshModel &m, RichParameterSet &parlst)
{

    MeshDocument *md = m.parent;
	
    if(md == NULL){
        qDebug()<<"meshDOC is NULL";
        return;
    }

    QStringList curvNameList = QStringList();
    for(int ii = 0; ii < md->meshList.size();++ii)
    {
         curvNameList.push_back(md->meshList[ii]->shortName());
    }
    int li = (md->meshList.size()>=1)?0:-1;
    int ri = (md->meshList.size()>=2)?1:-1;


								
    switch(ID(action))
    {
        case FP_DUAL_ALGO_DEMO:
            parlst.addParam(new RichEnum("originmesh", li, curvNameList, tr("Original Mesh:"),
                    QString("Choose mesh for left window")));
            parlst.addParam(new RichEnum("targetmesh", ri, curvNameList, tr("Target Right:"),
                    QString("Choose mesh for right window")));
            break;
        case FP_SINGLE_ALGO_DEMO:
            parlst.addParam(new RichEnum("originmesh", li, curvNameList, tr("Original Mesh:"),
                    QString("Choose mesh for left window")));
            break;
        default: break; // do not add any parameter for the other algos
    }
	/*
	parlst.addParam(new RichFloat("",0,"Directional Bias [0..1]","The balance between a uniform and a directionally biased set of lighting direction<br>:"
									" - 0 means light came only uniformly from any direction<br>"
									" - 1 means that all the light cames from the specified cone of directions <br>"
									" - other values mix the two set of lighting directions "));
	parlst.addParam(new RichInt ("loops",AMBOCC_DEFAULT_NUM_VIEWS,"Requested views", "Number of different views uniformly placed around the mesh. More views means better accuracy at the cost of increased calculation time"));
	parlst.addParam(new RichPoint3f("coneDir",Point3f(0,1,0),"Lighting Direction", "Number of different views placed around the mesh. More views means better accuracy at the cost of increased calculation time"));
	parlst.addParam(new RichFloat("coneAngle",30,"Cone amplitude", "Number of different views uniformly placed around the mesh. More views means better accuracy at the cost of increased calculation time"));
	parlst.addParam(new RichBool("useGPU",AMBOCC_USEGPU_BY_DEFAULT,"Use GPU acceleration","In order to use GPU-Mode, your hardware must support FBOs, FP32 Textures and Shaders. Normally increases the performance by a factor of 4x-5x"));
	parlst.addParam(new RichBool("useVBO",AMBOCC_USEVBO_BY_DEFAULT,"Use VBO if supported","By using VBO, Meshlab loads all the vertex structure in the VRam, greatly increasing rendering speed (for both CPU and GPU mode). Disable it if problem occurs"));
	parlst.addParam(new RichInt ("depthTexSize",AMBOCC_DEFAULT_TEXTURE_SIZE,"Depth texture size(should be 2^n)", "Defines the depth texture size used to compute occlusion from each point of view. Higher values means better accuracy usually with low impact on performance"));
	*/
	parlst.addParam(new RichInt ("loops",100,"loop times", "loop times"));
	parlst.addParam(new RichFloat("epsilon",0.01,"epsilon", "epsilon"));
}
void AlignTools::buildParameterSet(MeshDocument &md,RichParameterSet & parlst)
{
	vcg::AlignPair::Param ICPParameters;
	AlignParameter::buildRichParameterSet(ICPParameters, parlst);

	parlst.addParam(new RichBool(UseMarkers, true, "Use Markers for Alignment","if true (default), then use the user picked markers to do an alignment (or pre alignment if you also use ICP)."));
	parlst.addParam(new RichBool(AllowScaling, false, "Scale the mesh","if true (false by default), in addition to the alignment, scale the mesh based on the points picked"));
	
	parlst.addParam(new RichBool(UseICP, true, "Use ICP for Alignment","if true (default), then use the ICP to align the two meshes."));
	
	parlst.addParam(new RichMesh (StuckMesh, md.mm(), &md,"Stuck Mesh",
			"The mesh that will not move."));
	parlst.addParam(new RichMesh (MeshToMove, md.mm(), &md, "Mesh to Move",
			"The mesh that will move to fit close to the Stuck Mesh."));
}
Exemple #23
0
int test_simple(){
    RichParameterSet p;
    p.addParam(new RichBool("RichBoolExample", false));
    p.addParam(new RichFloat("RichFloatExample", 0.0f));
    p.addParam(new RichInt("RichIntExample", 0));
    p.addParam(new RichString("RichStringExample","something"));
    p.addParam(new RichColor("RichColorExample",Qt::black));
    p.addParam(new RichAbsPerc("RichAbsPercExample",.5));
    p.addParam(new RichFilePath("RichFilePathExample","pathexample"));   
    qDebug() << qPrintable( p.toString() );
    return 0;
}
Exemple #24
0
bool MeshGridPlugin::applyFilter(QAction *algo, MeshDocument &md,
                                 RichParameterSet & par, vcg::CallBackPos *cb)
{

    int cols = par.getInt("numVertX");
    int rows = par.getInt("numVertY");

    float totalw = 1.0;
    float totalh = 1.0;
    int w = cols+1;
    int h = rows+1;
    float wl = 1.0/cols;
    float hl = 1.0/rows;

    qDebug("w %d h %d",w,h);
    if(w <= 0 || h <= 0) {
        return false;
    }

    md.addNewMesh("",QString("%1_%2").arg(rows).arg(cols));
    MeshModel &m=*(md.mm());



    // use Grid function to generate Grid
    std::vector<float> data(w*h,0);
    tri::Grid<CMeshO>(m.cm, w, h, 1, 1, &data[0]);


    {
        // move x and y
        double halfw = double(w-1)/2;
        double halfh = double(h-1)/2;
        double wld = wl/double(w);
        double hld = hl/float(h);


//      CMeshO::VertexIterator vi;
//      for(vi = m.cm.vert.begin(); vi != m.cm.vert.end(); ++vi)
//      {
//         // qDebug("pos x: %f y: %f",(*vi).P()[0],(*vi).P()[1]);
//        //(*vi).P()[0] = (*vi).P()[0] - (wld * halfw);
//        //(*vi).P()[1] = (*vi).P()[1] - (hld * halfh);
//        //  (*vi).P()[0] = (*vi).P()[0] - totalw/2;
//        //  (*vi).P()[1] = (*vi).P()[1] - totalh/2;
//         // qDebug("after pos x: %f y: %f",(*vi).P()[0],(*vi).P()[1]);
//      }
    }
    // update bounding box, normals
//   Matrix44f rot; rot.SetRotateDeg(180,Point3f(0,1,0));
//   tri::UpdatePosition<CMeshO>::Matrix(m.cm,rot,false);
    tri::UpdateNormal<CMeshO>::PerVertexNormalizedPerFace(m.cm);
    tri::UpdateNormal<CMeshO>::NormalizePerFace(m.cm);
    tri::UpdateBounding<CMeshO>::Box(m.cm);

    CMeshO::VertexIterator vi;


    return true;
}
Exemple #25
0
// 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 parmeter 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 FilterCreate::initParameterSet(QAction *action, MeshModel & /*m*/, RichParameterSet & parlst)
{
	 switch(ID(action))	 {

    case CR_BOX :
      parlst.addParam(new RichFloat("size",1,"Scale factor","Scales the new mesh"));
      break;
    case CR_CONE:
      parlst.addParam(new RichFloat("r0",1,"Radius 1","Radius of the bottom circumference"));
      parlst.addParam(new RichFloat("r1",2,"Radius 2","Radius of the top circumference"));
      parlst.addParam(new RichFloat("h",3,"Height","Height of the Cone"));
      parlst.addParam(new RichInt("subdiv",36,"Side","Number of sides of the polygonal approximation of the cone"));
      break;
		default : return;
	}
}
 bool FilterCreateIso::applyFilter(QAction *filter, MeshDocument &md, RichParameterSet & 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;
 }
Exemple #27
0
// 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 ExtraSampleGPUPlugin::initParameterSet(QAction * action, MeshModel & m, RichParameterSet & parlst)
{
	(void)m;

	switch(ID(action))
	{
		case FP_GPU_EXAMPLE :
		{
			parlst.addParam(new RichColor    ("ImageBackgroundColor", QColor(50, 50, 50),                 "Image Background Color", "The color used as image background."        ));
			parlst.addParam(new RichInt      ("ImageWidth",           512,                                "Image Width",            "The width in pixels of the produced image." ));
			parlst.addParam(new RichInt      ("ImageHeight",          512,                                "Image Height",           "The height in pixels of the produced image."));
			parlst.addParam(new RichSaveFile ("ImageFileName",        "gpu_generated_image.png", "*.png", "Image File Name",        "The file name used to save the image."      ));
			break;
		}
		default : assert(0);
	}
}
Exemple #28
0
// 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 ExtraSamplePlugin::initParameterSet(QAction *action,MeshModel &m, RichParameterSet & parlst) 
{
	 switch(ID(action))	 {
		case FP_MOVE_VERTEX :  
 		  parlst.addParam(new RichBool ("UpdateNormals",
											true,
											"Recompute normals",
											"Toggle the recomputation of the normals after the random displacement.\n\n"
											"If disabled the face normals will remains unchanged resulting in a visually pleasant effect."));
			parlst.addParam(new RichAbsPerc("Displacement",
												m.cm.bbox.Diag()/100.0,0,m.cm.bbox.Diag(),
												"Max displacement",
												"The vertex are displaced of a vector whose norm is bounded by this value"));
											break;
											
		default : assert(0); 
	}
}
// given a RichParameterSet get back the alignment parameter  (dual of the buildParemeterSet)
void AlignParameter::buildAlignParameters(RichParameterSet &fps , AlignPair::Param &app)
{
	app.SampleNum=fps.getInt("SampleNum");
  app.MinDistAbs=fps.getFloat("MinDistAbs");
	app.TrgDistAbs=fps.getFloat("TrgDistAbs");
	app.MaxIterNum=fps.getInt("MaxIterNum");
	app.SampleMode= fps.getBool("SampleMode")?AlignPair::Param::SMNormalEqualized  : AlignPair::Param::SMRandom;
  app.ReduceFactorPerc=fps.getFloat("ReduceFactorPerc");
  app.PassHiFilter=fps.getFloat("PassHiFilter");
	app.MatchMode=fps.getBool("MatchMode")? AlignPair::Param::MMRigid : AlignPair::Param::MMClassic;
}
// given an alignment parameter builds the corresponding RichParameterSet (dual of the retrieveParemeterSet)
void AlignParameter::buildRichParameterSet(AlignPair::Param &app, RichParameterSet &fps)
{
	fps.clear();
	fps.addParam(new RichInt("SampleNum",app.SampleNum,"Sample Number","Number of samples that we try to choose at each ICP iteration"));
	fps.addParam(new RichFloat("MinDistAbs",app.MinDistAbs,"Minimal Starting Distance","For all the chosen sample on one mesh we consider for ICP only the samples nearer than this value."
							                             "If MSD is too large outliers could be included, if it is too small convergence will be very slow. "
							                             "A good guess is needed here, suggested values are in the range of 10-100 times of the device scanning error."
							                             "This value is also dynamically changed by the 'Reduce Distance Factor'"));
	fps.addParam(new RichFloat("TrgDistAbs",app.TrgDistAbs,"Target Distance","When 50% of the chosen samples are below this distance we consider the two mesh aligned. Usually it should be a value lower than the error of the scanning device. "));
	fps.addParam(new RichInt("MaxIterNum",app.MaxIterNum,"Max Iteration Num","The maximum number of iteration that the ICP is allowed to perform."));
	fps.addParam(new RichBool("SampleMode",app.SampleMode == AlignPair::Param::SMNormalEqualized,"Normal Equalized Sampling","if true (default) the sample points of icp are choosen with a  distribution uniform with respect to the normals of the surface. Otherwise they are distributed in a spatially uniform way."));
  fps.addParam(new RichFloat("ReduceFactorPerc",app.ReduceFactorPerc,"MSD Reduce Factor","At each ICP iteration the Minimal Starting Distance is reduced to be 5 times the <Reduce Factor> percentile of the sample distances (e.g. if RF is 0.9 the new Minimal Starting Distance is 5 times the value <X> such that 90% of the sample lies at a distance lower than <X>."));
  fps.addParam(new RichFloat("PassHiFilter",app.PassHiFilter,"Sample Cut High","At each ICP iteration all the sample that are farther than the <cuth high> percentile are discarded ( In practice we use only the <cut high> best results )."));
	fps.addParam(new RichBool("MatchMode",app.MatchMode == AlignPair::Param::MMRigid,"Rigid matching","If true the ICP is cosntrained to perform matching only throug roto-translations (no scaling allowed). If false a more relaxed transformation matrix is allowed (scaling and shearing can appear)."));
}