Merge pull request #487 from berndhahnebach/bhbdev066

Bhbdev066
This commit is contained in:
wwmayer 2017-01-31 12:30:09 +01:00 committed by GitHub
commit bcc2e45195
7 changed files with 90 additions and 16 deletions

View File

@ -281,16 +281,13 @@ private:
std::string EncodedName = std::string(fileName);
PyMem_Free(fileName);
if (!pcObj)
if (pcObj)
{
App::DocumentObjectPy* objpy= static_cast<App::DocumentObjectPy*>(pcObj);
App::DocumentObject* obj = objpy->getDocumentObjectPtr();
if (!obj)
if (PyObject_TypeCheck(pcObj, &(App::DocumentObjectPy::Type)))
{
App::Document* pcDoc = App::GetApplication().getActiveDocument();
obj = pcDoc->getActiveObject();
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(pcObj)->getDocumentObjectPtr();
FemVTKTools::writeResult(EncodedName.c_str(), obj);
}
FemVTKTools::readFluidicResult(EncodedName.c_str(), obj);
}
else
FemVTKTools::writeResult(EncodedName.c_str());

View File

@ -113,7 +113,9 @@ SET(FemScripts_SRCS
ccxFrdReader.py
convert2TetGen.py
importInpMesh.py
importVTKResults.py
importZ88Mesh.py
importZ88Results.py
Init.py
InitGui.py
FemAnalysis.py
@ -139,7 +141,6 @@ SET(FemScripts_SRCS
FemMaterial.py
FemSelectionObserver.py
TestFem.py
z88DispReader.py
TaskPanelFemBeamSection.ui
TaskPanelFemMeshGmsh.ui
TaskPanelFemMeshGroup.ui

View File

@ -116,7 +116,7 @@ INSTALL(
# solver Z88
importZ88Mesh.py
z88DispReader.py
importZ88Results.py
FemInputWriterZ88.py
FemToolsZ88.py
FemSolverZ88.py
@ -124,6 +124,9 @@ INSTALL(
_ViewProviderFemSolverZ88.py
_CommandSolverZ88.py
# additional imports and exports
importVTKResults.py
DESTINATION
Mod/Fem
)

View File

@ -190,11 +190,11 @@ class FemToolsZ88(FemTools.FemTools):
def load_results_o2(self):
import os
import z88DispReader
import importZ88Results
disp_result_file = self.working_dir + '/z88o2.txt'
if os.path.isfile(disp_result_file):
result_name_prefix = 'Z88_' + self.solver.AnalysisType + '_'
z88DispReader.import_z88_disp(disp_result_file, self.analysis, result_name_prefix)
importZ88Results.import_z88_disp(disp_result_file, self.analysis, result_name_prefix)
for m in self.analysis.Member:
if m.isDerivedFrom("Fem::FemResultObject"):
self.results_present = True

View File

@ -30,13 +30,14 @@ import FreeCAD
FreeCAD.addExportType("TetGen file (*.poly)", "convert2TetGen")
FreeCAD.addImportType("FEM formats (*.unv *.med *.dat *.bdf)", "Fem")
if("BUILD_FEM_VTK" in FreeCAD.__cmake__):
FreeCAD.addImportType("FEM results (*.vtk *.vtp *.vts *.vtr *.vtu *.vti)", "Fem")
FreeCAD.addImportType("FEM CFD Unstructure Mesh (*.vtk *.vtu)", "Fem")
FreeCAD.addExportType("FEM CFD Unstructure Mesh (*.vtk *.vtu)", "Fem")
# FreeCAD.addImportType("FEM results (*.vtk *.vtp *.vts *.vtr *.vtu *.vti)", "importVTKResults") # not implemented yet
FreeCAD.addExportType("FEM CFD Result in VTK format (*.vtk *.vtu)", "importVTKResults")
FreeCAD.addExportType("FEM formats (*.unv *.med *.dat *.inp)", "Fem")
FreeCAD.addImportType("CalculiX result (*.frd)", "ccxFrdReader")
FreeCAD.addImportType("Mesh from Calculix/Abaqus input file (*.inp)", "importInpMesh")
FreeCAD.addImportType("Z88 mesh file (*.txt)", "importZ88Mesh")
FreeCAD.addExportType("Z88 mesh file (*.txt)", "importZ88Mesh")
FreeCAD.addImportType("Z88 displacement result file (*.txt)", "z88DispReader")
FreeCAD.addImportType("Z88 result file (*.txt)", "importZ88Results")

View File

@ -0,0 +1,70 @@
# ***************************************************************************
# * (c) Qingfeng Xia 2017 *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with FreeCAD; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# * Juergen Riegel 2002 *
# ***************************************************************************/
__title__ = "FreeCAD Result import and export VTK file library"
__author__ = "Qingfeng Xia"
__url__ = "http://www.freecadweb.org"
## @package importVTKResults
# \ingroup FEM
import os
import FreeCAD
if open.__module__ == '__builtin__':
pyopen = open # because we'll redefine open below
def insert(filename, docname):
"called when freecad wants to import a file"
try:
doc = FreeCAD.getDocument(docname)
except NameError:
doc = FreeCAD.newDocument(docname)
FreeCAD.ActiveDocument = doc
importFemResult(filename)
def open(filename):
"called when freecad opens a file"
docname = os.path.splitext(os.path.basename(filename))[0]
insert(filename, docname)
def importFemResult(filename):
FreeCAD.Console.PrintError("FemResult import is not implemented, actually not necessary\n")
def export(objectslist, filename):
"called when freecad exports a fem result object"
if len(objectslist) != 1:
FreeCAD.Console.PrintError("This exporter can only export one object at once\n")
return
obj = objectslist[0]
if not obj.isDerivedFrom("Fem::FemResultObject"):
FreeCAD.Console.PrintError("object selcted is not FemResultObject.\n")
return
import Fem
Fem.writeResult(filename, obj)

View File

@ -24,7 +24,7 @@ __title__ = "FreeCAD Z88 Disp Reader"
__author__ = "Bernd Hahnebach "
__url__ = "http://www.freecadweb.org"
## @package z88DispReader
## @package importZ88Results
# \ingroup FEM
import FreeCAD
@ -57,6 +57,8 @@ def insert(filename, docname):
def import_z88_disp(filename, analysis=None, result_name_prefix=None):
'''insert a FreeCAD FEM Result object in the ActiveDocument
'''
if result_name_prefix is None:
result_name_prefix = ''
m = read_z88_disp(filename)
if(len(m['Nodes']) > 0):
if analysis is None:
@ -141,9 +143,9 @@ def read_z88_disp(z88_disp_input):
pure usage:
import FemToolsZ88
fea = FemToolsZ88.FemToolsZ88()
import z88dispReader
import importZ88Results
disp_file = '/pathtofile/z88o2.txt'
z88DispReader.import_z88_disp(disp_file , fea.analysis)
importZ88Results.import_z88_disp(disp_file , fea.analysis)
The FreeCAD file needs to have an Analysis and an appropiate FEM Mesh
'''