Blender  V2.93
bmesh_py_geometry.c
Go to the documentation of this file.
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  * The Original Code is Copyright (C) 2012 Blender Foundation.
17  * All rights reserved.
18  */
19 
27 #include <Python.h>
28 
29 #include "BLI_utildefines.h"
30 
31 #include "../mathutils/mathutils.h"
32 
33 #include "bmesh.h"
34 #include "bmesh_py_geometry.h" /* own include */
35 #include "bmesh_py_types.h"
36 
37 PyDoc_STRVAR(bpy_bm_geometry_intersect_face_point_doc,
38  ".. method:: intersect_face_point(face, point)\n"
39  "\n"
40  " Tests if the projection of a point is inside a face (using the face's normal).\n"
41  "\n"
42  " :arg face: The face to test.\n"
43  " :type face: :class:`bmesh.types.BMFace`\n"
44  " :arg point: The point to test.\n"
45  " :type point: float triplet\n"
46  " :return: True when the projection of the point is in the face.\n"
47  " :rtype: bool\n");
48 static PyObject *bpy_bm_geometry_intersect_face_point(BPy_BMFace *UNUSED(self), PyObject *args)
49 {
50  BPy_BMFace *py_face;
51  PyObject *py_point;
52  float point[3];
53  bool ret;
54 
55  if (!PyArg_ParseTuple(args, "O!O:intersect_face_point", &BPy_BMFace_Type, &py_face, &py_point)) {
56  return NULL;
57  }
58 
59  BPY_BM_CHECK_OBJ(py_face);
60  if (mathutils_array_parse(point, 3, 3, py_point, "intersect_face_point") == -1) {
61  return NULL;
62  }
63 
64  ret = BM_face_point_inside_test(py_face->f, point);
65 
66  return PyBool_FromLong(ret);
67 }
68 
69 static struct PyMethodDef BPy_BM_geometry_methods[] = {
70  {"intersect_face_point",
72  METH_VARARGS,
73  bpy_bm_geometry_intersect_face_point_doc},
74  {NULL, NULL, 0, NULL},
75 };
76 
77 PyDoc_STRVAR(BPy_BM_utils_doc,
78  "This module provides access to bmesh geometry evaluation functions.");
79 static struct PyModuleDef BPy_BM_geometry_module_def = {
80  PyModuleDef_HEAD_INIT,
81  "bmesh.geometry", /* m_name */
82  BPy_BM_utils_doc, /* m_doc */
83  0, /* m_size */
84  BPy_BM_geometry_methods, /* m_methods */
85  NULL, /* m_reload */
86  NULL, /* m_traverse */
87  NULL, /* m_clear */
88  NULL, /* m_free */
89 };
90 
91 PyObject *BPyInit_bmesh_geometry(void)
92 {
93  PyObject *submodule;
94 
95  submodule = PyModule_Create(&BPy_BM_geometry_module_def);
96 
97  return submodule;
98 }
#define UNUSED(x)
bool BM_face_point_inside_test(const BMFace *f, const float co[3])
PyDoc_STRVAR(bpy_bm_geometry_intersect_face_point_doc, ".. method:: intersect_face_point(face, point)\n" "\n" " Tests if the projection of a point is inside a face (using the face's normal).\n" "\n" " :arg face: The face to test.\n" " :type face: :class:`bmesh.types.BMFace`\n" " :arg point: The point to test.\n" " :type point: float triplet\n" " :return: True when the projection of the point is in the face.\n" " :rtype: bool\n")
PyObject * BPyInit_bmesh_geometry(void)
static struct PyModuleDef BPy_BM_geometry_module_def
static PyObject * bpy_bm_geometry_intersect_face_point(BPy_BMFace *UNUSED(self), PyObject *args)
static struct PyMethodDef BPy_BM_geometry_methods[]
PyTypeObject BPy_BMFace_Type
#define BPY_BM_CHECK_OBJ(obj)
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
Definition: mathutils.c:118
return ret
struct BMFace * f