您可以检查一个点是否位于实体内部:
solid_shape.isInside(point:App.Vector, tolerance:float, on_boundary_is_inside:bool)
例子:
import numpy as np
import FreeCAD as App
import Part
num_pts = 50
shape = Part.makeSphere(1) # radius
bb = shape.BoundBox
x = np.linspace(bb.XMin, bb.XMax, num_pts)
y = np.linspace(bb.YMin, bb.YMax, num_pts)
z = np.linspace(bb.ZMin, bb.ZMax, num_pts)
mesh_x = np.array([[x] * num_pts] * num_pts).transpose(0, 1, 2)
mesh_y = np.array([[y] * num_pts] * num_pts).transpose(2, 0, 1)
mesh_z = np.array([[z] * num_pts] * num_pts).transpose(1, 2, 0)
mesh = np.array([mesh_x.flatten(), mesh_y.flatten(), mesh_z.flatten()]).T
bool_array = np.array([shape.isInside(App.Vector(p), 0.000001, False) for p in mesh])
v_r = float(sum(bool_array)) / float(len(bool_array))
v_r # estimation of Volumeratio