Fem: Add option to set data mode for SolverCalculiX
This commit is contained in:
@@ -252,14 +252,14 @@ private:
|
||||
Py::Object frdToVTK(const Py::Tuple& args)
|
||||
{
|
||||
char* filename = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &filename)) {
|
||||
PyObject* binary = Py_True;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et|O!", "utf-8", &filename, &PyBool_Type, &binary)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
std::string encodedName = std::string(filename);
|
||||
PyMem_Free(filename);
|
||||
|
||||
FemVTKTools::frdToVTK(encodedName.c_str());
|
||||
FemVTKTools::frdToVTK(encodedName.c_str(), Base::asBoolean(binary));
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,7 @@ vtkSmartPointer<vtkMultiBlockDataSet> readFRD(std::ifstream& ifstr)
|
||||
|
||||
} // namespace FRDReader
|
||||
|
||||
void FemVTKTools::frdToVTK(const char* filename)
|
||||
void FemVTKTools::frdToVTK(const char* filename, bool binary)
|
||||
{
|
||||
Base::FileInfo fi(filename);
|
||||
|
||||
@@ -1733,6 +1733,8 @@ void FemVTKTools::frdToVTK(const char* filename)
|
||||
std::string type = info->GetValue(0).c_str();
|
||||
|
||||
auto writer = vtkSmartPointer<vtkXMLMultiBlockDataWriter>::New();
|
||||
writer->SetDataMode(binary ? vtkXMLMultiBlockDataWriter::Binary
|
||||
: vtkXMLMultiBlockDataWriter::Ascii);
|
||||
|
||||
std::string blockFile =
|
||||
dir + "/" + fi.fileNamePure() + type + "." + writer->GetDefaultFileExtension();
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
// write FemResult (activeObject if res= NULL) to vtkUnstructuredGrid dataset file
|
||||
static void writeResult(const char* filename, const App::DocumentObject* res = nullptr);
|
||||
|
||||
static void frdToVTK(const char* filename);
|
||||
static void frdToVTK(const char* filename, bool binary = true);
|
||||
};
|
||||
} // namespace Fem
|
||||
|
||||
|
||||
@@ -686,6 +686,33 @@ By uncheck this option, CalculiX command behave like SolverCalculiXCcxTools</str
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="l_result_format">
|
||||
<property name="text">
|
||||
<string>Result format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="2">
|
||||
<widget class="Gui::PrefCheckBox" name="ckb_result_format">
|
||||
<property name="toolTip">
|
||||
<string>Save result in binary format.
|
||||
Only ta kes effect if 'Pipeline only' is enabled</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use binary format</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>BinaryOutput</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Fem/Ccx</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -73,6 +73,7 @@ void DlgSettingsFemCcxImp::saveSettings()
|
||||
ui->dsb_ccx_minimum_time_step->onSave(); // Minimum time step
|
||||
ui->dsb_ccx_maximum_time_step->onSave(); // Maximum time step
|
||||
ui->ckb_pipeline_result->onSave();
|
||||
ui->ckb_result_format->onSave();
|
||||
|
||||
ui->cb_analysis_type->onSave();
|
||||
ui->cb_BeamShellOutput->onSave(); // Beam shell output 3d or 2d
|
||||
@@ -101,6 +102,7 @@ void DlgSettingsFemCcxImp::loadSettings()
|
||||
ui->dsb_ccx_minimum_time_step->onRestore(); // Minimum time step
|
||||
ui->dsb_ccx_maximum_time_step->onRestore(); // Maximum time step
|
||||
ui->ckb_pipeline_result->onRestore();
|
||||
ui->ckb_result_format->onRestore();
|
||||
|
||||
ui->cb_analysis_type->onRestore();
|
||||
ui->cb_BeamShellOutput->onRestore(); // Beam shell output 3d or 2d
|
||||
|
||||
@@ -172,7 +172,8 @@ class CalculiXTools:
|
||||
|
||||
def _load_ccxfrd_results(self):
|
||||
frd_result_prefix = os.path.join(self.obj.WorkingDirectory, self.input_deck)
|
||||
Fem.frdToVTK(frd_result_prefix + ".frd")
|
||||
binary_mode = self.fem_param.GetGroup("Ccx").GetBool("BinaryOutput", False)
|
||||
Fem.frdToVTK(frd_result_prefix + ".frd", binary_mode)
|
||||
files = os.listdir(self.obj.WorkingDirectory)
|
||||
for f in files:
|
||||
if f.endswith(".vtm"):
|
||||
|
||||
Reference in New Issue
Block a user