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 
17 /** \file
18  * \ingroup freestyle
19  */
20 
21 #include "BPy_SmoothingShader.h"
22 
23 #include "../../stroke/AdvancedStrokeShaders.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 ///////////////////////////////////////////////////////////////////////////////////////////
30 
31 //------------------------INSTANCE METHODS ----------------------------------
32 
33 static char SmoothingShader___doc__[] =
34     "Class hierarchy: :class:`freestyle.types.StrokeShader` > :class:`SmoothingShader`\n"
35     "\n"
36     "[Geometry shader]\n"
37     "\n"
38     ".. method:: __init__(num_iterations=100, factor_point=0.1, \\\n"
39     "      factor_curvature=0.0, factor_curvature_difference=0.2, \\\n"
40     "      aniso_point=0.0, aniso_normal=0.0, aniso_curvature=0.0, \\\n"
41     "      carricature_factor=1.0)\n"
42     "\n"
43     "   Builds a SmoothingShader object.\n"
44     "\n"
45     "   :arg num_iterations: The number of iterations.\n"
46     "   :type num_iterations: int\n"
47     "   :arg factor_point: 0.1\n"
48     "   :type factor_point: float\n"
49     "   :arg factor_curvature: 0.0\n"
50     "   :type factor_curvature: float\n"
51     "   :arg factor_curvature_difference: 0.2\n"
52     "   :type factor_curvature_difference: float\n"
53     "   :arg aniso_point: 0.0\n"
54     "   :type aniso_point: float\n"
55     "   :arg aniso_normal: 0.0\n"
56     "   :type aniso_normal: float\n"
57     "   :arg aniso_curvature: 0.0\n"
58     "   :type aniso_curvature: float\n"
59     "   :arg carricature_factor: 1.0\n"
60     "   :type carricature_factor: float\n"
61     "\n"
62     ".. method:: shade(stroke)\n"
63     "\n"
64     "   Smoothes the stroke by moving the vertices to make the stroke\n"
65     "   smoother.  Uses curvature flow to converge towards a curve of\n"
66     "   constant curvature.  The diffusion method we use is anisotropic to\n"
67     "   prevent the diffusion across corners.\n"
68     "\n"
69     "   :arg stroke: A Stroke object.\n"
70     "   :type stroke: :class:`freestyle.types.Stroke`\n";
71 
SmoothingShader___init__(BPy_SmoothingShader * self,PyObject * args,PyObject * kwds)72 static int SmoothingShader___init__(BPy_SmoothingShader *self, PyObject *args, PyObject *kwds)
73 {
74   static const char *kwlist[] = {
75       "num_iterations",
76       "factor_point",
77       "factor_curvature",
78       "factor_curvature_difference",
79       "aniso_point",
80       "aniso_normal",
81       "aniso_curvature",
82       "carricature_factor",
83       NULL,
84   };
85   int i1 = 100;
86   double d2 = 0.1, d3 = 0.0, d4 = 0.2, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 1.0;
87 
88   if (!PyArg_ParseTupleAndKeywords(
89           args, kwds, "|iddddddd", (char **)kwlist, &i1, &d2, &d3, &d4, &d5, &d6, &d7, &d8)) {
90     return -1;
91   }
92   self->py_ss.ss = new SmoothingShader(i1, d2, d3, d4, d5, d6, d7, d8);
93   return 0;
94 }
95 
96 /*-----------------------BPy_SmoothingShader type definition ------------------------------*/
97 
98 PyTypeObject SmoothingShader_Type = {
99     PyVarObject_HEAD_INIT(NULL, 0) "SmoothingShader", /* tp_name */
100     sizeof(BPy_SmoothingShader),                      /* tp_basicsize */
101     0,                                                /* tp_itemsize */
102     0,                                                /* tp_dealloc */
103     0,                                                /* tp_print */
104     0,                                                /* tp_getattr */
105     0,                                                /* tp_setattr */
106     0,                                                /* tp_reserved */
107     0,                                                /* tp_repr */
108     0,                                                /* tp_as_number */
109     0,                                                /* tp_as_sequence */
110     0,                                                /* tp_as_mapping */
111     0,                                                /* tp_hash  */
112     0,                                                /* tp_call */
113     0,                                                /* tp_str */
114     0,                                                /* tp_getattro */
115     0,                                                /* tp_setattro */
116     0,                                                /* tp_as_buffer */
117     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,         /* tp_flags */
118     SmoothingShader___doc__,                          /* tp_doc */
119     0,                                                /* tp_traverse */
120     0,                                                /* tp_clear */
121     0,                                                /* tp_richcompare */
122     0,                                                /* tp_weaklistoffset */
123     0,                                                /* tp_iter */
124     0,                                                /* tp_iternext */
125     0,                                                /* tp_methods */
126     0,                                                /* tp_members */
127     0,                                                /* tp_getset */
128     &StrokeShader_Type,                               /* tp_base */
129     0,                                                /* tp_dict */
130     0,                                                /* tp_descr_get */
131     0,                                                /* tp_descr_set */
132     0,                                                /* tp_dictoffset */
133     (initproc)SmoothingShader___init__,               /* tp_init */
134     0,                                                /* tp_alloc */
135     0,                                                /* tp_new */
136 };
137 
138 ///////////////////////////////////////////////////////////////////////////////////////////
139 
140 #ifdef __cplusplus
141 }
142 #endif
143