当前位置: 首页>>代码示例>>C++>>正文


C++ MeshModel::pathName方法代码示例

本文整理汇总了C++中MeshModel::pathName方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshModel::pathName方法的具体用法?C++ MeshModel::pathName怎么用?C++ MeshModel::pathName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MeshModel的用法示例。


在下文中一共展示了MeshModel::pathName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: save

bool IORenderman::save(const QString &formatName, const QString &fileName, MeshModel &m, const int mask,const RichParameterSet & par,  vcg::CallBackPos *cb, QWidget *parent)
{
	QString errorMsgFormat = "Error encountered while exportering file %1:\n%2";
  
  //***get the filter parameters and create destination directory***
	//MeshModel* m = md.mm();
	this->cb = cb;
	QTime tt; tt.start(); //time for debuging
	qDebug("Starting apply filter");

  if(templates.isEmpty()) //there aren't any template
	{
	  this->errorMessage = "No template scene has been found in \"render_template\" directory";
		return false;
	}
	QString templateName = templates.at(par.getEnum("scene")); //name of selected template
	QFileInfo templateFile = QFileInfo(templatesDir.absolutePath() + QDir::separator() + templateName + QDir::separator() + templateName + ".rib");
  
	//directory of current mesh
	//QString meshDirString = m->pathName();
  ////creating of destination directory
	//bool delRibFiles = !par.getBool("SaveScene");
	////if SaveScene is true create in same mesh directory, otherwise in system temporary directry
	//QDir destDir = QDir::temp(); //system temporary directry
	//if(!delRibFiles) {
	//	//destDir = QDir(par.getSaveFileName("SceneName"));
	//	destDir = QDir(meshDirString);
	//}
	////create scene directory if don't exists
	//if(!destDir.cd("scene")) {
 //   if(!destDir.mkdir("scene") || !destDir.cd("scene")) {
	//		this->errorMessage = "Creating scene directory at " + destDir.absolutePath();
	//		return false;
	//	}		
	//}
	//create a new directory with template name
	QDir destDir = QFileInfo(fileName).dir();
  QString destDirString = templateName + "-" + QFileInfo(m.fullName()).completeBaseName();
  QString newDir = destDirString;
	int k = 0;
	while(destDir.cd(newDir)) {
		destDir.cdUp();
		newDir = destDirString + "-" + QString::number(++k); //dir templateName+k
	}
	if(!destDir.mkdir(newDir) || !destDir.cd(newDir)) {
		this->errorMessage = "Creating scene directory at " + destDir.absolutePath();
		return false;
	}

	//destination diretory
	destDirString = destDir.absolutePath();

	//***Texture: take the list of texture mesh
	QStringList textureListPath = QStringList();
  for(size_t i=0; i<m.cm.textures.size(); i++) {
    QString path = QString(m.cm.textures[i].c_str());
		textureListPath << path;
	}
	
	//***read the template files and create the new scenes files
	QStringList shaderDirs, textureDirs, proceduralDirs, imagesRendered;
	qDebug("Starting reading cycle %i",tt.elapsed());
  if(!makeScene(&m, &textureListPath, par, &templateFile, destDirString, &shaderDirs, &textureDirs, &proceduralDirs, &imagesRendered))
		return false; //message already set
	qDebug("Cycle ending at %i",tt.elapsed());
	Log(GLLogStream::FILTER,"Successfully created scene");

	//check if the final rib file will render any image
	/*if(imagesRendered.size() == 0) {
		this->errorMessage = "The template description hasn't a statement to render any image";
		return false;
	}*/

	//***copy the rest of template files (shaders, textures, procedural..)
  UtilitiesHQR::copyFiles(templateFile.dir(), destDir, textureDirs);
  UtilitiesHQR::copyFiles(templateFile.dir(), destDir, shaderDirs);
  UtilitiesHQR::copyFiles(templateFile.dir(), destDir, proceduralDirs);
	qDebug("Copied needed file at %i",tt.elapsed());
	
  //***convert the texture mesh to tiff format 
  if(!textureListPath.empty() && (m.cm.HasPerWedgeTexCoord() || m.cm.HasPerVertexTexCoord())) {
    QString textureName = QFileInfo(textureListPath.first()).completeBaseName(); //just texture name
    QFile srcFile(m.pathName() + QDir::separator() + textureListPath.first());

		//destination directory it's the first readable/writable between textures directories
		QString newImageDir = ".";
		foreach(QString dir, textureDirs) {
			if(dir!="." && destDir.cd(dir)) {
				newImageDir = dir;
				destDir.cdUp();
				break;
			}
		}
		qDebug("source texture directory: %s", qPrintable(srcFile.fileName()));
		QString newTex = destDirString + QDir::separator() + newImageDir + QDir::separator() + textureName;
		qDebug("destination texture directory: %s", qPrintable(newTex + ".tiff"));
		if(srcFile.exists()) {
			//convert image to tiff format (the one readable in aqsis)
			QImage image;
			image.load(srcFile.fileName());
//.........这里部分代码省略.........
开发者ID:Booley,项目名称:nbis,代码行数:101,代码来源:io_renderman.cpp


注:本文中的MeshModel::pathName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。