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 source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIt
erator.cpp |
| 29 * \ingroup freestyle |
| 30 */ |
| 31 |
| 32 #include "BPy_orientedViewEdgeIterator.h" |
| 33 |
| 34 #include "../BPy_Convert.h" |
| 35 |
| 36 #ifdef __cplusplus |
| 37 extern "C" { |
| 38 #endif |
| 39 |
| 40 ////////////////////////////////////////////////////////////////////////////////
/////////// |
| 41 |
| 42 //------------------------INSTANCE METHODS ---------------------------------- |
| 43 |
| 44 PyDoc_STRVAR(orientedViewEdgeIterator_doc, |
| 45 "Class hierarchy: :class:`Iterator` > :class:`orientedViewEdgeIterator`\n" |
| 46 "\n" |
| 47 "Class representing an iterator over oriented ViewEdges around a\n" |
| 48 ":class:`ViewVertex`. This iterator allows a CCW iteration (in the image\n" |
| 49 "plane). An instance of an orientedViewEdgeIterator can only be\n" |
| 50 "obtained from a ViewVertex by calling edgesBegin() or edgesEnd().\n" |
| 51 "\n" |
| 52 ".. method:: __init__()\n" |
| 53 "\n" |
| 54 " Default constructor.\n" |
| 55 "\n" |
| 56 ".. method:: __init__(iBrother)\n" |
| 57 "\n" |
| 58 " Copy constructor.\n" |
| 59 "\n" |
| 60 " :arg iBrother: An orientedViewEdgeIterator object.\n" |
| 61 " :type iBrother: :class:`orientedViewEdgeIterator`"); |
| 62 |
| 63 static int orientedViewEdgeIterator_init(BPy_orientedViewEdgeIterator *self, PyO
bject *args, PyObject *kwds) |
| 64 { |
| 65 static const char *kwlist[] = {"brother", NULL}; |
| 66 PyObject *brother = 0; |
| 67 |
| 68 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &or
ientedViewEdgeIterator_Type, &brother)) |
| 69 return -1; |
| 70 if (!brother) |
| 71 self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator(
); |
| 72 else |
| 73 self->ove_it = new ViewVertexInternal::orientedViewEdgeIterator(
*(((BPy_orientedViewEdgeIterator *)brother)->ove_it)); |
| 74 self->py_it.it = self->ove_it; |
| 75 self->reversed = 0; |
| 76 return 0; |
| 77 } |
| 78 |
| 79 static PyObject * orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator
*self) |
| 80 { |
| 81 ViewVertex::directedViewEdge *dve; |
| 82 |
| 83 if (self->reversed) { |
| 84 if (self->ove_it->isBegin()) { |
| 85 PyErr_SetNone(PyExc_StopIteration); |
| 86 return NULL; |
| 87 } |
| 88 self->ove_it->decrement(); |
| 89 dve = self->ove_it->operator->(); |
| 90 } |
| 91 else { |
| 92 if (self->ove_it->isEnd()) { |
| 93 PyErr_SetNone(PyExc_StopIteration); |
| 94 return NULL; |
| 95 } |
| 96 dve = self->ove_it->operator->(); |
| 97 self->ove_it->increment(); |
| 98 } |
| 99 return BPy_directedViewEdge_from_directedViewEdge(*dve); |
| 100 } |
| 101 |
| 102 /*----------------------orientedViewEdgeIterator get/setters -------------------
---------*/ |
| 103 |
| 104 PyDoc_STRVAR(orientedViewEdgeIterator_object_doc, |
| 105 "The oriented ViewEdge (i.e., a tuple of the pointed ViewEdge and a boolean\n" |
| 106 "value) currently pointed by this iterator. If the boolean value is true,\n" |
| 107 "the ViewEdge is incoming.\n" |
| 108 "\n" |
| 109 ":type: (:class:`directedViewEdge`, bool)"); |
| 110 |
| 111 static PyObject *orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterato
r *self, void *UNUSED(closure)) |
| 112 { |
| 113 return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator
*()); |
| 114 } |
| 115 |
| 116 static PyGetSetDef BPy_orientedViewEdgeIterator_getseters[] = { |
| 117 {(char *)"object", (getter)orientedViewEdgeIterator_object_get, (setter)
NULL, (char *)orientedViewEdgeIterator_object_doc, NULL}, |
| 118 {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ |
| 119 }; |
| 120 |
| 121 /*-----------------------BPy_orientedViewEdgeIterator type definition ----------
--------------------*/ |
| 122 |
| 123 PyTypeObject orientedViewEdgeIterator_Type = { |
| 124 PyVarObject_HEAD_INIT(NULL, 0) |
| 125 "orientedViewEdgeIterator", /* tp_name */ |
| 126 sizeof(BPy_orientedViewEdgeIterator), /* tp_basicsize */ |
| 127 0, /* tp_itemsize */ |
| 128 0, /* tp_dealloc */ |
| 129 0, /* tp_print */ |
| 130 0, /* tp_getattr */ |
| 131 0, /* tp_setattr */ |
| 132 0, /* tp_reserved */ |
| 133 0, /* tp_repr */ |
| 134 0, /* tp_as_number */ |
| 135 0, /* tp_as_sequence */ |
| 136 0, /* tp_as_mapping */ |
| 137 0, /* tp_hash */ |
| 138 0, /* tp_call */ |
| 139 0, /* tp_str */ |
| 140 0, /* tp_getattro */ |
| 141 0, /* tp_setattro */ |
| 142 0, /* tp_as_buffer */ |
| 143 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
| 144 orientedViewEdgeIterator_doc, /* tp_doc */ |
| 145 0, /* tp_traverse */ |
| 146 0, /* tp_clear */ |
| 147 0, /* tp_richcompare */ |
| 148 0, /* tp_weaklistoffset */ |
| 149 PyObject_SelfIter, /* tp_iter */ |
| 150 (iternextfunc)orientedViewEdgeIterator_iternext, /* tp_iternext */ |
| 151 0, /* tp_methods */ |
| 152 0, /* tp_members */ |
| 153 BPy_orientedViewEdgeIterator_getseters, /* tp_getset */ |
| 154 &Iterator_Type, /* tp_base */ |
| 155 0, /* tp_dict */ |
| 156 0, /* tp_descr_get */ |
| 157 0, /* tp_descr_set */ |
| 158 0, /* tp_dictoffset */ |
| 159 (initproc)orientedViewEdgeIterator_init, /* tp_init */ |
| 160 0, /* tp_alloc */ |
| 161 0, /* tp_new */ |
| 162 }; |
| 163 |
| 164 ////////////////////////////////////////////////////////////////////////////////
/////////// |
| 165 |
| 166 #ifdef __cplusplus |
| 167 } |
| 168 #endif |
OLD | NEW |