本文整理汇总了C++中TIntSet::size方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntSet::size方法的具体用法?C++ TIntSet::size怎么用?C++ TIntSet::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntSet
的用法示例。
在下文中一共展示了TIntSet::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: end
void end( const TWallVertexVector& vb, TIntVector& polygon, TIntVector& ib )
{
assert( polygonCount );
if( polygonCount == 1 ) {
// trivial case, just output input polygon
polygon.resize( 0 );
polygon.reserve( vertices.size() );
int idx0 = *vertices.begin();
int idx = idx0;
do {
polygon.push_back( idx );
const TIntVector& vnext = vertexNexts[idx];
assert( vnext.size() == 1 );
idx = vnext[0];
} while( idx != idx0 );
triangulator::process( vb, polygon, ib );
} else {
// mark vertex types
markVertexTypes();
// trace and triangulate the polygon(s)
traceBorder( vb, polygon, ib );
}
}
示例2: loopPolygon
void traceBorder( const TWallVertexVector& vb, TIntVector& polygon, TIntVector& ib )
{
static int traceID = 0;
++traceID;
int idx0 = getBorderIndex();
assert( idx0 >= 0 && idx0 < vertexTypes.size() );
ib.resize( 0 );
polygon.resize( 0 );
polygon.reserve( vertices.size()/2 );
TIntVector localPolygon;
localPolygon.reserve( 128 );
TIntVector localIB;
localIB.reserve( 128 );
int idxPrev = idx0;
int idx = idx0;
int debugCounter = 0;
int debugLoopCounter = 0;
do {
localIB.resize( 0 );
bool willFormLoop;
do{
localPolygon.push_back( idx );
borderVertices.erase( idx );
vertexTraceID[idx] = traceID;
assert( ++debugCounter <= vertices.size()*2 );
// Next vertex is the neighbor of current, that is not interior
// and that is not the previous one.
// When there are many possible ones, trace based on angle.
int idxNext = -1;
SVector2 prevToCurr = vb[idx] - vb[idxPrev];
if( prevToCurr.lengthSq() < 1.0e-6f )
prevToCurr.set( -0.01f, -0.01f );
TIntIntsMap::const_iterator it;
it = vertexNexts.find( idx );
assert( it != vertexNexts.end() );
const TIntVector& vnext = it->second;
int n = vnext.size();
float bestAngle = 100.0f;
for( int i = 0; i < n; ++i ) {
int idx1 = vnext[i];
if( idx1 != idxPrev && vertexTypes[idx1] != VTYPE_INTERIOR ) {
//if( idx1 != idxPrev ) {
SVector2 currToNext = vb[idx1] - vb[idx];
float ang = signedAngle2D( prevToCurr, currToNext );
if( ang < bestAngle ) {
bestAngle = ang;
idxNext = idx1;
}
}
}
assert( bestAngle > -4.0f && bestAngle < 4.0f );
assert( idxNext >= 0 );
willFormLoop = (vertexTraceID[idxNext] == traceID);
// Optimization: if best angle is zero, then we're walking
// in a straight line. Optimize out the current vertex.
if( bestAngle == 0.0f && idx != idx0 && !willFormLoop ) {
localPolygon.pop_back();
}
idxPrev = idx;
idx = idxNext;
} while( !willFormLoop );
assert( localPolygon.size() >= 3 );
//if( localPolygon.size() < 3 ) {
// return;
//}
assert( ++debugLoopCounter < vertices.size() );
if( idx == idx0 ) {
// The polygon is simple or we found the last loop.
// Triangulate local and append to results.
triangulator::process( vb, localPolygon, localIB );
polygon.insert( polygon.end(), localPolygon.begin(), localPolygon.end() );
ib.insert( ib.end(), localIB.begin(), localIB.end() );
// We can have separated other loops. Try fetching them as well.
idx0 = getBorderIndex();
if( idx0 == -1 ) {
return;
} else {
localPolygon.resize( 0 );
idxPrev = idx0;
//.........这里部分代码省略.........