From 3e8ddef8e570757dab6fd9b51aa0088e03d4aaaf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2011 02:28:11 +0000 Subject: move validation into blender kernel so it can be called by internal modifier funcs more easily. --- source/blender/blenkernel/BKE_mesh.h | 10 +- source/blender/blenkernel/CMakeLists.txt | 1 + source/blender/blenkernel/intern/mesh_validate.c | 259 +++++++++++++++++++++++ source/blender/editors/include/ED_mesh.h | 4 - source/blender/editors/mesh/CMakeLists.txt | 1 - source/blender/editors/mesh/mesh_validate.c | 252 ---------------------- source/blender/makesrna/intern/rna_mesh_api.c | 7 +- 7 files changed, 273 insertions(+), 261 deletions(-) create mode 100644 source/blender/blenkernel/intern/mesh_validate.c delete mode 100644 source/blender/editors/mesh/mesh_validate.c (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 398e1d8a7f5..85b5ec96275 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -47,6 +47,8 @@ struct Object; struct MTFace; struct VecNor; struct CustomData; +struct DerivedMesh; +struct Scene; #ifdef __cplusplus extern "C" { @@ -147,9 +149,13 @@ int mesh_center_median(struct Mesh *me, float cent[3]); int mesh_center_bounds(struct Mesh *me, float cent[3]); void mesh_translate(struct Mesh *me, float offset[3], int do_keys); +/* mesh_validate.c */ +void BKE_mesh_validate_arrays(struct MVert *mverts, int totvert, struct MEdge *medges, int totedge, struct MFace *mfaces, int totface); +void BKE_mesh_validate(struct Mesh *me); +void BKE_mesh_validate_dm(struct DerivedMesh *dm); + #ifdef __cplusplus } #endif -#endif - +#endif /* BKE_MESH_H */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 63214f6ee11..5f5b413ecd8 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -105,6 +105,7 @@ set(SRC intern/material.c intern/mball.c intern/mesh.c + intern/mesh_validate.c intern/modifier.c intern/multires.c intern/nla.c diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c new file mode 100644 index 00000000000..4cef8c5560e --- /dev/null +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -0,0 +1,259 @@ +/** + * $Id: mesh_ops.c 34569 2011-01-30 16:19:08Z ton $ + * + * ***** 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2011 Blender Foundation. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BLI_utildefines.h" +#include "BLI_edgehash.h" + +#include "BKE_DerivedMesh.h" + +#include "MEM_guardedalloc.h" + +#include "ED_mesh.h" + +typedef struct SearchFace { + unsigned int v[4]; + unsigned int index; +} SearchFace; + +static int uint_cmp(const void *v1, const void *v2) +{ + const unsigned int x1= GET_INT_FROM_POINTER(v1), x2= GET_INT_FROM_POINTER(v2); + + if( x1 > x2 ) return 1; + else if( x1 < x2 ) return -1; + return 0; +} + +static int search_face_cmp(const void *v1, const void *v2) +{ + const SearchFace *sfa= v1, *sfb= v2; + + if (sfa->v[0] > sfb->v[0]) return 1; + else if (sfa->v[0] < sfb->v[0]) return -1; + + if (sfa->v[1] > sfb->v[1]) return 1; + else if (sfa->v[1] < sfb->v[1]) return -1; + + if (sfa->v[2] > sfb->v[2]) return 1; + else if (sfa->v[2] < sfb->v[2]) return -1; + + if (sfa->v[3] > sfb->v[3]) return 1; + else if (sfa->v[3] < sfb->v[3]) return -1; + + return 0; +} + +void BKE_mesh_validate_arrays(MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface) +{ +// MVert *mv; + MEdge *med; + MFace *mf; + int i; + + EdgeHash *edge_hash = BLI_edgehash_new(); + + SearchFace *search_faces= MEM_callocN(sizeof(SearchFace) * totface, "search faces"); + SearchFace *sf; + SearchFace *sf_prev; + + printf("ED_mesh_validate: verts(%d), edges(%d), faces(%d)\n", totvert, totedge, totface); + + if(totedge==0 && totface != 0) { + printf(" locical error, %d faces and 0 edges\n", totface); + } + + for(i=0, med=medges; iv1 == med->v2) { + printf(" edge %d: has matching verts, both %d\n", i, med->v1); + } + if(med->v1 < 0 || med->v1 >= totvert) { + printf(" edge %d: v1 index out of range, %d\n", i, med->v1); + } + if(med->v2 < 0 || med->v2 >= totvert) { + printf(" edge %d: v2 index out of range, %d\n", i, med->v2); + } + + if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) { + printf(" edge %d: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); + } + + BLI_edgehash_insert(edge_hash, med->v1, med->v2, SET_INT_IN_POINTER(i)); + } + + for(i=0, mf=mfaces; iv4 ? 3:2; + do { + fverts[fidx]= *(&mf->v1 + fidx); + if(fverts[fidx] < 0 || fverts[fidx] >= totvert) { + printf(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fverts[fidx]); + } + } while (fidx--); + + if(mf->v4) { + if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); + if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); + if(mf->v1 == mf->v4) printf(" face %d: verts invalid, v1/v4 both %d\n", i, mf->v1); + + if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); + if(mf->v2 == mf->v4) printf(" face %d: verts invalid, v2/v4 both %d\n", i, mf->v2); + + if(mf->v3 == mf->v4) printf(" face %d: verts invalid, v3/v4 both %d\n", i, mf->v3); + + if(totedge) { + if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); + if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); + if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) printf(" face %d: edge v3/v4 (%d,%d) is missing egde data\n", i, mf->v3, mf->v4); + if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) printf(" face %d: edge v4/v1 (%d,%d) is missing egde data\n", i, mf->v4, mf->v1); + } + /* TODO, avoid double lookop */ + /* + fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); + fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); + fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v4)); + fedges[3]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v4, mf->v1)); + */ + qsort(fverts, 4, sizeof(int), uint_cmp); + } + else { + if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); + if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); + + if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); + + if(totedge) { + if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); + if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); + if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) printf(" face %d: edge v3/v1 (%d,%d) is missing egde data\n", i, mf->v3, mf->v1); + } + /* TODO, avoid double lookop */ + /* + fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); + fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); + fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v1)); + */ + qsort(fverts, 3, sizeof(int), uint_cmp); + } + + search_faces[i].index = i; + + if(mf->v4) { + search_faces[i].v[0] = fverts[0]; + search_faces[i].v[1] = fverts[1]; + search_faces[i].v[2] = fverts[2]; + search_faces[i].v[3] = fverts[3]; + } + else { + search_faces[i].v[0] = fverts[0]; + search_faces[i].v[1] = fverts[1]; + search_faces[i].v[2] = fverts[2]; + search_faces[i].v[3] = UINT_MAX; + } + } + + qsort(search_faces, totface, sizeof(SearchFace), search_face_cmp); + + sf= search_faces; + sf_prev= sf; + sf++; + + for(i=1; iv, sf_prev->v, sizeof(sf_prev->v)) == 0) { + /* slow, could be smarter here */ + MFace *mf= mfaces + sf->index; + MFace *mf_prev= mfaces + sf_prev->index; + int size_expect, size_found; + + EdgeHash *eh_tmp= BLI_edgehash_new(); + if(mf->v4) { + BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf->v3, mf->v4, NULL); + BLI_edgehash_insert(eh_tmp, mf->v4, mf->v1, NULL); + + BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v4, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v4, mf_prev->v1, NULL); + + size_expect= 4; + } + else { + BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf->v3, mf->v1, NULL); + + BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v1, NULL); + + size_expect= 3; + } + + size_found= BLI_edgehash_size(eh_tmp); + BLI_edgehash_free(eh_tmp, NULL); + + if(size_found != size_expect) { + printf(" face %d & %d: are duplicates ", sf->index, sf_prev->index); + if(mf->v4) { + printf("(%d,%d,%d,%d) ", mf->v1, mf->v2, mf->v3, mf->v4); + printf("(%d,%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); + } + else { + printf("(%d,%d,%d) ", mf->v1, mf->v2, mf->v3); + printf("(%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3); + } + } + } + } + + BLI_edgehash_free(edge_hash, NULL); + MEM_freeN(search_faces); + + printf("BKE_mesh_validate: finished\n\n"); +} + +void BKE_mesh_validate(Mesh *me) +{ + printf("MESH: %s\n", me->id.name+2); + BKE_mesh_validate_arrays(me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface); +} + +void BKE_mesh_validate_dm(DerivedMesh *dm) +{ + BKE_mesh_validate_arrays(dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm)); +} diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 451bbe53bc9..057e5d3bf88 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -82,10 +82,6 @@ struct rcti; #define B_FRACTAL 0x2000 #define B_SPHERE 0x4000 -/* mesh_validate.c */ -void ED_mesh_validate_arrays(struct MVert *mverts, int totvert, struct MEdge *medges, int totedge, struct MFace *mfaces, int totface); -void ED_mesh_validate(struct Mesh *me); - /* meshtools.c */ intptr_t mesh_octree_table(struct Object *ob, struct EditMesh *em, float *co, char mode); diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index eabc0a599ff..82d1c7430fc 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -42,7 +42,6 @@ set(SRC loopcut.c mesh_data.c mesh_ops.c - mesh_validate.c meshtools.c mesh_intern.h diff --git a/source/blender/editors/mesh/mesh_validate.c b/source/blender/editors/mesh/mesh_validate.c deleted file mode 100644 index 667287e6a43..00000000000 --- a/source/blender/editors/mesh/mesh_validate.c +++ /dev/null @@ -1,252 +0,0 @@ -/** - * $Id: mesh_ops.c 34569 2011-01-30 16:19:08Z ton $ - * - * ***** 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2011 Blender Foundation. - * All rights reserved. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include -#include -#include -#include - -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" - -#include "BLI_utildefines.h" -#include "BLI_edgehash.h" - -#include "MEM_guardedalloc.h" - -#include "ED_mesh.h" - -typedef struct SearchFace { - unsigned int v[4]; - unsigned int index; -} SearchFace; - -static int uint_cmp(const void *v1, const void *v2) -{ - const unsigned int x1= GET_INT_FROM_POINTER(v1), x2= GET_INT_FROM_POINTER(v2); - - if( x1 > x2 ) return 1; - else if( x1 < x2 ) return -1; - return 0; -} - -static int search_face_cmp(const void *v1, const void *v2) -{ - const SearchFace *sfa= v1, *sfb= v2; - - if (sfa->v[0] > sfb->v[0]) return 1; - else if (sfa->v[0] < sfb->v[0]) return -1; - - if (sfa->v[1] > sfb->v[1]) return 1; - else if (sfa->v[1] < sfb->v[1]) return -1; - - if (sfa->v[2] > sfb->v[2]) return 1; - else if (sfa->v[2] < sfb->v[2]) return -1; - - if (sfa->v[3] > sfb->v[3]) return 1; - else if (sfa->v[3] < sfb->v[3]) return -1; - - return 0; -} - -void ED_mesh_validate_arrays(MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface) -{ -// MVert *mv; - MEdge *med; - MFace *mf; - int i; - - EdgeHash *edge_hash = BLI_edgehash_new(); - - SearchFace *search_faces= MEM_callocN(sizeof(SearchFace) * totface, "search faces"); - SearchFace *sf; - SearchFace *sf_prev; - - printf("ED_mesh_validate: verts(%d), edges(%d), faces(%d)\n", totvert, totedge, totface); - - if(totedge==0 && totface != 0) { - printf(" locical error, %d faces and 0 edges\n", totface); - } - - for(i=0, med=medges; iv1 == med->v2) { - printf(" edge %d: has matching verts, both %d\n", i, med->v1); - } - if(med->v1 < 0 || med->v1 >= totvert) { - printf(" edge %d: v1 index out of range, %d\n", i, med->v1); - } - if(med->v2 < 0 || med->v2 >= totvert) { - printf(" edge %d: v2 index out of range, %d\n", i, med->v2); - } - - if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) { - printf(" edge %d: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); - } - - BLI_edgehash_insert(edge_hash, med->v1, med->v2, SET_INT_IN_POINTER(i)); - } - - for(i=0, mf=mfaces; iv4 ? 3:2; - do { - fverts[fidx]= *(&mf->v1 + fidx); - if(fverts[fidx] < 0 || fverts[fidx] >= totvert) { - printf(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fverts[fidx]); - } - } while (fidx--); - - if(mf->v4) { - if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); - if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); - if(mf->v1 == mf->v4) printf(" face %d: verts invalid, v1/v4 both %d\n", i, mf->v1); - - if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); - if(mf->v2 == mf->v4) printf(" face %d: verts invalid, v2/v4 both %d\n", i, mf->v2); - - if(mf->v3 == mf->v4) printf(" face %d: verts invalid, v3/v4 both %d\n", i, mf->v3); - - if(totedge) { - if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); - if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); - if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) printf(" face %d: edge v3/v4 (%d,%d) is missing egde data\n", i, mf->v3, mf->v4); - if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) printf(" face %d: edge v4/v1 (%d,%d) is missing egde data\n", i, mf->v4, mf->v1); - } - /* TODO, avoid double lookop */ - /* - fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); - fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); - fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v4)); - fedges[3]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v4, mf->v1)); - */ - qsort(fverts, 4, sizeof(int), uint_cmp); - } - else { - if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); - if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); - - if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); - - if(totedge) { - if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); - if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); - if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) printf(" face %d: edge v3/v1 (%d,%d) is missing egde data\n", i, mf->v3, mf->v1); - } - /* TODO, avoid double lookop */ - /* - fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); - fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); - fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v1)); - */ - qsort(fverts, 3, sizeof(int), uint_cmp); - } - - search_faces[i].index = i; - - if(mf->v4) { - search_faces[i].v[0] = fverts[0]; - search_faces[i].v[1] = fverts[1]; - search_faces[i].v[2] = fverts[2]; - search_faces[i].v[3] = fverts[3]; - } - else { - search_faces[i].v[0] = fverts[0]; - search_faces[i].v[1] = fverts[1]; - search_faces[i].v[2] = fverts[2]; - search_faces[i].v[3] = UINT_MAX; - } - } - - qsort(search_faces, totface, sizeof(SearchFace), search_face_cmp); - - sf= search_faces; - sf_prev= sf; - sf++; - - for(i=1; iv, sf_prev->v, sizeof(sf_prev->v)) == 0) { - /* slow, could be smarter here */ - MFace *mf= mfaces + sf->index; - MFace *mf_prev= mfaces + sf_prev->index; - int size_expect, size_found; - - EdgeHash *eh_tmp= BLI_edgehash_new(); - if(mf->v4) { - BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf->v3, mf->v4, NULL); - BLI_edgehash_insert(eh_tmp, mf->v4, mf->v1, NULL); - - BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v4, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v4, mf_prev->v1, NULL); - - size_expect= 4; - } - else { - BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf->v3, mf->v1, NULL); - - BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v1, NULL); - - size_expect= 3; - } - - size_found= BLI_edgehash_size(eh_tmp); - BLI_edgehash_free(eh_tmp, NULL); - - if(size_found != size_expect) { - printf(" face %d & %d: are duplicates ", sf->index, sf_prev->index); - if(mf->v4) { - printf("(%d,%d,%d,%d) ", mf->v1, mf->v2, mf->v3, mf->v4); - printf("(%d,%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); - } - else { - printf("(%d,%d,%d) ", mf->v1, mf->v2, mf->v3); - printf("(%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3); - } - } - } - } - - BLI_edgehash_free(edge_hash, NULL); - MEM_freeN(search_faces); - - printf("ED_mesh_validate: finished\n\n"); -} - -void ED_mesh_validate(Mesh *me) -{ - printf("MESH: %s\n", me->id.name+2); - ED_mesh_validate_arrays(me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface); -} diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 82004f8c0b3..e8de1cfe5b4 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -33,6 +33,7 @@ #include "BLO_sys_types.h" +#include "BKE_mesh.h" #include "ED_mesh.h" #ifdef RNA_RUNTIME @@ -57,8 +58,10 @@ void RNA_api_mesh(StructRNA *srna) RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force recalculation of edges."); RNA_def_function_flag(func, FUNC_USE_CONTEXT); - /* Linking errors! */ - /* func= RNA_def_function(srna, "validate", "ED_mesh_validate"); */ + /* + func= RNA_def_function(srna, "validate", "BKE_mesh_validate"); + RNA_def_function_ui_description(func, "validate geometry."); + */ } #endif -- cgit v1.2.3