diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/freestyle/intern/python/Interface1D/FEdge | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface1D/FEdge')
4 files changed, 477 insertions, 440 deletions
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp index 8d83c942d93..e91ae155929 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp @@ -32,396 +32,414 @@ extern "C" { /*----------------------FEdgeSharp methods ----------------------------*/ PyDoc_STRVAR(FEdgeSharp_doc, -"Class hierarchy: :class:`Interface1D` > :class:`FEdge` > :class:`FEdgeSharp`\n" -"\n" -"Class defining a sharp FEdge. A Sharp FEdge corresponds to an initial\n" -"edge of the input mesh. It can be a silhouette, a crease or a border.\n" -"If it is a crease edge, then it is borded by two faces of the mesh.\n" -"Face a lies on its right whereas Face b lies on its left. If it is a\n" -"border edge, then it doesn't have any face on its right, and thus Face\n" -"a is None.\n" -"\n" -".. method:: __init__()\n" -"\n" -" Default constructor.\n" -"\n" -".. method:: __init__(brother)\n" -"\n" -" Copy constructor.\n" -"\n" -" :arg brother: An FEdgeSharp object.\n" -" :type brother: :class:`FEdgeSharp`\n" -"\n" -".. method:: __init__(first_vertex, second_vertex)\n" -"\n" -" Builds an FEdgeSharp going from the first vertex to the second.\n" -"\n" -" :arg first_vertex: The first SVertex object.\n" -" :type first_vertex: :class:`SVertex`\n" -" :arg second_vertex: The second SVertex object.\n" -" :type second_vertex: :class:`SVertex`"); + "Class hierarchy: :class:`Interface1D` > :class:`FEdge` > :class:`FEdgeSharp`\n" + "\n" + "Class defining a sharp FEdge. A Sharp FEdge corresponds to an initial\n" + "edge of the input mesh. It can be a silhouette, a crease or a border.\n" + "If it is a crease edge, then it is borded by two faces of the mesh.\n" + "Face a lies on its right whereas Face b lies on its left. If it is a\n" + "border edge, then it doesn't have any face on its right, and thus Face\n" + "a is None.\n" + "\n" + ".. method:: __init__()\n" + "\n" + " Default constructor.\n" + "\n" + ".. method:: __init__(brother)\n" + "\n" + " Copy constructor.\n" + "\n" + " :arg brother: An FEdgeSharp object.\n" + " :type brother: :class:`FEdgeSharp`\n" + "\n" + ".. method:: __init__(first_vertex, second_vertex)\n" + "\n" + " Builds an FEdgeSharp going from the first vertex to the second.\n" + "\n" + " :arg first_vertex: The first SVertex object.\n" + " :type first_vertex: :class:`SVertex`\n" + " :arg second_vertex: The second SVertex object.\n" + " :type second_vertex: :class:`SVertex`"); static int FEdgeSharp_init(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds) { - static const char *kwlist_1[] = {"brother", NULL}; - static const char *kwlist_2[] = {"first_vertex", "second_vertex", NULL}; - PyObject *obj1 = 0, *obj2 = 0; - - if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdgeSharp_Type, &obj1)) { - if (!obj1) - self->fes = new FEdgeSharp(); - else - self->fes = new FEdgeSharp(*(((BPy_FEdgeSharp *)obj1)->fes)); - } - else if (PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", (char **)kwlist_2, - &SVertex_Type, &obj1, &SVertex_Type, &obj2)) - { - self->fes = new FEdgeSharp(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv); - } - else { - PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); - return -1; - } - self->py_fe.fe = self->fes; - self->py_fe.py_if1D.if1D = self->fes; - self->py_fe.py_if1D.borrowed = false; - return 0; + static const char *kwlist_1[] = {"brother", NULL}; + static const char *kwlist_2[] = {"first_vertex", "second_vertex", NULL}; + PyObject *obj1 = 0, *obj2 = 0; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdgeSharp_Type, &obj1)) { + if (!obj1) + self->fes = new FEdgeSharp(); + else + self->fes = new FEdgeSharp(*(((BPy_FEdgeSharp *)obj1)->fes)); + } + else if (PyErr_Clear(), + PyArg_ParseTupleAndKeywords(args, + kwds, + "O!O!", + (char **)kwlist_2, + &SVertex_Type, + &obj1, + &SVertex_Type, + &obj2)) { + self->fes = new FEdgeSharp(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv); + } + else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + self->py_fe.fe = self->fes; + self->py_fe.py_if1D.if1D = self->fes; + self->py_fe.py_if1D.borrowed = false; + return 0; } /*----------------------mathutils callbacks ----------------------------*/ /* subtype */ -#define MATHUTILS_SUBTYPE_NORMAL_A 1 -#define MATHUTILS_SUBTYPE_NORMAL_B 2 +#define MATHUTILS_SUBTYPE_NORMAL_A 1 +#define MATHUTILS_SUBTYPE_NORMAL_B 2 static int FEdgeSharp_mathutils_check(BaseMathObject *bmo) { - if (!BPy_FEdgeSharp_Check(bmo->cb_user)) - return -1; - return 0; + if (!BPy_FEdgeSharp_Check(bmo->cb_user)) + return -1; + return 0; } static int FEdgeSharp_mathutils_get(BaseMathObject *bmo, int subtype) { - BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; - switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(self->fes->normalA()); - bmo->data[0] = p[0]; - bmo->data[1] = p[1]; - bmo->data[2] = p[2]; - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(self->fes->normalB()); - bmo->data[0] = p[0]; - bmo->data[1] = p[1]; - bmo->data[2] = p[2]; - } - break; - default: - return -1; - } - return 0; + BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; + switch (subtype) { + case MATHUTILS_SUBTYPE_NORMAL_A: { + Vec3r p(self->fes->normalA()); + bmo->data[0] = p[0]; + bmo->data[1] = p[1]; + bmo->data[2] = p[2]; + } break; + case MATHUTILS_SUBTYPE_NORMAL_B: { + Vec3r p(self->fes->normalB()); + bmo->data[0] = p[0]; + bmo->data[1] = p[1]; + bmo->data[2] = p[2]; + } break; + default: + return -1; + } + return 0; } static int FEdgeSharp_mathutils_set(BaseMathObject *bmo, int subtype) { - BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; - switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); - self->fes->setNormalA(p); - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); - self->fes->setNormalB(p); - } - break; - default: - return -1; - } - return 0; + BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; + switch (subtype) { + case MATHUTILS_SUBTYPE_NORMAL_A: { + Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); + self->fes->setNormalA(p); + } break; + case MATHUTILS_SUBTYPE_NORMAL_B: { + Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); + self->fes->setNormalB(p); + } break; + default: + return -1; + } + return 0; } static int FEdgeSharp_mathutils_get_index(BaseMathObject *bmo, int subtype, int index) { - BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; - switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(self->fes->normalA()); - bmo->data[index] = p[index]; - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(self->fes->normalB()); - bmo->data[index] = p[index]; - } - break; - default: - return -1; - } - return 0; + BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; + switch (subtype) { + case MATHUTILS_SUBTYPE_NORMAL_A: { + Vec3r p(self->fes->normalA()); + bmo->data[index] = p[index]; + } break; + case MATHUTILS_SUBTYPE_NORMAL_B: { + Vec3r p(self->fes->normalB()); + bmo->data[index] = p[index]; + } break; + default: + return -1; + } + return 0; } static int FEdgeSharp_mathutils_set_index(BaseMathObject *bmo, int subtype, int index) { - BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; - switch (subtype) { - case MATHUTILS_SUBTYPE_NORMAL_A: - { - Vec3r p(self->fes->normalA()); - p[index] = bmo->data[index]; - self->fes->setNormalA(p); - } - break; - case MATHUTILS_SUBTYPE_NORMAL_B: - { - Vec3r p(self->fes->normalB()); - p[index] = bmo->data[index]; - self->fes->setNormalB(p); - } - break; - default: - return -1; - } - return 0; + BPy_FEdgeSharp *self = (BPy_FEdgeSharp *)bmo->cb_user; + switch (subtype) { + case MATHUTILS_SUBTYPE_NORMAL_A: { + Vec3r p(self->fes->normalA()); + p[index] = bmo->data[index]; + self->fes->setNormalA(p); + } break; + case MATHUTILS_SUBTYPE_NORMAL_B: { + Vec3r p(self->fes->normalB()); + p[index] = bmo->data[index]; + self->fes->setNormalB(p); + } break; + default: + return -1; + } + return 0; } static Mathutils_Callback FEdgeSharp_mathutils_cb = { - FEdgeSharp_mathutils_check, - FEdgeSharp_mathutils_get, - FEdgeSharp_mathutils_set, - FEdgeSharp_mathutils_get_index, - FEdgeSharp_mathutils_set_index, + FEdgeSharp_mathutils_check, + FEdgeSharp_mathutils_get, + FEdgeSharp_mathutils_set, + FEdgeSharp_mathutils_get_index, + FEdgeSharp_mathutils_set_index, }; static unsigned char FEdgeSharp_mathutils_cb_index = -1; void FEdgeSharp_mathutils_register_callback() { - FEdgeSharp_mathutils_cb_index = Mathutils_RegisterCallback(&FEdgeSharp_mathutils_cb); + FEdgeSharp_mathutils_cb_index = Mathutils_RegisterCallback(&FEdgeSharp_mathutils_cb); } /*----------------------FEdgeSharp get/setters ----------------------------*/ PyDoc_STRVAR(FEdgeSharp_normal_right_doc, -"The normal to the face lying on the right of the FEdge. If this FEdge\n" -"is a border, it has no Face on its right and therefore no normal.\n" -"\n" -":type: :class:`mathutils.Vector`"); + "The normal to the face lying on the right of the FEdge. If this FEdge\n" + "is a border, it has no Face on its right and therefore no normal.\n" + "\n" + ":type: :class:`mathutils.Vector`"); static PyObject *FEdgeSharp_normal_right_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return Vector_CreatePyObject_cb((PyObject *)self, 3, FEdgeSharp_mathutils_cb_index, MATHUTILS_SUBTYPE_NORMAL_A); + return Vector_CreatePyObject_cb( + (PyObject *)self, 3, FEdgeSharp_mathutils_cb_index, MATHUTILS_SUBTYPE_NORMAL_A); } -static int FEdgeSharp_normal_right_set(BPy_FEdgeSharp *self, PyObject *value, void *UNUSED(closure)) +static int FEdgeSharp_normal_right_set(BPy_FEdgeSharp *self, + PyObject *value, + void *UNUSED(closure)) { - float v[3]; - if (mathutils_array_parse(v, 3, 3, value, - "value must be a 3-dimensional vector") == -1) - { - return -1; - } - Vec3r p(v[0], v[1], v[2]); - self->fes->setNormalA(p); - return 0; + float v[3]; + if (mathutils_array_parse(v, 3, 3, value, "value must be a 3-dimensional vector") == -1) { + return -1; + } + Vec3r p(v[0], v[1], v[2]); + self->fes->setNormalA(p); + return 0; } PyDoc_STRVAR(FEdgeSharp_normal_left_doc, -"The normal to the face lying on the left of the FEdge.\n" -"\n" -":type: :class:`mathutils.Vector`"); + "The normal to the face lying on the left of the FEdge.\n" + "\n" + ":type: :class:`mathutils.Vector`"); static PyObject *FEdgeSharp_normal_left_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return Vector_CreatePyObject_cb((PyObject *)self, 3, FEdgeSharp_mathutils_cb_index, MATHUTILS_SUBTYPE_NORMAL_B); + return Vector_CreatePyObject_cb( + (PyObject *)self, 3, FEdgeSharp_mathutils_cb_index, MATHUTILS_SUBTYPE_NORMAL_B); } static int FEdgeSharp_normal_left_set(BPy_FEdgeSharp *self, PyObject *value, void *UNUSED(closure)) { - float v[3]; - if (mathutils_array_parse(v, 3, 3, value, - "value must be a 3-dimensional vector") == -1) - { - return -1; - } - Vec3r p(v[0], v[1], v[2]); - self->fes->setNormalB(p); - return 0; + float v[3]; + if (mathutils_array_parse(v, 3, 3, value, "value must be a 3-dimensional vector") == -1) { + return -1; + } + Vec3r p(v[0], v[1], v[2]); + self->fes->setNormalB(p); + return 0; } PyDoc_STRVAR(FEdgeSharp_material_index_right_doc, -"The index of the material of the face lying on the right of the FEdge.\n" -"If this FEdge is a border, it has no Face on its right and therefore\n" -"no material.\n" -"\n" -":type: int"); + "The index of the material of the face lying on the right of the FEdge.\n" + "If this FEdge is a border, it has no Face on its right and therefore\n" + "no material.\n" + "\n" + ":type: int"); static PyObject *FEdgeSharp_material_index_right_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return PyLong_FromLong(self->fes->aFrsMaterialIndex()); + return PyLong_FromLong(self->fes->aFrsMaterialIndex()); } -static int FEdgeSharp_material_index_right_set(BPy_FEdgeSharp *self, PyObject *value, void *UNUSED(closure)) +static int FEdgeSharp_material_index_right_set(BPy_FEdgeSharp *self, + PyObject *value, + void *UNUSED(closure)) { - unsigned int i = PyLong_AsUnsignedLong(value); - if (PyErr_Occurred()) - return -1; - self->fes->setaFrsMaterialIndex(i); - return 0; + unsigned int i = PyLong_AsUnsignedLong(value); + if (PyErr_Occurred()) + return -1; + self->fes->setaFrsMaterialIndex(i); + return 0; } PyDoc_STRVAR(FEdgeSharp_material_index_left_doc, -"The index of the material of the face lying on the left of the FEdge.\n" -"\n" -":type: int"); + "The index of the material of the face lying on the left of the FEdge.\n" + "\n" + ":type: int"); static PyObject *FEdgeSharp_material_index_left_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return PyLong_FromLong(self->fes->bFrsMaterialIndex()); + return PyLong_FromLong(self->fes->bFrsMaterialIndex()); } -static int FEdgeSharp_material_index_left_set(BPy_FEdgeSharp *self, PyObject *value, void *UNUSED(closure)) +static int FEdgeSharp_material_index_left_set(BPy_FEdgeSharp *self, + PyObject *value, + void *UNUSED(closure)) { - unsigned int i = PyLong_AsUnsignedLong(value); - if (PyErr_Occurred()) - return -1; - self->fes->setbFrsMaterialIndex(i); - return 0; + unsigned int i = PyLong_AsUnsignedLong(value); + if (PyErr_Occurred()) + return -1; + self->fes->setbFrsMaterialIndex(i); + return 0; } PyDoc_STRVAR(FEdgeSharp_material_right_doc, -"The material of the face lying on the right of the FEdge. If this FEdge\n" -"is a border, it has no Face on its right and therefore no material.\n" -"\n" -":type: :class:`Material`"); + "The material of the face lying on the right of the FEdge. If this FEdge\n" + "is a border, it has no Face on its right and therefore no material.\n" + "\n" + ":type: :class:`Material`"); static PyObject *FEdgeSharp_material_right_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return BPy_FrsMaterial_from_FrsMaterial(self->fes->aFrsMaterial()); + return BPy_FrsMaterial_from_FrsMaterial(self->fes->aFrsMaterial()); } PyDoc_STRVAR(FEdgeSharp_material_left_doc, -"The material of the face lying on the left of the FEdge.\n" -"\n" -":type: :class:`Material`"); + "The material of the face lying on the left of the FEdge.\n" + "\n" + ":type: :class:`Material`"); static PyObject *FEdgeSharp_material_left_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return BPy_FrsMaterial_from_FrsMaterial(self->fes->bFrsMaterial()); + return BPy_FrsMaterial_from_FrsMaterial(self->fes->bFrsMaterial()); } PyDoc_STRVAR(FEdgeSharp_face_mark_right_doc, -"The face mark of the face lying on the right of the FEdge. If this FEdge\n" -"is a border, it has no face on the right and thus this property is set to\n" -"false.\n" -"\n" -":type: bool"); + "The face mark of the face lying on the right of the FEdge. If this FEdge\n" + "is a border, it has no face on the right and thus this property is set to\n" + "false.\n" + "\n" + ":type: bool"); static PyObject *FEdgeSharp_face_mark_right_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return PyBool_from_bool(self->fes->aFaceMark()); + return PyBool_from_bool(self->fes->aFaceMark()); } -static int FEdgeSharp_face_mark_right_set(BPy_FEdgeSharp *self, PyObject *value, void *UNUSED(closure)) +static int FEdgeSharp_face_mark_right_set(BPy_FEdgeSharp *self, + PyObject *value, + void *UNUSED(closure)) { - if (!PyBool_Check(value)) - return -1; - self->fes->setaFaceMark(bool_from_PyBool(value)); - return 0; + if (!PyBool_Check(value)) + return -1; + self->fes->setaFaceMark(bool_from_PyBool(value)); + return 0; } PyDoc_STRVAR(FEdgeSharp_face_mark_left_doc, -"The face mark of the face lying on the left of the FEdge.\n" -"\n" -":type: bool"); + "The face mark of the face lying on the left of the FEdge.\n" + "\n" + ":type: bool"); static PyObject *FEdgeSharp_face_mark_left_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - return PyBool_from_bool(self->fes->bFaceMark()); + return PyBool_from_bool(self->fes->bFaceMark()); } -static int FEdgeSharp_face_mark_left_set(BPy_FEdgeSharp *self, PyObject *value, void *UNUSED(closure)) +static int FEdgeSharp_face_mark_left_set(BPy_FEdgeSharp *self, + PyObject *value, + void *UNUSED(closure)) { - if (!PyBool_Check(value)) - return -1; - self->fes->setbFaceMark(bool_from_PyBool(value)); - return 0; + if (!PyBool_Check(value)) + return -1; + self->fes->setbFaceMark(bool_from_PyBool(value)); + return 0; } static PyGetSetDef BPy_FEdgeSharp_getseters[] = { - {(char *)"normal_right", (getter)FEdgeSharp_normal_right_get, (setter)FEdgeSharp_normal_right_set, - (char *)FEdgeSharp_normal_right_doc, NULL}, - {(char *)"normal_left", (getter)FEdgeSharp_normal_left_get, (setter)FEdgeSharp_normal_left_set, - (char *)FEdgeSharp_normal_left_doc, NULL}, - {(char *)"material_index_right", (getter)FEdgeSharp_material_index_right_get, - (setter)FEdgeSharp_material_index_right_set, - (char *)FEdgeSharp_material_index_right_doc, NULL}, - {(char *)"material_index_left", (getter)FEdgeSharp_material_index_left_get, - (setter)FEdgeSharp_material_index_left_set, - (char *)FEdgeSharp_material_index_left_doc, NULL}, - {(char *)"material_right", (getter)FEdgeSharp_material_right_get, (setter)NULL, - (char *)FEdgeSharp_material_right_doc, NULL}, - {(char *)"material_left", (getter)FEdgeSharp_material_left_get, (setter)NULL, - (char *)FEdgeSharp_material_left_doc, NULL}, - {(char *)"face_mark_right", (getter)FEdgeSharp_face_mark_right_get, (setter)FEdgeSharp_face_mark_right_set, - (char *)FEdgeSharp_face_mark_right_doc, NULL}, - {(char *)"face_mark_left", (getter)FEdgeSharp_face_mark_left_get, (setter)FEdgeSharp_face_mark_left_set, - (char *)FEdgeSharp_face_mark_left_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {(char *)"normal_right", + (getter)FEdgeSharp_normal_right_get, + (setter)FEdgeSharp_normal_right_set, + (char *)FEdgeSharp_normal_right_doc, + NULL}, + {(char *)"normal_left", + (getter)FEdgeSharp_normal_left_get, + (setter)FEdgeSharp_normal_left_set, + (char *)FEdgeSharp_normal_left_doc, + NULL}, + {(char *)"material_index_right", + (getter)FEdgeSharp_material_index_right_get, + (setter)FEdgeSharp_material_index_right_set, + (char *)FEdgeSharp_material_index_right_doc, + NULL}, + {(char *)"material_index_left", + (getter)FEdgeSharp_material_index_left_get, + (setter)FEdgeSharp_material_index_left_set, + (char *)FEdgeSharp_material_index_left_doc, + NULL}, + {(char *)"material_right", + (getter)FEdgeSharp_material_right_get, + (setter)NULL, + (char *)FEdgeSharp_material_right_doc, + NULL}, + {(char *)"material_left", + (getter)FEdgeSharp_material_left_get, + (setter)NULL, + (char *)FEdgeSharp_material_left_doc, + NULL}, + {(char *)"face_mark_right", + (getter)FEdgeSharp_face_mark_right_get, + (setter)FEdgeSharp_face_mark_right_set, + (char *)FEdgeSharp_face_mark_right_doc, + NULL}, + {(char *)"face_mark_left", + (getter)FEdgeSharp_face_mark_left_get, + (setter)FEdgeSharp_face_mark_left_set, + (char *)FEdgeSharp_face_mark_left_doc, + NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_FEdgeSharp type definition ------------------------------*/ PyTypeObject FEdgeSharp_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "FEdgeSharp", /* tp_name */ - sizeof(BPy_FEdgeSharp), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - FEdgeSharp_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - BPy_FEdgeSharp_getseters, /* tp_getset */ - &FEdge_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)FEdgeSharp_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ + PyVarObject_HEAD_INIT(NULL, 0) "FEdgeSharp", /* tp_name */ + sizeof(BPy_FEdgeSharp), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FEdgeSharp_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + BPy_FEdgeSharp_getseters, /* tp_getset */ + &FEdge_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FEdgeSharp_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h index be9adf311b6..450539acb16 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.h @@ -37,8 +37,8 @@ extern PyTypeObject FEdgeSharp_Type; /*---------------------------Python BPy_FEdgeSharp structure definition----------*/ typedef struct { - BPy_FEdge py_fe; - FEdgeSharp *fes; + BPy_FEdge py_fe; + FEdgeSharp *fes; } BPy_FEdgeSharp; /*---------------------------Python BPy_FEdgeSharp visible prototypes-----------*/ diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp index 726fe97b3ea..08d18123172 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp @@ -32,243 +32,261 @@ extern "C" { /*----------------------FEdgeSmooth methods ----------------------------*/ PyDoc_STRVAR(FEdgeSmooth_doc, -"Class hierarchy: :class:`Interface1D` > :class:`FEdge` > :class:`FEdgeSmooth`\n" -"\n" -"Class defining a smooth edge. This kind of edge typically runs across\n" -"a face of the input mesh. It can be a silhouette, a ridge or valley,\n" -"a suggestive contour.\n" -"\n" -".. method:: __init__()\n" -"\n" -" Default constructor.\n" -"\n" -".. method:: __init__(brother)\n" -"\n" -" Copy constructor.\n" -"\n" -" :arg brother: An FEdgeSmooth object.\n" -" :type brother: :class:`FEdgeSmooth`\n" -"\n" -".. method:: __init__(first_vertex, second_vertex)\n" -"\n" -" Builds an FEdgeSmooth going from the first to the second.\n" -"\n" -" :arg first_vertex: The first SVertex object.\n" -" :type first_vertex: :class:`SVertex`\n" -" :arg second_vertex: The second SVertex object.\n" -" :type second_vertex: :class:`SVertex`"); + "Class hierarchy: :class:`Interface1D` > :class:`FEdge` > :class:`FEdgeSmooth`\n" + "\n" + "Class defining a smooth edge. This kind of edge typically runs across\n" + "a face of the input mesh. It can be a silhouette, a ridge or valley,\n" + "a suggestive contour.\n" + "\n" + ".. method:: __init__()\n" + "\n" + " Default constructor.\n" + "\n" + ".. method:: __init__(brother)\n" + "\n" + " Copy constructor.\n" + "\n" + " :arg brother: An FEdgeSmooth object.\n" + " :type brother: :class:`FEdgeSmooth`\n" + "\n" + ".. method:: __init__(first_vertex, second_vertex)\n" + "\n" + " Builds an FEdgeSmooth going from the first to the second.\n" + "\n" + " :arg first_vertex: The first SVertex object.\n" + " :type first_vertex: :class:`SVertex`\n" + " :arg second_vertex: The second SVertex object.\n" + " :type second_vertex: :class:`SVertex`"); static int FEdgeSmooth_init(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwds) { - static const char *kwlist_1[] = {"brother", NULL}; - static const char *kwlist_2[] = {"first_vertex", "second_vertex", NULL}; - PyObject *obj1 = 0, *obj2 = 0; - - if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdgeSmooth_Type, &obj1)) { - if (!obj1) - self->fes = new FEdgeSmooth(); - else - self->fes = new FEdgeSmooth(*(((BPy_FEdgeSmooth *)obj1)->fes)); - } - else if (PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", (char **)kwlist_2, - &SVertex_Type, &obj1, &SVertex_Type, &obj2)) - { - self->fes = new FEdgeSmooth(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv); - } - else { - PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); - return -1; - } - self->py_fe.fe = self->fes; - self->py_fe.py_if1D.if1D = self->fes; - self->py_fe.py_if1D.borrowed = false; - return 0; + static const char *kwlist_1[] = {"brother", NULL}; + static const char *kwlist_2[] = {"first_vertex", "second_vertex", NULL}; + PyObject *obj1 = 0, *obj2 = 0; + + if (PyArg_ParseTupleAndKeywords( + args, kwds, "|O!", (char **)kwlist_1, &FEdgeSmooth_Type, &obj1)) { + if (!obj1) + self->fes = new FEdgeSmooth(); + else + self->fes = new FEdgeSmooth(*(((BPy_FEdgeSmooth *)obj1)->fes)); + } + else if (PyErr_Clear(), + PyArg_ParseTupleAndKeywords(args, + kwds, + "O!O!", + (char **)kwlist_2, + &SVertex_Type, + &obj1, + &SVertex_Type, + &obj2)) { + self->fes = new FEdgeSmooth(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv); + } + else { + PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); + return -1; + } + self->py_fe.fe = self->fes; + self->py_fe.py_if1D.if1D = self->fes; + self->py_fe.py_if1D.borrowed = false; + return 0; } /*----------------------mathutils callbacks ----------------------------*/ static int FEdgeSmooth_mathutils_check(BaseMathObject *bmo) { - if (!BPy_FEdgeSmooth_Check(bmo->cb_user)) - return -1; - return 0; + if (!BPy_FEdgeSmooth_Check(bmo->cb_user)) + return -1; + return 0; } static int FEdgeSmooth_mathutils_get(BaseMathObject *bmo, int /*subtype*/) { - BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; - Vec3r p(self->fes->normal()); - bmo->data[0] = p[0]; - bmo->data[1] = p[1]; - bmo->data[2] = p[2]; - return 0; + BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; + Vec3r p(self->fes->normal()); + bmo->data[0] = p[0]; + bmo->data[1] = p[1]; + bmo->data[2] = p[2]; + return 0; } static int FEdgeSmooth_mathutils_set(BaseMathObject *bmo, int /*subtype*/) { - BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; - Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); - self->fes->setNormal(p); - return 0; + BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; + Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]); + self->fes->setNormal(p); + return 0; } static int FEdgeSmooth_mathutils_get_index(BaseMathObject *bmo, int /*subtype*/, int index) { - BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; - Vec3r p(self->fes->normal()); - bmo->data[index] = p[index]; - return 0; + BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; + Vec3r p(self->fes->normal()); + bmo->data[index] = p[index]; + return 0; } static int FEdgeSmooth_mathutils_set_index(BaseMathObject *bmo, int /*subtype*/, int index) { - BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; - Vec3r p(self->fes->normal()); - p[index] = bmo->data[index]; - self->fes->setNormal(p); - return 0; + BPy_FEdgeSmooth *self = (BPy_FEdgeSmooth *)bmo->cb_user; + Vec3r p(self->fes->normal()); + p[index] = bmo->data[index]; + self->fes->setNormal(p); + return 0; } static Mathutils_Callback FEdgeSmooth_mathutils_cb = { - FEdgeSmooth_mathutils_check, - FEdgeSmooth_mathutils_get, - FEdgeSmooth_mathutils_set, - FEdgeSmooth_mathutils_get_index, - FEdgeSmooth_mathutils_set_index, + FEdgeSmooth_mathutils_check, + FEdgeSmooth_mathutils_get, + FEdgeSmooth_mathutils_set, + FEdgeSmooth_mathutils_get_index, + FEdgeSmooth_mathutils_set_index, }; static unsigned char FEdgeSmooth_mathutils_cb_index = -1; void FEdgeSmooth_mathutils_register_callback() { - FEdgeSmooth_mathutils_cb_index = Mathutils_RegisterCallback(&FEdgeSmooth_mathutils_cb); + FEdgeSmooth_mathutils_cb_index = Mathutils_RegisterCallback(&FEdgeSmooth_mathutils_cb); } /*----------------------FEdgeSmooth get/setters ----------------------------*/ PyDoc_STRVAR(FEdgeSmooth_normal_doc, -"The normal of the face that this FEdge is running across.\n" -"\n" -":type: :class:`mathutils.Vector`"); + "The normal of the face that this FEdge is running across.\n" + "\n" + ":type: :class:`mathutils.Vector`"); static PyObject *FEdgeSmooth_normal_get(BPy_FEdgeSmooth *self, void *UNUSED(closure)) { - return Vector_CreatePyObject_cb((PyObject *)self, 3, FEdgeSmooth_mathutils_cb_index, 0); + return Vector_CreatePyObject_cb((PyObject *)self, 3, FEdgeSmooth_mathutils_cb_index, 0); } static int FEdgeSmooth_normal_set(BPy_FEdgeSmooth *self, PyObject *value, void *UNUSED(closure)) { - float v[3]; - if (mathutils_array_parse(v, 3, 3, value, - "value must be a 3-dimensional vector") == -1) - { - return -1; - } - Vec3r p(v[0], v[1], v[2]); - self->fes->setNormal(p); - return 0; + float v[3]; + if (mathutils_array_parse(v, 3, 3, value, "value must be a 3-dimensional vector") == -1) { + return -1; + } + Vec3r p(v[0], v[1], v[2]); + self->fes->setNormal(p); + return 0; } PyDoc_STRVAR(FEdgeSmooth_material_index_doc, -"The index of the material of the face that this FEdge is running across.\n" -"\n" -":type: int"); + "The index of the material of the face that this FEdge is running across.\n" + "\n" + ":type: int"); static PyObject *FEdgeSmooth_material_index_get(BPy_FEdgeSmooth *self, void *UNUSED(closure)) { - return PyLong_FromLong(self->fes->frs_materialIndex()); + return PyLong_FromLong(self->fes->frs_materialIndex()); } -static int FEdgeSmooth_material_index_set(BPy_FEdgeSmooth *self, PyObject *value, void *UNUSED(closure)) +static int FEdgeSmooth_material_index_set(BPy_FEdgeSmooth *self, + PyObject *value, + void *UNUSED(closure)) { - unsigned int i = PyLong_AsUnsignedLong(value); - if (PyErr_Occurred()) - return -1; - self->fes->setFrsMaterialIndex(i); - return 0; + unsigned int i = PyLong_AsUnsignedLong(value); + if (PyErr_Occurred()) + return -1; + self->fes->setFrsMaterialIndex(i); + return 0; } PyDoc_STRVAR(FEdgeSmooth_material_doc, -"The material of the face that this FEdge is running across.\n" -"\n" -":type: :class:`Material`"); + "The material of the face that this FEdge is running across.\n" + "\n" + ":type: :class:`Material`"); static PyObject *FEdgeSmooth_material_get(BPy_FEdgeSmooth *self, void *UNUSED(closure)) { - return BPy_FrsMaterial_from_FrsMaterial(self->fes->frs_material()); + return BPy_FrsMaterial_from_FrsMaterial(self->fes->frs_material()); } PyDoc_STRVAR(FEdgeSmooth_face_mark_doc, -"The face mark of the face that this FEdge is running across.\n" -"\n" -":type: bool"); + "The face mark of the face that this FEdge is running across.\n" + "\n" + ":type: bool"); static PyObject *FEdgeSmooth_face_mark_get(BPy_FEdgeSmooth *self, void *UNUSED(closure)) { - return PyBool_from_bool(self->fes->faceMark()); + return PyBool_from_bool(self->fes->faceMark()); } static int FEdgeSmooth_face_mark_set(BPy_FEdgeSmooth *self, PyObject *value, void *UNUSED(closure)) { - if (!PyBool_Check(value)) - return -1; - self->fes->setFaceMark(bool_from_PyBool(value)); - return 0; + if (!PyBool_Check(value)) + return -1; + self->fes->setFaceMark(bool_from_PyBool(value)); + return 0; } static PyGetSetDef BPy_FEdgeSmooth_getseters[] = { - {(char *)"normal", (getter)FEdgeSmooth_normal_get, (setter)FEdgeSmooth_normal_set, - (char *)FEdgeSmooth_normal_doc, NULL}, - {(char *)"material_index", (getter)FEdgeSmooth_material_index_get, (setter)FEdgeSmooth_material_index_set, - (char *)FEdgeSmooth_material_index_doc, NULL}, - {(char *)"material", (getter)FEdgeSmooth_material_get, (setter)NULL, (char *)FEdgeSmooth_material_doc, NULL}, - {(char *)"face_mark", (getter)FEdgeSmooth_face_mark_get, (setter)FEdgeSmooth_face_mark_set, - (char *)FEdgeSmooth_face_mark_doc, NULL}, - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {(char *)"normal", + (getter)FEdgeSmooth_normal_get, + (setter)FEdgeSmooth_normal_set, + (char *)FEdgeSmooth_normal_doc, + NULL}, + {(char *)"material_index", + (getter)FEdgeSmooth_material_index_get, + (setter)FEdgeSmooth_material_index_set, + (char *)FEdgeSmooth_material_index_doc, + NULL}, + {(char *)"material", + (getter)FEdgeSmooth_material_get, + (setter)NULL, + (char *)FEdgeSmooth_material_doc, + NULL}, + {(char *)"face_mark", + (getter)FEdgeSmooth_face_mark_get, + (setter)FEdgeSmooth_face_mark_set, + (char *)FEdgeSmooth_face_mark_doc, + NULL}, + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; /*-----------------------BPy_FEdgeSmooth type definition ------------------------------*/ PyTypeObject FEdgeSmooth_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "FEdgeSmooth", /* tp_name */ - sizeof(BPy_FEdgeSmooth), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - FEdgeSmooth_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - BPy_FEdgeSmooth_getseters, /* tp_getset */ - &FEdge_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)FEdgeSmooth_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ + PyVarObject_HEAD_INIT(NULL, 0) "FEdgeSmooth", /* tp_name */ + sizeof(BPy_FEdgeSmooth), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + FEdgeSmooth_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + BPy_FEdgeSmooth_getseters, /* tp_getset */ + &FEdge_Type, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)FEdgeSmooth_init, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h index b460795228c..901741a76ff 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.h @@ -33,12 +33,13 @@ extern "C" { extern PyTypeObject FEdgeSmooth_Type; -#define BPy_FEdgeSmooth_Check(v) (PyObject_IsInstance((PyObject *)v, (PyObject *)&FEdgeSmooth_Type)) +#define BPy_FEdgeSmooth_Check(v) \ + (PyObject_IsInstance((PyObject *)v, (PyObject *)&FEdgeSmooth_Type)) /*---------------------------Python BPy_FEdgeSmooth structure definition----------*/ typedef struct { - BPy_FEdge py_fe; - FEdgeSmooth *fes; + BPy_FEdge py_fe; + FEdgeSmooth *fes; } BPy_FEdgeSmooth; /*---------------------------Python BPy_FEdgeSmooth visible prototypes-----------*/ |