Blender V4.5
BPy_TVertex.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_TVertex.h"
10
11#include "../../BPy_Convert.h"
12#include "../../BPy_Id.h"
15#include "../BPy_SVertex.h"
16
17using namespace Freestyle;
18
20
21/*----------------------TVertex methods ----------------------------*/
22
24 /* Wrap. */
25 TVertex_doc,
26 "Class hierarchy: :class:`Interface0D` > :class:`ViewVertex` > :class:`TVertex`\n"
27 "\n"
28 "Class to define a T vertex, i.e. an intersection between two edges.\n"
29 "It points towards two SVertex and four ViewEdges. Among the\n"
30 "ViewEdges, two are front and the other two are back. Basically a\n"
31 "front edge hides part of a back edge. So, among the back edges, one\n"
32 "is of invisibility N and the other of invisibility N+1.\n"
33 "\n"
34 ".. method:: __init__()\n"
35 "\n"
36 " Default constructor.");
37
38/* NOTE: No copy constructor in Python because the C++ copy constructor is 'protected'. */
39
40static int TVertex_init(BPy_TVertex *self, PyObject *args, PyObject *kwds)
41{
42 static const char *kwlist[] = {nullptr};
43
44 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
45 return -1;
46 }
47 self->tv = new TVertex();
48 self->py_vv.vv = self->tv;
49 self->py_vv.py_if0D.if0D = self->tv;
50 self->py_vv.py_if0D.borrowed = false;
51 return 0;
52}
53
55 /* Wrap. */
56 TVertex_get_svertex_doc,
57 ".. method:: get_svertex(fedge)\n"
58 "\n"
59 " Returns the SVertex (among the 2) belonging to the given FEdge.\n"
60 "\n"
61 " :arg fedge: An FEdge object.\n"
62 " :type fedge: :class:`FEdge`\n"
63 " :return: The SVertex belonging to the given FEdge.\n"
64 " :rtype: :class:`SVertex`");
65
66static PyObject *TVertex_get_svertex(BPy_TVertex *self, PyObject *args, PyObject *kwds)
67{
68 static const char *kwlist[] = {"fedge", nullptr};
69 PyObject *py_fe;
70
71 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) {
72 return nullptr;
73 }
74 SVertex *sv = self->tv->getSVertex(((BPy_FEdge *)py_fe)->fe);
75 if (sv) {
76 return BPy_SVertex_from_SVertex(*sv);
77 }
78 Py_RETURN_NONE;
79}
80
82 /* Wrap. */
83 TVertex_get_mate_doc,
84 ".. method:: get_mate(viewedge)\n"
85 "\n"
86 " Returns the mate edge of the ViewEdge given as argument. If the\n"
87 " ViewEdge is frontEdgeA, frontEdgeB is returned. If the ViewEdge is\n"
88 " frontEdgeB, frontEdgeA is returned. Same for back edges.\n"
89 "\n"
90 " :arg viewedge: A ViewEdge object.\n"
91 " :type viewedge: :class:`ViewEdge`\n"
92 " :return: The mate edge of the given ViewEdge.\n"
93 " :rtype: :class:`ViewEdge`");
94
95static PyObject *TVertex_get_mate(BPy_TVertex *self, PyObject *args, PyObject *kwds)
96{
97 static const char *kwlist[] = {"viewedge", nullptr};
98 PyObject *py_ve;
99
100 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
101 return nullptr;
102 }
103 ViewEdge *ve = self->tv->mate(((BPy_ViewEdge *)py_ve)->ve);
104 if (ve) {
105 return BPy_ViewEdge_from_ViewEdge(*ve);
106 }
107 Py_RETURN_NONE;
108}
109
110#ifdef __GNUC__
111# ifdef __clang__
112# pragma clang diagnostic push
113# pragma clang diagnostic ignored "-Wcast-function-type"
114# else
115# pragma GCC diagnostic push
116# pragma GCC diagnostic ignored "-Wcast-function-type"
117# endif
118#endif
119
120static PyMethodDef BPy_TVertex_methods[] = {
121 {"get_svertex",
122 (PyCFunction)TVertex_get_svertex,
123 METH_VARARGS | METH_KEYWORDS,
124 TVertex_get_svertex_doc},
125 {"get_mate",
126 (PyCFunction)TVertex_get_mate,
127 METH_VARARGS | METH_KEYWORDS,
128 TVertex_get_mate_doc},
129 {nullptr, nullptr, 0, nullptr},
130};
131
132#ifdef __GNUC__
133# ifdef __clang__
134# pragma clang diagnostic pop
135# else
136# pragma GCC diagnostic pop
137# endif
138#endif
139
140/*----------------------TVertex get/setters ----------------------------*/
141
143 /* Wrap. */
144 TVertex_front_svertex_doc,
145 "The SVertex that is closer to the viewpoint.\n"
146 "\n"
147 ":type: :class:`SVertex`");
148
149static PyObject *TVertex_front_svertex_get(BPy_TVertex *self, void * /*closure*/)
150{
151 SVertex *v = self->tv->frontSVertex();
152 if (v) {
154 }
155 Py_RETURN_NONE;
156}
157
158static int TVertex_front_svertex_set(BPy_TVertex *self, PyObject *value, void * /*closure*/)
159{
160 if (!BPy_SVertex_Check(value)) {
161 PyErr_SetString(PyExc_TypeError, "value must be an SVertex");
162 return -1;
163 }
164 self->tv->setFrontSVertex(((BPy_SVertex *)value)->sv);
165 return 0;
166}
167
169 /* Wrap. */
170 TVertex_back_svertex_doc,
171 "The SVertex that is further away from the viewpoint.\n"
172 "\n"
173 ":type: :class:`SVertex`");
174
175static PyObject *TVertex_back_svertex_get(BPy_TVertex *self, void * /*closure*/)
176{
177 SVertex *v = self->tv->backSVertex();
178 if (v) {
180 }
181 Py_RETURN_NONE;
182}
183
184static int TVertex_back_svertex_set(BPy_TVertex *self, PyObject *value, void * /*closure*/)
185{
186 if (!BPy_SVertex_Check(value)) {
187 PyErr_SetString(PyExc_TypeError, "value must be an SVertex");
188 return -1;
189 }
190 self->tv->setBackSVertex(((BPy_SVertex *)value)->sv);
191 return 0;
192}
193
195 /* Wrap. */
196 TVertex_id_doc,
197 "The Id of this TVertex.\n"
198 "\n"
199 ":type: :class:`Id`");
200
201static PyObject *TVertex_id_get(BPy_TVertex *self, void * /*closure*/)
202{
203 Id id(self->tv->getId());
204 return BPy_Id_from_Id(id); // return a copy
205}
206
207static int TVertex_id_set(BPy_TVertex *self, PyObject *value, void * /*closure*/)
208{
209 if (!BPy_Id_Check(value)) {
210 PyErr_SetString(PyExc_TypeError, "value must be an Id");
211 return -1;
212 }
213 self->tv->setId(*(((BPy_Id *)value)->id));
214 return 0;
215}
216
217static PyGetSetDef BPy_TVertex_getseters[] = {
218 {"front_svertex",
221 TVertex_front_svertex_doc,
222 nullptr},
223 {"back_svertex",
226 TVertex_back_svertex_doc,
227 nullptr},
228 {"id", (getter)TVertex_id_get, (setter)TVertex_id_set, TVertex_id_doc, nullptr},
229 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
230};
231
232/*-----------------------BPy_TVertex type definition ------------------------------*/
233
234PyTypeObject TVertex_Type = {
235 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
236 /*tp_name*/ "TVertex",
237 /*tp_basicsize*/ sizeof(BPy_TVertex),
238 /*tp_itemsize*/ 0,
239 /*tp_dealloc*/ nullptr,
240 /*tp_vectorcall_offset*/ 0,
241 /*tp_getattr*/ nullptr,
242 /*tp_setattr*/ nullptr,
243 /*tp_as_async*/ nullptr,
244 /*tp_repr*/ nullptr,
245 /*tp_as_number*/ nullptr,
246 /*tp_as_sequence*/ nullptr,
247 /*tp_as_mapping*/ nullptr,
248 /*tp_hash*/ nullptr,
249 /*tp_call*/ nullptr,
250 /*tp_str*/ nullptr,
251 /*tp_getattro*/ nullptr,
252 /*tp_setattro*/ nullptr,
253 /*tp_as_buffer*/ nullptr,
254 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
255 /*tp_doc*/ TVertex_doc,
256 /*tp_traverse*/ nullptr,
257 /*tp_clear*/ nullptr,
258 /*tp_richcompare*/ nullptr,
259 /*tp_weaklistoffset*/ 0,
260 /*tp_iter*/ nullptr,
261 /*tp_iternext*/ nullptr,
262 /*tp_methods*/ BPy_TVertex_methods,
263 /*tp_members*/ nullptr,
264 /*tp_getset*/ BPy_TVertex_getseters,
265 /*tp_base*/ &ViewVertex_Type,
266 /*tp_dict*/ nullptr,
267 /*tp_descr_get*/ nullptr,
268 /*tp_descr_set*/ nullptr,
269 /*tp_dictoffset*/ 0,
270 /*tp_init*/ (initproc)TVertex_init,
271 /*tp_alloc*/ nullptr,
272 /*tp_new*/ nullptr,
273};
274
PyObject * BPy_Id_from_Id(Id &id)
PyObject * BPy_SVertex_from_SVertex(SVertex &sv)
PyObject * BPy_ViewEdge_from_ViewEdge(ViewEdge &ve)
PyTypeObject FEdge_Type
#define BPy_Id_Check(v)
Definition BPy_Id.h:23
#define BPy_SVertex_Check(v)
Definition BPy_SVertex.h:19
static PyMethodDef BPy_TVertex_methods[]
PyTypeObject TVertex_Type
static PyObject * TVertex_get_svertex(BPy_TVertex *self, PyObject *args, PyObject *kwds)
static PyObject * TVertex_get_mate(BPy_TVertex *self, PyObject *args, PyObject *kwds)
static PyObject * TVertex_front_svertex_get(BPy_TVertex *self, void *)
PyDoc_STRVAR(TVertex_doc, "Class hierarchy: :class:`Interface0D` > :class:`ViewVertex` > :class:`TVertex`\n" "\n" "Class to define a T vertex, i.e. an intersection between two edges.\n" "It points towards two SVertex and four ViewEdges. Among the\n" "ViewEdges, two are front and the other two are back. Basically a\n" "front edge hides part of a back edge. So, among the back edges, one\n" "is of invisibility N and the other of invisibility N+1.\n" "\n" ".. method:: __init__()\n" "\n" " Default constructor.")
static int TVertex_back_svertex_set(BPy_TVertex *self, PyObject *value, void *)
static PyObject * TVertex_back_svertex_get(BPy_TVertex *self, void *)
static int TVertex_id_set(BPy_TVertex *self, PyObject *value, void *)
static PyObject * TVertex_id_get(BPy_TVertex *self, void *)
static PyGetSetDef BPy_TVertex_getseters[]
static int TVertex_front_svertex_set(BPy_TVertex *self, PyObject *value, void *)
static int TVertex_init(BPy_TVertex *self, PyObject *args, PyObject *kwds)
PyTypeObject ViewEdge_Type
PyTypeObject ViewVertex_Type
ATTR_WARN_UNUSED_RESULT const BMVert * v
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20