Blender V5.0
BPy_BBox.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_BBox.h"
10
11using namespace Freestyle;
12using namespace Freestyle::Geometry;
13
15
16//-------------------MODULE INITIALIZATION--------------------------------
17int BBox_Init(PyObject *module)
18{
19 if (module == nullptr) {
20 return -1;
21 }
22
23 if (PyType_Ready(&BBox_Type) < 0) {
24 return -1;
25 }
26 PyModule_AddObjectRef(module, "BBox", (PyObject *)&BBox_Type);
27
28 return 0;
29}
30
31//------------------------INSTANCE METHODS ----------------------------------
32
34 /* Wrap. */
35 BBox_doc,
36 "Class for representing a bounding box.\n"
37 "\n"
38 ".. method:: __init__()\n"
39 "\n"
40 " Default constructor.\n");
41static int BBox_init(BPy_BBox *self, PyObject *args, PyObject *kwds)
42{
43 static const char *kwlist[] = {nullptr};
44
45 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
46 return -1;
47 }
48 self->bb = new BBox<Vec3r>();
49 return 0;
50}
51
53{
54 delete self->bb;
55 Py_TYPE(self)->tp_free((PyObject *)self);
56}
57
58static PyObject *BBox_repr(BPy_BBox *self)
59{
60 return PyUnicode_FromFormat("BBox - address: %p", self->bb);
61}
62
63/*-----------------------BPy_BBox type definition ------------------------------*/
64
65PyTypeObject BBox_Type = {
66 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
67 /*tp_name*/ "BBox",
68 /*tp_basicsize*/ sizeof(BPy_BBox),
69 /*tp_itemsize*/ 0,
70 /*tp_dealloc*/ (destructor)BBox_dealloc,
71 /*tp_vectorcall_offset*/ 0,
72 /*tp_getattr*/ nullptr,
73 /*tp_setattr*/ nullptr,
74 /*tp_as_async*/ nullptr,
75 /*tp_repr*/ (reprfunc)BBox_repr,
76 /*tp_as_number*/ nullptr,
77 /*tp_as_sequence*/ nullptr,
78 /*tp_as_mapping*/ nullptr,
79 /*tp_hash*/ nullptr,
80 /*tp_call*/ nullptr,
81 /*tp_str*/ nullptr,
82 /*tp_getattro*/ nullptr,
83 /*tp_setattro*/ nullptr,
84 /*tp_as_buffer*/ nullptr,
85 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
86 /*tp_doc*/ BBox_doc,
87 /*tp_traverse*/ nullptr,
88 /*tp_clear*/ nullptr,
89 /*tp_richcompare*/ nullptr,
90 /*tp_weaklistoffset*/ 0,
91 /*tp_iter*/ nullptr,
92 /*tp_iternext*/ nullptr,
93 /*tp_methods*/ nullptr,
94 /*tp_members*/ nullptr,
95 /*tp_getset*/ nullptr,
96 /*tp_base*/ nullptr,
97 /*tp_dict*/ nullptr,
98 /*tp_descr_get*/ nullptr,
99 /*tp_descr_set*/ nullptr,
100 /*tp_dictoffset*/ 0,
101 /*tp_init*/ (initproc)BBox_init,
102 /*tp_alloc*/ nullptr,
103 /*tp_new*/ PyType_GenericNew,
104};
105
PyTypeObject BBox_Type
Definition BPy_BBox.cpp:65
PyDoc_STRVAR(BBox_doc, "Class for representing a bounding box.\n" "\n" ".. method:: __init__()\n" "\n" " Default constructor.\n")
static void BBox_dealloc(BPy_BBox *self)
Definition BPy_BBox.cpp:52
int BBox_Init(PyObject *module)
Definition BPy_BBox.cpp:17
static PyObject * BBox_repr(BPy_BBox *self)
Definition BPy_BBox.cpp:58
static int BBox_init(BPy_BBox *self, PyObject *args, PyObject *kwds)
Definition BPy_BBox.cpp:41
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20
static struct PyModuleDef module
Definition python.cpp:796