//添加元素
void FilterParameter::addQDomElement(FilterParameterSet &par, QDomElement &np)
{
		QString name=np.attribute("name");
		QString type=np.attribute("type");

		qDebug("    Reading Param with name %s : %s",qPrintable(name),qPrintable(type));

		if(type=="Bool")    { par.addBool(name,np.attribute("value")!=QString("false")); return; }
		if(type=="Int")     { par.addInt(name,np.attribute("value").toInt()); return; }
		if(type=="Float")   { par.addFloat(name,np.attribute("value").toDouble()); return; }
		if(type=="String")  { par.addString(name,np.attribute("value")); return; }
		if(type=="AbsPerc") { par.addAbsPerc(name,np.attribute("value").toFloat(),np.attribute("min").toFloat(),np.attribute("max").toFloat()); return; }
		if(type=="Color")		{ par.addColor(name,QColor::QColor(np.attribute("rgb").toUInt())); return; }
		if(type=="Matrix44")
		{
		  Matrix44f mm;
			for(int i=0;i<16;++i)
					mm.V()[i]=np.attribute(QString("val")+QString::number(i)).toDouble();
			par.addMatrix44(name,mm);    
			return;                    
		}
		if(type=="Enum")
		{
			QStringList list = QStringList::QStringList();
			for(QDomElement ns = np.firstChildElement("EnumString"); !ns.isNull(); ns = ns.nextSiblingElement("EnumString")){
				list<<ns.attribute("value");
			}
			par.addEnum(name,np.attribute("value").toInt(),list);
			return;
		}
		
		if(type == MeshPointerName())  { par.addMesh(name, np.attribute(ValueName()).toInt()); return; }
		if(type == FloatListName())
		{
			QList<float> values;
			for(QDomElement listItem = np.firstChildElement(ItemName());
					!listItem.isNull();
					listItem = listItem.nextSiblingElement(ItemName()))
			{
					values.append(listItem.attribute(ValueName()).toFloat()); 
				}
			par.addFloatList(name,values);
			return;
		}
			
		if(type == DynamicFloatName())  { par.addDynamicFloat(name, np.attribute(ValueName()).toFloat(), np.attribute(MinName()).toFloat(), np.attribute(MaxName()).toFloat(), np.attribute(MaskName()).toInt()); return; }
		if(type == OpenFileNameName())  { par.addOpenFileName(name, np.attribute(ValueName())); return; }
		if(type == SaveFileNameName())  { par.addSaveFileName(name, np.attribute(ValueName())); return; }
		if(type=="Point3f") 
		{
			Point3f val;
			val[0]=np.attribute("x").toFloat();
			val[1]=np.attribute("y").toFloat();
			val[2]=np.attribute("z").toFloat();
			par.addPoint3f(name, val);  
			return; 
		}

		assert(0); // we are trying to parse an unknown xml element
}
Ejemplo n.º 2
0
FilterParameterSet PhotoTexturingWidget::loadDefaultBakeSettings(){
	QSettings ptSettings;
	QVariant tmpValue;
	FilterParameterSet combineParamSet;
	tmpValue= ptSettings.value(PhotoTexturer::TEXTURE_SIZE_WIDTH,1024);
	combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_WIDTH,tmpValue.toInt(),"Image width:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::TEXTURE_SIZE_HEIGHT,1024);
	combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_HEIGHT,tmpValue.toInt(),"Image height:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ENABLE_ANGLE,true);
	combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_ANGLE,tmpValue.toBool(),"Enable angle map:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT,1);
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT,tmpValue.toInt(),"Angle map weight:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ANGLE,85.0);
	combineParamSet.addFloat(PhotoTexturer::UNPROJECT_ANGLE,tmpValue.toDouble(),"Max angle (degrees):","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS,1);
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS,tmpValue.toInt(),"Angle map sharpness:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE,false);
	combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE,tmpValue.toBool(),"Enable distance map:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT,1);
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT,tmpValue.toInt(),"Distance map weight:","");

	tmpValue = ptSettings.value(PhotoTexturer::BAKE_SAVE_UNPROJECT,true);
	combineParamSet.addBool(PhotoTexturer::BAKE_SAVE_UNPROJECT,tmpValue.toBool(),"Save unprojected textures:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING,false);
	combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING,tmpValue.toBool(),"Enable Texture edge Stretching:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS,2);
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS,tmpValue.toInt(),"Edge Stretching Passes:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::BAKE_MERGE_TEXTURES,true);
	combineParamSet.addBool(PhotoTexturer::BAKE_MERGE_TEXTURES,tmpValue.toBool(),"Merge unprojected textures:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::BAKE_MERGE_TYPE,0);
	combineParamSet.addEnum(PhotoTexturer::BAKE_MERGE_TYPE,tmpValue.toInt(),QStringList() <<"Merge Faces by Angle"<<"Smartblend","Merge Mode:","");
	
	tmpValue = ptSettings.value(PhotoTexturer::BAKE_SMARTBLEND,"smartblend.exe");
	//combineParamSet.addOpenFileName(PhotoTexturer::BAKE_SMARTBLEND,tmpValue.toString(),".exe","Smartblend:","");
	combineParamSet.addString(PhotoTexturer::BAKE_SMARTBLEND,tmpValue.toString(),"Smartblend:","");

	return combineParamSet;
	
}
Ejemplo n.º 3
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 SlidingCurvaturePlugin::initParameterSet(QAction *action,MeshModel &m, FilterParameterSet & parlst) 
{
	 switch(ID(action))	 {
		case FP_COMPUTE_PRINC_CURV_DIR_FROM_SLIDING :  
 		  parlst.addFloat ("radius",
											2.0,
											"Specify radius as multiplier of average edge lenght",
											"Specify radius as multiplier of average edge lenght"
											);
											break;
											
		default : assert(0); 
	}
}
Ejemplo n.º 4
0
void PhotoTexturingWidget::unprojectTextures(){
	QSettings ptSettings;
	QVariant setSmartBlend = ptSettings.value(PhotoTexturer::BAKE_SMARTBLEND,"smartblend.exe");
	
	FilterParameterSet combineParamSet;
	combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_WIDTH,1024,"Image width:","");
	combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_HEIGHT,1024,"Image height:","");
	
	combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_ANGLE,true,"Enable angle map:","");
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT,1,"Angle map weight:","");
	combineParamSet.addFloat(PhotoTexturer::UNPROJECT_ANGLE,85,"Min angle:","");
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS,1,"Angle map sharpness:","");
	
	combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE,false,"Enable distance map:","");
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT,1,"Distance map weight:","");

	combineParamSet.addBool(PhotoTexturer::BAKE_SAVE_UNPROJECT,true,"Save unprojected textures:","");
	combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING,false,"Enable Texture edge Stretching:","");
	combineParamSet.addInt(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS,2,"Edge Stretching Passes:","");
	
	combineParamSet.addBool(PhotoTexturer::BAKE_MERGE_TEXTURES,true,"Merge unprojected textures:","");
	combineParamSet.addEnum(PhotoTexturer::BAKE_MERGE_TYPE,0,QStringList() <<"Merge Faces by Angle"<<"Smartblend","Merge Mode:","");
	combineParamSet.addString(PhotoTexturer::BAKE_MERGED_TEXTURE,"","Merged Texture Filename:","");
	combineParamSet.addString(PhotoTexturer::BAKE_SMARTBLEND,setSmartBlend.toString(),"smartblend:","");

	QListWidgetItem* lwis = ui.textureListWidget->currentItem();
	int textureID = lwis[0].type();

	GenericParamDialog ad(this,&combineParamSet,"Texture Baking Parameters");
	int result=ad.exec();
	ptSettings.setValue(PhotoTexturer::BAKE_SMARTBLEND,combineParamSet.getString(PhotoTexturer::BAKE_SMARTBLEND));
	

	if (result == 1){
		photoTexturer->unprojectTextures(mesh,textureID,&combineParamSet);
	}
	update();

	updateGLAreaTextures();
}
void FilterFeatureAlignment::initParameterSet(QAction *a, MeshDocument& md, FilterParameterSet & par)
{
    switch(ID(a))
    {
        case AF_COMPUTE_FEATURE:
        {
            QStringList l;
            l << "GMSmooth curvature"
              << "APSS curvature"
              << "RGB";
            par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh.");
            break;
        }
        case AF_EXTRACTION:
        {
            QStringList l, st;
            l << "GMSmooth curvature"
              << "RGB";
            st << "Uniform" << "Poisson disk";
            par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh.");
            par.addInt("numMovFeatureSelected", 250, "Number of features:", "The number of feature points you want to extract from the current mesh.");
            par.addEnum("samplingStrategy", 0, st,"Sampling strategy:", "The sampling strategy used to select feature points:<br>Uniform -> random selection<br>Poisson disk -> Poisson disk sampling.");
            par.addBool("pickPoints", false, "Store feature points", "Turns on and off storing of feature points into PickedPoints attribute. Check this if you plan of showing feature points. NOTICE: rendering more of two hundred feature points can be very slow.");
            break;
        }
        case AF_MATCHING:
        {
            QStringList l;
            l << "GMSmooth curvature"
              << "RGB feature";
            par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh.");
            par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment.");
            par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh.");
            par.addInt("numMovFeatureSelected", 250, "Number of features:", "The number of feature points you want to extract from Move Mesh. The base of feature points that has to be matched is randomly picked in this subset.");
            par.addInt("nBase", 4, "Number of base features:", "Number of feature points that make a base. At least 3 are required, 4 get a better result.");
            par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower.");
            break;
        }
        case AF_RIGID_TRANSFORMATION :
        {
            QStringList l;
            l << "GMSmooth curvature"
              << "RGB";
            par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh.");
            par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment.");
            par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh.");
            par.addInt("numMovFeatureSelected", 250, "Number of features:", "The number of feature points you want to extract from Move Mesh. The base of feature points that has to be matched is randomly picked in this subset.");
            par.addInt("nBase", 4, "Number of base features:", "Number of feature points that make a base. At least 3 are required, 4 get a better result.");
            par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower.");
            break;
        }        
        case AF_CONSENSUS :
        {            
            par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment.");
            par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh.");
            par.addFloat("consensusDist", 2, "Consensus distance:","Consensus distance expressed in percentage of Move Mesh bounding box diagonal. It states how close two verteces must be to be in consensus.");
            par.addInt("fullConsensusSamples", 2500, "Number of samples:", "Number of samples used to perform consensus procedure. Greater values get a more actual esteem but takes more time to be computed.");
            par.addBool("normEq", true, "Normal equalization","If checked samples are selected according a normal equilezed strategy, elsewhere a random selection is performed. Normal equalization is computationally more expensive but provides a better esteem, specially with few samples.");
            par.addBool("paint", true, "Paint Move Mesh","If checked Move Mesh is painted according to consensus as follows:<br>white -> not tested<br>blue -> too far<br>yellow -> close but badly oriented<br>red -> in consensus.");
            break;
        }
        case AF_RANSAC:
        {
            QStringList l;
            l << "GMSmooth curvature"
              << "APSS curvature"
              << "RGB";
            par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh.");
            par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment.");
            par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh.");
            par.addInt("ransacIter", 500, "Iterations:", "Number of iterations of the RANSAC algorithm. Greater values provides a greater success probability but requires more time.");
            par.addFloat("overlap", 75.0, "Overlap:", "A measure, expressed in percentage, of how much Move Mesh overlaps with Fix Mesh. It is very important to provide an actual esteem: lower values can produce false positive results or too rough alignments; higher values produce a small success probability and no alignements at all.");
            par.addFloat("consensusDist", 2, "Consensus distance:","Consensus distance expressed in percentage of Move Mesh bounding box diagonal. It states how close two verteces must be to be in consensus.");
            par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower.");
            par.addBool("pickPoints", false, "Store best match", "If checked, feature points of the base picked on Move Mesh and feature points of the best matching base on Fix Mesh are stored into PickedPoints attribute. Bases are stored only if alignment process ends successfully, i.e at least one base have to exceed full consensus.");
            break;
        }
        case AF_RANSAC_DIAGRAM:
        {
            QStringList l;
            l << "GMSmooth curvature"
              << "APSS curvature"
              << "RGB";
            par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh.");
            par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment.");
            par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh.");
            par.addFloat("overlap", 75.0, "Overlap:", "A measure, expressed in percentage, of how much Move Mesh overlaps with Fix Mesh. It is very important to provide an actual esteem: lower values can produce false positive results or too rough alignments; higher values produce a small success probability and no alignements at all.");
            par.addFloat("consensusDist", 2, "Consensus distance:","Consensus distance expressed in percentage of Move Mesh bounding box diagonal. It states how close two verteces must be to be in consensus.");
            par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower.");
            par.addInt("trials", 100, "Trials:", "How many times the alignment process is repeated with the same amount of RANSAC iterations.");
            par.addInt("from", 100, "From iteration:", "Number of RANSAC iteration used to perform the first battery of alignments.");
            par.addInt("to", 1000, "To iteration:", "Number of RANSAC iteration over which no more alignments are performed.");
            par.addInt("step", 100, "Step:", "Step used to increment RANSAC iterations after that the specified number of attempts has been done.");
            break;
        }                                 
        default: assert(0);
    }
}