Blender V5.3
BPy_UnaryFunction0DVec3f.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "../BPy_Convert.h"
13
15
16using namespace Freestyle;
17
19
20//-------------------MODULE INITIALIZATION--------------------------------
21
22int UnaryFunction0DVec3f_Init(PyObject *module)
23{
24 if (module == nullptr) {
25 return -1;
26 }
27
28 if (PyType_Ready(&UnaryFunction0DVec3f_Type) < 0) {
29 return -1;
30 }
31 PyModule_AddObjectRef(module, "UnaryFunction0DVec3f", (PyObject *)&UnaryFunction0DVec3f_Type);
32
33 if (PyType_Ready(&VertexOrientation3DF0D_Type) < 0) {
34 return -1;
35 }
36 PyModule_AddObjectRef(
37 module, "VertexOrientation3DF0D", (PyObject *)&VertexOrientation3DF0D_Type);
38
39 return 0;
40}
41
42//------------------------INSTANCE METHODS ----------------------------------
43
45 /* Wrap. */
46 UnaryFunction0DVec3f___doc__,
47 "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVec3f`\n"
48 "\n"
49 "Base class for unary functions (functors) that work on\n"
50 ":class:`Interface0DIterator` and return a 3D vector.\n"
51 "\n"
52 ".. method:: __init__()\n"
53 "\n"
54 " Default constructor.\n");
56 PyObject *args,
57 PyObject *kwds)
58{
59 static const char *kwlist[] = {nullptr};
60
61 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
62 return -1;
63 }
65 self->uf0D_vec3f->py_uf0D = (PyObject *)self;
66 return 0;
67}
68
70{
71 delete self->uf0D_vec3f;
72 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
73}
74
76{
77 return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vec3f);
78}
79
81 PyObject *args,
82 PyObject *kwds)
83{
84 static const char *kwlist[] = {"it", nullptr};
85 PyObject *obj;
86
87 if (!PyArg_ParseTupleAndKeywords(args,
88 kwds,
89 "O!" /* `it` */
90 ":__call__",
91 (char **)kwlist,
93 &obj))
94 {
95 return nullptr;
96 }
97
98 if (typeid(*(self->uf0D_vec3f)) == typeid(UnaryFunction0D<Vec3f>)) {
99 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
100 return nullptr;
101 }
102 if (self->uf0D_vec3f->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
103 if (!PyErr_Occurred()) {
104 string class_name(Py_TYPE(self)->tp_name);
105 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
106 }
107 return nullptr;
108 }
109 return Vector_from_Vec3f(self->uf0D_vec3f->result);
110}
111
112/*-----------------------BPy_UnaryFunction0DVec3f type definition ------------------------------*/
113
115 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
116 /*tp_name*/ "UnaryFunction0DVec3f",
117 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DVec3f),
118 /*tp_itemsize*/ 0,
119 /*tp_dealloc*/ (destructor)UnaryFunction0DVec3f___dealloc__,
120 /*tp_vectorcall_offset*/ 0,
121 /*tp_getattr*/ nullptr,
122 /*tp_setattr*/ nullptr,
123 /*tp_as_async*/ nullptr,
124 /*tp_repr*/ (reprfunc)UnaryFunction0DVec3f___repr__,
125 /*tp_as_number*/ nullptr,
126 /*tp_as_sequence*/ nullptr,
127 /*tp_as_mapping*/ nullptr,
128 /*tp_hash*/ nullptr,
129 /*tp_call*/ (ternaryfunc)UnaryFunction0DVec3f___call__,
130 /*tp_str*/ nullptr,
131 /*tp_getattro*/ nullptr,
132 /*tp_setattro*/ nullptr,
133 /*tp_as_buffer*/ nullptr,
134 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
135 /*tp_doc*/ UnaryFunction0DVec3f___doc__,
136 /*tp_traverse*/ nullptr,
137 /*tp_clear*/ nullptr,
138 /*tp_richcompare*/ nullptr,
139 /*tp_weaklistoffset*/ 0,
140 /*tp_iter*/ nullptr,
141 /*tp_iternext*/ nullptr,
142 /*tp_methods*/ nullptr,
143 /*tp_members*/ nullptr,
144 /*tp_getset*/ nullptr,
145 /*tp_base*/ &UnaryFunction0D_Type,
146 /*tp_dict*/ nullptr,
147 /*tp_descr_get*/ nullptr,
148 /*tp_descr_set*/ nullptr,
149 /*tp_dictoffset*/ 0,
150 /*tp_init*/ (initproc)UnaryFunction0DVec3f___init__,
151 /*tp_alloc*/ nullptr,
152 /*tp_new*/ nullptr,
153};
154
PyObject * Vector_from_Vec3f(Vec3f &vec)
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 Interface0DIterator_Type
static void UnaryFunction0DVec3f___dealloc__(BPy_UnaryFunction0DVec3f *self)
int UnaryFunction0DVec3f_Init(PyObject *module)
static PyObject * UnaryFunction0DVec3f___repr__(BPy_UnaryFunction0DVec3f *self)
PyTypeObject UnaryFunction0DVec3f_Type
static PyObject * UnaryFunction0DVec3f___call__(BPy_UnaryFunction0DVec3f *self, PyObject *args, PyObject *kwds)
static int UnaryFunction0DVec3f___init__(BPy_UnaryFunction0DVec3f *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0D_Type
PyTypeObject VertexOrientation3DF0D_Type
inherits from class Rep
Definition AppCanvas.cpp:20
Freestyle::UnaryFunction0D< Freestyle::Geometry::Vec3f > * uf0D_vec3f