summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-08 11:46:51 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-08 11:46:51 +0100
commit5ffac39b0edfe04c081191b399cadcd69ad3ccd2 (patch)
treefa5c3630a176aeec73b08364ae25d16016a5a250
parentRemember the name of the adjacent face of each halfedge of each named face (diff)
downloadilt-5ffac39b0edfe04c081191b399cadcd69ad3ccd2.tar.bz2
ilt-5ffac39b0edfe04c081191b399cadcd69ad3ccd2.tar.xz
ilt-5ffac39b0edfe04c081191b399cadcd69ad3ccd2.zip
Generate extrusion face names from halfedge adjacent face names
-rw-r--r--assetFactory/faceController.cpp18
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(), &centre](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;
}