Blender V5.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
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
73 ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesEnd());
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 " :param 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,
99 kwds,
100 "O!" /* `edge` */
101 ":edges_iterator",
102 (char **)kwlist,
104 &py_ve))
105 {
106 return nullptr;
107 }
108 ViewEdge *ve = ((BPy_ViewEdge *)py_ve)->ve;
111}
112
113#ifdef __GNUC__
114# ifdef __clang__
115# pragma clang diagnostic push
116# pragma clang diagnostic ignored "-Wcast-function-type"
117# else
118# pragma GCC diagnostic push
119# pragma GCC diagnostic ignored "-Wcast-function-type"
120# endif
121#endif
122
123static PyMethodDef BPy_ViewVertex_methods[] = {
124 {"edges_begin", (PyCFunction)ViewVertex_edges_begin, METH_NOARGS, ViewVertex_edges_begin_doc},
125 {"edges_end", (PyCFunction)ViewVertex_edges_end, METH_NOARGS, ViewVertex_edges_end_doc},
126 {"edges_iterator",
127 (PyCFunction)ViewVertex_edges_iterator,
128 METH_VARARGS | METH_KEYWORDS,
129 ViewVertex_edges_iterator_doc},
130 {nullptr, nullptr, 0, nullptr},
131};
132
133#ifdef __GNUC__
134# ifdef __clang__
135# pragma clang diagnostic pop
136# else
137# pragma GCC diagnostic pop
138# endif
139#endif
140
141/*----------------------ViewVertex get/setters ----------------------------*/
142
144 /* Wrap. */
145 ViewVertex_nature_doc,
146 "The nature of this ViewVertex.\n"
147 "\n"
148 ":type: :class:`Nature`\n");
149static PyObject *ViewVertex_nature_get(BPy_ViewVertex *self, void * /*closure*/)
150{
151 Nature::VertexNature nature = self->vv->getNature();
152 if (PyErr_Occurred()) {
153 return nullptr;
154 }
155 return BPy_Nature_from_Nature(nature); // return a copy
156}
157
158static int ViewVertex_nature_set(BPy_ViewVertex *self, PyObject *value, void * /*closure*/)
159{
160 if (!BPy_Nature_Check(value)) {
161 PyErr_SetString(PyExc_TypeError, "value must be a Nature");
162 return -1;
163 }
164 self->vv->setNature(PyLong_AsLong((PyObject *)&((BPy_Nature *)value)->i));
165 return 0;
166}
167
168static PyGetSetDef BPy_ViewVertex_getseters[] = {
169 {"nature",
170 (getter)ViewVertex_nature_get,
171 (setter)ViewVertex_nature_set,
172 ViewVertex_nature_doc,
173 nullptr},
174 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
175};
176
177/*-----------------------BPy_ViewVertex type definition ------------------------------*/
178
179PyTypeObject ViewVertex_Type = {
180 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
181 /*tp_name*/ "ViewVertex",
182 /*tp_basicsize*/ sizeof(BPy_ViewVertex),
183 /*tp_itemsize*/ 0,
184 /*tp_dealloc*/ nullptr,
185 /*tp_vectorcall_offset*/ 0,
186 /*tp_getattr*/ nullptr,
187 /*tp_setattr*/ nullptr,
188 /*tp_as_async*/ nullptr,
189 /*tp_repr*/ nullptr,
190 /*tp_as_number*/ nullptr,
191 /*tp_as_sequence*/ nullptr,
192 /*tp_as_mapping*/ nullptr,
193 /*tp_hash*/ nullptr,
194 /*tp_call*/ nullptr,
195 /*tp_str*/ nullptr,
196 /*tp_getattro*/ nullptr,
197 /*tp_setattro*/ nullptr,
198 /*tp_as_buffer*/ nullptr,
199 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
200 /*tp_doc*/ ViewVertex_doc,
201 /*tp_traverse*/ nullptr,
202 /*tp_clear*/ nullptr,
203 /*tp_richcompare*/ nullptr,
204 /*tp_weaklistoffset*/ 0,
205 /*tp_iter*/ nullptr,
206 /*tp_iternext*/ nullptr,
207 /*tp_methods*/ BPy_ViewVertex_methods,
208 /*tp_members*/ nullptr,
209 /*tp_getset*/ BPy_ViewVertex_getseters,
210 /*tp_base*/ &Interface0D_Type,
211 /*tp_dict*/ nullptr,
212 /*tp_descr_get*/ nullptr,
213 /*tp_descr_set*/ nullptr,
214 /*tp_dictoffset*/ 0,
215 /*tp_init*/ (initproc)ViewVertex_init,
216 /*tp_alloc*/ nullptr,
217 /*tp_new*/ nullptr,
218};
219
PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(ViewVertexInternal::orientedViewEdgeIterator &ove_it, bool reversed)
PyObject * BPy_Nature_from_Nature(ushort n)
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\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)
virtual Nature::VertexNature getNature() const
Definition ViewMap.h:312
virtual ViewVertexInternal::orientedViewEdgeIterator edgesBegin()=0
virtual ViewVertexInternal::orientedViewEdgeIterator edgesIterator(ViewEdge *iEdge)=0
void setNature(Nature::VertexNature iNature)
Definition ViewMap.h:319
ushort VertexNature
Definition Nature.h:22
inherits from class Rep
Definition AppCanvas.cpp:20
Freestyle::ViewVertex * vv