Blender V5.3
BPy_Chain.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BPy_Chain.h"
10
11#include "../../BPy_Convert.h"
12#include "../../BPy_Id.h"
13#include "../BPy_ViewEdge.h"
14
15using namespace Freestyle;
16
18
19/*----------------------Chain methods ----------------------------*/
20
22 /* Wrap. */
23 Chain_doc,
24 "Class hierarchy: :class:`Interface1D` > :class:`Curve` > :class:`Chain`\n"
25 "\n"
26 "Class to represent a 1D elements issued from the chaining process. A\n"
27 "Chain is the last step before the :class:`Stroke` and is used in the\n"
28 "Splitting and Creation processes.\n"
29 "\n"
30 ".. method:: __init__(*args)\n"
31 "\n"
32 " Accepted call signatures:\n"
33 "\n"
34 " - ``__init__()``\n"
35 " - ``__init__(brother)``\n"
36 " - ``__init__(id)``\n"
37 "\n"
38 " Builds a :class:`Chain` using the default constructor,\n"
39 " copy constructor or from an :class:`Id`.\n"
40 "\n"
41 " :param brother: A Chain object.\n"
42 " :type brother: :class:`Chain`\n"
43 " :param id: An Id object.\n"
44 " :type id: :class:`Id`\n");
45static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds)
46{
47 static const char *kwlist_1[] = {"brother", nullptr};
48 static const char *kwlist_2[] = {"id", nullptr};
49 PyObject *obj = nullptr;
50
51 if (PyArg_ParseTupleAndKeywords(args,
52 kwds,
53 "|" /* Optional arguments. */
54 "O!" /* `brother` */
55 ":__init__",
56 (char **)kwlist_1,
58 &obj))
59 {
60 if (!obj) {
61 self->c = new Chain();
62 }
63 else {
64 self->c = new Chain(*(((BPy_Chain *)obj)->c));
65 }
66 }
67 else if ((void)PyErr_Clear(),
68 PyArg_ParseTupleAndKeywords(args,
69 kwds,
70 "O!" /* `id` */
71 ":__init__",
72 (char **)kwlist_2,
73 &Id_Type,
74 &obj))
75 {
76 self->c = new Chain(*(((BPy_Id *)obj)->id));
77 }
78 else {
79 PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
80 return -1;
81 }
82 self->py_c.c = self->c;
83 self->py_c.py_if1D.if1D = self->c;
84 self->py_c.py_if1D.borrowed = false;
85 return 0;
86}
87
89 /* Wrap. */
90 Chain_push_viewedge_back_doc,
91 ".. method:: push_viewedge_back(viewedge, orientation)\n"
92 "\n"
93 " Adds a ViewEdge at the end of the Chain.\n"
94 "\n"
95 " :param viewedge: The ViewEdge that must be added.\n"
96 " :type viewedge: :class:`ViewEdge`\n"
97 " :param orientation: The orientation with which the ViewEdge must be processed.\n"
98 " :type orientation: bool\n");
99static PyObject *Chain_push_viewedge_back(BPy_Chain *self, PyObject *args, PyObject *kwds)
100{
101 static const char *kwlist[] = {"viewedge", "orientation", nullptr};
102 PyObject *obj1 = nullptr, *obj2 = nullptr;
103
104 if (!PyArg_ParseTupleAndKeywords(args,
105 kwds,
106 "O!" /* `viewedge` */
107 "O!" /* `orientation` */
108 ":push_viewedge_back",
109 (char **)kwlist,
111 &obj1,
112 &PyBool_Type,
113 &obj2))
114 {
115 return nullptr;
116 }
117 ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve;
118 bool orientation = bool_from_PyBool(obj2);
119 self->c->push_viewedge_back(ve, orientation);
120 Py_RETURN_NONE;
121}
122
124 /* Wrap. */
125 Chain_push_viewedge_front_doc,
126 ".. method:: push_viewedge_front(viewedge, orientation)\n"
127 "\n"
128 " Adds a ViewEdge at the beginning of the Chain.\n"
129 "\n"
130 " :param viewedge: The ViewEdge that must be added.\n"
131 " :type viewedge: :class:`ViewEdge`\n"
132 " :param orientation: The orientation with which the ViewEdge must be\n"
133 " processed.\n"
134 " :type orientation: bool\n");
135static PyObject *Chain_push_viewedge_front(BPy_Chain *self, PyObject *args, PyObject *kwds)
136{
137 static const char *kwlist[] = {"viewedge", "orientation", nullptr};
138 PyObject *obj1 = nullptr, *obj2 = nullptr;
139
140 if (!PyArg_ParseTupleAndKeywords(args,
141 kwds,
142 "O!" /* `viewedge` */
143 "O!" /* `orientation` */
144 ":push_viewedge_front",
145 (char **)kwlist,
147 &obj1,
148 &PyBool_Type,
149 &obj2))
150 {
151 return nullptr;
152 }
153 ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve;
154 bool orientation = bool_from_PyBool(obj2);
155 self->c->push_viewedge_front(ve, orientation);
156 Py_RETURN_NONE;
157}
158
159#ifdef __GNUC__
160# ifdef __clang__
161# pragma clang diagnostic push
162# pragma clang diagnostic ignored "-Wcast-function-type"
163# else
164# pragma GCC diagnostic push
165# pragma GCC diagnostic ignored "-Wcast-function-type"
166# endif
167#endif
168
169static PyMethodDef BPy_Chain_methods[] = {
170 {"push_viewedge_back",
171 (PyCFunction)Chain_push_viewedge_back,
172 METH_VARARGS | METH_KEYWORDS,
173 Chain_push_viewedge_back_doc},
174 {"push_viewedge_front",
175 (PyCFunction)Chain_push_viewedge_front,
176 METH_VARARGS | METH_KEYWORDS,
177 Chain_push_viewedge_front_doc},
178 {nullptr, nullptr, 0, nullptr},
179};
180
181#ifdef __GNUC__
182# ifdef __clang__
183# pragma clang diagnostic pop
184# else
185# pragma GCC diagnostic pop
186# endif
187#endif
188
189/*-----------------------BPy_Chain type definition ------------------------------*/
190
191PyTypeObject Chain_Type = {
192 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
193 /*tp_name*/ "Chain",
194 /*tp_basicsize*/ sizeof(BPy_Chain),
195 /*tp_itemsize*/ 0,
196 /*tp_dealloc*/ nullptr,
197 /*tp_vectorcall_offset*/ 0,
198 /*tp_getattr*/ nullptr,
199 /*tp_setattr*/ nullptr,
200 /*tp_as_async*/ nullptr,
201 /*tp_repr*/ nullptr,
202 /*tp_as_number*/ nullptr,
203 /*tp_as_sequence*/ nullptr,
204 /*tp_as_mapping*/ nullptr,
205 /*tp_hash*/ nullptr,
206 /*tp_call*/ nullptr,
207 /*tp_str*/ nullptr,
208 /*tp_getattro*/ nullptr,
209 /*tp_setattro*/ nullptr,
210 /*tp_as_buffer*/ nullptr,
211 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
212 /*tp_doc*/ Chain_doc,
213 /*tp_traverse*/ nullptr,
214 /*tp_clear*/ nullptr,
215 /*tp_richcompare*/ nullptr,
216 /*tp_weaklistoffset*/ 0,
217 /*tp_iter*/ nullptr,
218 /*tp_iternext*/ nullptr,
219 /*tp_methods*/ BPy_Chain_methods,
220 /*tp_members*/ nullptr,
221 /*tp_getset*/ nullptr,
222 /*tp_base*/ &FrsCurve_Type,
223 /*tp_dict*/ nullptr,
224 /*tp_descr_get*/ nullptr,
225 /*tp_descr_set*/ nullptr,
226 /*tp_dictoffset*/ 0,
227 /*tp_init*/ (initproc)Chain_init,
228 /*tp_alloc*/ nullptr,
229 /*tp_new*/ nullptr,
230};
231
static PyObject * Chain_push_viewedge_front(BPy_Chain *self, PyObject *args, PyObject *kwds)
PyTypeObject Chain_Type
static PyMethodDef BPy_Chain_methods[]
static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds)
Definition BPy_Chain.cpp:45
static PyObject * Chain_push_viewedge_back(BPy_Chain *self, PyObject *args, PyObject *kwds)
Definition BPy_Chain.cpp:99
bool bool_from_PyBool(PyObject *b)
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\n")
PyTypeObject FrsCurve_Type
PyTypeObject Id_Type
Definition BPy_Id.cpp:176
PyTypeObject ViewEdge_Type
void push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
Definition Chain.cpp:80
void push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
Definition Chain.cpp:17
inherits from class Rep
Definition AppCanvas.cpp:20
BPy_FrsCurve py_c
Definition BPy_Chain.h:23
Freestyle::Chain * c
Definition BPy_Chain.h:24
BPy_Interface1D py_if1D
Freestyle::Curve * c
PyObject_HEAD Freestyle::Interface1D * if1D