Commit: 36fa6826a8935abd3590e6a6f76ff08919dd1e6b
Author: Martin Felke
Date:   Sun Oct 5 20:35:26 2014 +0200
Branches: fracture_modifier
https://developer.blender.org/rB36fa6826a8935abd3590e6a6f76ff08919dd1e6b

cleanup, removed old unused code (old access method with filepointer)

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

M       extern/voro++/src/c_interface.cc
M       extern/voro++/src/c_interface.hh
M       source/blender/blenkernel/intern/fracture.c

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

diff --git a/extern/voro++/src/c_interface.cc b/extern/voro++/src/c_interface.cc
index ea6b053..0522f19 100644
--- a/extern/voro++/src/c_interface.cc
+++ b/extern/voro++/src/c_interface.cc
@@ -16,14 +16,6 @@ particle_order* particle_order_new(void)
        return (particle_order*)(new voro::particle_order());
 }
 
-loop_order* loop_order_new(container* con, particle_order* p_order)
-{
-       voro::container* c = (voro::container*)con;
-       voro::particle_order* po = (voro::particle_order*)p_order;
-       
-       return (loop_order*)(new voro::c_loop_order(*c, *po));
-}
-
 void container_put(container* con, particle_order* p_order, int n,double 
x,double y,double z)
 {
        voro::container* c = (voro::container*)con;
@@ -40,18 +32,6 @@ void container_put(container* con, particle_order* p_order, 
int n,double x,doubl
        
 }
 
-// redesign... need a struct with function pointers which are callable from C, 
call C++ functions themselves and return their returnvalues to C
-// first we need to iterate over a container, lets maybe return a vector of 
cells here
-// this will be converted to an array of equivalent cell structs
-
-void container_print_custom(loop_order* l_order, container* con, const char* 
format, FILE* fp)
-{
-       voro::container* c = (voro::container*)con;
-       voro::c_loop_order* lo = (voro::c_loop_order*)l_order;
-       
-       c->print_custom(*lo, format, fp);
-}
-
 void container_compute_cells(container* con, cell* cells)
 {
        int i = 0, v = 0, fo = 0, fv = 0, n = 0;
@@ -71,10 +51,10 @@ void container_compute_cells(container* con, cell* cells)
                                double *pp, centroid[3];
                                pp = vl.p[vl.ijk]+vl.ps*vl.q;
 
-                               //cell particle index
+                               // cell particle index
                                c.index = cn->id[vl.ijk][vl.q];
 
-                               //verts
+                               // verts
                                vc.vertices(*pp, pp[1], pp[2], verts);
                                c.totvert = vc.p;
                                c.verts = new float[c.totvert][3];
@@ -84,7 +64,7 @@ void container_compute_cells(container* con, cell* cells)
                                        c.verts[v][2] = (float)verts[v * 3 + 2];
                                }
 
-                               //faces
+                               // faces
                                c.totpoly = vc.number_of_faces();
                                vc.face_orders(face_orders);
                                c.poly_totvert = new int[c.totpoly];
@@ -105,7 +85,7 @@ void container_compute_cells(container* con, cell* cells)
                                        skip += (num_verts+1);
                                }
 
-                               //neighbors
+                               // neighbors
                                vc.neighbors(neighbors);
                                c.neighbors = new int[c.totpoly];
                                for (n = 0; n < c.totpoly; n++)
@@ -113,18 +93,27 @@ void container_compute_cells(container* con, cell* cells)
                                        c.neighbors[n] = neighbors[n];
                                }
 
-                               //centroid
+                               // centroid
                                vc.centroid(centroid[0], centroid[1], 
centroid[2]);
                                c.centroid[0] = (float)centroid[0] + (float)*pp;
                                c.centroid[1] = (float)centroid[1] + 
(float)pp[1];
                                c.centroid[2] = (float)centroid[2] + 
(float)pp[2];
 
-                               //valid cell, store
+                               // valid cell, store
                                cells[i] = c;
 
                        }
-                       else {//invalid cell, set NULL XXX TODO (Somehow !!!)
-                               cells[i] = c;
+                       else { // invalid cell, set NULL XXX TODO (Somehow !!!)
+                               c.centroid[0] = 0.0f;
+                               c.centroid[1] = 0.0f;
+                               c.centroid[2] = 0.0f;
+                               c.index = 0;
+                               c.neighbors = NULL;
+                               c.totpoly = 0;
+                               c.totvert = 0;
+                               c.poly_totvert = NULL;
+                               c.poly_indices = NULL;
+                               c.verts = NULL;
                        }
                        i++;
                }
@@ -138,12 +127,6 @@ void container_free(container* con)
        delete c;
 }
 
-void loop_order_free(loop_order* l_order)
-{
-       voro::c_loop_order* lo = (voro::c_loop_order*)l_order;
-       delete lo;
-}
-
 void particle_order_free(particle_order* p_order)
 {
        voro::particle_order* po = (voro::particle_order*)p_order;
diff --git a/extern/voro++/src/c_interface.hh b/extern/voro++/src/c_interface.hh
index af29288..f0f584c 100644
--- a/extern/voro++/src/c_interface.hh
+++ b/extern/voro++/src/c_interface.hh
@@ -46,13 +46,10 @@ typedef struct cell {
 container* container_new(double ax_,double bx_,double ay_,double by_,double 
az_,double bz_,
                          int nx_,int ny_,int nz_,int xperiodic_,int 
yperiodic_,int zperiodic_,int init_mem);
 particle_order* particle_order_new(void);
-loop_order* loop_order_new(container* con, particle_order* po);
 
 void container_put(container* con, particle_order* po, int n, double x, double 
y, double z);
-void container_print_custom(loop_order* lo, container* con, const char* 
format, FILE* fp);
 
 void container_free(container* con);
-void loop_order_free(loop_order* lo);
 void particle_order_free(particle_order* po);
 
 // cell array for direct access
diff --git a/source/blender/blenkernel/intern/fracture.c 
b/source/blender/blenkernel/intern/fracture.c
index 7917816..d52db19 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -72,24 +72,12 @@
 #endif
 
 /* prototypes */
-#if 0
-static void parse_stream(FILE *fp, int expected_shards, ShardID shard_id, 
FracMesh *fm, int algorithm, Object *obj, DerivedMesh *dm, short 
inner_material_index);
-static Shard *parse_shard(FILE *fp);
-static void parse_verts(FILE *fp, MVert *mvert, int totvert);
-static void parse_polys(FILE *fp, MPoly *mpoly, int totpoly, int *r_totloop);
-static void parse_loops(FILE *fp, MLoop *mloop, int totloop, MPoly *mpoly, int 
totpoly);
-static void parse_neighbors(FILE *fp, int *neighbors, int totpoly);
-#endif
-
 static void add_shard(FracMesh *fm, Shard *s);
-
-#if 1
 static Shard *parse_cell(cell c);
 static void parse_cell_verts(cell c, MVert *mvert, int totvert);
 static void parse_cell_polys(cell c, MPoly *mpoly, int totpoly, int 
*r_totloop);
 static void parse_cell_loops(cell c, MLoop *mloop, int totloop, MPoly *mpoly, 
int totpoly);
 static void parse_cell_neighbors(cell c, int *neighbors, int totpoly);
-#endif
 
 static void add_shard(FracMesh *fm, Shard *s)
 {
@@ -170,360 +158,6 @@ static int shard_sortsize(const void *s1, const void *s2, 
void* context)
                                return  0;
 }
 
-#if 0
-/* parse the voro++ raw data */
-static void parse_stream(FILE *fp, int expected_shards, ShardID parent_id, 
FracMesh *fm, int algorithm, Object* obj, DerivedMesh *dm, short 
inner_material_index)
-{
-       /*Parse voronoi raw data*/
-       int i = 0;
-       Shard* s = NULL, *p = BKE_shard_by_id(fm, parent_id, dm);
-       float obmat[4][4]; /* use unit matrix for now */
-       float centroid[3];
-       BMesh* bm_parent = NULL;
-       DerivedMesh *dm_parent = NULL;
-       Shard **tempshards;
-       Shard **tempresults;
-
-       tempshards = MEM_mallocN(sizeof(Shard*) * expected_shards, 
"tempshards");
-       tempresults = MEM_mallocN(sizeof(Shard*) * expected_shards, 
"tempresults");
-
-       p->flag = 0;
-       p->flag |= SHARD_FRACTURED;
-       unit_m4(obmat);
-
-       if (algorithm == MOD_FRACTURE_BOOLEAN) {
-               MPoly* mpoly, *mp;
-               int totpoly, i;
-               dm_parent = BKE_shard_create_dm(p, true);
-               mpoly = dm_parent->getPolyArray(dm_parent);
-               totpoly = dm_parent->getNumPolys(dm_parent);
-               for (i = 0, mp = mpoly; i < totpoly; i++, mp++) {
-                       mp->flag &= ~ME_FACE_SEL;
-               }
-       }
-       else if (algorithm == MOD_FRACTURE_BISECT || algorithm == 
MOD_FRACTURE_BISECT_FILL ||
-                algorithm == MOD_FRACTURE_BISECT_FAST || algorithm == 
MOD_FRACTURE_BISECT_FAST_FILL)
-       {
-#define MYTAG (1 << 6)
-               bm_parent = shard_to_bmesh(p);
-               copy_v3_v3(centroid, p->centroid);
-       }
-
-       for (i = 0; i < expected_shards; i++) {
-               if (fm->cancel == 1) {
-                       break;
-               }
-
-               printf("Parsing shard: %d\n", i);
-               s = parse_shard(fp);
-               tempshards[i] = s;
-               tempresults[i] = NULL;
-               fm->progress_counter++;
-       }
-
-       if (algorithm != MOD_FRACTURE_BISECT_FAST && algorithm != 
MOD_FRACTURE_BISECT_FAST_FILL) {
-               for (i = 0; i < expected_shards; i++) {
-                       Shard* t;
-                       if (fm->cancel == 1)
-                               break;
-
-                       printf("Processing shard: %d\n", i);
-                       t = tempshards[i];
-
-                       if (t != NULL) {
-                               t->parent_id = parent_id;
-                               t->flag = SHARD_INTACT;
-                       }
-
-                       if (t == NULL || t->totvert == 0 || t->totloop == 0 || 
t->totpoly == 0) {
-                               /* invalid shard, stop parsing */
-                               break;
-                       }
-
-                       /* XXX TODO, need object for material as well, or 
atleast a material index... */
-                       if (algorithm == MOD_FRACTURE_BOOLEAN) {
-                               s = BKE_fracture_shard_boolean(obj, dm_parent, 
t, inner_material_index);
-                       }
-                       else if (algorithm == MOD_FRACTURE_BISECT || algorithm 
== MOD_FRACTURE_BISECT_FILL) {
-                               float co[3] = {0, 0, 0};
-                               printf("Bisecting cell %d...\n", i);
-                               s = BKE_fracture_shard_bisect(bm_parent, t, 
obmat, algorithm == MOD_FRACTURE_BISECT_FILL, false, true, 0, co, 
inner_material_index);
-                       }
-                       else {
-                               /* do not fracture case */
-                               s = t;
-                       }
-
-                       if (s != NULL) {
-                               s->parent_id = parent_id;
-                               s->flag = SHARD_INTACT;
-
-                               tempresults[i] = s;
-                       }
-
-                       fm->progress_counter++;
-               }
-       }
-       else {
-               for (i = 0; i < expected_shards; i++) {
-                       Shard* s = NULL;
-                       Shard* s2 = NULL;
-                       Shard* t;
-                       int index = 0;
-
-                       if (fm->cancel == 1) {
-                               break;
-                       }
-
-                       printf("Processing shard: %d\n", i);
-                       t = tempshards[i];
-
-                       if (t != NULL) {
-                               t->parent_id = parent_id;
-                               t->flag = SHARD_INTACT;
-                       }
-
-                       if (t == NULL || t->totvert == 0 || t->totloop == 0 || 
t->totpoly == 0) {
-                               /* invalid shard, stop parsing*/
-                               break;
-                       }
-
-                       index = (int)(BLI_frand() * (t->totpoly-1));
-                       if (index == 0) {
-                               index = 1;
-                       }
-
-                       printf("Bisecting cell %d...\n", i);
-                       printf("Bisecting cell %d...\n", i+1);
-
-                       s = BKE_fracture_shard_bisect(bm_parent, t, obmat, 
algorithm == MOD_FRACTURE_BISECT_FAST_FILL, false, true, index, centroid, 
inner_material_index);
-                       s2 = BKE_fracture_shard_bisect(bm_parent, t, obmat, 
algorithm == MOD_FRACTURE_BISECT_FAST_FILL, true, false, index, centroid, 
inner_material_index);
-
-                       if (s != NULL && s2 != NULL && tempresults != NULL) {
-                               int j = 0;
-
-                               fm->progress_counter++;
-
-                               s->parent_id = parent_id;
-                               s->flag = SHARD_INTACT;
-
-                               s2->parent_id = parent_id;
-                               s2->flag = SHARD_INTACT;
-
-                               if (bm_parent != NULL) {
-                                       BM_mesh_free(bm_parent);
-                                       bm_parent = NULL;
-                               }
-
-                               if (dm_parent != NULL) {
-                                       dm_parent->needsFree = 1;
-                                       dm_parent->release(dm_parent);
-                                       dm_parent = NULL;
-                               }
-                               tempresults[i] = s;
-                               tempresults[i+1] = s2;
-
-                               BLI_qsort_r(tempresults, i+1, sizeof(Shard*), 
shard_sortsize, i);
-
-                               while (tempresults[j] == NULL && j < (i+1)) {
-                                       /* ignore invalid shards */
-                                       j++;
-                               }
-
-                               /* cont

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to