[Bf-blender-cvs] [1cb8937527b] newboolean: tritri test 5 now works.

Howard Trickey noreply at git.blender.org
Wed Oct 2 14:41:32 CEST 2019


Commit: 1cb8937527b969e53a8d75d76f32de98b7c8f962
Author: Howard Trickey
Date:   Wed Oct 2 08:40:03 2019 -0400
Branches: newboolean
https://developer.blender.org/rB1cb8937527b969e53a8d75d76f32de98b7c8f962

tritri test 5 now works.

===================================================================

M	source/blender/bmesh/tools/bmesh_boolean.c

===================================================================

diff --git a/source/blender/bmesh/tools/bmesh_boolean.c b/source/blender/bmesh/tools/bmesh_boolean.c
index 27cab28425c..159862216ac 100644
--- a/source/blender/bmesh/tools/bmesh_boolean.c
+++ b/source/blender/bmesh/tools/bmesh_boolean.c
@@ -221,7 +221,7 @@ enum { TEST_NONE = -1, TEST_B = 0, TEST_A = 1, TEST_ALL = 2 };
 #  define ATTU
 #endif
 
-#define BOOLDEBUG
+// #define BOOLDEBUG
 #ifdef BOOLDEBUG
 /* For Debugging. */
 #  define CO3(v) (v)->co[0], (v)->co[1], (v)->co[2]
@@ -255,6 +255,7 @@ static int meshadd_facelen(const MeshAdd *meshadd, int f);
 static int meshadd_face_vert(const MeshAdd *meshadd, int f, int index);
 static void meshadd_get_vert_co(const MeshAdd *meshadd, int v, float *r_coords);
 static void meshadd_get_edge_verts(const MeshAdd *meshadd, int e, int *r_v1, int *r_v2);
+static bool meshdelete_find_vert(MeshDelete *meshdelete, int v);
 static bool meshdelete_find_edge(MeshDelete *meshdelete, int e);
 static bool meshdelete_find_face(MeshDelete *meshdelete, int f);
 static int find_edge_by_verts_in_meshadd(const MeshAdd *meshadd, int v1, int v2);
@@ -311,7 +312,7 @@ static void init_intintmap(IntIntMap *intintmap)
   intintmap->listhead.last_node = NULL;
 }
 
-static int intintmap_size(const IntIntMap *intintmap)
+ATTU static int intintmap_size(const IntIntMap *intintmap)
 {
   return BLI_linklist_count(intintmap->listhead.list);
 }
@@ -343,13 +344,13 @@ static bool find_in_intintmap(const IntIntMap *map, int key, int *r_val)
 /* Note: this is a shallow copy: afterwards, dst and src will
  * share underlying list
  */
-static void copy_intintmap_intintmap(IntIntMap *dst, IntIntMap *src)
+ATTU static void copy_intintmap_intintmap(IntIntMap *dst, IntIntMap *src)
 {
   dst->listhead.list = src->listhead.list;
   dst->listhead.last_node = src->listhead.last_node;
 }
 
-static void set_intintmap_entry(BoolState *bs, IntIntMap *map, int key, int value)
+ATTU static void set_intintmap_entry(BoolState *bs, IntIntMap *map, int key, int value)
 {
   LinkNode *ln;
 
@@ -369,7 +370,7 @@ static void set_intintmap_entry(BoolState *bs, IntIntMap *map, int key, int valu
  * iteration, but not the key.
  */
 
-static void intintmap_iter_init(IntIntMapIterator *iter, const IntIntMap *map)
+ATTU static void intintmap_iter_init(IntIntMapIterator *iter, const IntIntMap *map)
 {
   iter->map = map;
   iter->curlink = map->listhead.list;
@@ -386,7 +387,7 @@ static inline bool intintmap_iter_done(IntIntMapIterator *iter)
   return iter->curlink == NULL;
 }
 
-static void intintmap_iter_step(IntIntMapIterator *iter)
+ATTU static void intintmap_iter_step(IntIntMapIterator *iter)
 {
   iter->curlink = iter->curlink->next;
   if (iter->curlink) {
@@ -1024,8 +1025,15 @@ static void apply_meshadd_to_bmesh(BMesh *bm,
   BMEdge **new_bmes, **face_bmes;
   BMEdge *bme, *bme_eg;
   BMFace *bmf, *bmf_eg;
+#ifdef BOOLDEBUG
+  int dbg_level = 1;
+#endif
 
-  printf("\n\nAPPLY_MESHADD_TO_BMESH\n\n");
+#ifdef BOOLDEBUG
+  if (dbg_level > 0) {
+    printf("\n\nAPPLY_MESHADD_TO_BMESH\n\n");
+  }
+#endif
 
   /* Create new BMVerts. */
   bm_tot_v = bm->totvert;
@@ -1034,11 +1042,15 @@ static void apply_meshadd_to_bmesh(BMesh *bm,
     new_bmvs = BLI_array_alloca(new_bmvs, (size_t)tot_new_v);
     for (v = meshadd->vindex_start; v < meshadd->vindex_start + tot_new_v; v++) {
       newvert = meshadd_get_newvert(meshadd, v);
-      if (newvert->example != -1) {
-        printf("implement using example to create BMVert\n");
-      }
       BLI_assert(newvert != NULL);
       bmv = BM_vert_create(bm, newvert->co, NULL, 0);
+#ifdef BOOLDEBUG
+      if (dbg_level > 0) {
+        printf("created new BMVert for new vert %d at (%f,%f,%f)\n", v, F3(newvert->co));
+        printf("  -> bmv=%p\n", bmv);
+        /* BM_mesh_validate(bm); */
+      }
+#endif
       new_bmvs[v - meshadd->vindex_start] = bmv;
     }
   }
@@ -1085,6 +1097,18 @@ static void apply_meshadd_to_bmesh(BMesh *bm,
       }
       BLI_assert(bmv2 != NULL);
       bme = BM_edge_create(bm, bmv1, bmv2, bme_eg, BM_CREATE_NO_DOUBLE);
+#ifdef BOOLDEBUG
+      if (dbg_level > 0) {
+        printf("created BMEdge for new edge %d, v1=%d, v2=%d, bmv1=%p, bmv2=%p\n",
+               e,
+               v1,
+               v2,
+               bmv1,
+               bmv2);
+        printf("  -> bme=%p\n", bme);
+        /* BM_mesh_validate(bm); */
+      }
+#endif
       new_bmes[e - meshadd->eindex_start] = bme;
     }
   }
@@ -1133,7 +1157,14 @@ static void apply_meshadd_to_bmesh(BMesh *bm,
         BLI_assert(bme != NULL);
         face_bmes[i] = bme;
       }
-      BM_face_create(bm, face_bmvs, face_bmes, facelen, bmf_eg, 0);
+      bmf = BM_face_create(bm, face_bmvs, face_bmes, facelen, bmf_eg, 0);
+#ifdef BOOLDEBUG
+      if (dbg_level > 0) {
+        printf("created BMFace for new face %d\n", f);
+        printf("  -> bmf = %p\n", bmf);
+        /* BM_mesh_validate(bm); */
+      }
+#endif
     }
   }
 
@@ -1143,12 +1174,36 @@ static void apply_meshadd_to_bmesh(BMesh *bm,
     if (meshdelete_find_face(meshdelete, f)) {
       bmf = bm->ftable[f];
       BM_face_kill(bm, bmf);
+#ifdef BOOLDEBUG
+      if (dbg_level > 0) {
+        printf("killed bmf=%p for ftable[%d]\n", bmf, f);
+        /* BM_mesh_validate(bm); */
+      }
+#endif
     }
   }
   for (e = 0; e < bm_tot_e; e++) {
     if (meshdelete_find_edge(meshdelete, e)) {
       bme = bm->etable[e];
       BM_edge_kill(bm, bme);
+#ifdef BOOLDEBUG
+      if (dbg_level > 0) {
+        printf("killed bme=%p for etable[%d]\n", bme, e);
+        /* BM_mesh_validate(bm); */
+      }
+#endif
+    }
+  }
+  for (v = 0; v < bm_tot_v; v++) {
+    if (meshdelete_find_vert(meshdelete, v)) {
+      bmv = bm->vtable[v];
+      BM_vert_kill(bm, bmv);
+#ifdef BOOLDEBUG
+       if (dbg_level > 0) {
+         printf("killed bmv=%p for vtable[%d]\n", bmv, v);
+         /* BM_mesh_validate(bm); */
+       }
+#endif
     }
   }
 }
@@ -1222,7 +1277,7 @@ static int meshadd_add_vert(
 
   if (checkdup) {
     for (ln = meshadd->verts.list, i = meshadd->vindex_start; ln; ln = ln->next, i++) {
-      if (compare_v3v3((float *)ln->link, co, bs->eps)) {
+      if (compare_v3v3((float *)ln->link, co, (float)bs->eps)) {
         return i;
       }
     }
@@ -1707,7 +1762,7 @@ static void add_face_to_part(BoolState *bs, MeshPart *part, int f)
 /* If part consists of only one face from IMesh, return the number of vertices
  * in the face. Else return 0.
  */
-static int part_is_one_im_face(BoolState *bs, const MeshPart *part)
+ATTU static int part_is_one_im_face(BoolState *bs, const MeshPart *part)
 {
   int f;
 
@@ -1869,19 +1924,33 @@ static PartPartIntersect *self_intersect_part_and_ppis(BoolState *bs,
   double mat_2d_inv[3][3];
   double xyz[3], save_z, p[3], q[3];
   bool ok;
+#ifdef BOOLDEBUG
+  int dbg_level = 0;
+#endif
 
-  dump_part(part, "self_intersect_part");
-  printf("ppis\n");
-  for (ln = ppis->list; ln; ln = ln->next) {
-    ppi = (PartPartIntersect *)ln->link;
-    dump_partpartintersect(ppi, "");
+#ifdef BOOLDEBUG
+  if (dbg_level > 0) {
+    printf("\nSELF_INTERSECT_PART_AND_PPIS\n\n");
+    if (dbg_level > 1) {
+      dump_part(part, "self_intersect_part");
+      printf("ppis\n");
+      for (ln = ppis->list; ln; ln = ln->next) {
+        ppi = (PartPartIntersect *)ln->link;
+        dump_partpartintersect(ppi, "");
+      }
+    }
   }
+#endif
   /* Find which vertices are needed for CDT input */
   part_nf = part_totface(part);
   part_ne = part_totedge(part);
   part_nv = part_totvert(part);
   if (part_nf <= 1 && part_ne == 0 && part_nv == 0 && ppis->list == NULL) {
-    printf("trivial 1 face case\n");
+#ifdef BOOLDEBUG
+    if (dbg_level > 0) {
+      printf("trivial 1 face case\n");
+    }
+#endif
     return NULL;
   }
   init_intset(&verts_needed);
@@ -1893,7 +1962,11 @@ static PartPartIntersect *self_intersect_part_and_ppis(BoolState *bs,
   init_imeshplus(&imp, &bs->im, meshadd);
 
   /* nfaceverts will accumulate the total lengths of all faces added. */
-  printf("gathering needed edges and verts\n");
+#ifdef BOOLDEBUG
+  if (dbg_level > 0) {
+    printf("\nself_intersect_part_and_ppis: gathering needed edges and verts\n\n");
+  }
+#endif
   nfaceverts = 0;
   for (i = 0; i < part_nf; i++) {
     f = part_face(part, i);
@@ -1905,11 +1978,9 @@ static PartPartIntersect *self_intersect_part_and_ppis(BoolState *bs,
       BLI_assert(v != -1);
       v_index = add_int_to_intset(bs, &verts_needed, v);
       add_to_intintmap(bs, &in_to_vmap, v_index, v);
-      printf("A. in_to_vmap[%d] = %d\n", v_index, v);
     }
     f_index = add_int_to_intset(bs, &faces_needed, f);
     add_to_intintmap(bs, &in_to_fmap, f_index, f);
-    printf("B. in_to_fmap[%d] = %d\n", f_index, f);
   }
   for (i = 0; i < part_ne; i++) {
     e = part_edge(part, i);
@@ -1918,20 +1989,16 @@ static PartPartIntersect *self_intersect_part_and_ppis(BoolState *bs,
     BLI_assert(v1 != -1 && v2 != -1);
     v_index = add_int_to_intset(bs, &verts_needed, v1);
     add_to_intintmap(bs, &in_to_vmap, v_index, v1);
-    printf("C. in_to_vmap[%d] = %d\n", v_index, v1);
     v_index = add_int_to_intset(bs, &verts_needed, v2);
     add_to_intintmap(bs, &in_to_vmap, v_index, v2);
-    printf("D. in_to_vmap[%d] = %d\n", v_index, v2);
     e_index = add_int_to_intset(bs, &edges_needed, e);
     add_to_intintmap(bs, &in_to_emap, e_index, e);
-    printf("E. in_to_emap[%d] = %d\n", e_index, e);
   }
   for (i = 0; i < part_nv; i++) {
     v = part_vert(part, i);
     BLI_assert(v != -1);
     v_index = add_int_to_intset(bs, &verts_needed, v);
     add_to_intintmap(bs, &in_to_vmap, v_index, v);
-    printf("F. in_to_vmap[%d] = %d\n", v_index, v);
   }
   for (ln = ppis->list; ln; ln = ln->next) {
     ppi = (PartPartIntersect *)ln->link;
@@ -1939,7 +2006,6 @@ static PartPartIntersect *self_intersect_part_and_ppis(BoolState *bs,
       v = POINTER_AS_INT(lnv->link);
       v_index = add_int_to_intset(bs, &verts_needed, v);
       add_to_intintmap(bs, &in_to_vmap, v_index, v);
-      printf("G. in_to_vmap[%d] = %d\n", v_index, v);
     }
     for (lne = ppi->edges.list; lne; lne = lne->next) {
       e = POINTER_AS_INT(lne->link);
@@ -1947,13 +2013,10 @@ static PartPartIntersect *self_intersect_part_and_ppis(

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list