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