Blender V4.5
BPy_ViewVertex.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_ViewVertex.h"
10
11#include "../BPy_Convert.h"
12#include "../BPy_Nature.h"
14
15using namespace Freestyle;
16
18
19/*----------------------ViewVertex methods----------------------------*/
20
22 /* Wrap. */
23 ViewVertex_doc,
24 "Class hierarchy: :class:`Interface0D` > :class:`ViewVertex`\n"
25 "\n"
26 "Class to define a view vertex. A view vertex is a feature vertex\n"
27 "corresponding to a point of the image graph, where the characteristics\n"
28 "of an edge (e.g., nature and visibility) might change. A\n"
29 ":class:`ViewVertex` can be of two kinds: A :class:`TVertex` when it\n"
30 "corresponds to the intersection between two ViewEdges or a\n"
31 ":class:`NonTVertex` when it corresponds to a vertex of the initial\n"
32 "input mesh (it is the case for vertices such as corners for example).\n"
33 "Thus, this class can be specialized into two classes, the\n"
34 ":class:`TVertex` class and the :class:`NonTVertex` class.");
35
36static int ViewVertex_init(BPy_ViewVertex * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/)
37{
38 PyErr_SetString(PyExc_TypeError, "cannot instantiate abstract class");
39 return -1;
40}
41
43 /* Wrap. */
44 ViewVertex_edges_begin_doc,
45 ".. method:: edges_begin()\n"
46 "\n"
47 " Returns an iterator over the ViewEdges that goes to or comes from\n"
48 " this ViewVertex pointing to the first ViewEdge of the list. The\n"
49 " orientedViewEdgeIterator allows to iterate in CCW order over these\n"
50 " ViewEdges and to get the orientation for each ViewEdge\n"
51 " (incoming/outgoing).\n"
52 "\n"
53 " :return: An orientedViewEdgeIterator pointing to the first ViewEdge.\n"
54 " :rtype: :class:`orientedViewEdgeIterator`");
55
61
63 /* Wrap. */
64 ViewVertex_edges_end_doc,
65 ".. method:: edges_end()\n"
66 "\n"
67 " Returns an orientedViewEdgeIterator over the ViewEdges around this\n"
68 " ViewVertex, pointing after the last ViewEdge.\n"
69 "\n"
70 " :return: An orientedViewEdgeIterator pointing after the last ViewEdge.\n"
71 " :rtype: :class:`orientedViewEdgeIterator`");
72
73static PyObject *ViewVertex_edges_end(BPy_ViewVertex * /*self*/)
74{
75#if 0
78#else
79 PyErr_SetString(PyExc_NotImplementedError, "edges_end method currently disabled");
80 return nullptr;
81#endif
82}
83
85 /* Wrap. */
86 ViewVertex_edges_iterator_doc,
87 ".. method:: edges_iterator(edge)\n"
88 "\n"
89 " Returns an orientedViewEdgeIterator pointing to the ViewEdge given\n"
90 " as argument.\n"
91 "\n"
92 " :arg edge: A ViewEdge object.\n"
93 " :type edge: :class:`ViewEdge`\n"
94 " :return: An orientedViewEdgeIterator pointing to the given ViewEdge.\n"
95 " :rtype: :class:`orientedViewEdgeIterator`");
96
97static PyObject *ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args, PyObject *kwds)
98{
99 static const char *kwlist[] = {"edge", nullptr};
100 PyObject *py_ve;
101
102 if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
103 return nullptr;
104 }
105 ViewEdge *ve = ((BPy_ViewEdge *)py_ve)->ve;
106 ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesIterator(ve));
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_ViewVertex_methods[] = {
121 {"edges_begin", (PyCFunction)ViewVertex_edges_begin, METH_NOARGS, ViewVertex_edges_begin_doc},
122 {"edges_end", (PyCFunction)ViewVertex_edges_end, METH_NOARGS, ViewVertex_edges_end_doc},
123 {"edges_iterator",
124 (PyCFunction)ViewVertex_edges_iterator,
125 METH_VARARGS | METH_KEYWORDS,
126 ViewVertex_edges_iterator_doc},
127 {nullptr, nullptr, 0, nullptr},
128};
129
130#ifdef __GNUC__
131# ifdef __clang__
132# pragma clang diagnostic pop
133# else
134# pragma GCC diagnostic pop
135# endif
136#endif
137
138/*----------------------ViewVertex get/setters ----------------------------*/
139
141 /* Wrap. */
142 ViewVertex_nature_doc,
143 "The nature of this ViewVertex.\n"
144 "\n"
145 ":type: :class:`Nature`");
146
147static PyObject *ViewVertex_nature_get(BPy_ViewVertex *self, void * /*closure*/)
148{
149 Nature::VertexNature nature = self->vv->getNature();
150 if (PyErr_Occurred()) {
151 return nullptr;
152 }
153 return BPy_Nature_from_Nature(nature); // return a copy
154}
155
156static int ViewVertex_nature_set(BPy_ViewVertex *self, PyObject *value, void * /*closure*/)
157{
158 if (!BPy_Nature_Check(value)) {
159 PyErr_SetString(PyExc_TypeError, "value must be a Nature");
160 return -1;
161 }
162 self->vv->setNature(PyLong_AsLong((PyObject *)&((BPy_Nature *)value)->i));
163 return 0;
164}
165
166static PyGetSetDef BPy_ViewVertex_getseters[] = {
167 {"nature",
168 (getter)ViewVertex_nature_get,
169 (setter)ViewVertex_nature_set,
170 ViewVertex_nature_doc,
171 nullptr},
172 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
173};
174
175/*-----------------------BPy_ViewVertex type definition ------------------------------*/
176
177PyTypeObject ViewVertex_Type = {
178 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
179 /*tp_name*/ "ViewVertex",
180 /*tp_basicsize*/ sizeof(BPy_ViewVertex),
181 /*tp_itemsize*/ 0,
182 /*tp_dealloc*/ nullptr,
183 /*tp_vectorcall_offset*/ 0,
184 /*tp_getattr*/ nullptr,
185 /*tp_setattr*/ nullptr,
186 /*tp_as_async*/ nullptr,
187 /*tp_repr*/ nullptr,
188 /*tp_as_number*/ nullptr,
189 /*tp_as_sequence*/ nullptr,
190 /*tp_as_mapping*/ nullptr,
191 /*tp_hash*/ nullptr,
192 /*tp_call*/ nullptr,
193 /*tp_str*/ nullptr,
194 /*tp_getattro*/ nullptr,
195 /*tp_setattro*/ nullptr,
196 /*tp_as_buffer*/ nullptr,
197 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
198 /*tp_doc*/ ViewVertex_doc,
199 /*tp_traverse*/ nullptr,
200 /*tp_clear*/ nullptr,
201 /*tp_richcompare*/ nullptr,
202 /*tp_weaklistoffset*/ 0,
203 /*tp_iter*/ nullptr,
204 /*tp_iternext*/ nullptr,
205 /*tp_methods*/ BPy_ViewVertex_methods,
206 /*tp_members*/ nullptr,
207 /*tp_getset*/ BPy_ViewVertex_getseters,
208 /*tp_base*/ &Interface0D_Type,
209 /*tp_dict*/ nullptr,
210 /*tp_descr_get*/ nullptr,
211 /*tp_descr_set*/ nullptr,
212 /*tp_dictoffset*/ 0,
213 /*tp_init*/ (initproc)ViewVertex_init,
214 /*tp_alloc*/ nullptr,
215 /*tp_new*/ nullptr,
216};
217
PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(ViewVertexInternal::orientedViewEdgeIterator &ove_it, bool reversed)
PyObject * BPy_Nature_from_Nature(ushort n)
PyTypeObject Interface0D_Type
#define BPy_Nature_Check(v)
Definition BPy_Nature.h:21
PyTypeObject ViewEdge_Type
static PyMethodDef BPy_ViewVertex_methods[]
static PyObject * ViewVertex_edges_end(BPy_ViewVertex *)
static int ViewVertex_init(BPy_ViewVertex *, PyObject *, PyObject *)
PyTypeObject ViewVertex_Type
static PyGetSetDef BPy_ViewVertex_getseters[]
static PyObject * ViewVertex_nature_get(BPy_ViewVertex *self, void *)
static int ViewVertex_nature_set(BPy_ViewVertex *self, PyObject *value, void *)
static PyObject * ViewVertex_edges_begin(BPy_ViewVertex *self)
static PyObject * ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args, PyObject *kwds)
PyDoc_STRVAR(ViewVertex_doc, "Class hierarchy: :class:`Interface0D` > :class:`ViewVertex`\n" "\n" "Class to define a view vertex. A view vertex is a feature vertex\n" "corresponding to a point of the image graph, where the characteristics\n" "of an edge (e.g., nature and visibility) might change. A\n" ":class:`ViewVertex` can be of two kinds: A :class:`TVertex` when it\n" "corresponds to the intersection between two ViewEdges or a\n" ":class:`NonTVertex` when it corresponds to a vertex of the initial\n" "input mesh (it is the case for vertices such as corners for example).\n" "Thus, this class can be specialized into two classes, the\n" ":class:`TVertex` class and the :class:`NonTVertex` class.")
PyObject * self
ushort VertexNature
Definition Nature.h:22
inherits from class Rep
Definition AppCanvas.cpp:20
i
Definition text_draw.cc:230