Blender  V2.93
BPy_NonTVertex.cpp
Go to the documentation of this file.
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 
21 #include "BPy_NonTVertex.h"
22 
23 #include "../../BPy_Convert.h"
24 #include "../BPy_SVertex.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 using namespace Freestyle;
31 
33 
34 /*----------------------NonTVertex methods ----------------------------*/
35 
37  NonTVertex_doc,
38  "Class hierarchy: :class:`Interface0D` > :class:`ViewVertex` > :class:`NonTVertex`\n"
39  "\n"
40  "View vertex for corners, cusps, etc. associated to a single SVertex.\n"
41  "Can be associated to 2 or more view edges.\n"
42  "\n"
43  ".. method:: __init__()\n"
44  " __init__(svertex)\n"
45  "\n"
46  " Builds a :class:`NonTVertex` using the default constructor or a :class:`SVertex`.\n"
47  "\n"
48  " :arg svertex: An SVertex object.\n"
49  " :type svertex: :class:`SVertex`");
50 
51 /* Note: No copy constructor in Python because the C++ copy constructor is 'protected'. */
52 
53 static int NonTVertex_init(BPy_NonTVertex *self, PyObject *args, PyObject *kwds)
54 {
55  static const char *kwlist[] = {"svertex", nullptr};
56  PyObject *obj = nullptr;
57 
58  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &SVertex_Type, &obj)) {
59  return -1;
60  }
61  if (!obj) {
62  self->ntv = new NonTVertex();
63  }
64  else {
65  self->ntv = new NonTVertex(((BPy_SVertex *)obj)->sv);
66  }
67  self->py_vv.vv = self->ntv;
68  self->py_vv.py_if0D.if0D = self->ntv;
69  self->py_vv.py_if0D.borrowed = false;
70  return 0;
71 }
72 
73 /*----------------------NonTVertex get/setters ----------------------------*/
74 
75 PyDoc_STRVAR(NonTVertex_svertex_doc,
76  "The SVertex on top of which this NonTVertex is built.\n"
77  "\n"
78  ":type: :class:`SVertex`");
79 
80 static PyObject *NonTVertex_svertex_get(BPy_NonTVertex *self, void *UNUSED(closure))
81 {
82  SVertex *v = self->ntv->svertex();
83  if (v) {
84  return BPy_SVertex_from_SVertex(*v);
85  }
86  Py_RETURN_NONE;
87 }
88 
89 static int NonTVertex_svertex_set(BPy_NonTVertex *self, PyObject *value, void *UNUSED(closure))
90 {
91  if (!BPy_SVertex_Check(value)) {
92  PyErr_SetString(PyExc_TypeError, "value must be an SVertex");
93  return -1;
94  }
95  self->ntv->setSVertex(((BPy_SVertex *)value)->sv);
96  return 0;
97 }
98 
99 static PyGetSetDef BPy_NonTVertex_getseters[] = {
100  {"svertex",
101  (getter)NonTVertex_svertex_get,
102  (setter)NonTVertex_svertex_set,
103  NonTVertex_svertex_doc,
104  nullptr},
105  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
106 };
107 
108 /*-----------------------BPy_NonTVertex type definition ------------------------------*/
109 PyTypeObject NonTVertex_Type = {
110  PyVarObject_HEAD_INIT(nullptr, 0) "NonTVertex", /* tp_name */
111  sizeof(BPy_NonTVertex), /* tp_basicsize */
112  0, /* tp_itemsize */
113  nullptr, /* tp_dealloc */
114  0, /* tp_vectorcall_offset */
115  nullptr, /* tp_getattr */
116  nullptr, /* tp_setattr */
117  nullptr, /* tp_reserved */
118  nullptr, /* tp_repr */
119  nullptr, /* tp_as_number */
120  nullptr, /* tp_as_sequence */
121  nullptr, /* tp_as_mapping */
122  nullptr, /* tp_hash */
123  nullptr, /* tp_call */
124  nullptr, /* tp_str */
125  nullptr, /* tp_getattro */
126  nullptr, /* tp_setattro */
127  nullptr, /* tp_as_buffer */
128  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
129  NonTVertex_doc, /* tp_doc */
130  nullptr, /* tp_traverse */
131  nullptr, /* tp_clear */
132  nullptr, /* tp_richcompare */
133  0, /* tp_weaklistoffset */
134  nullptr, /* tp_iter */
135  nullptr, /* tp_iternext */
136  nullptr, /* tp_methods */
137  nullptr, /* tp_members */
138  BPy_NonTVertex_getseters, /* tp_getset */
139  &ViewVertex_Type, /* tp_base */
140  nullptr, /* tp_dict */
141  nullptr, /* tp_descr_get */
142  nullptr, /* tp_descr_set */
143  0, /* tp_dictoffset */
144  (initproc)NonTVertex_init, /* tp_init */
145  nullptr, /* tp_alloc */
146  nullptr, /* tp_new */
147 };
148 
150 
151 #ifdef __cplusplus
152 }
153 #endif
#define UNUSED(x)
PyObject * BPy_SVertex_from_SVertex(SVertex &sv)
static int NonTVertex_svertex_set(BPy_NonTVertex *self, PyObject *value, void *UNUSED(closure))
static PyGetSetDef BPy_NonTVertex_getseters[]
PyDoc_STRVAR(NonTVertex_doc, "Class hierarchy: :class:`Interface0D` > :class:`ViewVertex` > :class:`NonTVertex`\n" "\n" "View vertex for corners, cusps, etc. associated to a single SVertex.\n" "Can be associated to 2 or more view edges.\n" "\n" ".. method:: __init__()\n" " __init__(svertex)\n" "\n" " Builds a :class:`NonTVertex` using the default constructor or a :class:`SVertex`.\n" "\n" " :arg svertex: An SVertex object.\n" " :type svertex: :class:`SVertex`")
PyTypeObject NonTVertex_Type
static int NonTVertex_init(BPy_NonTVertex *self, PyObject *args, PyObject *kwds)
static PyObject * NonTVertex_svertex_get(BPy_NonTVertex *self, void *UNUSED(closure))
PyTypeObject SVertex_Type
#define BPy_SVertex_Check(v)
Definition: BPy_SVertex.h:35
PyTypeObject ViewVertex_Type
ATTR_WARN_UNUSED_RESULT const BMVert * v
inherits from class Rep
Definition: AppCanvas.cpp:32