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