Blender V4.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
12#include <Python.h>
13
14#include "BLI_utildefines.h"
15
17
18#include "bmesh.hh"
19#include "bmesh_py_geometry.hh" /* own include */
20#include "bmesh_py_types.hh"
21
23 /* Wrap. */
24 bpy_bm_geometry_intersect_face_point_doc,
25 ".. method:: 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 " :arg face: The face to test.\n"
30 " :type face: :class:`bmesh.types.BMFace`\n"
31 " :arg point: The point to test.\n"
32 " :type point: float triplet\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, "O!O:intersect_face_point", &BPy_BMFace_Type, &py_face, &py_point)) {
43 return nullptr;
44 }
45
46 BPY_BM_CHECK_OBJ(py_face);
47 if (mathutils_array_parse(point, 3, 3, py_point, "intersect_face_point") == -1) {
48 return nullptr;
49 }
50
51 ret = BM_face_point_inside_test(py_face->f, point);
52
53 return PyBool_FromLong(ret);
54}
55
56static PyMethodDef BPy_BM_geometry_methods[] = {
57 {"intersect_face_point",
59 METH_VARARGS,
60 bpy_bm_geometry_intersect_face_point_doc},
61 {nullptr, nullptr, 0, nullptr},
62};
63
65 /* Wrap. */
66 BPy_BM_utils_doc,
67 "This module provides access to bmesh geometry evaluation functions.");
68static PyModuleDef BPy_BM_geometry_module_def = {
69 /*m_base*/ PyModuleDef_HEAD_INIT,
70 /*m_name*/ "bmesh.geometry",
71 /*m_doc*/ BPy_BM_utils_doc,
72 /*m_size*/ 0,
73 /*m_methods*/ BPy_BM_geometry_methods,
74 /*m_slots*/ nullptr,
75 /*m_traverse*/ nullptr,
76 /*m_clear*/ nullptr,
77 /*m_free*/ nullptr,
78};
79
81{
82 PyObject *submodule;
83
84 submodule = PyModule_Create(&BPy_BM_geometry_module_def);
85
86 return submodule;
87}
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:97
return ret