Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bmesh_error.h « intern « bmesh « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 587e33e7dfd4c61b277179de3425e420c965d841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * 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.
 */

#pragma once

/** \file
 * \ingroup bmesh
 */

#include "bmesh_operator_api.h"

/*----------- bmop error system ----------*/

/* Pushes an error onto the bmesh error stack.
 * if msg is null, then the default message for the `errcode` is used. */
void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg);

/* Gets the topmost error from the stack.
 * returns error code or 0 if no error. */
int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op);
bool BMO_error_occurred(BMesh *bm);

/* Same as #BMO_error_get, only pops the error off the stack as well. */
int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op);
void BMO_error_clear(BMesh *bm);

/* This is meant for handling errors, like self-intersection test failures.
 * it's dangerous to handle errors in general though, so disabled for now. */

/* Catches an error raised by the op pointed to by catchop.
 * errorcode is either the errorcode, or BMERR_ALL for any
 * error. */

/* Not yet implemented. */
// int BMO_error_catch_op(BMesh *bm, BMOperator *catchop, int errorcode, char **msg);

#define BM_ELEM_INDEX_VALIDATE(_bm, _msg_a, _msg_b) \
  BM_mesh_elem_index_validate(_bm, __FILE__ ":" STRINGIFY(__LINE__), __func__, _msg_a, _msg_b)

/*------ error code defines -------*/

/** Error messages. */
enum {
  BMERR_CONNECTVERT_FAILED = 1,
  BMERR_DISSOLVEFACES_FAILED,
  BMERR_INVALID_SELECTION,
  BMERR_MESH_ERROR,
  BMERR_CONVEX_HULL_FAILED,

  BMERR_TOTAL,
};

/* BMESH_ASSERT */
#ifdef WITH_ASSERT_ABORT
#  define _BMESH_DUMMY_ABORT abort
#else
#  define _BMESH_DUMMY_ABORT() (void)0
#endif

/* This is meant to be higher level than BLI_assert(),
 * its enabled even when in Release mode. */
#define BMESH_ASSERT(a) \
  (void)((!(a)) ? ((fprintf(stderr, \
                            "BMESH_ASSERT failed: %s, %s(), %d at \'%s\'\n", \
                            __FILE__, \
                            __func__, \
                            __LINE__, \
                            STRINGIFY(a)), \
                    _BMESH_DUMMY_ABORT(), \
                    NULL)) : \
                  NULL)