1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#include "BPy_AdjacencyIterator.h"
#include "../BPy_Convert.h"
#include "../Interface0D/BPy_ViewVertex.h"
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
/*--------------- Python API function prototypes for AdjacencyIterator instance -----------*/
static int AdjacencyIterator___init__(BPy_AdjacencyIterator *self, PyObject *args);
static PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self);
static PyObject * AdjacencyIterator_isIncoming(BPy_AdjacencyIterator *self);
static PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self);
/*----------------------AdjacencyIterator instance definitions ----------------------------*/
static PyMethodDef BPy_AdjacencyIterator_methods[] = {
{"isIncoming", ( PyCFunction ) AdjacencyIterator_isIncoming, METH_NOARGS, "() Returns true if the current ViewEdge is is coming towards the iteration vertex. False otherwise."},
{"getObject", ( PyCFunction ) AdjacencyIterator_getObject, METH_NOARGS, "() Get object referenced by the iterator"},
{NULL, NULL, 0, NULL}
};
/*-----------------------BPy_AdjacencyIterator type definition ------------------------------*/
PyTypeObject AdjacencyIterator_Type = {
PyObject_HEAD_INIT(NULL)
"AdjacencyIterator", /* tp_name */
sizeof(BPy_AdjacencyIterator), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
"AdjacencyIterator objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)AdjacencyIterator_iternext, /* tp_iternext */
BPy_AdjacencyIterator_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
&Iterator_Type, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)AdjacencyIterator___init__, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
};
//------------------------INSTANCE METHODS ----------------------------------
int AdjacencyIterator___init__(BPy_AdjacencyIterator *self, PyObject *args )
{
PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0;
if (! PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) )
return -1;
if( !obj1 && !obj2 && !obj3 ){
self->a_it = new AdjacencyIterator();
} else if( BPy_AdjacencyIterator_Check(obj1) ) {
self->a_it = new AdjacencyIterator(*( ((BPy_AdjacencyIterator *) obj1)->a_it ));
} else if( BPy_ViewVertex_Check(obj1) ) {
bool restrictToSelection = ( obj2 ) ? bool_from_PyBool(obj2) : true;
bool restrictToUnvisited = ( obj3 ) ? bool_from_PyBool(obj3) : true;
self->a_it = new AdjacencyIterator( ((BPy_ViewVertex *) obj1)->vv, restrictToSelection, restrictToUnvisited );
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
return -1;
}
self->py_it.it = self->a_it;
return 0;
}
PyObject * AdjacencyIterator_iternext(BPy_AdjacencyIterator *self) {
if (self->a_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
ViewEdge *ve = self->a_it->operator*();
self->a_it->increment();
return BPy_ViewEdge_from_ViewEdge( *ve );
}
PyObject * AdjacencyIterator_isIncoming(BPy_AdjacencyIterator *self) {
return PyBool_from_bool(self->a_it->isIncoming());
}
PyObject * AdjacencyIterator_getObject(BPy_AdjacencyIterator *self) {
ViewEdge *ve = self->a_it->operator*();
if( ve )
return BPy_ViewEdge_from_ViewEdge( *ve );
Py_RETURN_NONE;
}
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
|