//---------------------------------------------------------------------------- ConvexClipper::ConvexClipper (const ConvexPolyhedron& rkPoly, Real fEpsilon) { m_fEpsilon = fEpsilon; const vector<Vector3>& rakPoint = rkPoly.GetPoints(); int iVQuantity = rkPoly.GetVQuantity(); m_akVertex.resize(iVQuantity); for (int iV = 0; iV < iVQuantity; iV++) m_akVertex[iV].m_kPoint = rakPoint[iV]; int iEQuantity = rkPoly.GetEQuantity(); m_akEdge.resize(iEQuantity); for (int iE = 0; iE < iEQuantity; iE++) { const MTEdge& rkE = rkPoly.GetEdge(iE); for (int i = 0; i < 2; i++) { m_akEdge[iE].m_aiVertex[i] = rkPoly.GetVLabel(rkE.GetVertex(i)); m_akEdge[iE].m_aiFace[i] = rkE.GetTriangle(i); } } int iTQuantity = rkPoly.GetTQuantity(); m_akFace.resize(iTQuantity); for (int iT = 0; iT < iTQuantity; iT++) { m_akFace[iT].m_kPlane = rkPoly.GetPlane(iT); const MTTriangle& rkT = rkPoly.GetTriangle(iT); for (int i = 0; i < 3; i++) m_akFace[iT].m_akEdge.insert(rkT.GetEdge(i)); } }
ConvexClipper<Real>::ConvexClipper (const ConvexPolyhedron<Real>& polyhedron, Real epsilon) : mEpsilon(epsilon) { const std::vector<Vector3<Real> >& points = polyhedron.GetPoints(); int numVertices = polyhedron.GetNumVertices(); mVertices.resize(numVertices); for (int v = 0; v < numVertices; ++v) { mVertices[v].Point = points[v]; } int numEdges = polyhedron.GetNumEdges(); mEdges.resize(numEdges); for (int e = 0; e < numEdges; ++e) { const MTEdge& edge = polyhedron.GetEdge(e); for (int i = 0; i < 2; ++i) { mEdges[e].Vertex[i] = polyhedron.GetVLabel(edge.GetVertex(i)); mEdges[e].Face[i] = edge.GetTriangle(i); } } int numTriangles = polyhedron.GetNumTriangles(); mFaces.resize(numTriangles); for (int t = 0; t < numTriangles; ++t) { mFaces[t].Plane = polyhedron.GetPlane(t); const MTTriangle& triangle = polyhedron.GetTriangle(t); for (int i = 0; i < 3; ++i) { mFaces[t].Edges.insert(triangle.GetEdge(i)); } } }