bmesh api: add 'is_boundary' attribute to verts.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 14 May 2013 02:56:24 +0000 (02:56 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 14 May 2013 02:56:24 +0000 (02:56 +0000)
source/blender/bmesh/intern/bmesh_queries.c
source/blender/bmesh/intern/bmesh_queries.h
source/blender/python/bmesh/bmesh_py_types.c

index 8a1d513a8fc49059bf5c857fd415195118b1ce80..aefea576563b7ca275e84e0c3bed78933d5aaf74 100644 (file)
@@ -821,6 +821,25 @@ int BM_edge_is_boundary(BMEdge *e)
 }
 #endif
 
+bool BM_vert_is_boundary(BMVert *v)
+{
+       if (v->e) {
+               BMEdge *e_first, *e_iter;
+
+               e_first = e_iter = v->e;
+               do {
+                       if (BM_edge_is_boundary(e_iter)) {
+                               return true;
+                       }
+               } while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
+
+               return false;
+       }
+       else {
+               return false;
+       }
+}
+
 /**
  * Returns the number of faces that are adjacent to both f1 and f2,
  * \note Could be sped up a bit by not using iterators and by tagging
index 6b1bfca2d80be24748418ee3f020371f5d968d7f..47b6d87f91a5bae221278f62db2be9a6f1259ec1 100644 (file)
@@ -61,6 +61,7 @@ bool    BM_edge_is_wire(BMEdge *e);
 
 bool    BM_vert_is_manifold(BMVert *v);
 bool    BM_edge_is_manifold(BMEdge *e);
+bool    BM_vert_is_boundary(BMVert *v);
 bool    BM_edge_is_boundary(BMEdge *e);
 bool    BM_edge_is_contiguous(BMEdge *e);
 bool    BM_edge_is_convex(BMEdge *e);
index 2a0964cefbd0b96428dc480a237241df5447d2ea..e6f9958d1d10aa0e7f206660874d1cd9eb36ba22 100644 (file)
@@ -401,6 +401,15 @@ static PyObject *bpy_bmvert_is_wire_get(BPy_BMVert *self)
        return PyBool_FromLong(BM_vert_is_wire(self->v));
 }
 
+PyDoc_STRVAR(bpy_bmvert_is_boundary_doc,
+"True when this vertex connected to any boundary edges (read-only).\n\n:type: boolean"
+);
+static PyObject *bpy_bmvert_is_boundary_get(BPy_BMVert *self)
+{
+       BPY_BM_CHECK_OBJ(self);
+       return PyBool_FromLong(BM_vert_is_boundary(self->v));
+}
+
 
 /* Edge
  * ^^^^ */
@@ -685,6 +694,7 @@ static PyGetSetDef bpy_bmvert_getseters[] = {
        /* readonly checks */
        {(char *)"is_manifold",  (getter)bpy_bmvert_is_manifold_get,  (setter)NULL, (char *)bpy_bmvert_is_manifold_doc, NULL},
        {(char *)"is_wire",      (getter)bpy_bmvert_is_wire_get,      (setter)NULL, (char *)bpy_bmvert_is_wire_doc, NULL},
+       {(char *)"is_boundary",  (getter)bpy_bmvert_is_boundary_get,  (setter)NULL, (char *)bpy_bmvert_is_boundary_doc, NULL},
        {(char *)"is_valid",     (getter)bpy_bm_is_valid_get,         (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL},
 
        {NULL, NULL, NULL, NULL, NULL} /* Sentinel */