Blender  V3.3
BPy_ViewVertex.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "BPy_ViewVertex.h"
8 
9 #include "../BPy_Convert.h"
10 #include "../BPy_Nature.h"
11 #include "../Interface1D/BPy_ViewEdge.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 using namespace Freestyle;
18 
20 
21 /*----------------------ViewVertex methods----------------------------*/
22 
23 PyDoc_STRVAR(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 
36 static 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 
42 PyDoc_STRVAR(ViewVertex_edges_begin_doc,
43  ".. method:: edges_begin()\n"
44  "\n"
45  " Returns an iterator over the ViewEdges that goes to or comes from\n"
46  " this ViewVertex pointing to the first ViewEdge of the list. The\n"
47  " orientedViewEdgeIterator allows to iterate in CCW order over these\n"
48  " ViewEdges and to get the orientation for each ViewEdge\n"
49  " (incoming/outgoing).\n"
50  "\n"
51  " :return: An orientedViewEdgeIterator pointing to the first ViewEdge.\n"
52  " :rtype: :class:`orientedViewEdgeIterator`");
53 
54 static PyObject *ViewVertex_edges_begin(BPy_ViewVertex *self)
55 {
56  ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesBegin());
58 }
59 
60 PyDoc_STRVAR(ViewVertex_edges_end_doc,
61  ".. method:: edges_end()\n"
62  "\n"
63  " Returns an orientedViewEdgeIterator over the ViewEdges around this\n"
64  " ViewVertex, pointing after the last ViewEdge.\n"
65  "\n"
66  " :return: An orientedViewEdgeIterator pointing after the last ViewEdge.\n"
67  " :rtype: :class:`orientedViewEdgeIterator`");
68 
69 static PyObject *ViewVertex_edges_end(BPy_ViewVertex * /*self*/)
70 {
71 #if 0
72  ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesEnd());
74 #else
75  PyErr_SetString(PyExc_NotImplementedError, "edges_end method currently disabled");
76  return nullptr;
77 #endif
78 }
79 
80 PyDoc_STRVAR(ViewVertex_edges_iterator_doc,
81  ".. method:: edges_iterator(edge)\n"
82  "\n"
83  " Returns an orientedViewEdgeIterator pointing to the ViewEdge given\n"
84  " as argument.\n"
85  "\n"
86  " :arg edge: A ViewEdge object.\n"
87  " :type edge: :class:`ViewEdge`\n"
88  " :return: An orientedViewEdgeIterator pointing to the given ViewEdge.\n"
89  " :rtype: :class:`orientedViewEdgeIterator`");
90 
91 static PyObject *ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args, PyObject *kwds)
92 {
93  static const char *kwlist[] = {"edge", nullptr};
94  PyObject *py_ve;
95 
96  if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
97  return nullptr;
98  }
99  ViewEdge *ve = ((BPy_ViewEdge *)py_ve)->ve;
100  ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesIterator(ve));
102 }
103 
104 static PyMethodDef BPy_ViewVertex_methods[] = {
105  {"edges_begin", (PyCFunction)ViewVertex_edges_begin, METH_NOARGS, ViewVertex_edges_begin_doc},
106  {"edges_end", (PyCFunction)ViewVertex_edges_end, METH_NOARGS, ViewVertex_edges_end_doc},
107  {"edges_iterator",
108  (PyCFunction)ViewVertex_edges_iterator,
109  METH_VARARGS | METH_KEYWORDS,
110  ViewVertex_edges_iterator_doc},
111  {nullptr, nullptr, 0, nullptr},
112 };
113 
114 /*----------------------ViewVertex get/setters ----------------------------*/
115 
116 PyDoc_STRVAR(ViewVertex_nature_doc,
117  "The nature of this ViewVertex.\n"
118  "\n"
119  ":type: :class:`Nature`");
120 
121 static PyObject *ViewVertex_nature_get(BPy_ViewVertex *self, void *UNUSED(closure))
122 {
123  Nature::VertexNature nature = self->vv->getNature();
124  if (PyErr_Occurred()) {
125  return nullptr;
126  }
127  return BPy_Nature_from_Nature(nature); // return a copy
128 }
129 
130 static int ViewVertex_nature_set(BPy_ViewVertex *self, PyObject *value, void *UNUSED(closure))
131 {
132  if (!BPy_Nature_Check(value)) {
133  PyErr_SetString(PyExc_TypeError, "value must be a Nature");
134  return -1;
135  }
136  self->vv->setNature(PyLong_AsLong((PyObject *)&((BPy_Nature *)value)->i));
137  return 0;
138 }
139 
140 static PyGetSetDef BPy_ViewVertex_getseters[] = {
141  {"nature",
142  (getter)ViewVertex_nature_get,
143  (setter)ViewVertex_nature_set,
144  ViewVertex_nature_doc,
145  nullptr},
146  {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
147 };
148 
149 /*-----------------------BPy_ViewVertex type definition ------------------------------*/
150 PyTypeObject ViewVertex_Type = {
151  PyVarObject_HEAD_INIT(nullptr, 0) "ViewVertex", /* tp_name */
152  sizeof(BPy_ViewVertex), /* tp_basicsize */
153  0, /* tp_itemsize */
154  nullptr, /* tp_dealloc */
155  0, /* tp_vectorcall_offset */
156  nullptr, /* tp_getattr */
157  nullptr, /* tp_setattr */
158  nullptr, /* tp_reserved */
159  nullptr, /* tp_repr */
160  nullptr, /* tp_as_number */
161  nullptr, /* tp_as_sequence */
162  nullptr, /* tp_as_mapping */
163  nullptr, /* tp_hash */
164  nullptr, /* tp_call */
165  nullptr, /* tp_str */
166  nullptr, /* tp_getattro */
167  nullptr, /* tp_setattro */
168  nullptr, /* tp_as_buffer */
169  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
170  ViewVertex_doc, /* tp_doc */
171  nullptr, /* tp_traverse */
172  nullptr, /* tp_clear */
173  nullptr, /* tp_richcompare */
174  0, /* tp_weaklistoffset */
175  nullptr, /* tp_iter */
176  nullptr, /* tp_iternext */
177  BPy_ViewVertex_methods, /* tp_methods */
178  nullptr, /* tp_members */
179  BPy_ViewVertex_getseters, /* tp_getset */
180  &Interface0D_Type, /* tp_base */
181  nullptr, /* tp_dict */
182  nullptr, /* tp_descr_get */
183  nullptr, /* tp_descr_set */
184  0, /* tp_dictoffset */
185  (initproc)ViewVertex_init, /* tp_init */
186  nullptr, /* tp_alloc */
187  nullptr, /* tp_new */
188 };
189 
191 
192 #ifdef __cplusplus
193 }
194 #endif
#define UNUSED(x)
PyObject * BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(ViewVertexInternal::orientedViewEdgeIterator &ove_it, bool reversed)
PyObject * BPy_Nature_from_Nature(unsigned short n)
PyTypeObject Interface0D_Type
#define BPy_Nature_Check(v)
Definition: BPy_Nature.h:23
PyTypeObject ViewEdge_Type
static PyMethodDef BPy_ViewVertex_methods[]
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.")
static int ViewVertex_init(BPy_ViewVertex *, PyObject *, PyObject *)
static PyObject * ViewVertex_nature_get(BPy_ViewVertex *self, void *UNUSED(closure))
PyTypeObject ViewVertex_Type
static int ViewVertex_nature_set(BPy_ViewVertex *self, PyObject *value, void *UNUSED(closure))
static PyObject * ViewVertex_edges_begin(BPy_ViewVertex *self)
static PyGetSetDef BPy_ViewVertex_getseters[]
static PyObject * ViewVertex_edges_end(BPy_ViewVertex *)
static PyObject * ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args, PyObject *kwds)
PyObject * self
Definition: bpy_driver.c:165
unsigned short VertexNature
Definition: Nature.h:18
inherits from class Rep
Definition: AppCanvas.cpp:18