本文整理汇总了C++中SArray::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ SArray::Insert方法的具体用法?C++ SArray::Insert怎么用?C++ SArray::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SArray
的用法示例。
在下文中一共展示了SArray::Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeEdgeCost
double MeshDecimator::ComputeEdgeCost(long v1, long v2, Vec3<Float> & newPos) const
{
double Q[10];
double M[12];
Vec3<double> pos;
for(int i = 0; i < 10; ++i) Q[i] = m_vertices[v1].m_Q[i] + m_vertices[v2].m_Q[i];
M[0] = Q[0]; // (0, 0)
M[1] = Q[1]; // (0, 1)
M[2] = Q[2]; // (0, 2)
M[3] = Q[3]; // (0, 3)
M[4] = Q[1]; // (1, 0)
M[5] = Q[4]; // (1, 1)
M[6] = Q[5]; // (1, 2)
M[7] = Q[6]; // (1, 3)
M[8] = Q[2]; // (2, 0)
M[9] = Q[5]; // (2, 1)
M[10] = Q[7]; // (2, 2);
M[11] = Q[8]; // (2, 3);
double det = M[0] * M[5] * M[10] + M[1] * M[6] * M[8] + M[2] * M[4] * M[9]
- M[0] * M[6] * M[9] - M[1] * M[4] * M[10]- M[2] * M[5] * M[8];
if (det != 0.0)
{
double d = 1.0 / det;
pos.X() = d * (M[1]*M[7]*M[10] + M[2]*M[5]*M[11] + M[3]*M[6]*M[9]
-M[1]*M[6]*M[11] - M[2]*M[7]*M[9] - M[3]*M[5]*M[10]);
pos.Y() = d * (M[0]*M[6]*M[11] + M[2]*M[7]*M[8] + M[3]*M[4]*M[10]
-M[0]*M[7]*M[10] - M[2]*M[4]*M[11] - M[3]*M[6]*M[8]);
pos.Z() = d * (M[0]*M[7]*M[9] + M[1]*M[4]*M[11] + M[3]*M[5]*M[8]
-M[0]*M[5]*M[11] - M[1]*M[7]*M[8] - M[3]*M[4]*M[9]);
newPos.X() = static_cast<Float>(pos.X());
newPos.Y() = static_cast<Float>(pos.Y());
newPos.Z() = static_cast<Float>(pos.Z());
}
else
{
const Float w = static_cast<Float>(0.5f);
newPos = w * m_points[v1] + w * m_points[v2];
pos.X() = static_cast<double>(newPos.X());
pos.Y() = static_cast<double>(newPos.Y());
pos.Z() = static_cast<double>(newPos.Z());
}
double qem = pos.X() * (Q[0] * pos.X() + Q[1] * pos.Y() + Q[2] * pos.Z() + Q[3]) +
pos.Y() * (Q[1] * pos.X() + Q[4] * pos.Y() + Q[5] * pos.Z() + Q[6]) +
pos.Z() * (Q[2] * pos.X() + Q[5] * pos.Y() + Q[7] * pos.Z() + Q[8]) +
(Q[3] * pos.X() + Q[6] * pos.Y() + Q[8] * pos.Z() + Q[9]) ;
Vec3<Float> d1;
Vec3<Float> d2;
Vec3<Float> n1;
Vec3<Float> n2;
Vec3<Float> oldPosV1 = m_points[v1];
Vec3<Float> oldPosV2 = m_points[v2];
SArray<long, SARRAY_DEFAULT_MIN_SIZE> triangles = m_vertices[v1].m_triangles;
long idTriangle;
for(size_t itT = 0; itT < m_vertices[v2].m_triangles.Size(); ++itT)
{
idTriangle = m_vertices[v2].m_triangles[itT];
triangles.Insert(idTriangle);
}
long a[3];
for(size_t itT = 0; itT != triangles.Size(); ++itT)
{
idTriangle = triangles[itT];
a[0] = m_triangles[idTriangle].X();
a[1] = m_triangles[idTriangle].Y();
a[2] = m_triangles[idTriangle].Z();
d1 = m_points[a[1]] - m_points[a[0]];
d2 = m_points[a[2]] - m_points[a[0]];
n1 = d1^d2;
m_points[v1] = newPos;
m_points[v2] = newPos;
d1 = m_points[a[1]] - m_points[a[0]];
d2 = m_points[a[2]] - m_points[a[0]];
n2 = d1^d2;
m_points[v1] = oldPosV1;
m_points[v2] = oldPosV2;
n1.Normalize();
n2.Normalize();
if (n1*n2 < 0.0)
{
return std::numeric_limits<double>::max();
}
}
if ( m_ecolManifoldConstraint && !ManifoldConstraint(v1, v2))
{
return std::numeric_limits<double>::max();
}
return qem;
}