本文整理汇总了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