Blender V5.0
bmesh_py_geometry.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#include <Python.h>
13
15
16#include "bmesh.hh"
17#include "bmesh_py_geometry.hh" /* own include */
18#include "bmesh_py_types.hh"
19
21 /* Wrap. */
22 bpy_bm_geometry_intersect_face_point_doc,
23 ".. method:: intersect_face_point(face, point)\n"
24 "\n"
25 " Tests if the projection of a point is inside a face (using the face's normal).\n"
26 "\n"
27 " :arg face: The face to test.\n"
28 " :type face: :class:`bmesh.types.BMFace`\n"
29 " :arg point: The point to test.\n"
30 " :type point: float triplet\n"
31 " :return: True when the projection of the point is in the face.\n"
32 " :rtype: bool\n");
33static PyObject *bpy_bm_geometry_intersect_face_point(BPy_BMFace * /*self*/, PyObject *args)
34{
35 BPy_BMFace *py_face;
36 PyObject *py_point;
37 float point[3];
38 bool ret;
39
40 if (!PyArg_ParseTuple(args, "O!O:intersect_face_point", &BPy_BMFace_Type, &py_face, &py_point)) {
41 return nullptr;
42 }
43
44 BPY_BM_CHECK_OBJ(py_face);
45 if (mathutils_array_parse(point, 3, 3, py_point, "intersect_face_point") == -1) {
46 return nullptr;
47 }
48
49 ret = BM_face_point_inside_test(py_face->f, point);
50
51 return PyBool_FromLong(ret);
52}
53
54static PyMethodDef BPy_BM_geometry_methods[] = {
55 {"intersect_face_point",
57 METH_VARARGS,
58 bpy_bm_geometry_intersect_face_point_doc},
59 {nullptr, nullptr, 0, nullptr},
60};
61
63 /* Wrap. */
64 BPy_BM_utils_doc,
65 "This module provides access to bmesh geometry evaluation functions.\n");
66static PyModuleDef BPy_BM_geometry_module_def = {
67 /*m_base*/ PyModuleDef_HEAD_INIT,
68 /*m_name*/ "bmesh.geometry",
69 /*m_doc*/ BPy_BM_utils_doc,
70 /*m_size*/ 0,
71 /*m_methods*/ BPy_BM_geometry_methods,
72 /*m_slots*/ nullptr,
73 /*m_traverse*/ nullptr,
74 /*m_clear*/ nullptr,
75 /*m_free*/ nullptr,
76};
77
79{
80 PyObject *submodule;
81
82 submodule = PyModule_Create(&BPy_BM_geometry_module_def);
83
84 return submodule;
85}
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")
static PyMethodDef BPy_BM_geometry_methods[]
static PyModuleDef BPy_BM_geometry_module_def
static PyObject * bpy_bm_geometry_intersect_face_point(BPy_BMFace *, PyObject *args)
PyObject * BPyInit_bmesh_geometry()
PyTypeObject BPy_BMFace_Type
#define BPY_BM_CHECK_OBJ(obj)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
Definition mathutils.cc:96
return ret