Blender  V3.3
BPy_UnaryFunction0DVectorViewShape.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 
9 #include "../BPy_Convert.h"
10 #include "../Iterator/BPy_Interface0DIterator.h"
11 
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 using namespace Freestyle;
19 
21 
22 //-------------------MODULE INITIALIZATION--------------------------------
23 
25 {
26  if (module == nullptr) {
27  return -1;
28  }
29 
30  if (PyType_Ready(&UnaryFunction0DVectorViewShape_Type) < 0) {
31  return -1;
32  }
34  PyModule_AddObject(
35  module, "UnaryFunction0DVectorViewShape", (PyObject *)&UnaryFunction0DVectorViewShape_Type);
36 
37  if (PyType_Ready(&GetOccludersF0D_Type) < 0) {
38  return -1;
39  }
40  Py_INCREF(&GetOccludersF0D_Type);
41  PyModule_AddObject(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type);
42 
43  return 0;
44 }
45 
46 //------------------------INSTANCE METHODS ----------------------------------
47 
49  "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVectorViewShape`\n"
50  "\n"
51  "Base class for unary functions (functors) that work on\n"
52  ":class:`Interface0DIterator` and return a list of :class:`ViewShape`\n"
53  "objects.\n"
54  "\n"
55  ".. method:: __init__()\n"
56  "\n"
57  " Default constructor.\n";
58 
60  PyObject *args,
61  PyObject *kwds)
62 {
63  static const char *kwlist[] = {nullptr};
64 
65  if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
66  return -1;
67  }
68  self->uf0D_vectorviewshape = new UnaryFunction0D<std::vector<ViewShape *>>();
69  self->uf0D_vectorviewshape->py_uf0D = (PyObject *)self;
70  return 0;
71 }
72 
74 {
75  delete self->uf0D_vectorviewshape;
76  UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
77 }
78 
80 {
81  return PyUnicode_FromFormat(
82  "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vectorviewshape);
83 }
84 
86  PyObject *args,
87  PyObject *kwds)
88 {
89  static const char *kwlist[] = {"it", nullptr};
90  PyObject *obj;
91 
92  if (!PyArg_ParseTupleAndKeywords(
93  args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
94  return nullptr;
95  }
96 
97  if (typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D<std::vector<ViewShape *>>)) {
98  PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
99  return nullptr;
100  }
101  if (self->uf0D_vectorviewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
102  if (!PyErr_Occurred()) {
103  string class_name(Py_TYPE(self)->tp_name);
104  PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
105  }
106  return nullptr;
107  }
108 
109  const unsigned int list_len = self->uf0D_vectorviewshape->result.size();
110  PyObject *list = PyList_New(list_len);
111  for (unsigned int i = 0; i < list_len; i++) {
112  ViewShape *v = self->uf0D_vectorviewshape->result[i];
113  PyList_SET_ITEM(list, i, v ? BPy_ViewShape_from_ViewShape(*v) : (Py_INCREF(Py_None), Py_None));
114  }
115 
116  return list;
117 }
118 
119 /*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ---------------------*/
120 
122  PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DVectorViewShape", /* tp_name */
123  sizeof(BPy_UnaryFunction0DVectorViewShape), /* tp_basicsize */
124  0, /* tp_itemsize */
125  (destructor)UnaryFunction0DVectorViewShape___dealloc__, /* tp_dealloc */
126  0, /* tp_vectorcall_offset */
127  nullptr, /* tp_getattr */
128  nullptr, /* tp_setattr */
129  nullptr, /* tp_reserved */
130  (reprfunc)UnaryFunction0DVectorViewShape___repr__, /* tp_repr */
131  nullptr, /* tp_as_number */
132  nullptr, /* tp_as_sequence */
133  nullptr, /* tp_as_mapping */
134  nullptr, /* tp_hash */
135  (ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* tp_call */
136  nullptr, /* tp_str */
137  nullptr, /* tp_getattro */
138  nullptr, /* tp_setattro */
139  nullptr, /* tp_as_buffer */
140  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
142  nullptr, /* tp_traverse */
143  nullptr, /* tp_clear */
144  nullptr, /* tp_richcompare */
145  0, /* tp_weaklistoffset */
146  nullptr, /* tp_iter */
147  nullptr, /* tp_iternext */
148  nullptr, /* tp_methods */
149  nullptr, /* tp_members */
150  nullptr, /* tp_getset */
151  &UnaryFunction0D_Type, /* tp_base */
152  nullptr, /* tp_dict */
153  nullptr, /* tp_descr_get */
154  nullptr, /* tp_descr_set */
155  0, /* tp_dictoffset */
156  (initproc)UnaryFunction0DVectorViewShape___init__, /* tp_init */
157  nullptr, /* tp_alloc */
158  nullptr, /* tp_new */
159 };
160 
162 
163 #ifdef __cplusplus
164 }
165 #endif
PyObject * BPy_ViewShape_from_ViewShape(ViewShape &vs)
PyTypeObject GetOccludersF0D_Type
PyTypeObject Interface0DIterator_Type
PyTypeObject UnaryFunction0DVectorViewShape_Type
static PyObject * UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds)
int UnaryFunction0DVectorViewShape_Init(PyObject *module)
static PyObject * UnaryFunction0DVectorViewShape___repr__(BPy_UnaryFunction0DVectorViewShape *self)
static char UnaryFunction0DVectorViewShape___doc__[]
static void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVectorViewShape *self)
static int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0D_Type
ATTR_WARN_UNUSED_RESULT const BMVert * v
PyObject * self
Definition: bpy_driver.c:165
inherits from class Rep
Definition: AppCanvas.cpp:18
static struct PyModuleDef module
Definition: python.cpp:972