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