From 5ffac39b0edfe04c081191b399cadcd69ad3ccd2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 8 Apr 2023 11:46:51 +0100 Subject: Generate extrusion face names from halfedge adjacent face names --- assetFactory/faceController.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'assetFactory') diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index 28812d8..92cc8d2 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -69,7 +69,6 @@ FaceController::extrude(ModelFactoryMesh & mesh, const std::string & faceName, O }); const auto vertexCount = points.size(); const auto centre = mesh.calc_face_centroid(faceHandle); - Shape::CreatedFaces newFaces; // mutate points std::for_each(points.begin(), points.end(), [mutation = getMatrix(), ¢re](auto && p) { p = centre + ((p - centre) % mutation); @@ -79,17 +78,22 @@ FaceController::extrude(ModelFactoryMesh & mesh, const std::string & faceName, O std::transform(points.begin(), points.end(), std::back_inserter(vertices), [&mesh](auto && p) { return mesh.add_vertex(p); }); + // get new faces names + std::vector faceNames; + for (size_t idx {}; idx < vertexCount; ++idx) { + const auto next = (idx + 1) % vertexCount; + const auto existingEdge = mesh.find_halfedge(baseVertices[idx], baseVertices[next]); + faceNames.push_back(mesh.property(mesh.nameAdjFaceProperty, existingEdge)); + } // create new faces - const auto ofrange = materializeRange(mesh.ff_range(faceHandle)); mesh.delete_face(faceHandle); + Shape::CreatedFaces newFaces; for (size_t idx {}; idx < vertexCount; ++idx) { const auto next = (idx + 1) % vertexCount; - const auto newFace = mesh.add_face({baseVertices[idx], baseVertices[next], vertices[next], vertices[idx]}); - auto & newFaceName = mesh.property(mesh.nameFaceProperty, newFace); - newFaceName = getAdjacentFaceName(mesh, ofrange, newFace); - newFaces.emplace(newFaceName, newFace); + newFaces.emplace(mesh.add_namedFace( + faceNames[idx], baseVertices[idx], baseVertices[next], vertices[next], vertices[idx])); } - newFaces.emplace(faceName, mesh.add_face(vertices)); + newFaces.emplace(mesh.add_namedFace(faceName, vertices)); return newFaces; } -- cgit v1.2.3