FEM: mesh api, export of z88 mesh file with Fem API
This commit is contained in:
committed by
Yorik van Havre
parent
78df4424b7
commit
92e9b7cebd
@@ -42,6 +42,7 @@
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/TimeInfo.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <App/Application.h>
|
||||
|
||||
#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
@@ -80,6 +81,7 @@
|
||||
# include <TopoDS_Shape.hxx>
|
||||
|
||||
# include <ShapeAnalysis_ShapeTolerance.hxx>
|
||||
# include <FemMeshPy.h>
|
||||
|
||||
//to simplify parsing input files we use the boost lib
|
||||
#include <boost/tokenizer.hpp>
|
||||
@@ -1191,7 +1193,7 @@ void FemMesh::read(const char *FileName)
|
||||
#if SMESH_VERSION_MAJOR < 7
|
||||
else if (File.hasExtension("dat") ) {
|
||||
// read brep-file
|
||||
// vejmarie disable
|
||||
// vejmarie disable
|
||||
myMesh->DATToMesh(File.filePath().c_str());
|
||||
}
|
||||
#endif
|
||||
@@ -1600,6 +1602,36 @@ void FemMesh::writeABAQUS(const std::string &Filename, int elemParam, bool group
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FemMesh::writeZ88(const std::string &FileName) const
|
||||
{
|
||||
Base::TimeInfo Start;
|
||||
Base::Console().Log("Start: FemMesh::writeZ88() =================================\n");
|
||||
|
||||
/*
|
||||
Python command to export FemMesh from StartWB FEM 3D example:
|
||||
import feminout.importZ88Mesh
|
||||
feminout.importZ88Mesh.write(App.ActiveDocument.Box_Mesh.FemMesh, '/tmp/mesh.z88')
|
||||
*/
|
||||
|
||||
PyObject* module = PyImport_ImportModule("feminout.importZ88Mesh");
|
||||
if (!module)
|
||||
return;
|
||||
try {
|
||||
Py::Module z88mod(module, true);
|
||||
Py::Object mesh = Py::asObject(new FemMeshPy(const_cast<FemMesh*>(this)));
|
||||
Py::Callable method(z88mod.getAttr("write"));
|
||||
Py::Tuple args(2);
|
||||
args.setItem(0, mesh);
|
||||
args.setItem(1, Py::String(FileName));
|
||||
method.apply(args);
|
||||
}
|
||||
catch (Py::Exception& e) {
|
||||
e.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FemMesh::write(const char *FileName) const
|
||||
{
|
||||
Base::FileInfo File(FileName);
|
||||
@@ -1639,6 +1671,11 @@ void FemMesh::write(const char *FileName) const
|
||||
FemVTKTools::writeVTKMesh(File.filePath().c_str(), this);
|
||||
}
|
||||
#endif
|
||||
else if (File.hasExtension("z88") ) {
|
||||
Base::Console().Log("FEM mesh object will be exported to z88 format.\n");
|
||||
// write z88 file
|
||||
writeZ88(File.filePath());
|
||||
}
|
||||
else{
|
||||
throw Base::FileException("An unknown file extension was added!");
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ public:
|
||||
void read(const char *FileName);
|
||||
void write(const char *FileName) const;
|
||||
void writeABAQUS(const std::string &Filename, int elemParam, bool groupParam) const;
|
||||
void writeZ88(const std::string &FileName) const;
|
||||
|
||||
private:
|
||||
void copyMeshData(const FemMesh&);
|
||||
|
||||
@@ -66,7 +66,10 @@
|
||||
</Methode>
|
||||
<Methode Name="write" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Write out a DAT, UNV, MED or STL file.</UserDocu>
|
||||
<UserDocu>Write out various FEM mesh file formats.
|
||||
write(file.endingToExportTo)
|
||||
supported formats: DAT, INP, MED, STL, UNV, VTK, Z88
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="writeABAQUS" Const="true">
|
||||
|
||||
@@ -30,8 +30,9 @@ import FreeCAD
|
||||
|
||||
FreeCAD.addExportType("FEM mesh TetGen (*.poly)", "feminout.convert2TetGen")
|
||||
|
||||
FreeCAD.addImportType("FEM mesh formats (*.unv *.med *.dat *.bdf)", "Fem")
|
||||
FreeCAD.addExportType("FEM mesh formats (*.unv *.med *.stl *.dat *.inp *.vtk *.vtu)", "Fem")
|
||||
# see FemMesh::read() and FemMesh::write() methods in src/Mod/Fem/App/FemMesh.cpp
|
||||
FreeCAD.addImportType("FEM mesh formats (*.unv *.med *.dat *.bdf *.vtk *.vtu)", "Fem")
|
||||
FreeCAD.addExportType("FEM mesh formats (*.unv *.med *.stl *.dat *.inp *.vtk *.vtu *.z88)", "Fem")
|
||||
|
||||
FreeCAD.addImportType("FEM mesh CalculiX/Abaqus (*.inp)", "feminout.importInpMesh")
|
||||
FreeCAD.addImportType("FEM result CalculiX (*.frd)", "feminout.importCcxFrdResults")
|
||||
@@ -39,7 +40,7 @@ FreeCAD.addImportType("FEM result CalculiX (*.frd)", "feminout.importCcxFrdResul
|
||||
FreeCAD.addImportType("FEM mesh Fenics (*.xml *.xdmf)", "feminout.importFenicsMesh")
|
||||
FreeCAD.addExportType("FEM mesh Fenics (*.xml *.xdmf)", "feminout.importFenicsMesh")
|
||||
|
||||
FreeCAD.addImportType("FEM mesh Z88 (*i1.txt)", "feminout.importZ88Mesh")
|
||||
FreeCAD.addImportType("FEM mesh Z88 (*i1.txt *.z88)", "feminout.importZ88Mesh")
|
||||
FreeCAD.addExportType("FEM mesh Z88 (*i1.txt)", "feminout.importZ88Mesh")
|
||||
|
||||
FreeCAD.addImportType("FEM result Z88 displacements (*o2.txt)", "feminout.importZ88O2Results")
|
||||
|
||||
Reference in New Issue
Block a user