本文整理汇总了C++中Tuple::unitcross方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::unitcross方法的具体用法?C++ Tuple::unitcross怎么用?C++ Tuple::unitcross使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple::unitcross方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
ProgressiveMesh::ProgressiveMesh(Mesh *m) {
_oriMesh = m;
_mesh = *m;
_edgeCollapseList.clear();
_visibleTriangles = _mesh.getNumTriangles();
// calculate Quadric Matrix();
set<border> bs;
for (int i = 0; i < _mesh.getNumVerts(); i++) {
_mesh.getVertex(i).calcQuadric(_mesh);
_mesh.getVertex(i).getAllBorderEdges(bs, _mesh);
}
// increase borders' error cost
if (!bs.empty()) {
set<border>::iterator pos;
for (pos = bs.begin(); pos != bs.end(); ++pos) {
border edge = *pos;
vertex &v1 = _mesh.getVertex(edge.vert1);
vertex &v2 = _mesh.getVertex(edge.vert2);
Tuple &vec1 = v1.getXYZ();
Tuple &vec2 = v2.getXYZ();
Tuple edgeTuple = vec1 - vec2;
triangle &tri = _mesh.getTri(edge.triIndex);
Tuple normal = tri.getNormalTuple();
Tuple abc = edgeTuple.unitcross(normal);
float ary[4] = {abc.x, abc.y, abc.z, -(abc.dot(vec1))};
double q[4][4];
for (int i = 0; i < 4; i++)
for (int j = i; j < 4; j++)
q[i][j] = BORDER_WT * ary[i] * ary[j];
for (int i = 1; i < 4; i++)
for (int j = 0; j < i; j++)
q[i][j] = q[j][i];
double q1[4][4], q2[4][4];
v1.getQuadric(q1);
v2.getQuadric(q2);
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
q1[i][j] += q[i][j], q2[i][j] += q[i][j];
v1.setQuadric(q1);
v2.setQuadric(q2);
}
}
VertexPointerSet vs;
vector<VertexPointerSet::iterator> vsVec(_mesh.getNumVerts());
// calculate edge collapse error cost
for (int i = 0; i < _mesh.getNumVerts(); i++) {
_quadricCollapseCost(_mesh.getVertex(i));
VertexPointer v;
v.index = i;
v.mesh = &_mesh;
vsVec[i] = vs.insert(v);
}
// build edge collapse list
while(vs.size()) {
const VertexPointer vp = *(vs.begin());
vertex v = _mesh.getVertex(vp.index);
EdgeCollapse e;
bool valid = true;
e.from = v.index;
e.to = v.minCostNeighbor;
if (-1 == e.to || !_mesh.getVertex(e.from).active) valid = false;
else if (!_mesh.getVertex(e.to).active) {
_quadricCollapseCost(v);
e.to = v.minCostNeighbor;
if (-1 == e.to || !_mesh.getVertex(e.to).active) valid = false;
}
_mesh.getVertex(e.from).active = false;
vs.erase(vs.begin());
if (!valid) continue;
vertex& to = _mesh.getVertex(e.to);
vertex& from = _mesh.getVertex(e.from);
// add from's cost to to's
double qf[4][4], qt[4][4];
to.getQuadric(qt);
from.getQuadric(qf);
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
qt[i][j] += qf[i][j];
to.setQuadric(qt);
set<int> affectedV;
_updateTriangles(e, v, affectedV);
_updateAffectedVerts(vs, vsVec, e, affectedV);
//.........这里部分代码省略.........