[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39384] branches/soc-2011-avocado/blender/ source/blender/editors/mesh/autoseam_tools.c: Handling the components of a mesh using the internal properties of Bmesh is integrated .
shuvro sarker
shuvro05 at gmail.com
Sun Aug 14 07:52:14 CEST 2011
Revision: 39384
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39384
Author: shuvro
Date: 2011-08-14 05:52:13 +0000 (Sun, 14 Aug 2011)
Log Message:
-----------
Handling the components of a mesh using the internal properties of Bmesh is integrated. The idea of doing this is proposed and implemented mostly by Elubie. The previous handle_separate_components is also kept as an option too. Need to experiment a bit about which is more efficient.
Modified Paths:
--------------
branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
Modified: branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c
===================================================================
--- branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c 2011-08-14 05:25:11 UTC (rev 39383)
+++ branches/soc-2011-avocado/blender/source/blender/editors/mesh/autoseam_tools.c 2011-08-14 05:52:13 UTC (rev 39384)
@@ -228,6 +228,88 @@
*component_size = *component_size + 1;
}
+static int next_component(BMesh *bm, GHash *visithash, int recursion_depth, bContext *C)
+{
+ GHash* component = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "autoseam_component");
+ AUTOSEAM_Adjacency adj;
+ BMIter face_iter, edge_iter;
+ BMIter iter, liter;
+ BMFace *f1, *f2;
+ BMEdge *edge;
+ BMLoop *l, *loop;
+ int done = 1;
+ int i, n;
+
+ n = 0;
+ f1 = BMIter_New(&face_iter, bm, BM_FACES_OF_MESH, NULL);
+ for (; f1; f1=BMIter_Step(&face_iter) ) {
+ if (!BM_TestHFlag(f1, BM_SELECT)) continue;
+ if (BLI_ghash_haskey(visithash, f1)) continue;
+ done = 0;
+ BLI_ghash_insert(visithash, f1, NULL);
+ BLI_ghash_insert(component, f1, NULL);
+ BM_SetIndex(f1,n++);
+ l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f1);
+ for (; l; l=BMIter_Step(&liter)) {
+ f2 = BMIter_New(&iter, bm, BM_FACES_OF_EDGE, l->e);
+ for (; f2; f2=BMIter_Step(&iter)) {
+ if (!BM_TestHFlag(f2, BM_SELECT)) continue;
+ if (BLI_ghash_haskey(visithash, f2)) continue;
+ BM_SetIndex(f2,n++);
+ BLI_ghash_insert(component, f2, NULL);
+ BLI_ghash_insert(visithash, f2, NULL);
+ }
+ }
+ }
+
+ if (done) {
+ BLI_ghash_free(component, NULL, NULL);
+ return 1;
+ }
+
+ adj = autoseam_create_adjacency(n);
+
+ i = 0;
+ for(edge = BMIter_New(&edge_iter, bm, BM_EDGES_OF_MESH, bm ); edge; edge= BMIter_Step(&edge_iter))
+ {
+ /* if not boundary edge */
+ if(!BM_Boundary_Edge(edge)){
+
+ BM_ITER(loop, &face_iter, bm, BM_LOOPS_OF_EDGE, edge) {
+ /* Only create adjacency matrix for the selected faces */
+ if (BLI_ghash_haskey(component, loop->f) && BLI_ghash_haskey(component, loop->radial_next->f) )
+ {
+ autoseam_set_adjacent(adj, loop->f->head.index, loop->radial_next->f->head.index, 1.0);
+ min_value = 1.0;
+ }
+ }
+ }
+ }
+
+ autoseam_set_min_value(adj, min_value);
+ autoseam_set_map_default(adj);
+
+ generate_seam_recursive(bm, adj, adj, recursion_depth, C, -1.0);
+
+ BLI_ghash_free(component, NULL, NULL);
+ return 0;
+}
+
+
+
+static void do_all_components(BMesh *bm, int recursion_depth, bContext *C) {
+
+ GHash* visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "autoseam_visited");
+ int done = 0;
+
+ while (!done) {
+ done = next_component(bm, visithash, recursion_depth, C);
+ }
+
+ BLI_ghash_free(visithash, NULL, NULL);
+}
+
+
static int handle_separate_components(AUTOSEAM_Adjacency adj, int num_nodes, BMesh *bm, int recursion_depth, bContext *C)
{
int i, j, k;
@@ -568,7 +650,8 @@
autoseam_set_map_default(adj);
/* This function will call the recusive function for each of the components of bmesh*/
- handle_separate_components(adj, num_faces, bm, maxdepth, C);
+ //handle_separate_components(adj, num_faces, bm, maxdepth, C);
+ do_all_components(bm, maxdepth, C);
More information about the Bf-blender-cvs
mailing list