Made the Freestyle Python API compatible with Python 3.
[blender.git] / source / blender / freestyle / intern / python / Iterator / BPy_ChainSilhouetteIterator.cpp
1 #include "BPy_ChainSilhouetteIterator.h"
2
3 #include "../BPy_Convert.h"
4 #include "../Interface1D/BPy_ViewEdge.h"
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 ///////////////////////////////////////////////////////////////////////////////////////////
11
12 /*---------------  Python API function prototypes for ChainSilhouetteIterator instance  -----------*/
13 static int ChainSilhouetteIterator___init__(BPy_ChainSilhouetteIterator *self, PyObject *args);
14
15 /*-----------------------BPy_ChainSilhouetteIterator type definition ------------------------------*/
16
17 PyTypeObject ChainSilhouetteIterator_Type = {
18         PyObject_HEAD_INIT(NULL)
19         "ChainSilhouetteIterator",      /* tp_name */
20         sizeof(BPy_ChainSilhouetteIterator), /* tp_basicsize */
21         0,                              /* tp_itemsize */
22         0,                              /* tp_dealloc */
23         0,                              /* tp_print */
24         0,                              /* tp_getattr */
25         0,                              /* tp_setattr */
26         0,                              /* tp_reserved */
27         0,                              /* tp_repr */
28         0,                              /* tp_as_number */
29         0,                              /* tp_as_sequence */
30         0,                              /* tp_as_mapping */
31         0,                              /* tp_hash  */
32         0,                              /* tp_call */
33         0,                              /* tp_str */
34         0,                              /* tp_getattro */
35         0,                              /* tp_setattro */
36         0,                              /* tp_as_buffer */
37         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
38         "ChainSilhouetteIterator objects", /* tp_doc */
39         0,                              /* tp_traverse */
40         0,                              /* tp_clear */
41         0,                              /* tp_richcompare */
42         0,                              /* tp_weaklistoffset */
43         0,                              /* tp_iter */
44         0,                              /* tp_iternext */
45         0,                              /* tp_methods */
46         0,                              /* tp_members */
47         0,                              /* tp_getset */
48         &ChainingIterator_Type,         /* tp_base */
49         0,                              /* tp_dict */
50         0,                              /* tp_descr_get */
51         0,                              /* tp_descr_set */
52         0,                              /* tp_dictoffset */
53         (initproc)ChainSilhouetteIterator___init__, /* tp_init */
54         0,                              /* tp_alloc */
55         0,                              /* tp_new */
56 };
57
58 //------------------------INSTANCE METHODS ----------------------------------
59
60 // ChainSilhouetteIterator (bool iRestrictToSelection=true, ViewEdge *begin=NULL, bool orientation=true)
61 // ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
62
63 int ChainSilhouetteIterator___init__(BPy_ChainSilhouetteIterator *self, PyObject *args )
64 {       
65         PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0;
66
67         if (!( PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) ))
68             return -1;
69
70         if( obj1 && BPy_ChainSilhouetteIterator_Check(obj1)  ) { 
71                 self->cs_it = new ChainSilhouetteIterator(*( ((BPy_ChainSilhouetteIterator *) obj1)->cs_it ));
72         
73         } else {
74                 bool restrictToSelection = ( obj1 ) ? bool_from_PyBool(obj1) : true;
75                 ViewEdge *begin;
76                 if ( !obj2 || obj2 == Py_None )
77                         begin = NULL;
78                 else if ( BPy_ViewEdge_Check(obj2) )
79                         begin = ((BPy_ViewEdge *) obj2)->ve;
80                 else {
81                         PyErr_SetString(PyExc_TypeError, "2nd argument must be either a ViewEdge object or None");
82                         return -1;
83                 }
84                 bool orientation = ( obj3 ) ? bool_from_PyBool(obj3) : true;
85                 
86                 self->cs_it = new ChainSilhouetteIterator( restrictToSelection, begin, orientation);    
87         }
88         
89         self->py_c_it.c_it = self->cs_it;
90         self->py_c_it.py_ve_it.ve_it = self->cs_it;
91         self->py_c_it.py_ve_it.py_it.it = self->cs_it;
92         
93         return 0;
94         
95 }
96
97
98 ///////////////////////////////////////////////////////////////////////////////////////////
99
100 #ifdef __cplusplus
101 }
102 #endif