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


C++ Triangulation::push_back方法代码示例

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


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

示例1: triangulate

// This is a horrible function but it is intended to be a brute force 
// solution and not efficient or elegant.
void QuarticTriangulator::triangulate( const std::vector<ControlPoint> &points,
                                       Triangulation &result )
{
   bool bGoodTriangle;
   int n = points.size();

   // Just iterate through all possible triangles and keep the good ones.
   for( int i = 0; i < n; ++i )
   {
      Point A( points[i].point.getX(), 
               points[i].point.getY() );
      for( int j = 0; j < n; ++j )
      {
         if( j != i )
         {
            Point B( points[j].point.getX(), 
                     points[j].point.getY() );
            for( int k = 0; k < n; ++k )
            {
               if( k != i && k != j )
               {
                  Point C( points[k].point.getX(), 
                           points[k].point.getY() );

                  Triangle triangle( A, B, C );
                  Circle circumCircle( triangle );
                  bGoodTriangle = true;

                  for( int c = 0; c < n; ++c )
                  {
                     if( c != i && c != j && c != k )
                     {
                        Point D( points[c].point.getX(), 
                                 points[c].point.getY() );
                        if( circumCircle.encloses( D ) )
                        {
                           bGoodTriangle = false;
                           break;
                        }
                     }
                  } // end for c

                  if( bGoodTriangle )
                  {
                     Tri t;
                     t.a = i;
                     t.b = j;
                     t.c = k;
                     t.triangle = triangle;
                     result.push_back( t );
                  }
               }
            } // end for k
         }
      } // end for j
   } // end for i

   // Do final check and fix any problems.
   // This isn't actually necessary, but I'm leaving it commented in
   // case I want to run tests in the future.
/*   Triangulation old( result );
   bool isAllGood;

   result.clear();
   for( int m = 0; m < old.size(); ++m )
   {
      Circle C( old[m].triangle );
      isAllGood = true;

      for( int n = 0; n < points.size(); ++n )
      {
         Point P( points[n].point.getX(), points[n].point.getY() );
         if(  n != old[m].a && n != old[m].b && n != old[m].c &&
              C.encloses( P ) )
         {
            isAllGood = false;
            break;
         }
      }
      if( isAllGood )
      {
         result.push_back( old[m] );
      }
      else
      {
         printf( "Removed One\n" );
      }
   }
   */
   
   return;
} // end function triangulate
开发者ID:dmm,项目名称:cegis,代码行数:94,代码来源:QuarticTriangulator.cpp


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