+ simplify basic VRML export of mesh kernel, + allow to export mesh with texture via Python
This commit is contained in:
@@ -150,7 +150,8 @@ PyObject* MeshPy::write(PyObject *args)
|
||||
const char* Name;
|
||||
char* Ext=0;
|
||||
char* ObjName=0;
|
||||
if (!PyArg_ParseTuple(args, "s|ss",&Name,&Ext,&ObjName))
|
||||
PyObject* List=0;
|
||||
if (!PyArg_ParseTuple(args, "s|ss",&Name,&Ext,&ObjName,&PyList_Type,&List))
|
||||
return NULL;
|
||||
|
||||
MeshCore::MeshIO::Format format = MeshCore::MeshIO::Undefined;
|
||||
@@ -176,10 +177,31 @@ PyObject* MeshPy::write(PyObject *args)
|
||||
};
|
||||
|
||||
PY_TRY {
|
||||
getMeshObjectPtr()->save(Name, format, 0, ObjName);
|
||||
if (List) {
|
||||
MeshCore::Material mat;
|
||||
Py::List list(List);
|
||||
for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
Py::Tuple t(*it);
|
||||
float r = (float)Py::Float(t.getItem(0));
|
||||
float g = (float)Py::Float(t.getItem(1));
|
||||
float b = (float)Py::Float(t.getItem(2));
|
||||
mat.diffuseColor.push_back(App::Color(r,g,b));
|
||||
}
|
||||
|
||||
if (mat.diffuseColor.size() == getMeshObjectPtr()->countPoints())
|
||||
mat.binding = MeshCore::MeshIO::PER_VERTEX;
|
||||
else if (mat.diffuseColor.size() == getMeshObjectPtr()->countFacets())
|
||||
mat.binding = MeshCore::MeshIO::PER_FACE;
|
||||
else
|
||||
mat.binding = MeshCore::MeshIO::OVERALL;
|
||||
getMeshObjectPtr()->save(Name, format, &mat, ObjName);
|
||||
}
|
||||
else {
|
||||
getMeshObjectPtr()->save(Name, format, 0, ObjName);
|
||||
}
|
||||
} PY_CATCH;
|
||||
|
||||
Py_Return;
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* MeshPy::writeInventor(PyObject *args)
|
||||
|
||||
Reference in New Issue
Block a user