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


C++ PointSet::Reserve方法代码示例

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


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

示例1: Material

main(int argc, char *argv[])
{

  PointSet *myPts = new PointSet;
  LineCell *lCell = new LineCell;
  LineCell *sCell = new LineCell;
  PolygonCell *pCell = new PolygonCell;
  Material *mat;
  MaterialSet *matSet;
  CellSet *dSet = new CellSet;
  OGLRenderer *aren = new OGLRenderer;
  float tmp[3];
  float rgba[] = { 1.0, 1.0, 0.0, 1.0 };

  mat = new Material(rgba);
  matSet = new MaterialSet;
  *matSet += mat;
  myPts->Reserve(10);
  tmp[0] = 0.0;tmp[1] = 0.0;tmp[2] = 0.0; *myPts += new PointType(tmp);
  tmp[0] = 1.0;tmp[1] = 0.0;tmp[2] = 0.0; *myPts += new PointType(tmp);
  tmp[0] = 1.0;tmp[1] = 1.0;tmp[2] = 0.0; *myPts += new PointType(tmp);
  tmp[0] = 0.0;tmp[1] = 1.0;tmp[2] = 0.0; *myPts += new PointType(tmp);
  tmp[0] = 0.0;tmp[1] = 0.0;tmp[2] = 1.0; *myPts += new PointType(tmp);
  tmp[0] = 1.0;tmp[1] = 0.0;tmp[2] = 1.0; *myPts += new PointType(tmp);
  tmp[0] = 1.0;tmp[1] = 1.0;tmp[2] = 1.0; *myPts += new PointType(tmp);
  tmp[0] = 0.0;tmp[1] = 1.0;tmp[2] = 1.0; *myPts += new PointType(tmp);
  tmp[0] = 0.5;tmp[1] = 0.5;tmp[2] = 0.5; *myPts += new PointType(tmp);

  // Draw a Triangle with lines
  *lCell += 0; *lCell += 1; *lCell += 1; *lCell+= 2; *lCell += 2; *lCell += 0;
  lCell->SetPoints(myPts);
  lCell->SetMaterials(matSet);
  // Draw a Solid Triangle
  *pCell += 0; *pCell += 1; *pCell+= 8; *pCell += 0;
  pCell->SetPoints(myPts);
  pCell->SetMaterials(matSet);
  sleep(2);
  // Draw a Square
  *sCell += 4; *sCell += 5; *sCell += 5; *sCell += 6; *sCell += 6; *sCell += 7; *sCell +=7; *sCell += 4;
  sCell->SetMaterials(matSet);
  sCell->SetPoints(myPts);
  // Add Cells to the CellSet
  *dSet += lCell;
  *dSet += pCell;
  *dSet += sCell;

  lCell->PrintSelf(cout);
  pCell->PrintSelf(cout);
  sCell->PrintSelf(cout);

  // Initialize the Renderer, creates window and attaches OpenGL Visual
  aren->Initialize(argc, argv);
  // Add this  CellSet to the Renderers collection.
  aren->AddCellSet(dSet);
  aren->AddCamera(new OGLCamera);
  aren->AddLight(new OGLLight(0));

  // Starts the Event loop.
  aren->PrintSelf(cout);
  aren->MainLoop();

  return(0);
}
开发者ID:citrit,项目名称:ECSE4750,代码行数:63,代码来源:objTest.C


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