OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
| 3 * |
| 4 * This program is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU General Public License |
| 6 * as published by the Free Software Foundation; either version 2 |
| 7 * of the License, or (at your option) any later version. |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software Foundation, |
| 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 * |
| 18 * The Original Code is Copyright (C) 2010 Blender Foundation. |
| 19 * All rights reserved. |
| 20 * |
| 21 * The Original Code is: all of this file. |
| 22 * |
| 23 * Contributor(s): none yet. |
| 24 * |
| 25 * ***** END GPL LICENSE BLOCK ***** |
| 26 */ |
| 27 |
| 28 /** \file source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D
_double/BPy_DensityF1D.cpp |
| 29 * \ingroup freestyle |
| 30 */ |
| 31 |
| 32 #include "BPy_DensityF1D.h" |
| 33 |
| 34 #include "../../../stroke/AdvancedFunctions1D.h" |
| 35 #include "../../BPy_Convert.h" |
| 36 #include "../../BPy_IntegrationType.h" |
| 37 |
| 38 #ifdef __cplusplus |
| 39 extern "C" { |
| 40 #endif |
| 41 |
| 42 ////////////////////////////////////////////////////////////////////////////////
/////////// |
| 43 |
| 44 //------------------------INSTANCE METHODS ---------------------------------- |
| 45 |
| 46 static char DensityF1D___doc__[] = |
| 47 "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DDouble` > :c
lass:`DensityF1D`\n" |
| 48 "\n" |
| 49 ".. method:: __init__(sigma=2.0, integration_type=IntegrationType.MEAN, sampling
=2.0)\n" |
| 50 "\n" |
| 51 " Builds a DensityF1D object.\n" |
| 52 "\n" |
| 53 " :arg sigma: The sigma used in DensityF0D and determining the window size\n" |
| 54 " used in each density query.\n" |
| 55 " :type sigma: float\n" |
| 56 " :arg integration_type: The integration method used to compute a single value
\n" |
| 57 " from a set of values.\n" |
| 58 " :type integration_type: :class:`IntegrationType`\n" |
| 59 " :arg sampling: The resolution used to sample the chain: the\n" |
| 60 " corresponding 0D function is evaluated at each sample point and\n" |
| 61 " the result is obtained by combining the resulting values into a\n" |
| 62 " single one, following the method specified by integration_type.\n" |
| 63 " :type sampling: float\n" |
| 64 "\n" |
| 65 ".. method:: __call__(inter)\n" |
| 66 "\n" |
| 67 " Returns the density evaluated for an Interface1D. The density is\n" |
| 68 " evaluated for a set of points along the Interface1D (using the\n" |
| 69 " :class:`DensityF0D` functor) with a user-defined sampling and then\n" |
| 70 " integrated into a single value using a user-defined integration\n" |
| 71 " method.\n" |
| 72 "\n" |
| 73 " :arg inter: An Interface1D object.\n" |
| 74 " :type inter: :class:`Interface1D`\n" |
| 75 " :return: The density evaluated for an Interface1D.\n" |
| 76 " :rtype: float\n"; |
| 77 |
| 78 static int DensityF1D___init__(BPy_DensityF1D* self, PyObject *args, PyObject *k
wds) |
| 79 { |
| 80 static const char *kwlist[] = {"sigma", "integration_type", "sampling",
NULL}; |
| 81 PyObject *obj = 0; |
| 82 double d = 2.0; |
| 83 float f = 2.0; |
| 84 |
| 85 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|dO!f", (char **)kwlist, &
d, &IntegrationType_Type, &obj, &f)) |
| 86 return -1; |
| 87 IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj
) : MEAN; |
| 88 self->py_uf1D_double.uf1D_double = new Functions1D::DensityF1D(d,t,f); |
| 89 return 0; |
| 90 } |
| 91 |
| 92 /*-----------------------BPy_DensityF1D type definition ------------------------
------*/ |
| 93 |
| 94 PyTypeObject DensityF1D_Type = { |
| 95 PyVarObject_HEAD_INIT(NULL, 0) |
| 96 "DensityF1D", /* tp_name */ |
| 97 sizeof(BPy_DensityF1D), /* tp_basicsize */ |
| 98 0, /* tp_itemsize */ |
| 99 0, /* tp_dealloc */ |
| 100 0, /* tp_print */ |
| 101 0, /* tp_getattr */ |
| 102 0, /* tp_setattr */ |
| 103 0, /* tp_reserved */ |
| 104 0, /* tp_repr */ |
| 105 0, /* tp_as_number */ |
| 106 0, /* tp_as_sequence */ |
| 107 0, /* tp_as_mapping */ |
| 108 0, /* tp_hash */ |
| 109 0, /* tp_call */ |
| 110 0, /* tp_str */ |
| 111 0, /* tp_getattro */ |
| 112 0, /* tp_setattro */ |
| 113 0, /* tp_as_buffer */ |
| 114 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
| 115 DensityF1D___doc__, /* tp_doc */ |
| 116 0, /* tp_traverse */ |
| 117 0, /* tp_clear */ |
| 118 0, /* tp_richcompare */ |
| 119 0, /* tp_weaklistoffset */ |
| 120 0, /* tp_iter */ |
| 121 0, /* tp_iternext */ |
| 122 0, /* tp_methods */ |
| 123 0, /* tp_members */ |
| 124 0, /* tp_getset */ |
| 125 &UnaryFunction1DDouble_Type, /* tp_base */ |
| 126 0, /* tp_dict */ |
| 127 0, /* tp_descr_get */ |
| 128 0, /* tp_descr_set */ |
| 129 0, /* tp_dictoffset */ |
| 130 (initproc)DensityF1D___init__, /* tp_init */ |
| 131 0, /* tp_alloc */ |
| 132 0, /* tp_new */ |
| 133 }; |
| 134 |
| 135 ////////////////////////////////////////////////////////////////////////////////
/////////// |
| 136 |
| 137 #ifdef __cplusplus |
| 138 } |
| 139 #endif |
OLD | NEW |