本文整理汇总了C++中SimulationModel::addStrainTriangleConstraint方法的典型用法代码示例。如果您正苦于以下问题:C++ SimulationModel::addStrainTriangleConstraint方法的具体用法?C++ SimulationModel::addStrainTriangleConstraint怎么用?C++ SimulationModel::addStrainTriangleConstraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimulationModel
的用法示例。
在下文中一共展示了SimulationModel::addStrainTriangleConstraint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMesh
//.........这里部分代码省略.........
pd.setMass((nRows-1)*nCols, 0.0);
// init constraints
for (unsigned int cm = 0; cm < model.getTriangleModels().size(); cm++)
{
if (simulationMethod == 1)
{
const unsigned int offset = model.getTriangleModels()[cm]->getIndexOffset();
const unsigned int nEdges = model.getTriangleModels()[cm]->getParticleMesh().numEdges();
const IndexedFaceMesh::Edge *edges = model.getTriangleModels()[cm]->getParticleMesh().getEdges().data();
for (unsigned int i = 0; i < nEdges; i++)
{
const unsigned int v1 = edges[i].m_vert[0] + offset;
const unsigned int v2 = edges[i].m_vert[1] + offset;
model.addDistanceConstraint(v1, v2);
}
}
else if (simulationMethod == 2)
{
const unsigned int offset = model.getTriangleModels()[cm]->getIndexOffset();
TriangleModel::ParticleMesh &mesh = model.getTriangleModels()[cm]->getParticleMesh();
const unsigned int *tris = mesh.getFaces().data();
const unsigned int nFaces = mesh.numFaces();
for (unsigned int i = 0; i < nFaces; i++)
{
const unsigned int v1 = tris[3 * i] + offset;
const unsigned int v2 = tris[3 * i + 1] + offset;
const unsigned int v3 = tris[3 * i + 2] + offset;
model.addFEMTriangleConstraint(v1, v2, v3);
}
}
else if (simulationMethod == 3)
{
const unsigned int offset = model.getTriangleModels()[cm]->getIndexOffset();
TriangleModel::ParticleMesh &mesh = model.getTriangleModels()[cm]->getParticleMesh();
const unsigned int *tris = mesh.getFaces().data();
const unsigned int nFaces = mesh.numFaces();
for (unsigned int i = 0; i < nFaces; i++)
{
const unsigned int v1 = tris[3 * i] + offset;
const unsigned int v2 = tris[3 * i + 1] + offset;
const unsigned int v3 = tris[3 * i + 2] + offset;
model.addStrainTriangleConstraint(v1, v2, v3);
}
}
if (bendingMethod != 0)
{
const unsigned int offset = model.getTriangleModels()[cm]->getIndexOffset();
TriangleModel::ParticleMesh &mesh = model.getTriangleModels()[cm]->getParticleMesh();
unsigned int nEdges = mesh.numEdges();
const TriangleModel::ParticleMesh::Edge *edges = mesh.getEdges().data();
const unsigned int *tris = mesh.getFaces().data();
for (unsigned int i = 0; i < nEdges; i++)
{
const int tri1 = edges[i].m_face[0];
const int tri2 = edges[i].m_face[1];
if ((tri1 != 0xffffffff) && (tri2 != 0xffffffff))
{
// Find the triangle points which do not lie on the axis
const int axisPoint1 = edges[i].m_vert[0];
const int axisPoint2 = edges[i].m_vert[1];
int point1 = -1;
int point2 = -1;
for (int j = 0; j < 3; j++)
{
if ((tris[3 * tri1 + j] != axisPoint1) && (tris[3 * tri1 + j] != axisPoint2))
{
point1 = tris[3 * tri1 + j];
break;
}
}
for (int j = 0; j < 3; j++)
{
if ((tris[3 * tri2 + j] != axisPoint1) && (tris[3 * tri2 + j] != axisPoint2))
{
point2 = tris[3 * tri2 + j];
break;
}
}
if ((point1 != -1) && (point2 != -1))
{
const unsigned int vertex1 = point1 + offset;
const unsigned int vertex2 = point2 + offset;
const unsigned int vertex3 = edges[i].m_vert[0] + offset;
const unsigned int vertex4 = edges[i].m_vert[1] + offset;
if (bendingMethod == 1)
model.addDihedralConstraint(vertex1, vertex2, vertex3, vertex4);
else if (bendingMethod == 2)
model.addIsometricBendingConstraint(vertex1, vertex2, vertex3, vertex4);
}
}
}
}
}
std::cout << "Number of triangles: " << nIndices / 3 << "\n";
std::cout << "Number of vertices: " << nRows*nCols << "\n";
}