From 7f9e28e4e91ac757680fef56e771122cde14c9db Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 8 Apr 2023 11:42:43 +0100 Subject: Remember the name of the adjacent face of each halfedge of each named face Used when extruding to remember what the new face name will be, even after the adjacent face has been removed/replaced/split/etc --- assetFactory/modelFactoryMesh.cpp | 16 ++++++++++++++++ assetFactory/modelFactoryMesh.h | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'assetFactory') diff --git a/assetFactory/modelFactoryMesh.cpp b/assetFactory/modelFactoryMesh.cpp index 806ac3b..e640502 100644 --- a/assetFactory/modelFactoryMesh.cpp +++ b/assetFactory/modelFactoryMesh.cpp @@ -4,4 +4,20 @@ ModelFactoryMesh::ModelFactoryMesh() { add_property(smoothFaceProperty); add_property(nameFaceProperty); + add_property(nameAdjFaceProperty); +} + +void +ModelFactoryMesh::configNamedFace(const std::string & name, OpenMesh::FaceHandle handle) +{ + property(nameFaceProperty, handle) = name; + const auto halfEdges = fh_range(handle); + for (const auto & he : halfEdges) { + if (auto ofh = opposite_face_handle(he); ofh.is_valid()) { + property(nameAdjFaceProperty, he) = property(nameFaceProperty, ofh); + } + if (auto oheh = opposite_halfedge_handle(he); oheh.is_valid()) { + property(nameAdjFaceProperty, oheh) = name; + } + } } diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h index a862dc1..8ac2edd 100644 --- a/assetFactory/modelFactoryMesh.h +++ b/assetFactory/modelFactoryMesh.h @@ -48,13 +48,17 @@ struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT smoothFaceProperty; OpenMesh::FPropHandleT nameFaceProperty; + OpenMesh::HPropHandleT nameAdjFaceProperty; template std::pair add_namedFace(std::string name, Vs &&... vs) { const auto handle = add_face(std::forward(vs)...); - property(nameFaceProperty, handle) = name; - return std::make_pair(name, handle); + configNamedFace(name, handle); + return {std::move(name), handle}; } + +private: + void configNamedFace(const std::string & name, OpenMesh::FaceHandle); }; -- cgit v1.2.3