Blender V5.3
BPy_UnaryFunction1DVectorViewShape.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "../BPy_Convert.h"
13#include "../BPy_Interface1D.h"
14
18
19#include "BLI_sys_types.hh"
20
21using namespace Freestyle;
22
24
25//-------------------MODULE INITIALIZATION--------------------------------
26
28{
29 if (module == nullptr) {
30 return -1;
31 }
32
33 if (PyType_Ready(&UnaryFunction1DVectorViewShape_Type) < 0) {
34 return -1;
35 }
36 PyModule_AddObjectRef(
37 module, "UnaryFunction1DVectorViewShape", (PyObject *)&UnaryFunction1DVectorViewShape_Type);
38
39 if (PyType_Ready(&GetOccludeeF1D_Type) < 0) {
40 return -1;
41 }
42 PyModule_AddObjectRef(module, "GetOccludeeF1D", (PyObject *)&GetOccludeeF1D_Type);
43
44 if (PyType_Ready(&GetOccludersF1D_Type) < 0) {
45 return -1;
46 }
47 PyModule_AddObjectRef(module, "GetOccludersF1D", (PyObject *)&GetOccludersF1D_Type);
48
49 if (PyType_Ready(&GetShapeF1D_Type) < 0) {
50 return -1;
51 }
52 PyModule_AddObjectRef(module, "GetShapeF1D", (PyObject *)&GetShapeF1D_Type);
53
54 return 0;
55}
56
57//------------------------INSTANCE METHODS ----------------------------------
58
60 /* Wrap. */
61 UnaryFunction1DVectorViewShape___doc__,
62 "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DVectorViewShape`\n"
63 "\n"
64 "Base class for unary functions (functors) that work on\n"
65 ":class:`Interface1D` and return a list of :class:`ViewShape`\n"
66 "objects.\n"
67 "\n"
68 ".. method:: __init__(*args)\n"
69 "\n"
70 " Accepted call signatures:\n"
71 "\n"
72 " - ``__init__()``\n"
73 " - ``__init__(integration_type)``\n"
74 "\n"
75 " Builds a unary 1D function using the default constructor\n"
76 " or the integration method given as an argument.\n"
77 "\n"
78 " :param integration_type: An integration method.\n"
79 " :type integration_type: :class:`IntegrationType`\n");
81 PyObject *args,
82 PyObject *kwds)
83{
84 static const char *kwlist[] = {"integration", nullptr};
85 PyObject *obj = nullptr;
86
87 if (!PyArg_ParseTupleAndKeywords(args,
88 kwds,
89 "|" /* Optional arguments. */
90 "O!" /* `integration` */
91 ":__init__",
92 (char **)kwlist,
94 &obj))
95 {
96 return -1;
97 }
98
99 if (!obj) {
101 }
102 else {
105 }
106
107 self->uf1D_vectorviewshape->py_uf1D = (PyObject *)self;
108
109 return 0;
110}
111
113{
114 delete self->uf1D_vectorviewshape;
115 UnaryFunction1D_Type.tp_dealloc((PyObject *)self);
116}
117
119{
120 return PyUnicode_FromFormat(
121 "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf1D_vectorviewshape);
122}
123
125 PyObject *args,
126 PyObject *kwds)
127{
128 static const char *kwlist[] = {"inter", nullptr};
129 PyObject *obj = nullptr;
130
131 if (!PyArg_ParseTupleAndKeywords(args,
132 kwds,
133 "O!" /* `inter` */
134 ":__call__",
135 (char **)kwlist,
137 &obj))
138 {
139 return nullptr;
140 }
141
142 if (typeid(*(self->uf1D_vectorviewshape)) == typeid(UnaryFunction1D<std::vector<ViewShape *>>)) {
143 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
144 return nullptr;
145 }
146 if (self->uf1D_vectorviewshape->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
147 if (!PyErr_Occurred()) {
148 string class_name(Py_TYPE(self)->tp_name);
149 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
150 }
151 return nullptr;
152 }
153
154 const uint list_len = self->uf1D_vectorviewshape->result.size();
155 PyObject *list = PyList_New(list_len);
156 for (uint i = 0; i < list_len; i++) {
158 PyList_SET_ITEM(list, i, v ? BPy_ViewShape_from_ViewShape(*v) : (Py_INCREF(Py_None), Py_None));
159 }
160
161 return list;
162}
163
164/*----------------------UnaryFunction1DVectorViewShape get/setters ----------------------------*/
165
167 /* Wrap. */
168 integration_type_doc,
169 "The integration method.\n"
170 "\n"
171 ":type: :class:`IntegrationType`\n");
177
179 PyObject *value,
180 void * /*closure*/)
181{
182 if (!BPy_IntegrationType_Check(value)) {
183 PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType");
184 return -1;
185 }
187 return 0;
188}
189
191 {"integration_type",
192 (getter)integration_type_get,
193 (setter)integration_type_set,
194 integration_type_doc,
195 nullptr},
196 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
197};
198
199/*-----------------------BPy_UnaryFunction1DVectorViewShape type definition ---------------------*/
200
202 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
203 /*tp_name*/ "UnaryFunction1DVectorViewShape",
204 /*tp_basicsize*/ sizeof(BPy_UnaryFunction1DVectorViewShape),
205 /*tp_itemsize*/ 0,
206 /*tp_dealloc*/ (destructor)UnaryFunction1DVectorViewShape___dealloc__,
207 /*tp_vectorcall_offset*/ 0,
208 /*tp_getattr*/ nullptr,
209 /*tp_setattr*/ nullptr,
210 /*tp_as_async*/ nullptr,
211 /*tp_repr*/ (reprfunc)UnaryFunction1DVectorViewShape___repr__,
212 /*tp_as_number*/ nullptr,
213 /*tp_as_sequence*/ nullptr,
214 /*tp_as_mapping*/ nullptr,
215 /*tp_hash*/ nullptr,
216 /*tp_call*/ (ternaryfunc)UnaryFunction1DVectorViewShape___call__,
217 /*tp_str*/ nullptr,
218 /*tp_getattro*/ nullptr,
219 /*tp_setattro*/ nullptr,
220 /*tp_as_buffer*/ nullptr,
221 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
222 /*tp_doc*/ UnaryFunction1DVectorViewShape___doc__,
223 /*tp_traverse*/ nullptr,
224 /*tp_clear*/ nullptr,
225 /*tp_richcompare*/ nullptr,
226 /*tp_weaklistoffset*/ 0,
227 /*tp_iter*/ nullptr,
228 /*tp_iternext*/ nullptr,
229 /*tp_methods*/ nullptr,
230 /*tp_members*/ nullptr,
232 /*tp_base*/ &UnaryFunction1D_Type,
233 /*tp_dict*/ nullptr,
234 /*tp_descr_get*/ nullptr,
235 /*tp_descr_set*/ nullptr,
236 /*tp_dictoffset*/ 0,
237 /*tp_init*/ (initproc)UnaryFunction1DVectorViewShape___init__,
238 /*tp_alloc*/ nullptr,
239 /*tp_new*/ nullptr,
240};
241
IntegrationType IntegrationType_from_BPy_IntegrationType(PyObject *obj)
PyObject * BPy_IntegrationType_from_IntegrationType(IntegrationType i)
PyObject * BPy_ViewShape_from_ViewShape(ViewShape &vs)
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 GetOccludeeF1D_Type
PyTypeObject GetOccludersF1D_Type
PyTypeObject GetShapeF1D_Type
PyTypeObject IntegrationType_Type
#define BPy_IntegrationType_Check(v)
PyTypeObject Interface1D_Type
static int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorViewShape *self, PyObject *args, PyObject *kwds)
static int integration_type_set(BPy_UnaryFunction1DVectorViewShape *self, PyObject *value, void *)
static PyObject * UnaryFunction1DVectorViewShape___repr__(BPy_UnaryFunction1DVectorViewShape *self)
static PyGetSetDef BPy_UnaryFunction1DVectorViewShape_getseters[]
static PyObject * UnaryFunction1DVectorViewShape___call__(BPy_UnaryFunction1DVectorViewShape *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction1DVectorViewShape_Type
int UnaryFunction1DVectorViewShape_Init(PyObject *module)
static void UnaryFunction1DVectorViewShape___dealloc__(BPy_UnaryFunction1DVectorViewShape *self)
static PyObject * integration_type_get(BPy_UnaryFunction1DVectorViewShape *self, void *)
PyTypeObject UnaryFunction1D_Type
IntegrationType getIntegrationType() const
Definition Functions1D.h:97
void setIntegrationType(IntegrationType integration)
Definition Functions1D.h:91
inherits from class Rep
Definition AppCanvas.cpp:20
Freestyle::UnaryFunction1D< std::vector< Freestyle::ViewShape * > > * uf1D_vectorviewshape