static PyObject * show(PyObject *self, PyObject *args) { PyObject *pcObj; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &pcObj)) return NULL; PY_TRY { App::Document *pcDoc = App::GetApplication().getActiveDocument(); if (!pcDoc) pcDoc = App::GetApplication().newDocument(); MeshPy* pMesh = static_cast<MeshPy*>(pcObj); Mesh::Feature *pcFeature = (Mesh::Feature *)pcDoc->addObject("Mesh::Feature", "Mesh"); Mesh::MeshObject* mo = pMesh->getMeshObjectPtr(); if (!mo) { PyErr_SetString(PyExc_ReferenceError, "object doesn't reference a valid mesh"); return 0; } // copy the data pcFeature->Mesh.setValue(*mo); } PY_CATCH; Py_Return; }
void PropertyMeshKernel::setPyObject(PyObject *value) { if (PyObject_TypeCheck(value, &(MeshPy::Type))) { MeshPy* mesh = static_cast<MeshPy*>(value); // Do not allow to reassign the same instance if (&(*this->_meshObject) != mesh->getMeshObjectPtr()) { // Note: Copy the content, do NOT reference the same mesh object setValue(*(mesh->getMeshObjectPtr())); } } else if (PyList_Check(value)) { // new instance of MeshObject Py::List triangles(value); MeshObject* mesh = MeshObject::createMeshFromList(triangles); setValuePtr(mesh); } else { std::string error = std::string("type must be 'Mesh', not "); error += value->ob_type->tp_name; throw Base::TypeError(error); } }
PyObject* MeshPy::outer(PyObject *args) { MeshPy *pcObject; PyObject *pcObj; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &pcObj)) // convert args: Python->C return NULL; // NULL triggers exception pcObject = static_cast<MeshPy*>(pcObj); PY_TRY { MeshObject* mesh = getMeshObjectPtr()->outer(*pcObject->getMeshObjectPtr()); return new MeshPy(mesh); } PY_CATCH; Py_Return; }