本文整理汇总了C++中Face::AddSeg方法的典型用法代码示例。如果您正苦于以下问题:C++ Face::AddSeg方法的具体用法?C++ Face::AddSeg怎么用?C++ Face::AddSeg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Face
的用法示例。
在下文中一共展示了Face::AddSeg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClipEar
/*
1.26 ClipEar implements the Clipping-Ear-Algorithm.
It finds an "Ear" in this Face, clips it and returns it as separate face.
Note that the original Face is modified by this method!
It is mainly used to implement evaporisation of faces
*/
Face Face::ClipEar() {
Face ret;
if (v.size() <= 3) {
// Nothing to do if this Face consists only of three points
return Face(v);
} else {
Pt a, b, c;
unsigned int n = v.size();
// Go through the corner-points, which are sorted counter-clockwise
for (unsigned int i = 0; i < n; i++) {
// Take the next three points
a = v[(i + 0) % n].s;
b = v[(i + 1) % n].s;
c = v[(i + 2) % n].s;
if (Pt::sign(a, b, c) < 0) {
// If the third point c is right of the segment (a b), then
// the three points don't form an "Ear"
continue;
}
// Otherwise check, if any point is inside the triangle (a b c)
bool inside = false;
for (unsigned int j = 0; j < (n - 3); j++) {
Pt x = v[(i + j + 3) % n].s;
inside = Pt::insideTriangle(a, b, c, x) &&
!(a == x) && !(b == x) && !(c == x);
if (inside) {
// If a point inside was found, we haven't found an ear.
break;
}
}
if (!inside) {
// No point was inside, so build the Ear-Face in "ret",
ret.AddSeg(v[i + 0]);
ret.AddSeg(v[(i + 1)%n]);
Seg nw(v[(i + 1)%n].e, v[i + 0].s);
ret.AddSeg(nw);
// remove the Face-Segment (a b),
v.erase(v.begin() + i);
// and finally replace the segment (b c) by (a c)
v[i].s = nw.e;
v[i].e = nw.s;
hullSeg.valid = 0;
return ret;
}
}
}
DEBUG(2, "No ear found on face " << ToString());
// If we are here it means we haven't found an ear. This shouldn't happen.
// One reason could be that the face wasn't valid in the first place.
return ret;
}