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