RedisConnectionConfig RedisConnectionConfig::createFromXml(QDomNode & connectionNode) 
{
    RedisConnectionConfig connectionConfig;

    if (!connectionNode.hasAttributes()) {
        return connectionConfig;
    }

    QDomNamedNodeMap attr = connectionNode.attributes();

    getValueFromXml(attr, "name", connectionConfig.name);
    getValueFromXml(attr, "host", connectionConfig.host);
    getValueFromXml(attr, "port", connectionConfig.port);    
    getValueFromXml(attr, "auth", connectionConfig.auth);        

    getValueFromXml(attr, "sshHost", connectionConfig.sshHost);    
    getValueFromXml(attr, "sshUser", connectionConfig.sshUser);    
    getValueFromXml(attr, "sshPassword", connectionConfig.sshPassword);
    getValueFromXml(attr, "sshPort", connectionConfig.sshPort);

    getValueFromXml(attr, "sshPublicKey", connectionConfig.sshPublicKey);
    getValueFromXml(attr, "sshPrivateKey", connectionConfig.sshPrivateKey);

    getValueFromXml(attr, "namespaceSeparator", connectionConfig.namespaceSeparator);   
    getValueFromXml(attr, "connectionTimeout", connectionConfig.connectionTimeout);   
    getValueFromXml(attr, "executeTimeout", connectionConfig.executeTimeout);   

    return connectionConfig;
}
Exemple #2
0
bool QDomNodeProto:: hasAttributes() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->hasAttributes();
  return false;
}
QString ServiceDefinition::argumentType(const QString &serviceName,
                                        const QString &argument) const {
  QDomNode node = d->mInputArguments[serviceName][argument];

  if (node.hasAttributes()) {
    QDomAttr attr = d->getAttributeFromNode(node, "type");
    return attr.nodeValue();
  }

  return "";
}
Exemple #4
0
bool EpochModel::Init(QDomNode &node)
{
 if(!node.hasAttributes()) return false;
 QDomNamedNodeMap attr= node.attributes();
 QString indexString = (attr.namedItem("index")).nodeValue() ;
 qDebug("reading Model with index %i ",indexString.toInt());
        for(QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling())
              {
                if(n.nodeName() == QString("camera"))  cameraName = n.attributes().namedItem("filename").nodeValue();
                if(n.nodeName() == QString("texture")) textureName= n.attributes().namedItem("filename").nodeValue();
                if(n.nodeName() == QString("depth"))   depthName  = n.attributes().namedItem("filename").nodeValue();
                if(n.nodeName() == QString("count"))   countName  = n.attributes().namedItem("filename").nodeValue();
            }

  QString tmpName=textureName.left(textureName.length()-4);
  maskName = tmpName.append(".mask.png");
  return true;
}
Exemple #5
0
QString getFactoryDirection(int direction)
{
  QString direct;
  QDomDocument doc("factDirDoc");
  QFile *file = new QFile("languagedata.xml");
  QString fId;
  fId.sprintf("IDS_FACTORY_NAME_DIR_%d", direction);

  if (!file->open(QIODevice::ReadOnly))
    return " ";
  if (!doc.setContent(file))
  {
    file->close();
    return " ";
  }

  QDomNodeList list = doc.elementsByTagName("tu");
  for(int i = 0; i < list.count(); i++)
  {
    QDomNode tu = list.at(i);
    if(tu.hasAttributes() && tu.hasChildNodes())
    {
      QString attrib = tu.attributes().namedItem("tuid").nodeValue();
      if(attrib == fId)
      {
        qDebug() << "Bingo";
        QDomNodeList child = tu.childNodes();
        direct = child.at(2).toElement().text();
        file->close();
        return direct;
      }
    }
  }
  file->close();
  return direct;
}
Exemple #6
0
QString getFactoryName(int factoryId, int cityId, int factoryDirection)
{
  QDomDocument doc("mydocument");
  QFile *file = new QFile("languagedata.xml");
  QString factoryName = "-----";
  QString fId;
  fId.sprintf("IDS_FACT_%03d", factoryId);

  if (!file->open(QIODevice::ReadOnly))
    return " ";
  if (!doc.setContent(file))
  {
    file->close();
    return " ";
  }

  QDomNodeList list = doc.elementsByTagName("tu");
  for(int i = 0; i < list.count(); i++)
  {
    QDomNode tu = list.at(i);
    if(tu.hasAttributes() && tu.hasChildNodes())
    {
      QString attrib = tu.attributes().namedItem("tuid").nodeValue();
      if(attrib == fId)
      {
        QDomNodeList child = tu.childNodes();
        factoryName = child.at(2).toElement().text();
        file->close();
        factoryName = factoryName + " " + getCityName(cityId) + " " + getFactoryDirection(factoryDirection);
        return factoryName;
      }
    }
  }
  file->close();
  return factoryName;
}
bool Arc3DModel::Init(QDomNode &node)
{
    if(!node.hasAttributes()) return false;
    QDomNamedNodeMap attr= node.attributes();
    QString indexString = (attr.namedItem("index")).nodeValue() ;
    qDebug("reading Model with index %i ",indexString.toInt());
    for(QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling())
    {
        if(n.nodeName() == QString("camera"))  cameraName = n.attributes().namedItem("filename").nodeValue();
        if(n.nodeName() == QString("texture")) textureName= n.attributes().namedItem("filename").nodeValue();
        if(n.nodeName() == QString("depth"))   depthName  = n.attributes().namedItem("filename").nodeValue();
        if(n.nodeName() == QString("count"))   countName  = n.attributes().namedItem("filename").nodeValue();

        // import leuven camera
        {
            double cam[9];
            float focus,scale;

            FILE* lvcam;

            lvcam = fopen(cameraName.toUtf8().data(),"rb");

            // focus + image centers
            fscanf(lvcam,"%lf %lf %lf",&(cam[0]),&(cam[1]),&(cam[2]));
            fscanf(lvcam,"%lf %lf %lf",&(cam[3]),&(cam[4]),&(cam[5]));
            fscanf(lvcam,"%lf %lf %lf",&(cam[6]),&(cam[7]),&(cam[8]));

            shot.Intrinsics.DistorCenterPx[0] = cam[2];
            shot.Intrinsics.DistorCenterPx[1] = cam[5];
            //shot.Intrinsics.CenterPx[0] = cam[2];
            //shot.Intrinsics.CenterPx[1] = cam[5];
            focus = cam[4];
            scale = 1.0f;
            while(focus>150.0f)
            {
                focus /= 10.0f;
                scale /= 10.0f;
            }
            shot.Intrinsics.FocalMm = focus;
            shot.Intrinsics.PixelSizeMm[0] = scale;
            shot.Intrinsics.PixelSizeMm[1] = scale;

            // distortion
            fscanf(lvcam,"%lf %lf %lf",&(cam[0]),&(cam[1]),&(cam[2]));
            //shot.Intrinsics.k[0] = cam[0];
            //shot.Intrinsics.k[1] = cam[1];
            shot.Intrinsics.k[0] = 0.0;
            shot.Intrinsics.k[1] = 0.0;

            // orientation axis
            fscanf(lvcam,"%lf %lf %lf",&(cam[0]),&(cam[1]),&(cam[2]));
            fscanf(lvcam,"%lf %lf %lf",&(cam[3]),&(cam[4]),&(cam[5]));
            fscanf(lvcam,"%lf %lf %lf",&(cam[6]),&(cam[7]),&(cam[8]));

            Matrix44m myrot;

            myrot[0][0] = cam[0];		myrot[0][1] = cam[3];		myrot[0][2] = cam[6];		myrot[0][3] = 0.0f;
            myrot[1][0] = -cam[1];	myrot[1][1] = -cam[4];	myrot[1][2] = -cam[7];	myrot[1][3] = 0.0f;
            myrot[2][0] = -cam[2];	myrot[2][1] = -cam[5];	myrot[2][2] = -cam[8];	myrot[2][3] = 0.0f;
            myrot[3][0] = 0.0f;			myrot[3][1] = 0.0f;			myrot[3][2] = 0.0f;			myrot[3][3] = 1.0;


            shot.Extrinsics.SetRot(myrot);

            // camera position
            fscanf(lvcam,"%lf %lf %lf",&(cam[0]),&(cam[1]),&(cam[2]));
            shot.Extrinsics.SetTra(Point3m(cam[0], cam[1], cam[2]));
            //				shot.Extrinsics.sca = 1.0f;


            // image size
            fscanf(lvcam,"%lf %lf",&(cam[0]),&(cam[1]));
            shot.Intrinsics.ViewportPx.X() = (int)(cam[0]);
            shot.Intrinsics.ViewportPx.Y() = (int)(cam[1]);
            shot.Intrinsics.CenterPx[0] = (double)shot.Intrinsics.ViewportPx[0]/2.0;
            shot.Intrinsics.CenterPx[1] = (double)shot.Intrinsics.ViewportPx[1]/2.0;
            //shot.Intrinsics.DistorCenterPx[0]=shot.Intrinsics.CenterPx[0];
            //shot.Intrinsics.DistorCenterPx[1]=shot.Intrinsics.CenterPx[1];


            fclose(lvcam);
        }
    }

    QString tmpName=textureName.left(textureName.length()-4);
    maskName = tmpName.append(".mask.png");
    return true;
}
bool EditArc3DPlugin::StartEdit(MeshDocument &_md, GLArea *_gla )
{
    er.modelList.clear();
    this->md=&_md;
    gla=_gla;
    ///////
    delete arc3DDialog;
    arc3DDialog=new v3dImportDialog(gla->window(),this);
    QString fileName=arc3DDialog->fileName;

    if (fileName.isEmpty()) return false;

    // this change of dir is needed for subsequent texture/material loading
    QString FileNameDir = fileName.left(fileName.lastIndexOf("/"));
    QDir::setCurrent(FileNameDir);

    QString errorMsgFormat = "Error encountered while loading file %1:\n%2";
    string stdfilename = QFile::encodeName(fileName).constData ();

    QDomDocument doc;


    QFile file(fileName);
    if (file.open(QIODevice::ReadOnly) && doc.setContent(&file))
    {
        file.close();
        QDomElement root = doc.documentElement();
        if (root.nodeName() == tr("reconstruction"))
        {
            QDomNode nhead = root.firstChildElement("head");
            for(QDomNode n = nhead.firstChildElement("meta"); !n.isNull(); n = n.nextSiblingElement("meta"))
            {
                if(!n.hasAttributes()) return false;
                QDomNamedNodeMap attr= n.attributes();
                if(attr.contains("name")) er.name = (attr.namedItem("name")).nodeValue() ;
                if(attr.contains("author")) er.author = (attr.namedItem("author")).nodeValue() ;
                if(attr.contains("created")) er.created = (attr.namedItem("created")).nodeValue() ;
            }
            for(QDomNode n = root.firstChildElement("model"); !n.isNull(); n = n.nextSiblingElement("model"))
            {
                Arc3DModel em;
                em.Init(n);
                //em.cam.TR
                er.modelList.push_back(em);

            }
        }
    }


    arc3DDialog->setArc3DReconstruction( &er);

    arc3DDialog->exportToPLY=false;


    connect(arc3DDialog, SIGNAL(closing()),gla,SLOT(endEdit()) );
    connect(arc3DDialog->ui.plyButton, SIGNAL(clicked()),this,SLOT(ExportPly()) );
    connect(arc3DDialog->ui.exportbut,SIGNAL(clicked()),this,SLOT(exportShotsToRasters()));
    connect(this,SIGNAL(resetTrackBall()),gla,SLOT(resetTrackBall()));


    return true;
}
    bool operator()(QDomNode node) {
	if(!node.hasChildNodes() && !node.hasAttributes() && !node.isText()) {
	    return true;
	}
	return false;
    }
void ReadAndWriteXML::parseEntry(const QDomElement &element, QTreeWidgetItem *parent, int parentLevel)
{
 //   item->setText(0, element.attribute("term"));
    QDomNode node = element.firstChild();
    while (!node.isNull()) {
        //qDebug() << "DomParser::parseEntry  node " << node.toElement().tagName();
    //    qDebug() << "DomParser::parseEntry  parsing node " << node.nodeName();
         if (node.isElement()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is element ";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            QString _attr="";
            if (node.hasAttributes()) {
               childitem=new QTreeWidgetItem(childitem, QStringList(QString("Attributes node %1").arg(node.nodeName())));
               parseAttribute(node.attributes(), childitem, parentLevel);
            }
            node = node.nextSibling();
            continue;
         }
         if (node.isCDATASection()) {
             //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is CDATASection --" << node.toText().data() << "--";
             new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
             node = node.nextSibling();
             continue;
         }
         if (node.isComment()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is comment --" << node.toText().data() << "--";
            new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
            node = node.nextSibling();
            continue;
         }
         if (node.isText()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " text --" << node.toText().data() << "--";
            new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
            node = node.nextSibling();
            continue;
         }
         if (node.isDocument()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is document ";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            node = node.nextSibling();
            continue;
         }
         if (node.isDocumentType()) {
            qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is  document type";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            node = node.nextSibling();
            continue;
         }
         if (node.isDocumentFragment()) {
            qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is  document fragment";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            node = node.nextSibling();
            continue;
         }
         if (node.isEntity() || node.isEntityReference () || node.isNotation () || node.isProcessingInstruction ()) {
             qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is  not supported";
             node = node.nextSibling();
             continue;
         }

        node = node.nextSibling();
    }
}
//---------------------------------------------------------------------
// Utility functions
bool hasAttribute(const QDomNode &node, const QString &attr) {
	return (node.hasAttributes() && node.attributes().contains(attr));
}
Exemple #12
0
bool EpochIO::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask,const RichParameterSet & /*par*/, CallBackPos *cb, QWidget *parent)
{
  EpochReconstruction er;
	
  mask = vcg::tri::io::Mask::IOM_VERTCOLOR | vcg::tri::io::Mask::IOM_VERTQUALITY; 
// just to be sure...
	
	if (fileName.isEmpty()) return false;
		// initializing progress bar status
	if (cb != NULL) (*cb)(0, "Loading...");

	// this change of dir is needed for subsequent texture/material loading
	QString FileNameDir = fileName.left(fileName.lastIndexOf("/")); 
	QDir::setCurrent(FileNameDir);

	QString errorMsgFormat = "Error encountered while loading file %1:\n%2";
	string stdfilename = QFile::encodeName(fileName).constData ();
  //string filename = fileName.toUtf8().data();

	QDomDocument doc;
	
	if(formatName.toUpper() == tr("V3D") &&  fileName.endsWith(".v3d"))
	{
  		QFile file(fileName);
			if (file.open(QIODevice::ReadOnly) && doc.setContent(&file)) 
        {
					file.close();
					QDomElement root = doc.documentElement();
					if (root.nodeName() == tr("reconstruction")) 
          {
            QDomNode nhead = root.firstChildElement("head");
            for(QDomNode n = nhead.firstChildElement("meta"); !n.isNull(); n = n.nextSiblingElement("meta"))
              {
               if(!n.hasAttributes()) return false;
               QDomNamedNodeMap attr= n.attributes();
               if(attr.contains("name")) er.name = (attr.namedItem("name")).nodeValue() ;
               if(attr.contains("author")) er.author = (attr.namedItem("author")).nodeValue() ;
               if(attr.contains("created")) er.created = (attr.namedItem("created")).nodeValue() ;
              }    
             for(QDomNode n = root.firstChildElement("model"); !n.isNull(); n = n.nextSiblingElement("model"))
              {
                EpochModel em;
                em.Init(n);
                er.modelList.push_back(em);
              }
          }
        }
    }

	epochDialog->setEpochReconstruction( &er, cb);
  do
	{
			epochDialog->exportToPLY=false;
			
			//Here we invoke the modal dialog and wait for its termination
			int continueValue = epochDialog->exec();

			// The user has pressed the ok button: now start the real processing:
			
			if(epochDialog->exportToPLY == true) qDebug("Starting the ply exporting process");
			
			int t0=clock();
			logFP=fopen("epoch.log","w");

			int subSampleVal = epochDialog->subsampleSpinBox->value();
			int minCountVal= epochDialog->minCountSpinBox->value();
			float maxCCDiagVal= epochDialog->maxCCDiagSpinBox->value();
			int mergeResolution=epochDialog->mergeResolutionSpinBox->value();
			int smoothSteps=epochDialog->smoothSpinBox->value();
			bool closeHole = epochDialog->holeCheckBox->isChecked();
			int maxHoleSize = epochDialog->holeSpinBox->value();
			if (continueValue == QDialog::Rejected)
			{
					QMessageBox::warning(parent, "Open V3d format","Aborted");    
					return false;
			}
			CMeshO mm;
			QTableWidget *qtw=epochDialog->imageTableWidget;
			float MinAngleCos=cos(vcg::math::ToRad(epochDialog->qualitySpinBox->value()));
			bool clustering=epochDialog->fastMergeCheckBox->isChecked();
			bool removeSmallCC=epochDialog->removeSmallCCCheckBox->isChecked();
			vcg::tri::Clustering<CMeshO, vcg::tri::AverageColorCell<CMeshO> > Grid;

			int selectedNum=0,selectedCount=0;
			int i;
			 for(i=0;i<qtw->rowCount();++i) if(qtw->isItemSelected(qtw->item(i,0))) ++selectedNum;
			if(selectedNum==0)
				{
					QMessageBox::warning(parent, "Open V3d format","No range map selected. Nothing loaded");    
					return false;
			}

			bool dilationFlag = epochDialog->dilationCheckBox->isChecked();
			int dilationN = epochDialog->dilationNumPassSpinBox->value();
			int dilationSz = epochDialog->dilationSizeSlider->value() * 2 + 1;
			bool erosionFlag = epochDialog->erosionCheckBox->isChecked();
			int erosionN = epochDialog->erosionNumPassSpinBox->value();
			int erosionSz = epochDialog->erosionSizeSlider->value() * 2 + 1;
			float scalingFactor = epochDialog->scaleLineEdit->text().toFloat();
			std::vector<string> savedMeshVector;

			bool firstTime=true;
			QList<EpochModel>::iterator li;
			for(li=er.modelList.begin(), i=0;li!=er.modelList.end();++li,++i)
			{
					if(qtw->isItemSelected(qtw->item(i,0)))
					{
						++selectedCount;
						mm.Clear();
						int tt0=clock();
						(*li).BuildMesh(mm,subSampleVal,minCountVal,MinAngleCos,smoothSteps, 
							dilationFlag, dilationN, dilationSz, erosionFlag, erosionN, erosionSz,scalingFactor);
						int tt1=clock();
						if(logFP) fprintf(logFP,"** Mesh %i : Build in %i\n",selectedCount,tt1-tt0);

						if(epochDialog->exportToPLY) 
								{
									QString plyFilename =(*li).textureName.left((*li).textureName.length()-4);
									plyFilename.append(".x.ply");	
									savedMeshVector.push_back(qPrintable(plyFilename));
									int mask= tri::io::Mask::IOM_VERTCOORD + tri::io::Mask::IOM_VERTCOLOR + tri::io::Mask::IOM_VERTQUALITY;
                                    tri::io::ExporterPLY<CMeshO>::Save(mm,qPrintable(plyFilename),mask);
								}
						else 
								{
								if(clustering)
									{
										if (firstTime) 
											{
												//Grid.Init(mm.bbox,100000);
												vcg::tri::UpdateBounding<CMeshO>::Box(mm);	
												//Grid.Init(mm.bbox,1000.0*pow(10.0,mergeResolution),mm.bbox.Diag()/1000.0f);
												Grid.Init(mm.bbox,100000.0*pow(10.0,mergeResolution));
												firstTime=false;
											}
                                                                                Grid.AddMesh(mm);
									}
								else  
									tri::Append<CMeshO,CMeshO>::Mesh(m.cm,mm); // append mesh mr to ml
							}
							int tt2=clock();
							if(logFP) fprintf(logFP,"** Mesh %i : Append in %i\n",selectedCount,tt2-tt1);

					}
					if (cb)(*cb)(selectedCount*90/selectedNum, "Building meshes");
			}
			 
			if (cb != NULL) (*cb)(90, "Final Processing: clustering");
			if(clustering)  
			{
                                Grid.ExtractPointSet(m.cm);
			}
			
			if(epochDialog->exportToPLY) 
			{
				QString ALNfilename = fileName.left(fileName.length()-4).append(".aln");
				ALNParser::SaveALN(qPrintable(ALNfilename), savedMeshVector);
			}
			int t1=clock();
			if(logFP) fprintf(logFP,"Extracted %i meshes in %i\n",selectedCount,t1-t0);

			if (cb != NULL) (*cb)(95, "Final Processing: Removing Small Connected Components");
			if(removeSmallCC)
			{
				vcg::tri::UpdateBounding<CMeshO>::Box(m.cm);					// updates bounding box
				m.updateDataMask(MeshModel::MM_FACEFACETOPO | MeshModel::MM_FACEFLAGBORDER | MeshModel::MM_FACEMARK);
				tri::Clean<CMeshO>::RemoveSmallConnectedComponentsDiameter(m.cm,m.cm.bbox.Diag()*maxCCDiagVal/100.0);
			}

			int t2=clock();
			if(logFP) fprintf(logFP,"Topology and removed CC in %i\n",t2-t1);

			vcg::tri::UpdateBounding<CMeshO>::Box(m.cm);					// updates bounding box
			
			if (cb != NULL) (*cb)(97, "Final Processing: Closing Holes");
			if(closeHole)
			{
				m.updateDataMask(MeshModel::MM_FACEFACETOPO | MeshModel::MM_FACEFLAGBORDER | MeshModel::MM_FACEMARK);
				tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFace(m.cm);	    
				vcg::tri::Hole<CMeshO>::EarCuttingFill<vcg::tri::MinimumWeightEar< CMeshO> >(m.cm,maxHoleSize,false);
			}

			if (cb != NULL) (*cb)(100, "Done");
		//  vcg::tri::UpdateNormals<CMeshO>::PerVertex(m.cm);		// updates normals
			 
				m.updateDataMask(MeshModel::MM_VERTCOLOR);

			int t3=clock();
			if(logFP) fprintf(logFP,"---------- Total Processing Time%i\n\n\n",t3-t0);
			if(logFP) fclose(logFP);
			logFP=0;
	} while(epochDialog->exportToPLY);
	
	return true;
}