Blender V4.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
9#include "BPy_Chain.h"
10
11#include "../../BPy_Convert.h"
12#include "../../BPy_Id.h"
13#include "../BPy_ViewEdge.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19using namespace Freestyle;
20
22
23/*----------------------Chain methods ----------------------------*/
24
26 /* Wrap. */
27 Chain_doc,
28 "Class hierarchy: :class:`Interface1D` > :class:`Curve` > :class:`Chain`\n"
29 "\n"
30 "Class to represent a 1D elements issued from the chaining process. A\n"
31 "Chain is the last step before the :class:`Stroke` and is used in the\n"
32 "Splitting and Creation processes.\n"
33 "\n"
34 ".. method:: __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 " :arg brother: A Chain object.\n"
42 " :type brother: :class:`Chain`\n"
43 " :arg id: An Id object.\n"
44 " :type id: :class:`Id`");
45
46static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds)
47{
48 static const char *kwlist_1[] = {"brother", nullptr};
49 static const char *kwlist_2[] = {"id", nullptr};
50 PyObject *obj = nullptr;
51
52 if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &Chain_Type, &obj)) {
53 if (!obj) {
54 self->c = new Chain();
55 }
56 else {
57 self->c = new Chain(*(((BPy_Chain *)obj)->c));
58 }
59 }
60 else if ((void)PyErr_Clear(),
61 PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj))
62 {
63 self->c = new Chain(*(((BPy_Id *)obj)->id));
64 }
65 else {
66 PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
67 return -1;
68 }
69 self->py_c.c = self->c;
70 self->py_c.py_if1D.if1D = self->c;
71 self->py_c.py_if1D.borrowed = false;
72 return 0;
73}
74
76 /* Wrap. */
77 Chain_push_viewedge_back_doc,
78 ".. method:: push_viewedge_back(viewedge, orientation)\n"
79 "\n"
80 " Adds a ViewEdge at the end of the Chain.\n"
81 "\n"
82 " :arg viewedge: The ViewEdge that must be added.\n"
83 " :type viewedge: :class:`ViewEdge`\n"
84 " :arg orientation: The orientation with which the ViewEdge must be\n"
85 " processed.\n"
86 " :type orientation: bool");
87
88static PyObject *Chain_push_viewedge_back(BPy_Chain *self, PyObject *args, PyObject *kwds)
89{
90 static const char *kwlist[] = {"viewedge", "orientation", nullptr};
91 PyObject *obj1 = nullptr, *obj2 = nullptr;
92
93 if (!PyArg_ParseTupleAndKeywords(
94 args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2))
95 {
96 return nullptr;
97 }
98 ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve;
99 bool orientation = bool_from_PyBool(obj2);
100 self->c->push_viewedge_back(ve, orientation);
101 Py_RETURN_NONE;
102}
103
105 /* Wrap. */
106 Chain_push_viewedge_front_doc,
107 ".. method:: push_viewedge_front(viewedge, orientation)\n"
108 "\n"
109 " Adds a ViewEdge at the beginning of the Chain.\n"
110 "\n"
111 " :arg viewedge: The ViewEdge that must be added.\n"
112 " :type viewedge: :class:`ViewEdge`\n"
113 " :arg orientation: The orientation with which the ViewEdge must be\n"
114 " processed.\n"
115 " :type orientation: bool");
116
117static PyObject *Chain_push_viewedge_front(BPy_Chain *self, PyObject *args, PyObject *kwds)
118{
119 static const char *kwlist[] = {"viewedge", "orientation", nullptr};
120 PyObject *obj1 = nullptr, *obj2 = nullptr;
121
122 if (!PyArg_ParseTupleAndKeywords(
123 args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2))
124 {
125 return nullptr;
126 }
127 ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve;
128 bool orientation = bool_from_PyBool(obj2);
129 self->c->push_viewedge_front(ve, orientation);
130 Py_RETURN_NONE;
131}
132
133static PyMethodDef BPy_Chain_methods[] = {
134 {"push_viewedge_back",
135 (PyCFunction)Chain_push_viewedge_back,
136 METH_VARARGS | METH_KEYWORDS,
137 Chain_push_viewedge_back_doc},
138 {"push_viewedge_front",
139 (PyCFunction)Chain_push_viewedge_front,
140 METH_VARARGS | METH_KEYWORDS,
141 Chain_push_viewedge_front_doc},
142 {nullptr, nullptr, 0, nullptr},
143};
144
145/*-----------------------BPy_Chain type definition ------------------------------*/
146
147PyTypeObject Chain_Type = {
148 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
149 /*tp_name*/ "Chain",
150 /*tp_basicsize*/ sizeof(BPy_Chain),
151 /*tp_itemsize*/ 0,
152 /*tp_dealloc*/ nullptr,
153 /*tp_vectorcall_offset*/ 0,
154 /*tp_getattr*/ nullptr,
155 /*tp_setattr*/ nullptr,
156 /*tp_as_async*/ nullptr,
157 /*tp_repr*/ nullptr,
158 /*tp_as_number*/ nullptr,
159 /*tp_as_sequence*/ nullptr,
160 /*tp_as_mapping*/ nullptr,
161 /*tp_hash*/ nullptr,
162 /*tp_call*/ nullptr,
163 /*tp_str*/ nullptr,
164 /*tp_getattro*/ nullptr,
165 /*tp_setattro*/ nullptr,
166 /*tp_as_buffer*/ nullptr,
167 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
168 /*tp_doc*/ Chain_doc,
169 /*tp_traverse*/ nullptr,
170 /*tp_clear*/ nullptr,
171 /*tp_richcompare*/ nullptr,
172 /*tp_weaklistoffset*/ 0,
173 /*tp_iter*/ nullptr,
174 /*tp_iternext*/ nullptr,
175 /*tp_methods*/ BPy_Chain_methods,
176 /*tp_members*/ nullptr,
177 /*tp_getset*/ nullptr,
178 /*tp_base*/ &FrsCurve_Type,
179 /*tp_dict*/ nullptr,
180 /*tp_descr_get*/ nullptr,
181 /*tp_descr_set*/ nullptr,
182 /*tp_dictoffset*/ 0,
183 /*tp_init*/ (initproc)Chain_init,
184 /*tp_alloc*/ nullptr,
185 /*tp_new*/ nullptr,
186};
187
189
190#ifdef __cplusplus
191}
192#endif
static PyObject * Chain_push_viewedge_front(BPy_Chain *self, PyObject *args, PyObject *kwds)
PyDoc_STRVAR(Chain_doc, "Class hierarchy: :class:`Interface1D` > :class:`Curve` > :class:`Chain`\n" "\n" "Class to represent a 1D elements issued from the chaining process. A\n" "Chain is the last step before the :class:`Stroke` and is used in the\n" "Splitting and Creation processes.\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" " __init__(id)\n" "\n" " Builds a :class:`Chain` using the default constructor,\n" " copy constructor or from an :class:`Id`.\n" "\n" " :arg brother: A Chain object.\n" " :type brother: :class:`Chain`\n" " :arg id: An Id object.\n" " :type id: :class:`Id`")
PyTypeObject Chain_Type
static PyMethodDef BPy_Chain_methods[]
static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds)
Definition BPy_Chain.cpp:46
static PyObject * Chain_push_viewedge_back(BPy_Chain *self, PyObject *args, PyObject *kwds)
Definition BPy_Chain.cpp:88
bool bool_from_PyBool(PyObject *b)
PyTypeObject FrsCurve_Type
PyTypeObject Id_Type
Definition BPy_Id.cpp:164
PyTypeObject ViewEdge_Type
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20
static uint c
Definition RandGen.cpp:87