Initialize a mesh and returns errors if any
| 49 | |
| 50 | // Initialize a mesh and returns errors if any |
| 51 | bool ConvexMesh::init(const PolygonVertexArray& polygonVertexArray, std::vector<Message>& errors) { |
| 52 | |
| 53 | bool isValid = true; |
| 54 | |
| 55 | // Reserve memory for the vertices, faces and edges |
| 56 | mVertices.reserve(polygonVertexArray.getNbVertices()); |
| 57 | mFacesNormals.reserve(polygonVertexArray.getNbFaces()); |
| 58 | mHalfEdgeStructure.reserve(polygonVertexArray.getNbFaces(), polygonVertexArray.getNbVertices(), |
| 59 | (polygonVertexArray.getNbVertices() + polygonVertexArray.getNbFaces() - 2) * 2); |
| 60 | |
| 61 | // Copy the vertices from the PolygonVertexArray into the mesh |
| 62 | isValid &= copyVertices(polygonVertexArray, errors); |
| 63 | |
| 64 | // Create the half-edge structure of the mesh |
| 65 | isValid &= createHalfEdgeStructure(polygonVertexArray, errors); |
| 66 | |
| 67 | // Compute the faces normals |
| 68 | isValid &= computeFacesNormals(errors); |
| 69 | |
| 70 | // Compute the volume of the mesh |
| 71 | computeVolume(); |
| 72 | |
| 73 | return isValid; |
| 74 | } |
| 75 | |
| 76 | // Copy the vertices into the mesh |
| 77 | bool ConvexMesh::copyVertices(const PolygonVertexArray& polygonVertexArray, std::vector<Message>& errors) { |
nothing calls this directly
no test coverage detected