本文整理汇总了C++中DrawElementsUInt::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawElementsUInt::insert方法的具体用法?C++ DrawElementsUInt::insert怎么用?C++ DrawElementsUInt::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawElementsUInt
的用法示例。
在下文中一共展示了DrawElementsUInt::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: combinePolygons
DrawElementsUInt* combinePolygons( DrawElementsUInt* poly1, DrawElementsUInt* poly2){
DrawElementsUInt* candidatePoly = new DrawElementsUInt( PrimitiveSet::POLYGON, 0 );
for (int i = 0; i < poly1->size(); i++){
candidatePoly->push_back(poly1->at(i));
}
//Look for a shared edge
int sharedIndex1 = -1;
int sharedIndex2 = -1;
bool opposite = false;
for (int i = 0; i < candidatePoly->size(); i++) {
if (sharedIndex1 != -1) {
break;
}
for (int j = 0; j < poly2->size(); j++) {
int ind11 = candidatePoly->at(i);
int ind12 = candidatePoly->at((i+1) % candidatePoly->size());
int ind21 = poly2->at(j);
int ind22 = poly2->at((j+1) % poly2->size());
if ((ind11 == ind21) && (ind12 == ind22)){
sharedIndex1 = i;
sharedIndex2 = j;
break;
}
if ((ind11 == ind22) && (ind12 == ind21)){
sharedIndex1 = i;
sharedIndex2 = j;
opposite = true;
break;
}
}
}
if (sharedIndex1 == -1){
return NULL;
}
//insert places elements before selected location, so we go backwards when ordering is the same.
if (!opposite){
for (int i = poly2->size()-1; i >= 0; --i) {
int index = (sharedIndex2 + i + 2) % poly2->size();
candidatePoly->insert(candidatePoly->begin() + sharedIndex1 + 1, poly2->at(index));
}
}
else {
int offset = sharedIndex1 + 1;
for (int i = 0; i < poly2->size() - 2; ++i) {
int index = (sharedIndex2 + i + 2) % poly2->size();
candidatePoly->insert(candidatePoly->begin() + offset, poly2->at(index));
offset += 1;
}
}
return candidatePoly;
}