[Bf-blender-cvs] [2f8a2fad296] soc-2021-adaptive-cloth: adaptive_cloth: Mesh: is_edge_on_boundary()
ishbosamiya
noreply at git.blender.org
Mon Jul 19 17:35:42 CEST 2021
Commit: 2f8a2fad296f453f1b4be29d883a10f2f5c7421d
Author: ishbosamiya
Date: Wed Jul 14 12:30:42 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB2f8a2fad296f453f1b4be29d883a10f2f5c7421d
adaptive_cloth: Mesh: is_edge_on_boundary()
Checks if the given edge lies on the boundary of the mesh.
===================================================================
M source/blender/blenkernel/BKE_cloth_remesh.hh
M source/blender/modifiers/intern/MOD_adaptive_remesh.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index b70ff8967f3..47f20a4b824 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -1646,6 +1646,33 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
std::move(deleted_faces));
}
+ /**
+ * Boundary is the set of "3D edges" that have only a single
+ * face. Not all meshes will have a boundary.
+ */
+ bool is_edge_on_boundary(const Edge<EED> &edge) const
+ {
+ const auto [n1, n2] = this->get_checked_nodes_of_edge(edge, false);
+ auto edge_indices = this->get_connecting_edge_indices(n1, n2);
+
+ auto num_face = 0;
+ for (const auto &edge_index : edge_indices) {
+ const auto &e = this->get_checked_edge(edge_index);
+ num_face += e.faces.size();
+ }
+
+ return num_face == 1;
+ }
+
+ /**
+ * Easy call when only `edge_index` is available.
+ */
+ bool is_edge_on_boundary(EdgeIndex edge_index) const
+ {
+ const auto &edge = this->get_checked_edge(edge_index);
+ return is_edge_on_boundary(edge);
+ }
+
/**
* An edge is flippable only if the edge has exactly 2 faces, and
* both faces are triangulated.
@@ -2205,6 +2232,50 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
return {edge_vert_1, edge_vert_2};
}
+ inline std::tuple<const Vert<EVD> &, const Vert<EVD> &> get_checked_verts_of_edge(
+ const Edge<EED> &edge, bool verts_swapped) const
+ {
+ BLI_assert(edge.verts);
+ const auto &edge_verts = edge.verts.value();
+
+ if (verts_swapped) {
+ const auto &edge_vert_1 = this->get_checked_vert(std::get<1>(edge_verts));
+ const auto &edge_vert_2 = this->get_checked_vert(std::get<0>(edge_verts));
+ return {edge_vert_1, edge_vert_2};
+ }
+
+ const auto &edge_vert_1 = this->get_checked_vert(std::get<0>(edge_verts));
+ const auto &edge_vert_2 = this->get_checked_vert(std::get<1>(edge_verts));
+
+ return {edge_vert_1, edge_vert_2};
+ }
+
+ inline std::tuple<Node<END> &, Node<END> &> get_checked_nodes_of_edge(const Edge<EED> &edge,
+ bool nodes_swapped)
+ {
+ auto [v1, v2] = this->get_checked_verts_of_edge(edge, nodes_swapped);
+
+ BLI_assert(v1.node);
+ BLI_assert(v2.node);
+ auto &n1 = this->get_checked_node(v1.node.value());
+ auto &n2 = this->get_checked_node(v2.node.value());
+
+ return {n1, n2};
+ }
+
+ inline std::tuple<const Node<END> &, const Node<END> &> get_checked_nodes_of_edge(
+ const Edge<EED> &edge, bool nodes_swapped) const
+ {
+ const auto [v1, v2] = this->get_checked_verts_of_edge(edge, nodes_swapped);
+
+ BLI_assert(v1.node);
+ BLI_assert(v2.node);
+ const auto &n1 = this->get_checked_node(v1.node.value());
+ const auto &n2 = this->get_checked_node(v2.node.value());
+
+ return {n1, n2};
+ }
+
inline Node<END> &get_checked_node_of_vert(const Vert<EVD> &vert)
{
BLI_assert(vert.node);
diff --git a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
index 72472a584c0..33d558783f3 100644
--- a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -63,6 +63,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
auto edge_index = op_edge_index.value();
std::cout << "edge_index: " << edge_index << " edge_i: " << armd->edge_index
<< " across_seams: " << across_seams << " mode: " << mode << std::endl;
+ bool is_on_boundary = internal_mesh.is_edge_on_boundary(edge_index);
+ std::cout << "is_on_boundary: " << is_on_boundary << std::endl;
if (mode == ADAPTIVE_REMESH_SPLIT_EDGE) {
internal_mesh.split_edge_triangulate(edge_index, across_seams);
}
More information about the Bf-blender-cvs
mailing list