Blender V5.3
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
20namespace blender {
21
23 /* Wrap. */
24 bpy_bm_geometry_intersect_face_point_doc,
25 ".. function:: intersect_face_point(face, point)\n"
26 "\n"
27 " Tests if the projection of a point is inside a face (using the face's normal).\n"
28 "\n"
29 " :param face: The face to test.\n"
30 " :type face: :class:`bmesh.types.BMFace`\n"
31 " :param point: The 3D point to test.\n"
32 " :type point: tuple[float, float, float] | Sequence[float]\n"
33 " :return: True when the projection of the point is in the face.\n"
34 " :rtype: bool\n");
35static PyObject *bpy_bm_geometry_intersect_face_point(BPy_BMFace * /*self*/, PyObject *args)
36{
37 BPy_BMFace *py_face;
38 PyObject *py_point;
39 float point[3];
40 bool ret;
41
42 if (!PyArg_ParseTuple(args,
43 "O!" /* `face` */
44 "O" /* `point` */
45 ":intersect_face_point",
47 &py_face,
48 &py_point))
49 {
50 return nullptr;
51 }
52
53 BPY_BM_CHECK_OBJ(py_face);
54 if (mathutils_array_parse(point, 3, 3, py_point, "intersect_face_point") == -1) {
55 return nullptr;
56 }
57
58 ret = BM_face_point_inside_test(py_face->f, point);
59
60 return PyBool_FromLong(ret);
61}
62
63static PyMethodDef BPy_BM_geometry_methods[] = {
64 {"intersect_face_point",
65 reinterpret_cast<PyCFunction>(bpy_bm_geometry_intersect_face_point),
66 METH_VARARGS,
67 bpy_bm_geometry_intersect_face_point_doc},
68 {nullptr, nullptr, 0, nullptr},
69};
70
72 /* Wrap. */
73 BPy_BM_utils_doc,
74 "This module provides access to bmesh geometry evaluation functions.\n");
75static PyModuleDef BPy_BM_geometry_module_def = {
76 /*m_base*/ PyModuleDef_HEAD_INIT,
77 /*m_name*/ "bmesh.geometry",
78 /*m_doc*/ BPy_BM_utils_doc,
79 /*m_size*/ 0,
80 /*m_methods*/ BPy_BM_geometry_methods,
81 /*m_slots*/ nullptr,
82 /*m_traverse*/ nullptr,
83 /*m_clear*/ nullptr,
84 /*m_free*/ nullptr,
85};
86
88{
89 PyObject *submodule;
90
91 submodule = PyModule_Create(&BPy_BM_geometry_module_def);
92
93 return submodule;
94}
95
96} // namespace blender
#define BPY_BM_CHECK_OBJ(obj)
BMesh Iterators.
static PyModuleDef BPy_BM_geometry_module_def
static PyMethodDef BPy_BM_geometry_methods[]
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
bool BM_face_point_inside_test(const BMFace *f, const float co[3])
PyTypeObject BPy_BMFace_Type
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
Definition mathutils.cc:97
static PyObject * bpy_bm_geometry_intersect_face_point(BPy_BMFace *, PyObject *args)
PyObject * BPyInit_bmesh_geometry()