Blender  V2.93
BPy_BBox.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "BPy_BBox.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 using namespace Freestyle;
28 using namespace Freestyle::Geometry;
29 
31 
32 //-------------------MODULE INITIALIZATION--------------------------------
33 int BBox_Init(PyObject *module)
34 {
35  if (module == nullptr) {
36  return -1;
37  }
38 
39  if (PyType_Ready(&BBox_Type) < 0) {
40  return -1;
41  }
42  Py_INCREF(&BBox_Type);
43  PyModule_AddObject(module, "BBox", (PyObject *)&BBox_Type);
44 
45  return 0;
46 }
47 
48 //------------------------INSTANCE METHODS ----------------------------------
49 
50 PyDoc_STRVAR(BBox_doc,
51  "Class for representing a bounding box.\n"
52  "\n"
53  ".. method:: __init__()\n"
54  "\n"
55  " Default constructor.");
56 
57 static int BBox_init(BPy_BBox *self, PyObject *args, PyObject *kwds)
58 {
59  static const char *kwlist[] = {nullptr};
60 
61  if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
62  return -1;
63  }
64  self->bb = new BBox<Vec3r>();
65  return 0;
66 }
67 
68 static void BBox_dealloc(BPy_BBox *self)
69 {
70  delete self->bb;
71  Py_TYPE(self)->tp_free((PyObject *)self);
72 }
73 
74 static PyObject *BBox_repr(BPy_BBox *self)
75 {
76  return PyUnicode_FromFormat("BBox - address: %p", self->bb);
77 }
78 
79 /*-----------------------BPy_BBox type definition ------------------------------*/
80 
81 PyTypeObject BBox_Type = {
82  PyVarObject_HEAD_INIT(nullptr, 0) "BBox", /* tp_name */
83  sizeof(BPy_BBox), /* tp_basicsize */
84  0, /* tp_itemsize */
85  (destructor)BBox_dealloc, /* tp_dealloc */
86  0, /* tp_vectorcall_offset */
87  nullptr, /* tp_getattr */
88  nullptr, /* tp_setattr */
89  nullptr, /* tp_reserved */
90  (reprfunc)BBox_repr, /* tp_repr */
91  nullptr, /* tp_as_number */
92  nullptr, /* tp_as_sequence */
93  nullptr, /* tp_as_mapping */
94  nullptr, /* tp_hash */
95  nullptr, /* tp_call */
96  nullptr, /* tp_str */
97  nullptr, /* tp_getattro */
98  nullptr, /* tp_setattro */
99  nullptr, /* tp_as_buffer */
100  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
101  BBox_doc, /* tp_doc */
102  nullptr, /* tp_traverse */
103  nullptr, /* tp_clear */
104  nullptr, /* tp_richcompare */
105  0, /* tp_weaklistoffset */
106  nullptr, /* tp_iter */
107  nullptr, /* tp_iternext */
108  nullptr, /* tp_methods */
109  nullptr, /* tp_members */
110  nullptr, /* tp_getset */
111  nullptr, /* tp_base */
112  nullptr, /* tp_dict */
113  nullptr, /* tp_descr_get */
114  nullptr, /* tp_descr_set */
115  0, /* tp_dictoffset */
116  (initproc)BBox_init, /* tp_init */
117  nullptr, /* tp_alloc */
118  PyType_GenericNew, /* tp_new */
119 };
120 
122 
123 #ifdef __cplusplus
124 }
125 #endif
PyTypeObject BBox_Type
Definition: BPy_BBox.cpp:81
static PyObject * BBox_repr(BPy_BBox *self)
Definition: BPy_BBox.cpp:74
static void BBox_dealloc(BPy_BBox *self)
Definition: BPy_BBox.cpp:68
int BBox_Init(PyObject *module)
Definition: BPy_BBox.cpp:33
static int BBox_init(BPy_BBox *self, PyObject *args, PyObject *kwds)
Definition: BPy_BBox.cpp:57
PyDoc_STRVAR(BBox_doc, "Class for representing a bounding box.\n" "\n" ".. method:: __init__()\n" "\n" " Default constructor.")
static struct PyModuleDef module
PyObject * self
Definition: bpy_driver.c:185
inherits from class Rep
Definition: AppCanvas.cpp:32