9 #include "../BPy_Convert.h"
10 #include "../Interface0D/BPy_ViewVertex.h"
11 #include "../Interface1D/BPy_ViewEdge.h"
26 "Class hierarchy: :class:`Iterator` > :class:`ViewEdgeIterator` > :class:`ChainingIterator`\n"
28 "Base class for chaining iterators. This class is designed to be\n"
29 "overloaded in order to describe chaining rules. It makes the\n"
30 "description of chaining rules easier. The two main methods that need\n"
31 "to overloaded are traverse() and init(). traverse() tells which\n"
32 ":class:`ViewEdge` to follow, among the adjacent ones. If you specify\n"
33 "restriction rules (such as \"Chain only ViewEdges of the selection\"),\n"
34 "they will be included in the adjacency iterator (i.e, the adjacent\n"
35 "iterator will only stop on \"valid\" edges).\n"
37 ".. method:: __init__(restrict_to_selection=True, restrict_to_unvisited=True,"
38 " begin=None, orientation=True)\n"
39 " __init__(brother)\n"
41 " Builds a Chaining Iterator from the first ViewEdge used for\n"
42 " iteration and its orientation or by using the copy constructor.\n"
44 " :arg restrict_to_selection: Indicates whether to force the chaining\n"
45 " to stay within the set of selected ViewEdges or not.\n"
46 " :type restrict_to_selection: bool\n"
47 " :arg restrict_to_unvisited: Indicates whether a ViewEdge that has\n"
48 " already been chained must be ignored ot not.\n"
49 " :type restrict_to_unvisited: bool\n"
50 " :arg begin: The ViewEdge from which to start the chain.\n"
51 " :type begin: :class:`ViewEdge` or None\n"
52 " :arg orientation: The direction to follow to explore the graph. If\n"
53 " true, the direction indicated by the first ViewEdge is used.\n"
54 " :type orientation: bool\n"
56 " :type brother: ChainingIterator");
63 *((PyObject **)
v) = obj;
69 static const char *kwlist_1[] = {
"brother",
nullptr};
70 static const char *kwlist_2[] = {
71 "restrict_to_selection",
"restrict_to_unvisited",
"begin",
"orientation",
nullptr};
72 PyObject *obj1 =
nullptr, *obj2 =
nullptr, *obj3 =
nullptr, *obj4 =
nullptr;
74 if (PyArg_ParseTupleAndKeywords(
78 else if ((
void)PyErr_Clear(),
79 (
void)(obj1 = obj2 = obj3 = obj4 =
nullptr),
80 PyArg_ParseTupleAndKeywords(args,
97 restrict_to_selection, restrict_to_unvisited, begin, orientation);
100 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
103 self->py_ve_it.ve_it =
self->c_it;
104 self->py_ve_it.py_it.it =
self->c_it;
106 self->c_it->py_c_it = (PyObject *)
self;
112 ".. method:: init()\n"
114 " Initializes the iterator context. This method is called each\n"
115 " time a new chain is started. It can be used to reset some\n"
116 " history information that you might want to keep.");
121 PyErr_SetString(PyExc_TypeError,
"init() method not properly overridden");
129 ".. method:: traverse(it)\n"
131 " This method iterates over the potential next ViewEdges and returns\n"
132 " the one that will be followed next. Returns the next ViewEdge to\n"
133 " follow or None when the end of the chain is reached.\n"
135 " :arg it: The iterator over the ViewEdges adjacent to the end vertex\n"
136 " of the current ViewEdge. The adjacency iterator reflects the\n"
137 " restriction rules by only iterating over the valid ViewEdges.\n"
138 " :type it: :class:`AdjacencyIterator`\n"
139 " :return: Returns the next ViewEdge to follow, or None if chaining ends.\n"
140 " :rtype: :class:`ViewEdge` or None");
146 static const char *kwlist[] = {
"it",
nullptr};
150 PyErr_SetString(PyExc_TypeError,
"traverse() method not properly overridden");
153 if (!PyArg_ParseTupleAndKeywords(
167 METH_VARARGS | METH_KEYWORDS,
168 ChainingIterator_traverse_doc},
169 {
nullptr,
nullptr, 0,
nullptr},
175 "The ViewEdge object currently pointed by this iterator.\n"
177 ":type: :class:`ViewEdge`");
181 if (
self->c_it->isEnd()) {
182 PyErr_SetString(PyExc_RuntimeError,
"iteration has stopped");
185 ViewEdge *ve =
self->c_it->operator*();
194 "The ViewVertex that is the next crossing.\n"
196 ":type: :class:`ViewVertex`");
210 "True if the current iteration is an incrementation.\n"
224 ChainingIterator_object_doc,
229 ChainingIterator_next_vertex_doc,
234 ChainingIterator_is_incrementing_doc,
236 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
242 PyVarObject_HEAD_INIT(
nullptr, 0)
"ChainingIterator",
260 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
261 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