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