Blender  V3.3
BPy_ChainSilhouetteIterator.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 
9 #include "../BPy_Convert.h"
10 #include "../Interface1D/BPy_ViewEdge.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 using namespace Freestyle;
17 
19 
20 //------------------------INSTANCE METHODS ----------------------------------
21 
22 // ChainSilhouetteIterator (bool restrict_to_selection=true, ViewEdge *begin=NULL, bool
23 // orientation=true) ChainSilhouetteIterator (const ChainSilhouetteIterator &brother)
24 
25 PyDoc_STRVAR(ChainSilhouetteIterator_doc,
26  "Class hierarchy: :class:`freestyle.types.Iterator` >\n"
27  ":class:`freestyle.types.ViewEdgeIterator` >\n"
28  ":class:`freestyle.types.ChainingIterator` >\n"
29  ":class:`ChainSilhouetteIterator`\n"
30  "\n"
31  "A ViewEdge Iterator used to follow ViewEdges the most naturally. For\n"
32  "example, it will follow visible ViewEdges of same nature. As soon, as\n"
33  "the nature or the visibility changes, the iteration stops (by setting\n"
34  "the pointed ViewEdge to 0). In the case of an iteration over a set of\n"
35  "ViewEdge that are both Silhouette and Crease, there will be a\n"
36  "precedence of the silhouette over the crease criterion.\n"
37  "\n"
38  ".. method:: __init__(restrict_to_selection=True, begin=None, orientation=True)\n"
39  " __init__(brother)\n"
40  "\n"
41  " Builds a ChainSilhouetteIterator from the first ViewEdge used for\n"
42  " iteration and its orientation or the copy constructor.\n"
43  "\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 begin: The ViewEdge from where to start the iteration.\n"
48  " :type begin: :class:`freestyle.types.ViewEdge` or None\n"
49  " :arg orientation: If true, we'll look for the next ViewEdge among\n"
50  " the ViewEdges that surround the ending ViewVertex of begin. If\n"
51  " false, we'll search over the ViewEdges surrounding the ending\n"
52  " ViewVertex of begin.\n"
53  " :type orientation: bool\n"
54  " :arg brother: A ChainSilhouetteIterator object.\n"
55  " :type brother: :class:`ChainSilhouetteIterator`");
56 
57 static int check_begin(PyObject *obj, void *v)
58 {
59  if (obj != nullptr && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
60  return 0;
61  }
62  *((PyObject **)v) = obj;
63  return 1;
64 }
65 
67  PyObject *args,
68  PyObject *kwds)
69 {
70  static const char *kwlist_1[] = {"brother", nullptr};
71  static const char *kwlist_2[] = {"restrict_to_selection", "begin", "orientation", nullptr};
72  PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr;
73 
74  if (PyArg_ParseTupleAndKeywords(
75  args, kwds, "O!", (char **)kwlist_1, &ChainSilhouetteIterator_Type, &obj1)) {
76  self->cs_it = new ChainSilhouetteIterator(*(((BPy_ChainSilhouetteIterator *)obj1)->cs_it));
77  }
78  else if ((void)PyErr_Clear(),
79  (void)(obj1 = obj2 = obj3 = nullptr),
80  PyArg_ParseTupleAndKeywords(args,
81  kwds,
82  "|O!O&O!",
83  (char **)kwlist_2,
84  &PyBool_Type,
85  &obj1,
87  &obj2,
88  &PyBool_Type,
89  &obj3)) {
90  bool restrict_to_selection = (!obj1) ? true : bool_from_PyBool(obj1);
91  ViewEdge *begin = (!obj2 || obj2 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj2)->ve;
92  bool orientation = (!obj3) ? true : bool_from_PyBool(obj3);
93  self->cs_it = new ChainSilhouetteIterator(restrict_to_selection, begin, orientation);
94  }
95  else {
96  PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
97  return -1;
98  }
99  self->py_c_it.c_it = self->cs_it;
100  self->py_c_it.py_ve_it.ve_it = self->cs_it;
101  self->py_c_it.py_ve_it.py_it.it = self->cs_it;
102  return 0;
103 }
104 
105 /*-----------------------BPy_ChainSilhouetteIterator type definition ----------------------------*/
106 
108  PyVarObject_HEAD_INIT(nullptr, 0) "ChainSilhouetteIterator", /* tp_name */
109  sizeof(BPy_ChainSilhouetteIterator), /* tp_basicsize */
110  0, /* tp_itemsize */
111  nullptr, /* tp_dealloc */
112  0, /* tp_vectorcall_offset */
113  nullptr, /* tp_getattr */
114  nullptr, /* tp_setattr */
115  nullptr, /* tp_reserved */
116  nullptr, /* tp_repr */
117  nullptr, /* tp_as_number */
118  nullptr, /* tp_as_sequence */
119  nullptr, /* tp_as_mapping */
120  nullptr, /* tp_hash */
121  nullptr, /* tp_call */
122  nullptr, /* tp_str */
123  nullptr, /* tp_getattro */
124  nullptr, /* tp_setattro */
125  nullptr, /* tp_as_buffer */
126  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
127  ChainSilhouetteIterator_doc, /* tp_doc */
128  nullptr, /* tp_traverse */
129  nullptr, /* tp_clear */
130  nullptr, /* tp_richcompare */
131  0, /* tp_weaklistoffset */
132  nullptr, /* tp_iter */
133  nullptr, /* tp_iternext */
134  nullptr, /* tp_methods */
135  nullptr, /* tp_members */
136  nullptr, /* tp_getset */
137  &ChainingIterator_Type, /* tp_base */
138  nullptr, /* tp_dict */
139  nullptr, /* tp_descr_get */
140  nullptr, /* tp_descr_set */
141  0, /* tp_dictoffset */
142  (initproc)ChainSilhouetteIterator_init, /* tp_init */
143  nullptr, /* tp_alloc */
144  nullptr, /* tp_new */
145 };
146 
148 
149 #ifdef __cplusplus
150 }
151 #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:21
ATTR_WARN_UNUSED_RESULT const BMVert * v
inherits from class Rep
Definition: AppCanvas.cpp:18