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