MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / insert

Method insert

src/Mod/Fem/App/AppFemPy.cpp:170–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 15

importVTKCellGroupMethod · 0.45
getGroupElementsMethod · 0.45
addGroupElementsMethod · 0.45
getIdByElementTypeMethod · 0.45
getEdgesMethod · 0.45
getFacesMethod · 0.45
getVolumesMethod · 0.45
getVolumesByFaceMethod · 0.45
getFacesByFaceMethod · 0.45
getEdgesByEdgeMethod · 0.45
getccxVolumesByFaceMethod · 0.45
getNodesBySolidMethod · 0.45

Calls 14

fileNamePureMethod · 0.80
ExceptionClass · 0.50
ptrMethod · 0.45
getDocumentMethod · 0.45
getActiveDocumentMethod · 0.45
newDocumentMethod · 0.45
c_strMethod · 0.45
readMethod · 0.45
setValueMethod · 0.45
setValuePtrMethod · 0.45
releaseMethod · 0.45
purgeTouchedMethod · 0.45

Tested by

no test coverage detected