Blender V5.0
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.\n");
35static int ViewVertex_init(BPy_ViewVertex * /*self*/, PyObject * /*args*/, PyObject * /*kwds*/)
36{
37 PyErr_SetString(PyExc_TypeError, "cannot instantiate abstract class");
38 return -1;
39}
40
42 /* Wrap. */
43 ViewVertex_edges_begin_doc,
44 ".. method:: edges_begin()\n"
45 "\n"
46 " Returns an iterator over the ViewEdges that goes to or comes from\n"
47 " this ViewVertex pointing to the first ViewEdge of the list. The\n"
48 " orientedViewEdgeIterator allows to iterate in CCW order over these\n"
49 " ViewEdges and to get the orientation for each ViewEdge\n"
50 " (incoming/outgoing).\n"
51 "\n"
52 " :return: An orientedViewEdgeIterator pointing to the first ViewEdge.\n"
53 " :rtype: :class:`orientedViewEdgeIterator`\n");
59
61 /* Wrap. */
62 ViewVertex_edges_end_doc,
63 ".. method:: edges_end()\n"
64 "\n"
65 " Returns an orientedViewEdgeIterator over the ViewEdges around this\n"
66 " ViewVertex, pointing after the last ViewEdge.\n"
67 "\n"
68 " :return: An orientedViewEdgeIterator pointing after the last ViewEdge.\n"
69 " :rtype: :class:`orientedViewEdgeIterator`\n");
70static PyObject *ViewVertex_edges_end(BPy_ViewVertex * /*self*/)
71{
72#if 0
75#else
76 PyErr_SetString(PyExc_NotImplementedError, "edges_end method currently disabled");
77 return nullptr;
78#endif
79}
80
82 /* Wrap. */
83 ViewVertex_edges_iterator_doc,
84 ".. method:: edges_iterator(edge)\n"
85 "\n"
86 " Returns an orientedViewEdgeIterator pointing to the ViewEdge given\n"
87 " as argument.\n"
88 "\n"
89 " :arg edge: A ViewEdge object.\n"
90 " :type edge: :class:`ViewEdge`\n"
91 " :return: An orientedViewEdgeIterator pointing to the given ViewEdge.\n"
92 " :rtype: :class:`orientedViewEdgeIterator`\n");
93static PyObject *ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args, PyObject *kwds)
94{
95 static const char *kwlist[] = {"edge", nullptr};
96 PyObject *py_ve;
97
98 if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
99 return nullptr;
100 }
101 ViewEdge *ve = ((BPy_ViewEdge *)py_ve)->ve;
102 ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesIterator(ve));
104}
105
106#ifdef __GNUC__
107# ifdef __clang__
108# pragma clang diagnostic push
109# pragma clang diagnostic ignored "-Wcast-function-type"
110# else
111# pragma GCC diagnostic push
112# pragma GCC diagnostic ignored "-Wcast-function-type"
113# endif
114#endif
115
116static PyMethodDef BPy_ViewVertex_methods[] = {
117 {"edges_begin", (PyCFunction)ViewVertex_edges_begin, METH_NOARGS, ViewVertex_edges_begin_doc},
118 {"edges_end", (PyCFunction)ViewVertex_edges_end, METH_NOARGS, ViewVertex_edges_end_doc},
119 {"edges_iterator",
120 (PyCFunction)ViewVertex_edges_iterator,
121 METH_VARARGS | METH_KEYWORDS,
122 ViewVertex_edges_iterator_doc},
123 {nullptr, nullptr, 0, nullptr},
124};
125
126#ifdef __GNUC__
127# ifdef __clang__
128# pragma clang diagnostic pop
129# else
130# pragma GCC diagnostic pop
131# endif
132#endif
133
134/*----------------------ViewVertex get/setters ----------------------------*/
135
137 /* Wrap. */
138 ViewVertex_nature_doc,
139 "The nature of this ViewVertex.\n"
140 "\n"
141 ":type: :class:`Nature`\n");
142static PyObject *ViewVertex_nature_get(BPy_ViewVertex *self, void * /*closure*/)
143{
144 Nature::VertexNature nature = self->vv->getNature();
145 if (PyErr_Occurred()) {
146 return nullptr;
147 }
148 return BPy_Nature_from_Nature(nature); // return a copy
149}
150
151static int ViewVertex_nature_set(BPy_ViewVertex *self, PyObject *value, void * /*closure*/)
152{
153 if (!BPy_Nature_Check(value)) {
154 PyErr_SetString(PyExc_TypeError, "value must be a Nature");
155 return -1;
156 }
157 self->vv->setNature(PyLong_AsLong((PyObject *)&((BPy_Nature *)value)->i));
158 return 0;
159}
160
161static PyGetSetDef BPy_ViewVertex_getseters[] = {
162 {"nature",
163 (getter)ViewVertex_nature_get,
164 (setter)ViewVertex_nature_set,
165 ViewVertex_nature_doc,
166 nullptr},
167 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
168};
169
170/*-----------------------BPy_ViewVertex type definition ------------------------------*/
171
172PyTypeObject ViewVertex_Type = {
173 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
174 /*tp_name*/ "ViewVertex",
175 /*tp_basicsize*/ sizeof(BPy_ViewVertex),
176 /*tp_itemsize*/ 0,
177 /*tp_dealloc*/ nullptr,
178 /*tp_vectorcall_offset*/ 0,
179 /*tp_getattr*/ nullptr,
180 /*tp_setattr*/ nullptr,
181 /*tp_as_async*/ nullptr,
182 /*tp_repr*/ nullptr,
183 /*tp_as_number*/ nullptr,
184 /*tp_as_sequence*/ nullptr,
185 /*tp_as_mapping*/ nullptr,
186 /*tp_hash*/ nullptr,
187 /*tp_call*/ nullptr,
188 /*tp_str*/ nullptr,
189 /*tp_getattro*/ nullptr,
190 /*tp_setattro*/ nullptr,
191 /*tp_as_buffer*/ nullptr,
192 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
193 /*tp_doc*/ ViewVertex_doc,
194 /*tp_traverse*/ nullptr,
195 /*tp_clear*/ nullptr,
196 /*tp_richcompare*/ nullptr,
197 /*tp_weaklistoffset*/ 0,
198 /*tp_iter*/ nullptr,
199 /*tp_iternext*/ nullptr,
200 /*tp_methods*/ BPy_ViewVertex_methods,
201 /*tp_members*/ nullptr,
202 /*tp_getset*/ BPy_ViewVertex_getseters,
203 /*tp_base*/ &Interface0D_Type,
204 /*tp_dict*/ nullptr,
205 /*tp_descr_get*/ nullptr,
206 /*tp_descr_set*/ nullptr,
207 /*tp_dictoffset*/ 0,
208 /*tp_init*/ (initproc)ViewVertex_init,
209 /*tp_alloc*/ nullptr,
210 /*tp_new*/ nullptr,
211};
212
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.\n")
PyObject * self
ushort VertexNature
Definition Nature.h:22
inherits from class Rep
Definition AppCanvas.cpp:20
i
Definition text_draw.cc:230