本文整理汇总了C++中BOP_Indexs::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ BOP_Indexs::erase方法的具体用法?C++ BOP_Indexs::erase怎么用?C++ BOP_Indexs::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOP_Indexs
的用法示例。
在下文中一共展示了BOP_Indexs::erase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mergeFaces
/**
* Merge a set of faces removing the vertex index v.
* @param faces set of faces
* @param oldFaces set of old faces obtained from the merge
* @param newFaces set of new faces obtained from the merge
* @param vertices sequence of indexs (v1 ... vi = v ... vn) where :
* v is the current vertex to test,
* vj (j < i) are tested vertices,
* vk (k >= i) are vertices required to test to merge vj
* (so if a vertex vk can't be merged, the merge is not possible).
* @param v vertex index
* @return true if the merge is succesful, false otherwise
*/
bool BOP_Merge::mergeFaces(BOP_Faces &faces, BOP_Faces &oldFaces, BOP_Faces &newFaces, BOP_Indexs &vertices, BOP_Index v)
{
bool merged = false;
if (faces.size() == 2) {
// Merge a pair of faces into a new face without v
BOP_Face *faceI = faces[0];
BOP_Face *faceJ = faces[1];
BOP_Face *faceK = mergeFaces(faceI,faceJ,vertices,v);
if (faceK != NULL) {
newFaces.push_back(faceK);
oldFaces.push_back(faceI);
oldFaces.push_back(faceJ);
merged = true;
}
else merged = false;
}
else if (faces.size() == 4) {
// Merge two pair of faces into a new pair without v
// First we try to perform a simplify merge to avoid more pending vertices
// (for example, if we have two triangles and two quads it will be better
// to do 3+4 and 3+4 than 3+3 and 4+4)
BOP_Face *oldFace1 = faces[0];
BOP_Face *oldFace2, *newFace1;
unsigned int indexJ = 1;
while (indexJ < faces.size() && !merged) {
oldFace2 = faces[indexJ];
newFace1 = mergeFaces(oldFace1,oldFace2,v);
if (newFace1 != NULL) merged = true;
else indexJ++;
}
if (merged) {
// Merge the other pair of faces
unsigned int indexK, indexL;
if (indexJ == 1) {indexK = 2;indexL = 3;}
else if (indexJ == 2) {indexK = 1;indexL = 3;}
else {indexK = 1;indexL = 2;}
BOP_Face *oldFace3 = faces[indexK];
BOP_Face *oldFace4 = faces[indexL];
unsigned int oldSize = vertices.size();
BOP_Face *newFace2 = mergeFaces(oldFace3,oldFace4,vertices,v);
if (newFace2 != NULL) {
newFaces.push_back(newFace1);
newFaces.push_back(newFace2);
oldFaces.push_back(oldFace1);
oldFaces.push_back(oldFace2);
oldFaces.push_back(oldFace3);
oldFaces.push_back(oldFace4);
merged = true;
}
else {
// Undo all changes
delete newFace1;
merged = false;
unsigned int count = vertices.size() - oldSize;
if (count != 0)
vertices.erase(vertices.end() - count, vertices.end());
}
}
if (!merged) {
// Try a complete merge
merged = true;
while (faces.size()>0 && merged) {
indexJ = 1;
BOP_Face *faceI = faces[0];
merged = false;
while (indexJ < faces.size()) {
BOP_Face *faceJ = faces[indexJ];
BOP_Face *faceK = mergeFaces(faceI,faceJ,vertices,v);
if (faceK != NULL) {
// faceK = faceI + faceJ and it does not include v!
faces.erase(faces.begin()+indexJ,faces.begin()+(indexJ+1));
faces.erase(faces.begin(),faces.begin()+1);
newFaces.push_back(faceK);
oldFaces.push_back(faceI);
oldFaces.push_back(faceJ);
merged = true;
break;
}
else indexJ++;
}
}
}
}
else merged = false; // there are N=1 or N=3 or N>4 faces!
//.........这里部分代码省略.........