1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 */ 16 17 #pragma once 18 19 /** \file 20 * \ingroup bmesh 21 */ 22 23 #include "bmesh_operator_api.h" 24 25 /*----------- bmop error system ----------*/ 26 27 /* pushes an error onto the bmesh error stack. 28 * if msg is null, then the default message for the errorcode is used.*/ 29 void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg); 30 31 /* gets the topmost error from the stack. 32 * returns error code or 0 if no error.*/ 33 int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op); 34 bool BMO_error_occurred(BMesh *bm); 35 36 /* same as geterror, only pops the error off the stack as well */ 37 int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op); 38 void BMO_error_clear(BMesh *bm); 39 40 /* this is meant for handling errors, like self-intersection test failures. 41 * it's dangerous to handle errors in general though, so disabled for now. */ 42 43 /* catches an error raised by the op pointed to by catchop. 44 * errorcode is either the errorcode, or BMERR_ALL for any 45 * error.*/ 46 47 /* not yet implemented. 48 * int BMO_error_catch_op(BMesh *bm, BMOperator *catchop, int errorcode, char **msg); 49 */ 50 51 #define BM_ELEM_INDEX_VALIDATE(_bm, _msg_a, _msg_b) \ 52 BM_mesh_elem_index_validate(_bm, __FILE__ ":" STRINGIFY(__LINE__), __func__, _msg_a, _msg_b) 53 54 /*------ error code defines -------*/ 55 56 /*error messages*/ 57 enum { 58 BMERR_CONNECTVERT_FAILED = 1, 59 BMERR_DISSOLVEFACES_FAILED, 60 BMERR_INVALID_SELECTION, 61 BMERR_MESH_ERROR, 62 BMERR_CONVEX_HULL_FAILED, 63 64 BMERR_TOTAL, 65 }; 66 67 /* BMESH_ASSERT */ 68 #ifdef WITH_ASSERT_ABORT 69 # define _BMESH_DUMMY_ABORT abort 70 #else 71 # define _BMESH_DUMMY_ABORT() (void)0 72 #endif 73 74 /* this is meant to be higher level than BLI_assert(), 75 * its enabled even when in Release mode*/ 76 #define BMESH_ASSERT(a) \ 77 (void)((!(a)) ? ((fprintf(stderr, \ 78 "BMESH_ASSERT failed: %s, %s(), %d at \'%s\'\n", \ 79 __FILE__, \ 80 __func__, \ 81 __LINE__, \ 82 STRINGIFY(a)), \ 83 _BMESH_DUMMY_ABORT(), \ 84 NULL)) : \ 85 NULL) 86