23 #include "../BPy_Convert.h"
24 #include "../BPy_Id.h"
25 #include "../Interface1D/BPy_FEdge.h"
38 "Class hierarchy: :class:`Interface0D` > :class:`SVertex`\n"
40 "Class to define a vertex of the embedding.\n"
42 ".. method:: __init__()\n"
43 " __init__(brother)\n"
44 " __init__(point_3d, id)\n"
46 " Builds a :class:`SVertex` using the default constructor,\n"
47 " copy constructor or the overloaded constructor which builds"
48 " a :class:`SVertex` from 3D coordinates and an Id.\n"
50 " :arg brother: A SVertex object.\n"
51 " :type brother: :class:`SVertex`\n"
52 " :arg point_3d: A three-dimensional vector.\n"
53 " :type point_3d: :class:`mathutils.Vector`\n"
54 " :arg id: An Id object.\n"
55 " :type id: :class:`Id`");
59 static const char *kwlist_1[] = {
"brother",
nullptr};
60 static const char *kwlist_2[] = {
"point_3d",
"id",
nullptr};
61 PyObject *obj =
nullptr;
64 if (PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist_1, &
SVertex_Type, &obj)) {
72 else if ((
void)PyErr_Clear(),
73 PyArg_ParseTupleAndKeywords(
79 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
82 self->py_if0D.if0D =
self->sv;
83 self->py_if0D.borrowed =
false;
88 ".. method:: add_normal(normal)\n"
90 " Adds a normal to the SVertex's set of normals. If the same normal\n"
91 " is already in the set, nothing changes.\n"
93 " :arg normal: A three-dimensional vector.\n"
94 " :type normal: :class:`mathutils.Vector`, list or tuple of 3 real numbers");
98 static const char *kwlist[] = {
"normal",
nullptr};
102 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O", (
char **)kwlist, &py_normal)) {
106 PyErr_SetString(PyExc_TypeError,
107 "argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
110 self->sv->AddNormal(n);
115 ".. method:: add_fedge(fedge)\n"
117 " Add an FEdge to the list of edges emanating from this SVertex.\n"
119 " :arg fedge: An FEdge.\n"
120 " :type fedge: :class:`FEdge`");
124 static const char *kwlist[] = {
"fedge",
nullptr};
127 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O!", (
char **)kwlist, &
FEdge_Type, &py_fe)) {
130 self->sv->AddFEdge(((
BPy_FEdge *)py_fe)->fe);
139 METH_VARARGS | METH_KEYWORDS,
140 SVertex_add_normal_doc},
143 METH_VARARGS | METH_KEYWORDS,
144 SVertex_add_fedge_doc},
145 {
nullptr,
nullptr, 0,
nullptr},
151 #define MATHUTILS_SUBTYPE_POINT3D 1
152 #define MATHUTILS_SUBTYPE_POINT2D 2
167 bmo->data[0] =
self->sv->getX();
168 bmo->data[1] =
self->sv->getY();
169 bmo->data[2] =
self->sv->getZ();
172 bmo->data[0] =
self->sv->getProjectedX();
173 bmo->data[1] =
self->sv->getProjectedY();
174 bmo->data[2] =
self->sv->getProjectedZ();
187 Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]);
188 self->sv->setPoint3D(p);
191 Vec3r p(bmo->data[0], bmo->data[1], bmo->data[2]);
192 self->sv->setPoint2D(p);
207 bmo->data[0] =
self->sv->getX();
210 bmo->data[1] =
self->sv->getY();
213 bmo->data[2] =
self->sv->getZ();
222 bmo->data[0] =
self->sv->getProjectedX();
225 bmo->data[1] =
self->sv->getProjectedY();
228 bmo->data[2] =
self->sv->getProjectedZ();
246 p[index] = bmo->data[index];
247 self->sv->setPoint3D(p);
251 p[index] = bmo->data[index];
252 self->sv->setPoint2D(p);
278 "The 3D coordinates of the SVertex.\n"
280 ":type: :class:`mathutils.Vector`");
295 self->sv->setPoint3D(p);
300 "The projected 3D coordinates of the SVertex.\n"
302 ":type: :class:`mathutils.Vector`");
317 self->sv->setPoint2D(p);
322 "The Id of this SVertex.\n"
324 ":type: :class:`Id`");
335 PyErr_SetString(PyExc_TypeError,
"value must be an Id");
338 self->sv->setId(*(((
BPy_Id *)value)->
id));
343 "The normals for this Vertex as a list. In a sharp surface, an SVertex\n"
344 "has exactly one normal. In a smooth surface, an SVertex can have any\n"
345 "number of normals.\n"
347 ":type: list of :class:`mathutils.Vector` objects");
351 PyObject *py_normals;
352 set<Vec3r>
normals =
self->sv->normals();
353 set<Vec3r>::iterator it;
354 py_normals = PyList_New(
normals.size());
365 "The number of different normals for this SVertex.\n"
371 return PyLong_FromLong(
self->sv->normalsSize());
375 "If this SVertex is also a ViewVertex, this property refers to the\n"
376 "ViewVertex, and None otherwise.\n"
378 ":type: :class:`ViewVertex`");
390 "Curvature information expressed in the form of a seven-element tuple\n"
391 "(K1, e1, K2, e2, Kr, er, dKr), where K1 and K2 are scalar values\n"
392 "representing the first (maximum) and second (minimum) principal\n"
393 "curvatures at this SVertex, respectively; e1 and e2 are\n"
394 "three-dimensional vectors representing the first and second principal\n"
395 "directions, i.e. the directions of the normal plane where the\n"
396 "curvature takes its maximum and minimum values, respectively; and Kr,\n"
397 "er and dKr are the radial curvature, radial direction, and the\n"
398 "derivative of the radial curvature at this SVertex, respectively.\n"
411 PyObject *retval = PyTuple_New(7);
413 PyFloat_FromDouble(info->
K1),
414 PyFloat_FromDouble(info->
K2),
417 PyFloat_FromDouble(info->
Kr),
419 PyFloat_FromDouble(info->
dKr));
427 SVertex_point_3d_doc,
432 SVertex_point_2d_doc,
439 SVertex_normals_size_doc,
444 SVertex_viewvertex_doc,
449 SVertex_curvatures_doc,
451 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
456 PyVarObject_HEAD_INIT(
nullptr, 0)
"SVertex",
474 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
PyObject * BPy_Id_from_Id(Id &id)
int convert_v3(PyObject *obj, void *v)
bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r &vec)
PyObject * Any_BPy_ViewVertex_from_ViewVertex(ViewVertex &vv)
PyObject * Vector_from_Vec3r(Vec3r &vec)
PyTypeObject Interface0D_Type
static int SVertex_point_2d_set(BPy_SVertex *self, PyObject *value, void *UNUSED(closure))
static PyObject * SVertex_curvatures_get(BPy_SVertex *self, void *UNUSED(closure))
#define MATHUTILS_SUBTYPE_POINT3D
static unsigned char SVertex_mathutils_cb_index
#define MATHUTILS_SUBTYPE_POINT2D
static PyObject * SVertex_add_fedge(BPy_SVertex *self, PyObject *args, PyObject *kwds)
void SVertex_mathutils_register_callback()
static PyObject * SVertex_point_3d_get(BPy_SVertex *self, void *UNUSED(closure))
static PyObject * SVertex_point_2d_get(BPy_SVertex *self, void *UNUSED(closure))
static PyObject * SVertex_normals_size_get(BPy_SVertex *self, void *UNUSED(closure))
static int SVertex_point_3d_set(BPy_SVertex *self, PyObject *value, void *UNUSED(closure))
static PyObject * SVertex_id_get(BPy_SVertex *self, void *UNUSED(closure))
static int SVertex_id_set(BPy_SVertex *self, PyObject *value, void *UNUSED(closure))
PyTypeObject SVertex_Type
static int SVertex_mathutils_set_index(BaseMathObject *bmo, int subtype, int index)
static PyMethodDef BPy_SVertex_methods[]
static int SVertex_init(BPy_SVertex *self, PyObject *args, PyObject *kwds)
static PyObject * SVertex_add_normal(BPy_SVertex *self, PyObject *args, PyObject *kwds)
static Mathutils_Callback SVertex_mathutils_cb
static PyObject * SVertex_viewvertex_get(BPy_SVertex *self, void *UNUSED(closure))
static int SVertex_mathutils_get(BaseMathObject *bmo, int subtype)
PyDoc_STRVAR(SVertex_doc, "Class hierarchy: :class:`Interface0D` > :class:`SVertex`\n" "\n" "Class to define a vertex of the embedding.\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" " __init__(point_3d, id)\n" "\n" " Builds a :class:`SVertex` using the default constructor,\n" " copy constructor or the overloaded constructor which builds" " a :class:`SVertex` from 3D coordinates and an Id.\n" "\n" " :arg brother: A SVertex object.\n" " :type brother: :class:`SVertex`\n" " :arg point_3d: A three-dimensional vector.\n" " :type point_3d: :class:`mathutils.Vector`\n" " :arg id: An Id object.\n" " :type id: :class:`Id`")
static int SVertex_mathutils_set(BaseMathObject *bmo, int subtype)
static PyObject * SVertex_normals_get(BPy_SVertex *self, void *UNUSED(closure))
static int SVertex_mathutils_get_index(BaseMathObject *bmo, int subtype, int index)
static int SVertex_mathutils_check(BaseMathObject *bmo)
static PyGetSetDef BPy_SVertex_getseters[]
#define BPy_SVertex_Check(v)
ATTR_WARN_UNUSED_RESULT const BMVert * v
static float normals[][3]
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int size, uchar cb_type, uchar cb_subtype)
#define PyTuple_SET_ITEMS(op_arg,...)