diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-08 11:46:51 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-08 11:46:51 +0100 |
commit | 5ffac39b0edfe04c081191b399cadcd69ad3ccd2 (patch) | |
tree | fa5c3630a176aeec73b08364ae25d16016a5a250 /assetFactory/faceController.cpp | |
parent | Remember the name of the adjacent face of each halfedge of each named face (diff) | |
download | ilt-5ffac39b0edfe04c081191b399cadcd69ad3ccd2.tar.bz2 ilt-5ffac39b0edfe04c081191b399cadcd69ad3ccd2.tar.xz ilt-5ffac39b0edfe04c081191b399cadcd69ad3ccd2.zip |
Generate extrusion face names from halfedge adjacent face names
Diffstat (limited to 'assetFactory/faceController.cpp')
-rw-r--r-- | assetFactory/faceController.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
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<std::string> 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; } |