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


C++ TriangleList::add方法代码示例

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


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

示例1: calcOptPrim

unsigned int TriangleAdjacencyGraph::calcOptPrim ( unsigned extIteration,
    bool doStrip, bool doFan, 
    unsigned minFanTriangles )
{
  int iteration = extIteration;
  bool sample = iteration > 1 ? true : false;
  bool checkRevOrder = sample;
  TriangleList degreeBag[4];
  TriangleList *fList = 0;
  int cost = 0, sampleCost = 0;
  int stripCost = 0, revCost = 0, fanCost = 0, triCost = 0;
  int bestCost = 0, worstCost = 0, lowDegree;
  unsigned int i, n;
  WalkCase walkCase = START;
  Triangle *triangle, *next;
  HalfEdge *twin = 0, *gateEdge = 0, *halfEdge = 0;
  bool doMainLoop = true;
  unsigned int seed = 1, bestSeed = 1;
  int mostDegree = 3;
  unsigned triangleLeft = _trianglePool.countElem();
  srand(1);

  if (doFan) {
    n = _temporaryVector.size();
    fanCost = 0;

    // find fans 

    for (i = 0; i < n; i++) 
      if ( (_temporaryVector[i].size() >= minFanTriangles) &&
	  (gateEdge = _temporaryVector[i][0].second) &&
	  (gateEdge->triangle->valid()) ) {
	for ( halfEdge = gateEdge->next->next->twin;
	    (halfEdge && halfEdge->triangle->valid() && (halfEdge != gateEdge));
	    halfEdge = halfEdge->next->next->twin )
	  ;
	if (halfEdge == gateEdge) {
	  // fan is closed; mark every triangle          

	  triangle = 0;
	  fList = new TriangleList;
	  for ( halfEdge = gateEdge;
	      !triangle || (halfEdge != gateEdge);
	      halfEdge = halfEdge->next->next->twin ) {
	    triangle = halfEdge->triangle;
	    _validTriangleBag.release(*triangle);
	    triangle->drop();
	    triangle->state = FAN_PART;
	    fList->add(*triangle);
	  }
	  _fanBag.push_back(Primitive(i,fList));
	  fanCost += (_temporaryVector[i].size() + 2);
	  triangleLeft -= _temporaryVector[i].size();
	}
      }
  }

  if (doStrip && iteration) {

    // push every triangle into the according degree bag

    degreeBag[mostDegree].paste(_validTriangleBag);
    for (triangle = degreeBag[mostDegree].first; triangle; triangle = next) {
      next = triangle->next;
      if (triangle->valid()) {
	if (triangle->state != mostDegree) {
	  degreeBag[mostDegree].release(*triangle);
	  _validTriangleBag.release(*triangle);
	  degreeBag[triangle->state].add( *triangle);
	}
      }
      else {
	cerr << "INVALID TRIANGLE IN VALID TRIANGLE BAG\n" << endl;
      }
    }

    for (iteration--; iteration >= 0; iteration--) {

      seed = iteration ? rand() : bestSeed;
      srand (seed);

      fList = 0;
      cost = 0;
      doMainLoop = true;
      walkCase = START;

      // run the main loop

      while (doMainLoop) {

	switch (walkCase) {
	  case START:      

	    stripCost = 0;
	    triangle = 0;

	    for (lowDegree = 1; lowDegree < 4; lowDegree++)
	      if ((degreeBag[lowDegree].empty() == false)) {
		if (sample) {
		  // pick a random triangle
//.........这里部分代码省略.........
开发者ID:Sophiealex,项目名称:jgt-code,代码行数:101,代码来源:TriangleAdjacencyGraph.cpp


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