Blender  V2.93
BPy_ChainSilhouetteIterator.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 
23 #include "../BPy_Convert.h"
24 #include "../Interface1D/BPy_ViewEdge.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 using namespace Freestyle;
31 
33 
34 //------------------------INSTANCE METHODS ----------------------------------
35 
36 // ChainSilhouetteIterator (bool restrict_to_selection=true, ViewEdge *begin=NULL, bool
37 // orientation=true) ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
38 
39 PyDoc_STRVAR(ChainSilhouetteIterator_doc,
40  "Class hierarchy: :class:`freestyle.types.Iterator` >\n"
41  ":class:`freestyle.types.ViewEdgeIterator` >\n"
42  ":class:`freestyle.types.ChainingIterator` >\n"
43  ":class:`ChainSilhouetteIterator`\n"
44  "\n"
45  "A ViewEdge Iterator used to follow ViewEdges the most naturally. For\n"
46  "example, it will follow visible ViewEdges of same nature. As soon, as\n"
47  "the nature or the visibility changes, the iteration stops (by setting\n"
48  "the pointed ViewEdge to 0). In the case of an iteration over a set of\n"
49  "ViewEdge that are both Silhouette and Crease, there will be a\n"
50  "precedence of the silhouette over the crease criterion.\n"
51  "\n"
52  ".. method:: __init__(restrict_to_selection=True, begin=None, orientation=True)\n"
53  " __init__(brother)\n"
54  "\n"
55  " Builds a ChainSilhouetteIterator from the first ViewEdge used for\n"
56  " iteration and its orientation or the copy constructor.\n"
57  "\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 begin: The ViewEdge from where to start the iteration.\n"
62  " :type begin: :class:`freestyle.types.ViewEdge` or None\n"
63  " :arg orientation: If true, we'll look for the next ViewEdge among\n"
64  " the ViewEdges that surround the ending ViewVertex of begin. If\n"
65  " false, we'll search over the ViewEdges surrounding the ending\n"
66  " ViewVertex of begin.\n"
67  " :type orientation: bool\n"
68  " :arg brother: A ChainSilhouetteIterator object.\n"
69  " :type brother: :class:`ChainSilhouetteIterator`");
70 
71 static int check_begin(PyObject *obj, void *v)
72 {
73  if (obj != nullptr && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
74  return 0;
75  }
76  *((PyObject **)v) = obj;
77  return 1;
78 }
79 
81  PyObject *args,
82  PyObject *kwds)
83 {
84  static const char *kwlist_1[] = {"brother", nullptr};
85  static const char *kwlist_2[] = {"restrict_to_selection", "begin", "orientation", nullptr};
86  PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr;
87 
88  if (PyArg_ParseTupleAndKeywords(
89  args, kwds, "O!", (char **)kwlist_1, &ChainSilhouetteIterator_Type, &obj1)) {
90  self->cs_it = new ChainSilhouetteIterator(*(((BPy_ChainSilhouetteIterator *)obj1)->cs_it));
91  }
92  else if ((void)PyErr_Clear(),
93  (void)(obj1 = obj2 = obj3 = nullptr),
94  PyArg_ParseTupleAndKeywords(args,
95  kwds,
96  "|O!O&O!",
97  (char **)kwlist_2,
98  &PyBool_Type,
99  &obj1,
100  check_begin,
101  &obj2,
102  &PyBool_Type,
103  &obj3)) {
104  bool restrict_to_selection = (!obj1) ? true : bool_from_PyBool(obj1);
105  ViewEdge *begin = (!obj2 || obj2 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj2)->ve;
106  bool orientation = (!obj3) ? true : bool_from_PyBool(obj3);
107  self->cs_it = new ChainSilhouetteIterator(restrict_to_selection, begin, orientation);
108  }
109  else {
110  PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
111  return -1;
112  }
113  self->py_c_it.c_it = self->cs_it;
114  self->py_c_it.py_ve_it.ve_it = self->cs_it;
115  self->py_c_it.py_ve_it.py_it.it = self->cs_it;
116  return 0;
117 }
118 
119 /*-----------------------BPy_ChainSilhouetteIterator type definition ----------------------------*/
120 
122  PyVarObject_HEAD_INIT(nullptr, 0) "ChainSilhouetteIterator", /* tp_name */
123  sizeof(BPy_ChainSilhouetteIterator), /* tp_basicsize */
124  0, /* tp_itemsize */
125  nullptr, /* tp_dealloc */
126  0, /* tp_vectorcall_offset */
127  nullptr, /* tp_getattr */
128  nullptr, /* tp_setattr */
129  nullptr, /* tp_reserved */
130  nullptr, /* tp_repr */
131  nullptr, /* tp_as_number */
132  nullptr, /* tp_as_sequence */
133  nullptr, /* tp_as_mapping */
134  nullptr, /* tp_hash */
135  nullptr, /* tp_call */
136  nullptr, /* tp_str */
137  nullptr, /* tp_getattro */
138  nullptr, /* tp_setattro */
139  nullptr, /* tp_as_buffer */
140  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
141  ChainSilhouetteIterator_doc, /* tp_doc */
142  nullptr, /* tp_traverse */
143  nullptr, /* tp_clear */
144  nullptr, /* tp_richcompare */
145  0, /* tp_weaklistoffset */
146  nullptr, /* tp_iter */
147  nullptr, /* tp_iternext */
148  nullptr, /* tp_methods */
149  nullptr, /* tp_members */
150  nullptr, /* tp_getset */
151  &ChainingIterator_Type, /* tp_base */
152  nullptr, /* tp_dict */
153  nullptr, /* tp_descr_get */
154  nullptr, /* tp_descr_set */
155  0, /* tp_dictoffset */
156  (initproc)ChainSilhouetteIterator_init, /* tp_init */
157  nullptr, /* tp_alloc */
158  nullptr, /* tp_new */
159 };
160 
162 
163 #ifdef __cplusplus
164 }
165 #endif
static int check_begin(PyObject *obj, void *v)
PyTypeObject ChainSilhouetteIterator_Type
PyDoc_STRVAR(ChainSilhouetteIterator_doc, "Class hierarchy: :class:`freestyle.types.Iterator` >\n" ":class:`freestyle.types.ViewEdgeIterator` >\n" ":class:`freestyle.types.ChainingIterator` >\n" ":class:`ChainSilhouetteIterator`\n" "\n" "A ViewEdge Iterator used to follow ViewEdges the most naturally. For\n" "example, it will follow visible ViewEdges of same nature. As soon, as\n" "the nature or the visibility changes, the iteration stops (by setting\n" "the pointed ViewEdge to 0). In the case of an iteration over a set of\n" "ViewEdge that are both Silhouette and Crease, there will be a\n" "precedence of the silhouette over the crease criterion.\n" "\n" ".. method:: __init__(restrict_to_selection=True, begin=None, orientation=True)\n" " __init__(brother)\n" "\n" " Builds a ChainSilhouetteIterator from the first ViewEdge used for\n" " iteration and its orientation or 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 begin: The ViewEdge from where to start the iteration.\n" " :type begin: :class:`freestyle.types.ViewEdge` or None\n" " :arg orientation: If true, we'll look for the next ViewEdge among\n" " the ViewEdges that surround the ending ViewVertex of begin. If\n" " false, we'll search over the ViewEdges surrounding the ending\n" " ViewVertex of begin.\n" " :type orientation: bool\n" " :arg brother: A ChainSilhouetteIterator object.\n" " :type brother: :class:`ChainSilhouetteIterator`")
static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self, PyObject *args, PyObject *kwds)
PyTypeObject ChainingIterator_Type
bool bool_from_PyBool(PyObject *b)
#define BPy_ViewEdge_Check(v)
Definition: BPy_ViewEdge.h:35
ATTR_WARN_UNUSED_RESULT const BMVert * v
inherits from class Rep
Definition: AppCanvas.cpp:32