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