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


C++ Geometry::AllocatePoints方法代码示例

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


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

示例1: loadFile

Geometry* PcdFile::loadFile(const string& fileName)
{
	bool zeroSeen = false, maxSeen = false;
	//QFileInfo fileInfo(fileName);

	//if (!fileInfo.exists()) {
	//	qDebug("File does not exist");
	//	return 0;
	//}
	struct stat fst;
	if (stat(fileName.c_str(), &fst) == -1) {
		printf("File does not exist\n");
		return 0;
	}

	//QString absFilePath = fileInfo.absFilePath();

	//FILE* fp = fopen(absFilePath, "r");
	FILE* fp = fopen(fileName.c_str(), "r");
	if (!fp) {
		//qDebug("Error opening file");
		printf("Error opening file\n");
		return 0;
	}

	// get the number of verts and triangles
	int numverts;
	if (1!=fscanf(fp, "%d", &numverts)) {
	  //qDebug("Error reading in number of verts and tris");
	  printf("Error reading in number of verts and tris\n");
	  fclose(fp);
	  return 0;
	}
	// make sure the number of verts & tris are positive
	if (numverts<0) {
		//qDebug("Negative number of verts or tris");
		printf("Negative number of verts\n");
		fclose(fp);
		return 0;
	}

	// initialize the geometry
	Geometry* geometry = new Geometry();
	geometry->AllocatePoints(numverts);

	int c;
	// read in the verts
	for (c=0; c<numverts; c++) {
	  // read in a single vert
	  if (3!=fscanf(fp, "%f %f %f", 
			&(geometry->m_Points[c*3+0]),
			&(geometry->m_Points[c*3+1]),
			&(geometry->m_Points[c*3+2]))) {
	    //qDebug("Error reading in vert # %d", c);
	    printf("Error reading in vert # %d\n", c);
	    delete geometry;
	    fclose(fp);
	    return 0;
	  }
	}
	
	fclose(fp);
	return geometry;
}
开发者ID:SoumyajitG,项目名称:VolRoverN,代码行数:64,代码来源:PcdFile.cpp

示例2: loadFile

Geometry* RawFile::loadFile(const string& fileName)
{
  cvcraw_geometry::geometry_t geom;
  
  try
    {
      cvcraw_geometry::read(geom, fileName);
    }
  catch(std::exception& e)
    {
      printf("Error: %s\n", e.what());
      return 0;
    }

  bool haveColor = !geom.colors.empty();

  Geometry *geometry = new Geometry();
  
  if(!geom.lines.empty())
    {
      geometry->AllocateLines(geom.points.size(),
			      geom.lines.size());

      for(unsigned int i = 0; i < geom.lines.size(); i++)
	{
	  geometry->m_Lines[i*2+0] = geom.lines[i][0];
	  geometry->m_Lines[i*2+1] = geom.lines[i][1];
	}
    }
  else if(!geom.tris.empty())
    {
      geometry->AllocateTris(geom.points.size(),
			     geom.tris.size());

      for(unsigned int i = 0; i < geom.tris.size(); i++)
	{
	  geometry->m_Tris[i*3+0] = geom.tris[i][0];
	  geometry->m_Tris[i*3+1] = geom.tris[i][1];
	  geometry->m_Tris[i*3+2] = geom.tris[i][2];
	}
    }
  else if(!geom.quads.empty())
    {
      geometry->AllocateQuads(geom.points.size(),
			      geom.quads.size());

      for(unsigned int i = 0; i < geom.quads.size(); i++)
	{
	  geometry->m_Quads[i*4+0] = geom.quads[i][0];
	  geometry->m_Quads[i*4+1] = geom.quads[i][1];
	  geometry->m_Quads[i*4+2] = geom.quads[i][2];
	  geometry->m_Quads[i*4+3] = geom.quads[i][3];
	}
    }
  else if(!geom.points.empty())
    {
      geometry->AllocatePoints(geom.points.size());
      geometry->AllocatePointNormals();
      geometry->AllocatePointColors();
    }

  for(unsigned int i = 0; i < geom.points.size(); i++)
    {
      geometry->m_Points[i*3+0] = geom.points[i][0];
      geometry->m_Points[i*3+1] = geom.points[i][1];
      geometry->m_Points[i*3+2] = geom.points[i][2];
    }

  if(!geom.normals.empty())
    {
      for(unsigned int i = 0; i < geom.points.size(); i++)
	{
	  geometry->m_PointNormals[i*3+0] = geom.normals[i][0];
	  geometry->m_PointNormals[i*3+1] = geom.normals[i][1];
	  geometry->m_PointNormals[i*3+2] = geom.normals[i][2];
	}
    }
      
  if(!geom.colors.empty())
    {
      for(unsigned int i = 0; i < geom.colors.size(); i++)
	{
	  geometry->m_PointColors[i*3+0] = geom.colors[i][0];
	  geometry->m_PointColors[i*3+1] = geom.colors[i][1];
	  geometry->m_PointColors[i*3+2] = geom.colors[i][2];
	}
    }

  return geometry;
#if 0
	bool zeroSeen = false, maxSeen = false;
	//QFileInfo fileInfo(fileName);

	//if (!fileInfo.exists()) {
	//	qDebug("File does not exist");
	//	return 0;
	//}
	struct stat fst;
	if (stat(fileName.c_str(), &fst) == -1) {
		printf("File does not exist\n");
//.........这里部分代码省略.........
开发者ID:SoumyajitG,项目名称:VolRoverN,代码行数:101,代码来源:RawFile.cpp


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