23 #include "../BPy_Convert.h"
24 #include "../Interface0D/BPy_ViewVertex.h"
25 #include "../Interface1D/BPy_ViewEdge.h"
40 "Class hierarchy: :class:`Iterator` > :class:`ViewEdgeIterator` > :class:`ChainingIterator`\n"
42 "Base class for chaining iterators. This class is designed to be\n"
43 "overloaded in order to describe chaining rules. It makes the\n"
44 "description of chaining rules easier. The two main methods that need\n"
45 "to overloaded are traverse() and init(). traverse() tells which\n"
46 ":class:`ViewEdge` to follow, among the adjacent ones. If you specify\n"
47 "restriction rules (such as \"Chain only ViewEdges of the selection\"),\n"
48 "they will be included in the adjacency iterator (i.e, the adjacent\n"
49 "iterator will only stop on \"valid\" edges).\n"
51 ".. method:: __init__(restrict_to_selection=True, restrict_to_unvisited=True,"
52 " begin=None, orientation=True)\n"
53 " __init__(brother)\n"
55 " Builds a Chaining Iterator from the first ViewEdge used for\n"
56 " iteration and its orientation or by using the copy constructor.\n"
58 " :arg restrict_to_selection: Indicates whether to force the chaining\n"
59 " to stay within the set of selected ViewEdges or not.\n"
60 " :type restrict_to_selection: bool\n"
61 " :arg restrict_to_unvisited: Indicates whether a ViewEdge that has\n"
62 " already been chained must be ignored ot not.\n"
63 " :type restrict_to_unvisited: bool\n"
64 " :arg begin: The ViewEdge from which to start the chain.\n"
65 " :type begin: :class:`ViewEdge` or None\n"
66 " :arg orientation: The direction to follow to explore the graph. If\n"
67 " true, the direction indicated by the first ViewEdge is used.\n"
68 " :type orientation: bool\n"
70 " :type brother: ChainingIterator");
77 *((PyObject **)
v) = obj;
83 static const char *kwlist_1[] = {
"brother",
nullptr};
84 static const char *kwlist_2[] = {
85 "restrict_to_selection",
"restrict_to_unvisited",
"begin",
"orientation",
nullptr};
86 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr, *obj4 =
nullptr;
88 if (PyArg_ParseTupleAndKeywords(
92 else if ((
void)PyErr_Clear(),
93 (
void)(obj1 = obj2 = obj3 = obj4 =
nullptr),
94 PyArg_ParseTupleAndKeywords(args,
111 restrict_to_selection, restrict_to_unvisited, begin, orientation);
114 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
117 self->py_ve_it.ve_it =
self->c_it;
118 self->py_ve_it.py_it.it =
self->c_it;
120 self->c_it->py_c_it = (PyObject *)
self;
126 ".. method:: init()\n"
128 " Initializes the iterator context. This method is called each\n"
129 " time a new chain is started. It can be used to reset some\n"
130 " history information that you might want to keep.");
135 PyErr_SetString(PyExc_TypeError,
"init() method not properly overridden");
143 ".. method:: traverse(it)\n"
145 " This method iterates over the potential next ViewEdges and returns\n"
146 " the one that will be followed next. Returns the next ViewEdge to\n"
147 " follow or None when the end of the chain is reached.\n"
149 " :arg it: The iterator over the ViewEdges adjacent to the end vertex\n"
150 " of the current ViewEdge. The adjacency iterator reflects the\n"
151 " restriction rules by only iterating over the valid ViewEdges.\n"
152 " :type it: :class:`AdjacencyIterator`\n"
153 " :return: Returns the next ViewEdge to follow, or None if chaining ends.\n"
154 " :rtype: :class:`ViewEdge` or None");
160 static const char *kwlist[] = {
"it",
nullptr};
164 PyErr_SetString(PyExc_TypeError,
"traverse() method not properly overridden");
167 if (!PyArg_ParseTupleAndKeywords(
181 METH_VARARGS | METH_KEYWORDS,
182 ChainingIterator_traverse_doc},
183 {
nullptr,
nullptr, 0,
nullptr},
189 "The ViewEdge object currently pointed by this iterator.\n"
191 ":type: :class:`ViewEdge`");
195 if (
self->c_it->isEnd()) {
196 PyErr_SetString(PyExc_RuntimeError,
"iteration has stopped");
199 ViewEdge *ve =
self->c_it->operator*();
208 "The ViewVertex that is the next crossing.\n"
210 ":type: :class:`ViewVertex`");
224 "True if the current iteration is an incrementation.\n"
238 ChainingIterator_object_doc,
243 ChainingIterator_next_vertex_doc,
248 ChainingIterator_is_incrementing_doc,
250 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
256 PyVarObject_HEAD_INIT(
nullptr, 0)
"ChainingIterator",
274 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
275 ChainingIterator_doc,
PyTypeObject AdjacencyIterator_Type
static PyObject * ChainingIterator_next_vertex_get(BPy_ChainingIterator *self, void *UNUSED(closure))
static int check_begin(PyObject *obj, void *v)
static PyObject * ChainingIterator_object_get(BPy_ChainingIterator *self, void *UNUSED(closure))
static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args, PyObject *kwds)
static PyGetSetDef BPy_ChainingIterator_getseters[]
static PyMethodDef BPy_ChainingIterator_methods[]
PyDoc_STRVAR(ChainingIterator_doc, "Class hierarchy: :class:`Iterator` > :class:`ViewEdgeIterator` > :class:`ChainingIterator`\n" "\n" "Base class for chaining iterators. This class is designed to be\n" "overloaded in order to describe chaining rules. It makes the\n" "description of chaining rules easier. The two main methods that need\n" "to overloaded are traverse() and init(). traverse() tells which\n" ":class:`ViewEdge` to follow, among the adjacent ones. If you specify\n" "restriction rules (such as \"Chain only ViewEdges of the selection\"),\n" "they will be included in the adjacency iterator (i.e, the adjacent\n" "iterator will only stop on \"valid\" edges).\n" "\n" ".. method:: __init__(restrict_to_selection=True, restrict_to_unvisited=True," " begin=None, orientation=True)\n" " __init__(brother)\n" "\n" " Builds a Chaining Iterator from the first ViewEdge used for\n" " iteration and its orientation or by using the copy constructor.\n" "\n" " :arg restrict_to_selection: Indicates whether to force the chaining\n" " to stay within the set of selected ViewEdges or not.\n" " :type restrict_to_selection: bool\n" " :arg restrict_to_unvisited: Indicates whether a ViewEdge that has\n" " already been chained must be ignored ot not.\n" " :type restrict_to_unvisited: bool\n" " :arg begin: The ViewEdge from which to start the chain.\n" " :type begin: :class:`ViewEdge` or None\n" " :arg orientation: The direction to follow to explore the graph. If\n" " true, the direction indicated by the first ViewEdge is used.\n" " :type orientation: bool\n" " :arg brother: \n" " :type brother: ChainingIterator")
static PyObject * ChainingIterator_is_incrementing_get(BPy_ChainingIterator *self, void *UNUSED(closure))
static PyObject * ChainingIterator_init(BPy_ChainingIterator *self)
PyTypeObject ChainingIterator_Type
static PyObject * ChainingIterator_traverse(BPy_ChainingIterator *self, PyObject *args, PyObject *kwds)
PyObject * PyBool_from_bool(bool b)
bool bool_from_PyBool(PyObject *b)
PyObject * BPy_ViewEdge_from_ViewEdge(ViewEdge &ve)
PyObject * Any_BPy_ViewVertex_from_ViewVertex(ViewVertex &vv)
PyTypeObject ViewEdgeIterator_Type
#define BPy_ViewEdge_Check(v)
ATTR_WARN_UNUSED_RESULT const BMVert * v