resolve some compiler warnings with intel c/c++ compiler
[blender.git] / source / blender / blenkernel / intern / BME_eulers.c
index 8ef46be1072283f1d49eb98e2a1f18f03d341a38..801e0b8bdec9ff97cdf3115eb4228f890e9fdf05 100644 (file)
@@ -5,14 +5,12 @@
  *
  * $Id: BME_eulers.c,v 1.00 2007/01/17 17:42:01 Briggs Exp $
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
+ * of the License, or (at your option) any later version.
  * about this. 
  *
  * This program is distributed in the hope that it will be useful,
@@ -31,7 +29,7 @@
  *
  * Contributor(s): Geoffrey Bantle.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 #include "MEM_guardedalloc.h"
@@ -41,6 +39,7 @@
 #include "DNA_mesh_types.h"
 
 #include "BKE_utildefines.h"
+#include "BKE_customdata.h"
 #include "BKE_bmesh.h"
 
 #include "BLI_blenlib.h"
@@ -230,9 +229,14 @@ BME_Poly *BME_MF(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge **elist, int
        tv = v1;
        curvert = v2;
        
+       if(bm->vtarlen < len){
+               MEM_freeN(bm->vtar);
+               bm->vtar = MEM_callocN(sizeof(BME_Vert *)* len, "BMesh Vert pointer array");
+               bm->vtarlen = len;
+       }
        /*insert tv into vlist since its the first vertex in face*/
        i=0;
-       vlist=MEM_callocN(sizeof(BME_Vert*)*len,"BME_MF vlist array");
+       vlist=bm->vtar;
        vlist[i] = tv;
 
        /*      Basic procedure: Starting with curv we find the edge in it's disk cycle which hasn't 
@@ -311,8 +315,6 @@ BME_Poly *BME_MF(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge **elist, int
                        if(edok != (l->e->eflag2 + 1)) BME_error();
                }
        }
-       
-       MEM_freeN(vlist);
        return f;
 }
 
@@ -617,8 +619,8 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo
        BME_disk_append_edge(e, v2);
        
        f2 = BME_addpolylist(bm,f);
-       f1loop = BME_create_loop(bm,v2,e,f,NULL);
-       f2loop = BME_create_loop(bm,v1,e,f2,NULL);
+       f1loop = BME_create_loop(bm,v2,e,f,v2loop);
+       f2loop = BME_create_loop(bm,v1,e,f2,v1loop);
        
        f1loop->prev = v2loop->prev;
        f2loop->prev = v1loop->prev;
@@ -662,16 +664,16 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo
  *     Takes a an edge and pointer to one of its vertices and collapses
  *     the edge on that vertex.
  *     
- *     Before:             OE      KE
+ *     Before:    OE      KE
  *                      ------- -------
  *               |     ||      |
- *                             OV     KV      TV
+ *             OV     KV      TV
  *
  *
  *   After:             OE      
  *                      ---------------
  *               |             |
- *                             OV             TV
+ *             OV             TV
  *
  *
  *     Restrictions:
@@ -722,6 +724,8 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv)
                        /*remove ke from tv's disk cycle*/
                        BME_disk_remove_edge(ke, tv);
                
+                       
+
                        /*deal with radial cycle of ke*/
                        if(ke->loop){
                                /*first step, fix the neighboring loops of all loops in ke's radial cycle*/
@@ -739,18 +743,30 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv)
                                /*second step, remove all the hanging loops attached to ke*/
                                killoop = ke->loop;
                                radlen = BME_cycle_length(&(ke->loop->radial));
+                               /*make sure we have enough room in bm->lpar*/
+                               if(bm->lparlen < radlen){
+                                       MEM_freeN(bm->lpar);
+                                       bm->lpar = MEM_callocN(sizeof(BME_Loop *)* radlen, "BMesh Loop pointer array");
+                                       bm->lparlen = bm->lparlen * radlen;
+                               }
+                               /*this should be wrapped into a bme_free_radial function to be used by BME_KF as well...*/
                                i=0;
                                while(i<radlen){
-                                       nextl = killoop->radial.next->data;
-                                       BME_free_loop(bm, killoop);
-                                       killoop = nextl;
+                                       bm->lpar[i] = killoop;
+                                       killoop = killoop->radial.next->data;
                                        i++;
-                               }       
+                               }
+                               i=0;
+                               while(i<radlen){
+                                       BME_free_loop(bm,bm->lpar[i]);
+                                       i++;
+                               }
                                /*Validate radial cycle of oe*/
                                edok = BME_cycle_validate(radlen,&(oe->loop->radial));
                                
                        }
                        
+
                        /*Validate disk cycles*/
                        diskbase = BME_disk_getpointer(ov->edge,ov);
                        edok = BME_cycle_validate(valance1, diskbase);
@@ -794,14 +810,13 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv)
 
 int BME_loop_reverse(BME_Mesh *bm, BME_Poly *f){
        BME_Loop *l = f->loopbase, *curloop, *oldprev, *oldnext;
-       BME_Edge **elist;
        int i, j, edok, len = 0;
 
        len = BME_cycle_length(l);
        if(bm->edarlen < len){
                MEM_freeN(bm->edar);
                bm->edar = MEM_callocN(sizeof(BME_Edge *)* len, "BMesh Edge pointer array");
-               bm->edarlen = bm->edarlen * len;
+               bm->edarlen = len;
        }
        
        for(i=0, curloop = l; i< len; i++, curloop=curloop->next){
@@ -840,11 +855,8 @@ int BME_loop_reverse(BME_Mesh *bm, BME_Poly *f){
                }
        }
        /*rebuild radial*/
-       for(i=0, curloop = l; i < len; i++, curloop = curloop->next){
-               BME_radial_append(curloop->e, curloop);
-               //radok = BME_cycle_validate(curloop->e->tmp.l, &(curloop->radial));
-               //if(!radok || curloop->e->loop == NULL) BME_error();
-       }
+       for(i=0, curloop = l; i < len; i++, curloop = curloop->next) BME_radial_append(curloop->e, curloop);
+       
        /*validate radial*/
        for(i=0, curloop = l; i < len; i++, curloop = curloop->next){
                edok = BME_cycle_validate(curloop->e->eflag2, &(curloop->radial));
@@ -893,7 +905,6 @@ BME_Poly *BME_JFKE(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e)
        BME_Loop *curloop, *f1loop=NULL, *f2loop=NULL;
        int loopok = 0, newlen = 0,i, f1len=0, f2len=0, radlen=0, edok;
        
-       if(f1->holes.first || f2->holes.first) return NULL; //dont operate on faces with holes. Not best solution but tolerable.
        if(f1 == f2) return NULL; //can't join a face to itself
        /*verify that e is in both f1 and f2*/
        f1len = BME_cycle_length(f1->loopbase);
@@ -963,4 +974,4 @@ BME_Poly *BME_JFKE(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e)
        BME_free_loop(bm, f2loop);
        BME_free_poly(bm, f2);  
        return f1;
-}
\ No newline at end of file
+}