| 168 | return Py::None(); |
| 169 | } |
| 170 | Py::Object insert(const Py::Tuple& args) |
| 171 | { |
| 172 | char* Name; |
| 173 | const char* DocName = nullptr; |
| 174 | if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &Name, &DocName)) { |
| 175 | throw Py::Exception(); |
| 176 | } |
| 177 | |
| 178 | std::string EncodedName = std::string(Name); |
| 179 | PyMem_Free(Name); |
| 180 | |
| 181 | App::Document* pcDoc = nullptr; |
| 182 | if (DocName) { |
| 183 | pcDoc = App::GetApplication().getDocument(DocName); |
| 184 | } |
| 185 | else { |
| 186 | pcDoc = App::GetApplication().getActiveDocument(); |
| 187 | } |
| 188 | |
| 189 | if (!pcDoc) { |
| 190 | pcDoc = App::GetApplication().newDocument(DocName); |
| 191 | } |
| 192 | |
| 193 | Base::FileInfo file(EncodedName.c_str()); |
| 194 | |
| 195 | try { |
| 196 | std::unique_ptr<FemMesh> mesh(new FemMesh); |
| 197 | mesh->read(EncodedName.c_str()); |
| 198 | |
| 199 | FemMeshObject* pcFeature = pcDoc->addObject<FemMeshObject>(file.fileNamePure().c_str()); |
| 200 | pcFeature->Label.setValue(file.fileNamePure().c_str()); |
| 201 | pcFeature->FemMesh.setValuePtr(mesh.release()); |
| 202 | pcFeature->purgeTouched(); |
| 203 | } |
| 204 | catch (Base::Exception&) { |
| 205 | #ifdef FC_USE_VTK |
| 206 | if (FemPostPipeline::canRead(file)) { |
| 207 | |
| 208 | auto* pcFeature = pcDoc->addObject<FemPostPipeline>(file.fileNamePure().c_str()); |
| 209 | |
| 210 | pcFeature->Label.setValue(file.fileNamePure().c_str()); |
| 211 | pcFeature->read(file); |
| 212 | pcFeature->touch(); |
| 213 | pcDoc->recomputeFeature(pcFeature); |
| 214 | } |
| 215 | else { |
| 216 | throw; |
| 217 | } |
| 218 | #else |
| 219 | throw; |
| 220 | #endif |
| 221 | } |
| 222 | |
| 223 | return Py::None(); |
| 224 | } |
| 225 | Py::Object exporter(const Py::Tuple& args) |
| 226 | { |
| 227 | PyObject* object; |
no test coverage detected