From 577f208da74f05b40edb4535737edb3ba501c789 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 19 Feb 2016 00:05:55 -0200 Subject: [PATCH] Revert "FEM: Updated fix to constraint displacement reference deletion, update hide show, remove custom input writer, update vertice, edge, face selection." This reverts commit ac4d4664438a7b7a83facbcc5c1fffd02ea55a68. --- src/Base/QuantityLexer.c | 7 +- src/Mod/Fem/App/CMakeLists.txt | 1 + src/Mod/Fem/CMakeLists.txt | 2 + src/Mod/Fem/FemCommands.py | 4 +- src/Mod/Fem/Gui/Command.cpp | 23 +++-- src/Mod/Fem/Gui/TaskFemConstraint.cpp | 5 - src/Mod/Fem/Gui/TaskFemConstraint.h | 5 +- .../Fem/Gui/TaskFemConstraintDisplacement.cpp | 42 +++------ src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp | 11 --- src/Mod/Fem/Gui/TaskFemConstraintFixed.h | 2 +- src/Mod/Fem/Gui/TaskFemConstraintForce.cpp | 2 - src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp | 4 +- src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp | 11 --- src/Mod/Fem/Gui/TaskFemConstraintPulley.h | 2 +- src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp | 20 ---- src/Mod/Fem/Gui/ViewProviderFemConstraint.h | 3 - .../ccxInpWriterFemConstraintDisplacement.py | 94 +++++++++++++++++++ 17 files changed, 129 insertions(+), 109 deletions(-) create mode 100644 src/Mod/Fem/ccxInpWriterFemConstraintDisplacement.py diff --git a/src/Base/QuantityLexer.c b/src/Base/QuantityLexer.c index 49473e26619d..c70b69d62014 100644 --- a/src/Base/QuantityLexer.c +++ b/src/Base/QuantityLexer.c @@ -109,10 +109,7 @@ typedef unsigned int flex_uint32_t; #endif /* Returned upon end-of-file. */ -# ifdef YY_NULL -# undef YY_NULL -# define YY_NULL 0 -# endif +#define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, @@ -689,7 +686,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned int n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index 3d7a9fec054d..1ef8c6f234e6 100755 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -110,6 +110,7 @@ SET(FemScripts_SRCS MechanicalMaterial.py SelectionObserverFem.py TestFem.py + ccxInpWriterFemConstraintDisplacement.py TaskPanelFemBeamSection.ui TaskPanelFemShellThickness.ui diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index 064341805942..59b7a89f2387 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -11,6 +11,8 @@ INSTALL( Init.py InitGui.py + ccxInpWriterFemConstraintDisplacement.py + convert2TetGen.py SelectionObserverFem.py diff --git a/src/Mod/Fem/FemCommands.py b/src/Mod/Fem/FemCommands.py index 91ab4a96dc33..c9bfb2508823 100644 --- a/src/Mod/Fem/FemCommands.py +++ b/src/Mod/Fem/FemCommands.py @@ -101,8 +101,8 @@ def analysis_has_solver(self): def hide_parts_constraints_show_meshes(self): if FreeCAD.GuiUp: for acnstrmesh in FreeCAD.activeDocument().Objects: - #if "Constraint" in acnstrmesh.TypeId: - # acnstrmesh.ViewObject.Visibility = False + if "Constraint" in acnstrmesh.TypeId: + acnstrmesh.ViewObject.Visibility = False if "Mesh" in acnstrmesh.TypeId: aparttoshow = acnstrmesh.Name.replace("_Mesh","") for apart in FreeCAD.activeDocument().Objects: diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 79d3a4e9ec82..5c4e2a6b11b6 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -81,12 +81,11 @@ bool getConstraintPrerequisits(Fem::FemAnalysis **Analysis) } //OvG: Visibility automation show parts and hide meshes on activation of a constraint -std::string gethideMeshShowPartStr(std::string showConstr="") +std::string gethideMeshShowPartStr() { - return "for amesh in App.activeDocument().Objects:\n\ - if \""+showConstr+"\" == amesh.Name:\n\ - amesh.ViewObject.Visibility = True\n\ - elif \"Mesh\" in amesh.TypeId:\n\ + return + "for amesh in App.activeDocument().Objects:\n\ + if \"Mesh\" in amesh.TypeId:\n\ aparttoshow = amesh.Name.replace(\"_Mesh\",\"\")\n\ for apart in App.activeDocument().Objects:\n\ if aparttoshow == apart.Name:\n\ @@ -292,7 +291,7 @@ void CmdFemConstraintBearing::activated(int iMsg) doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintBearing\",\"%s\")",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str()); - doCommand(Doc,"%s",gethideMeshShowPartStr(FeatName).c_str()); //OvG: Hide meshes and show parts + doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts updateActive(); @@ -334,7 +333,7 @@ void CmdFemConstraintFixed::activated(int iMsg) doCommand(Doc,"App.activeDocument().%s.Scale = 1",FeatName.c_str()); //OvG: set initial scale to 1 doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str()); - doCommand(Doc,"%s",gethideMeshShowPartStr(FeatName).c_str()); //OvG: Hide meshes and show parts + doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts updateActive(); @@ -378,7 +377,7 @@ void CmdFemConstraintForce::activated(int iMsg) doCommand(Doc,"App.activeDocument().%s.Scale = 1",FeatName.c_str()); //OvG: set initial scale to 1 doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str()); - doCommand(Doc,"%s",gethideMeshShowPartStr(FeatName).c_str()); //OvG: Hide meshes and show parts + doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts updateActive(); @@ -423,7 +422,7 @@ void CmdFemConstraintPressure::activated(int iMsg) doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]", Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str()); - doCommand(Doc,"%s",gethideMeshShowPartStr(FeatName).c_str()); //OvG: Hide meshes and show parts + doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts updateActive(); @@ -464,7 +463,7 @@ void CmdFemConstraintGear::activated(int iMsg) doCommand(Doc,"App.activeDocument().%s.Diameter = 100.0",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str()); - doCommand(Doc,"%s",gethideMeshShowPartStr(FeatName).c_str()); //OvG: Hide meshes and show parts + doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts updateActive(); @@ -510,7 +509,7 @@ void CmdFemConstraintPulley::activated(int iMsg) doCommand(Doc,"App.activeDocument().%s.TensionForce = 100.0",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str()); - doCommand(Doc,"%s",gethideMeshShowPartStr(FeatName).c_str()); //OvG: Hide meshes and show parts + doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts updateActive(); @@ -552,7 +551,7 @@ void CmdFemConstraintDisplacement::activated(int iMsg) doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]", Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str()); - doCommand(Doc,"%s",gethideMeshShowPartStr(FeatName).c_str()); //OvG: Hide meshes and show parts + doCommand(Doc,"%s",gethideMeshShowPartStr().c_str()); //OvG: Hide meshes and show parts updateActive(); diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.cpp b/src/Mod/Fem/Gui/TaskFemConstraint.cpp index 66ca6532052a..000b3bd1d154 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraint.cpp @@ -181,11 +181,6 @@ const QString TaskFemConstraint::makeRefText(const App::DocumentObject* obj, con //==== calls from the TaskView =============================================================== -void TaskDlgFemConstraint::open() -{ - ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts -} bool TaskDlgFemConstraint::accept() { diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.h b/src/Mod/Fem/Gui/TaskFemConstraint.h index 9108c25eafc0..275c38f76c2f 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.h +++ b/src/Mod/Fem/Gui/TaskFemConstraint.h @@ -77,10 +77,9 @@ class TaskDlgFemConstraint : public Gui::TaskView::TaskDialog Q_OBJECT public: - - /// is called the TaskView when the dialog is opened - void open(); /* + /// is called the TaskView when the dialog is opened + virtual void open() {} /// is called by the framework if an button is clicked which has no accept or reject role virtual void clicked(int) {} /// is called by the framework if the dialog is accepted (Ok) diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp index dceef06c922d..6d87aaf4a981 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp @@ -435,27 +435,10 @@ void TaskFemConstraintDisplacement::addToSelection() addMe=false; } } - // limit constraint such that only vertexes or faces or edges can be used depending on what was selected first - std::string searchStr(""); - if (subNames[subIt].find("Vertex")!=std::string::npos) - searchStr="Vertex"; - else if (subNames[subIt].find("Edge")!=std::string::npos) - searchStr="Edge"; - else - searchStr="Face"; - if ((std::none_of(SubElements.begin(),SubElements.end(),[&](std::string const &s){return s.find(searchStr)!=std::string::npos;}))&&(SubElements.size()>0)){ - std::string Msg="Only one type of selection (vertex,face or edge) per constraint allowed!"; - QMessageBox::warning(this, tr("Selection error"),QString::fromStdString(Msg)); - addMe=false; - } if (addMe){ - disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(setSelection(QListWidgetItem*))); Objects.push_back(obj); SubElements.push_back(subNames[subIt]); ui->lw_references->addItem(makeRefText(obj, subNames[subIt])); - connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(setSelection(QListWidgetItem*))); } } } @@ -475,7 +458,7 @@ void TaskFemConstraintDisplacement::removeFromSelection() Fem::ConstraintDisplacement* pcConstraint = static_cast(ConstraintView->getObject()); std::vector Objects = pcConstraint->References.getValues(); std::vector SubElements = pcConstraint->References.getSubValues(); - std::vector itemsToDel; + std::vector itemsToDel; for (std::vector::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object if (static_cast(it->getTypeName()).substr(0,4).compare(std::string("Part"))!=0){ QMessageBox::warning(this, tr("Selection error"),tr("Selected object is not a part!")); @@ -497,32 +480,30 @@ void TaskFemConstraintDisplacement::removeFromSelection() } } - std::sort(itemsToDel.begin(),itemsToDel.end()); while (itemsToDel.size()>0){ Objects.erase(Objects.begin()+itemsToDel.back()); SubElements.erase(SubElements.begin()+itemsToDel.back()); itemsToDel.pop_back(); } - //Update UI disconnect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); - + ui->lw_references->clear(); for (unsigned int j=0;jlw_references->addItem(makeRefText(Objects[j], SubElements[j])); } connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); - + pcConstraint->References.setValues(Objects,SubElements); updateUI(); } void TaskFemConstraintDisplacement::setSelection(QListWidgetItem* item){ - std::string s = item->text().toStdString(); std::string docName=ConstraintView->getObject()->getDocument()->getName(); - + + std::string s = item->text().toStdString(); std::string delimiter = ":"; size_t pos = 0; @@ -532,13 +513,16 @@ void TaskFemConstraintDisplacement::setSelection(QListWidgetItem* item){ objName = s.substr(0, pos); s.erase(0, pos + delimiter.length()); subName=s; - + Gui::Selection().clearSelection(); Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0); } void TaskFemConstraintDisplacement::onReferenceDeleted() { - TaskFemConstraintDisplacement::removeFromSelection(); //OvG: On right-click face is automatically selected, so just remove + int row = ui->lw_references->currentIndex().row(); + TaskFemConstraint::onReferenceDeleted(row); + ui->lw_references->model()->removeRow(row); + ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect); } const std::string TaskFemConstraintDisplacement::getReferences() const @@ -600,10 +584,8 @@ void TaskDlgFemConstraintDisplacement::open() { // a transaction is already open at creation time of the panel if (!Gui::Command::hasPendingCommand()) { - QString msg = QObject::tr("Constraint displacement"); + QString msg = QObject::tr("Constraint normal stress"); Gui::Command::openCommand((const char*)msg.toUtf8()); - ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts } } @@ -651,7 +633,7 @@ bool TaskDlgFemConstraintDisplacement::accept() name.c_str(), parameterDisplacement->get_rotzfix() ? "True" : "False"); std::string scale = parameterDisplacement->getScale(); //OvG: determine modified scale - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale } catch (const Base::Exception& e) { QMessageBox::warning(parameter, tr("Input error"), QString::fromLatin1(e.what())); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp index e367660ba90f..3a26270871c0 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp @@ -213,17 +213,6 @@ TaskDlgFemConstraintFixed::TaskDlgFemConstraintFixed(ViewProviderFemConstraintFi //==== calls from the TaskView =============================================================== -void TaskDlgFemConstraintFixed::open() -{ - // a transaction is already open at creation time of the panel - if (!Gui::Command::hasPendingCommand()) { - QString msg = QObject::tr("Constraint fixed"); - Gui::Command::openCommand((const char*)msg.toUtf8()); - ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts - } -} - bool TaskDlgFemConstraintFixed::accept() { std::string name = ConstraintView->getObject()->getNameInDocument(); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFixed.h b/src/Mod/Fem/Gui/TaskFemConstraintFixed.h index 08b93b1b3520..d6c404282172 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFixed.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintFixed.h @@ -76,7 +76,7 @@ class TaskDlgFemConstraintFixed : public TaskDlgFemConstraint /// is called by the framework if the dialog is accepted (Ok) virtual bool accept(); - void open(); + }; } //namespace FemGui diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp index b95d36e34d05..1e83b2b1d5e2 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp @@ -342,8 +342,6 @@ void TaskDlgFemConstraintForce::open() if (!Gui::Command::hasPendingCommand()) { QString msg = QObject::tr("Constraint force"); Gui::Command::openCommand((const char*)msg.toUtf8()); - ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts } } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp index dcc21be87ebc..cc276b2c8682 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp @@ -240,10 +240,8 @@ void TaskDlgFemConstraintPressure::open() { // a transaction is already open at creation time of the panel if (!Gui::Command::hasPendingCommand()) { - QString msg = QObject::tr("Constraint pressure"); + QString msg = QObject::tr("Constraint normal stress"); Gui::Command::openCommand((const char*)msg.toUtf8()); - ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts } } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp index 5a84ac364741..adcbb113d7f7 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp @@ -188,17 +188,6 @@ TaskDlgFemConstraintPulley::TaskDlgFemConstraintPulley(ViewProviderFemConstraint //==== calls from the TaskView =============================================================== -void TaskDlgFemConstraintPulley::open() -{ - // a transaction is already open at creation time of the panel - if (!Gui::Command::hasPendingCommand()) { - QString msg = QObject::tr("Constraint pulley"); - Gui::Command::openCommand((const char*)msg.toUtf8()); - ConstraintView->setVisible(true); - Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts - } -} - bool TaskDlgFemConstraintPulley::accept() { std::string name = ConstraintView->getObject()->getNameInDocument(); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPulley.h b/src/Mod/Fem/Gui/TaskFemConstraintPulley.h index 5ec4916cea62..f2b92c5b9e3f 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPulley.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintPulley.h @@ -66,7 +66,7 @@ class TaskDlgFemConstraintPulley : public TaskDlgFemConstraintGear /// is called by the framework if the dialog is accepted (Ok) virtual bool accept(); - void open(); + }; } //namespace FemGui diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp index 6042d868ae47..f5387339efdd 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp @@ -168,28 +168,8 @@ void ViewProviderFemConstraint::onChanged(const App::Property* prop) } } -//OvG: Visibility automation show parts and hide meshes on activation of a constraint -std::string ViewProviderFemConstraint::gethideMeshShowPartStr(const std::string showConstr) -{ - return "for amesh in App.activeDocument().Objects:\n\ - if \""+showConstr+"\" == amesh.Name:\n\ - amesh.ViewObject.Visibility = True\n\ - elif \"Mesh\" in amesh.TypeId:\n\ - aparttoshow = amesh.Name.replace(\"_Mesh\",\"\")\n\ - for apart in App.activeDocument().Objects:\n\ - if aparttoshow == apart.Name:\n\ - apart.ViewObject.Visibility = True\n\ - amesh.ViewObject.Visibility = False\n"; -} - -std::string ViewProviderFemConstraint::gethideMeshShowPartStr() -{ - return ViewProviderFemConstraint::gethideMeshShowPartStr(""); -} - bool ViewProviderFemConstraint::setEdit(int ModNum) { - Gui::Command::doCommand(Gui::Command::Doc,"%s",ViewProviderFemConstraint::gethideMeshShowPartStr().c_str()); return Gui::ViewProviderGeometryObject::setEdit(ModNum); } diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h index 688597714557..2bfe344a3226 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraint.h +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraint.h @@ -64,9 +64,6 @@ class FemGuiExport ViewProviderFemConstraint : public Gui::ViewProviderGeometryO std::vector claimChildren(void)const; void setupContextMenu(QMenu*, QObject*, const char*); - - static std::string gethideMeshShowPartStr(); - static std::string gethideMeshShowPartStr(const std::string showConstr); protected: void onChanged(const App::Property* prop); diff --git a/src/Mod/Fem/ccxInpWriterFemConstraintDisplacement.py b/src/Mod/Fem/ccxInpWriterFemConstraintDisplacement.py new file mode 100644 index 000000000000..3dbec76d06ad --- /dev/null +++ b/src/Mod/Fem/ccxInpWriterFemConstraintDisplacement.py @@ -0,0 +1,94 @@ +import FreeCAD +import os + +class ccxInpWriterFemConstraintDisplacement: + def __init__(self): + displacement_constraints = [] + beam_sections = [] + shell_thicknesses = [] + f_mesh = None + dir_name=None + file_name=None + + def writeFile(self): + print('started FemConstraintDisplacementInpFile') + import FemGui + f_analysis = FemGui.getActiveAnalysis() + displacement_constraints = [] + beam_sections = [] + shell_thicknesses = [] + f_mesh = None + dir_name=None + file_name=None + for m in f_analysis.Member: + if m.isDerivedFrom("Fem::ConstraintDisplacement"): + displacement_constraint_dict = {} + displacement_constraint_dict['Object'] = m + displacement_constraints.append(displacement_constraint_dict) + elif m.isDerivedFrom("Fem::FemMeshObject"): + f_mesh=m + elif hasattr(m, "Proxy") and m.Proxy.Type == 'FemBeamSection': + beam_section_dict = {} + beam_section_dict['Object'] = m + beam_sections.append(beam_section_dict) + elif hasattr(m, "Proxy") and m.Proxy.Type == "FemShellThickness": + shell_thickness_dict = {} + shell_thickness_dict['Object'] = m + shell_thicknesses.append(shell_thickness_dict) + dir_name = FreeCAD.ActiveDocument.TransientDir.replace('\\', '/') + '/FemConstraints' + if not os.path.isdir(dir_name): + os.mkdir(dir_name) + file_name = dir_name + '/' + 'FemConstraintDisplacement.txt' + print(file_name) + inpfile = open(file_name, 'w') + inpfile.write('\n***********************************************************\n') + inpfile.write('** Node sets for prescribed displacement constraint\n') + #inpfile.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) + for fobj in displacement_constraints: + disp_obj = fobj['Object'] + inpfile.write('*NSET,NSET='+disp_obj.Name + '\n') + for o, elem in disp_obj.References: + fo = o.Shape.getElement(elem) + n = [] + if fo.ShapeType == 'Face': + n = f_mesh.FemMesh.getNodesByFace(fo) + elif fo.ShapeType == 'Edge': + n = f_mesh.FemMesh.getNodesByEdge(fo) + elif fo.ShapeType == 'Vertex': + n = f_mesh.FemMesh.getNodesByVertex(fo) + for i in n: + inpfile.write(str(i) + ',\n') + inpfile.write('\n***********************************************************\n') + inpfile.write('** Displacement constraint applied\n') + #f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name)) + for disp_obj in displacement_constraints: + disp_obj_name = disp_obj['Object'].Name + inpfile.write('*BOUNDARY\n') + if disp_obj['Object'].xFix == True: + inpfile.write(disp_obj_name + ',1\n') + elif disp_obj['Object'].xFree == False: + inpfile.write(disp_obj_name + ',1,1,'+str(disp_obj['Object'].xDisplacement)+'\n') + if disp_obj['Object'].yFix == True: + inpfile.write(disp_obj_name + ',2\n') + elif disp_obj['Object'].yFree == False: + inpfile.write(disp_obj_name + ',2,2,'+str(disp_obj['Object'].yDisplacement)+'\n') + if disp_obj['Object'].zFix == True: + inpfile.write(disp_obj_name + ',3\n') + elif disp_obj['Object'].zFree == False: + inpfile.write(disp_obj_name + ',3,3,'+str(disp_obj['Object'].zDisplacement)+'\n') + + if beam_sections or shell_thicknesses: + if disp_obj['Object'].rotxFix == True: + inpfile.write(disp_obj_name + ',4\n') + elif disp_obj['Object'].rotxFree == False: + inpfile.write(disp_obj_name + ',4,4,'+str(disp_obj['Object'].xRotation)+'\n') + if disp_obj['Object'].rotyFix == True: + inpfile.write(disp_obj_name + ',5\n') + elif disp_obj['Object'].rotyFree == False: + inpfile.write(disp_obj_name + ',5,5,'+str(disp_obj['Object'].yRotation)+'\n') + if disp_obj['Object'].rotzFix == True: + inpfile.write(disp_obj_name + ',6\n') + elif disp_obj['Object'].rotzFree == False: + inpfile.write(disp_obj_name + ',6,6,'+str(disp_obj['Object'].zRotation)+'\n') + inpfile.close() + print('completed FemConstraintDisplacementInpFile')