MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / Geom_point_inside

Function Geom_point_inside

Code/Source/PythonAPI/Geometry_PyModule.cxx:276–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274");
275
276static PyObject *
277Geom_point_inside(PyObject* self, PyObject* args, PyObject* kwargs)
278{
279 //std::cout << "========== Geom_point_inside ==========" << std::endl;
280 auto api = PyUtilApiFunction("OO!", PyRunTimeErr, __func__);
281 static char *keywords[] = {"polydata", "point", NULL};
282 PyObject* pdObj;
283 PyObject* pointArg;
284
285 if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &pdObj, &PyList_Type, &pointArg)) {
286 return api.argsError();
287 }
288
289 // Get the vtkPolyData object from the Python object.
290 auto polydata = GetVtkPolyData(api, pdObj);
291 if (polydata == nullptr) {
292 return nullptr;
293 }
294
295 // Get the point data.
296 double point[3];
297 std::string emsg;
298 if (!PyUtilGetPointData<double>(pointArg, emsg, point)) {
299 api.error("The point argument " + emsg);
300 return nullptr;
301 }
302
303 // Result is -1 if the point is outside, 1 if it is inside.
304 cvPolyData cvPolydata(polydata);
305 int result;
306 if (sys_geom_Classify(&cvPolydata, point, &result) != SV_OK) {
307 api.error("Error classifying a point for the geometry.");
308 return nullptr;
309 }
310
311 return Py_BuildValue("N", PyBool_FromLong(result+1));
312}
313
314//-------------------------------
315// Geom_interpolate_closed_curve

Callers

nothing calls this directly

Calls 4

sys_geom_ClassifyFunction · 0.85
argsErrorMethod · 0.80
errorMethod · 0.80
GetVtkPolyDataFunction · 0.70

Tested by

no test coverage detected