FEM: Handle python vtk user installs that conflict with FreeCAD VTK
This commit is contained in:
@@ -40,6 +40,11 @@
|
||||
#ifdef FC_USE_VTK
|
||||
#include "FemPostPipeline.h"
|
||||
#include "FemVTKTools.h"
|
||||
#include <LibraryVersions.h>
|
||||
#endif
|
||||
|
||||
#ifdef FC_USE_VTK_PYTHON
|
||||
#include <vtkPythonUtil.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -75,6 +80,14 @@ public:
|
||||
&Module::writeResult,
|
||||
"write a CFD or FEM result (auto detect) to a file (file format "
|
||||
"detected from file suffix)");
|
||||
add_varargs_method("getVtkVersion",
|
||||
&Module::getVtkVersion,
|
||||
"Returns the VTK version freeCAD is linked against");
|
||||
#ifdef FC_USE_VTK_PYTHON
|
||||
add_varargs_method("isVtkCompatible",
|
||||
&Module::isVtkCompatible,
|
||||
"Checks if the passed vtkObject is compatible with the c++ VTK version freecad uses");
|
||||
#endif
|
||||
#endif
|
||||
add_varargs_method("show",
|
||||
&Module::show,
|
||||
@@ -318,6 +331,34 @@ private:
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
Py::Object getVtkVersion(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(),"")) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
return Py::String(fcVtkVersion);
|
||||
}
|
||||
|
||||
#ifdef FC_USE_VTK_PYTHON
|
||||
Py::Object isVtkCompatible(const Py::Tuple& args)
|
||||
{
|
||||
PyObject* pcObj = nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(),"O", &pcObj)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
// if non is returned the vtk object was created by annother vtk library, and the
|
||||
// python api used to create it cannot be used with FreeCAD
|
||||
vtkObjectBase *obj = vtkPythonUtil::GetPointerFromObject(pcObj, "vtkObject");
|
||||
if (!obj) {
|
||||
PyErr_Clear();
|
||||
return Py::False();
|
||||
}
|
||||
return Py::True();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Py::Object show(const Py::Tuple& args)
|
||||
|
||||
Reference in New Issue
Block a user