FEM: Add ConstraintPressure
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
parent
3c629f095d
commit
e13a8cf304
|
@ -47,6 +47,7 @@
|
||||||
#include "FemConstraintBearing.h"
|
#include "FemConstraintBearing.h"
|
||||||
#include "FemConstraintFixed.h"
|
#include "FemConstraintFixed.h"
|
||||||
#include "FemConstraintForce.h"
|
#include "FemConstraintForce.h"
|
||||||
|
#include "FemConstraintPressure.h"
|
||||||
#include "FemConstraintGear.h"
|
#include "FemConstraintGear.h"
|
||||||
#include "FemConstraintPulley.h"
|
#include "FemConstraintPulley.h"
|
||||||
|
|
||||||
|
@ -135,6 +136,7 @@ void AppFemExport initFem()
|
||||||
Fem::ConstraintBearing ::init();
|
Fem::ConstraintBearing ::init();
|
||||||
Fem::ConstraintFixed ::init();
|
Fem::ConstraintFixed ::init();
|
||||||
Fem::ConstraintForce ::init();
|
Fem::ConstraintForce ::init();
|
||||||
|
Fem::ConstraintPressure ::init();
|
||||||
Fem::ConstraintGear ::init();
|
Fem::ConstraintGear ::init();
|
||||||
Fem::ConstraintPulley ::init();
|
Fem::ConstraintPulley ::init();
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,8 @@ SET(FemConstraints_SRCS
|
||||||
FemConstraintFixed.h
|
FemConstraintFixed.h
|
||||||
FemConstraintForce.cpp
|
FemConstraintForce.cpp
|
||||||
FemConstraintForce.h
|
FemConstraintForce.h
|
||||||
|
FemConstraintPressure.cpp
|
||||||
|
FemConstraintPressure.h
|
||||||
FemConstraintGear.cpp
|
FemConstraintGear.cpp
|
||||||
FemConstraintGear.h
|
FemConstraintGear.h
|
||||||
FemConstraintPulley.cpp
|
FemConstraintPulley.cpp
|
||||||
|
|
81
src/Mod/Fem/App/FemConstraintPressure.cpp
Normal file
81
src/Mod/Fem/App/FemConstraintPressure.cpp
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2015 FreeCAD Developers *
|
||||||
|
* Author: Przemo Firszt <przemo@firszt.eu> *
|
||||||
|
* Based on Force constraint by Jan Rheinländer *
|
||||||
|
* This file is part of the FreeCAD CAx development system. *
|
||||||
|
* *
|
||||||
|
* This library is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
* License as published by the Free Software Foundation; either *
|
||||||
|
* version 2 of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This library 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 Library General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Library General Public *
|
||||||
|
* License along with this library; see the file COPYING.LIB. If not, *
|
||||||
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||||
|
* Suite 330, Boston, MA 02111-1307, USA *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "PreCompiled.h"
|
||||||
|
|
||||||
|
#ifndef _PreComp_
|
||||||
|
#include <BRepAdaptor_Curve.hxx>
|
||||||
|
#include <BRepAdaptor_Surface.hxx>
|
||||||
|
#include <Precision.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <gp_Lin.hxx>
|
||||||
|
#include <gp_Pln.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "FemConstraintPressure.h"
|
||||||
|
|
||||||
|
using namespace Fem;
|
||||||
|
|
||||||
|
PROPERTY_SOURCE(Fem::ConstraintPressure, Fem::Constraint);
|
||||||
|
|
||||||
|
ConstraintPressure::ConstraintPressure()
|
||||||
|
{
|
||||||
|
ADD_PROPERTY(Pressure,(0.0));
|
||||||
|
ADD_PROPERTY(Reversed,(0));
|
||||||
|
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintPressure",
|
||||||
|
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
|
||||||
|
"Points where arrows are drawn");
|
||||||
|
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintPressure",
|
||||||
|
App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
|
||||||
|
"Normals where symbols are drawn");
|
||||||
|
Points.setValues(std::vector<Base::Vector3d>());
|
||||||
|
Normals.setValues(std::vector<Base::Vector3d>());
|
||||||
|
}
|
||||||
|
|
||||||
|
App::DocumentObjectExecReturn *ConstraintPressure::execute(void)
|
||||||
|
{
|
||||||
|
return Constraint::execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* ConstraintPressure::getViewProviderName(void) const
|
||||||
|
{
|
||||||
|
return "FemGui::ViewProviderFemConstraintPressure";
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConstraintPressure::onChanged(const App::Property* prop)
|
||||||
|
{
|
||||||
|
Constraint::onChanged(prop);
|
||||||
|
|
||||||
|
if (prop == &References) {
|
||||||
|
std::vector<Base::Vector3d> points;
|
||||||
|
std::vector<Base::Vector3d> normals;
|
||||||
|
if (getPoints(points, normals)) {
|
||||||
|
Points.setValues(points);
|
||||||
|
Normals.setValues(normals);
|
||||||
|
Points.touch();
|
||||||
|
}
|
||||||
|
} else if (prop == &Reversed) {
|
||||||
|
Points.touch();
|
||||||
|
}
|
||||||
|
}
|
55
src/Mod/Fem/App/FemConstraintPressure.h
Normal file
55
src/Mod/Fem/App/FemConstraintPressure.h
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2015 FreeCAD Developers *
|
||||||
|
* Author: Przemo Firszt <przemo@firszt.eu> *
|
||||||
|
* Based on Force constraint by Jan Rheinländer *
|
||||||
|
* This file is part of the FreeCAD CAx development system. *
|
||||||
|
* *
|
||||||
|
* This library is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
* License as published by the Free Software Foundation; either *
|
||||||
|
* version 2 of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This library 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 Library General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Library General Public *
|
||||||
|
* License along with this library; see the file COPYING.LIB. If not, *
|
||||||
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||||
|
* Suite 330, Boston, MA 02111-1307, USA *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FEM_CONSTRAINTPRESSURE_H
|
||||||
|
#define FEM_CONSTRAINTPRESSURE_H
|
||||||
|
|
||||||
|
#include "FemConstraint.h"
|
||||||
|
|
||||||
|
namespace Fem {
|
||||||
|
|
||||||
|
class AppFemExport ConstraintPressure : public Fem::Constraint {
|
||||||
|
PROPERTY_HEADER(Fem::ConstraintPressure);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ConstraintPressure(void);
|
||||||
|
|
||||||
|
App::PropertyFloat Pressure;
|
||||||
|
App::PropertyBool Reversed;
|
||||||
|
App::PropertyVectorList Points;
|
||||||
|
App::PropertyVectorList Normals;
|
||||||
|
|
||||||
|
/// recalculate the object
|
||||||
|
virtual App::DocumentObjectExecReturn *execute(void);
|
||||||
|
|
||||||
|
/// returns the type name of the ViewProvider
|
||||||
|
const char* getViewProviderName(void) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void onChanged(const App::Property* prop);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FEM_CONSTRAINTPRESSURE_H
|
|
@ -45,6 +45,7 @@
|
||||||
#include "ViewProviderFemConstraintBearing.h"
|
#include "ViewProviderFemConstraintBearing.h"
|
||||||
#include "ViewProviderFemConstraintFixed.h"
|
#include "ViewProviderFemConstraintFixed.h"
|
||||||
#include "ViewProviderFemConstraintForce.h"
|
#include "ViewProviderFemConstraintForce.h"
|
||||||
|
#include "ViewProviderFemConstraintPressure.h"
|
||||||
#include "ViewProviderFemConstraintGear.h"
|
#include "ViewProviderFemConstraintGear.h"
|
||||||
#include "ViewProviderFemConstraintPulley.h"
|
#include "ViewProviderFemConstraintPulley.h"
|
||||||
#include "ViewProviderResult.h"
|
#include "ViewProviderResult.h"
|
||||||
|
@ -95,6 +96,7 @@ void FemGuiExport initFemGui()
|
||||||
FemGui::ViewProviderFemConstraintBearing ::init();
|
FemGui::ViewProviderFemConstraintBearing ::init();
|
||||||
FemGui::ViewProviderFemConstraintFixed ::init();
|
FemGui::ViewProviderFemConstraintFixed ::init();
|
||||||
FemGui::ViewProviderFemConstraintForce ::init();
|
FemGui::ViewProviderFemConstraintForce ::init();
|
||||||
|
FemGui::ViewProviderFemConstraintPressure ::init();
|
||||||
FemGui::ViewProviderFemConstraintGear ::init();
|
FemGui::ViewProviderFemConstraintGear ::init();
|
||||||
FemGui::ViewProviderFemConstraintPulley ::init();
|
FemGui::ViewProviderFemConstraintPulley ::init();
|
||||||
FemGui::ViewProviderResult ::init();
|
FemGui::ViewProviderResult ::init();
|
||||||
|
|
|
@ -49,6 +49,7 @@ set(FemGui_MOC_HDRS
|
||||||
TaskFemConstraintBearing.h
|
TaskFemConstraintBearing.h
|
||||||
TaskFemConstraintFixed.h
|
TaskFemConstraintFixed.h
|
||||||
TaskFemConstraintForce.h
|
TaskFemConstraintForce.h
|
||||||
|
TaskFemConstraintPressure.h
|
||||||
TaskFemConstraintGear.h
|
TaskFemConstraintGear.h
|
||||||
TaskFemConstraintPulley.h
|
TaskFemConstraintPulley.h
|
||||||
TaskTetParameter.h
|
TaskTetParameter.h
|
||||||
|
@ -68,6 +69,7 @@ set(FemGui_UIC_SRCS
|
||||||
TaskFemConstraintBearing.ui
|
TaskFemConstraintBearing.ui
|
||||||
TaskFemConstraintFixed.ui
|
TaskFemConstraintFixed.ui
|
||||||
TaskFemConstraintForce.ui
|
TaskFemConstraintForce.ui
|
||||||
|
TaskFemConstraintPressure.ui
|
||||||
TaskTetParameter.ui
|
TaskTetParameter.ui
|
||||||
TaskAnalysisInfo.ui
|
TaskAnalysisInfo.ui
|
||||||
TaskDriver.ui
|
TaskDriver.ui
|
||||||
|
@ -91,6 +93,9 @@ SET(FemGui_DLG_SRCS
|
||||||
TaskFemConstraintForce.ui
|
TaskFemConstraintForce.ui
|
||||||
TaskFemConstraintForce.cpp
|
TaskFemConstraintForce.cpp
|
||||||
TaskFemConstraintForce.h
|
TaskFemConstraintForce.h
|
||||||
|
TaskFemConstraintPressure.ui
|
||||||
|
TaskFemConstraintPressure.cpp
|
||||||
|
TaskFemConstraintPressure.h
|
||||||
TaskFemConstraintGear.cpp
|
TaskFemConstraintGear.cpp
|
||||||
TaskFemConstraintGear.h
|
TaskFemConstraintGear.h
|
||||||
TaskFemConstraintPulley.cpp
|
TaskFemConstraintPulley.cpp
|
||||||
|
@ -129,6 +134,8 @@ SET(FemGui_SRCS_ViewProvider
|
||||||
ViewProviderFemConstraintFixed.h
|
ViewProviderFemConstraintFixed.h
|
||||||
ViewProviderFemConstraintForce.cpp
|
ViewProviderFemConstraintForce.cpp
|
||||||
ViewProviderFemConstraintForce.h
|
ViewProviderFemConstraintForce.h
|
||||||
|
ViewProviderFemConstraintPressure.cpp
|
||||||
|
ViewProviderFemConstraintPressure.h
|
||||||
ViewProviderFemConstraintGear.cpp
|
ViewProviderFemConstraintGear.cpp
|
||||||
ViewProviderFemConstraintGear.h
|
ViewProviderFemConstraintGear.h
|
||||||
ViewProviderFemConstraintPulley.cpp
|
ViewProviderFemConstraintPulley.cpp
|
||||||
|
|
|
@ -321,6 +321,46 @@ bool CmdFemConstraintForce::isActive(void)
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
|
|
||||||
|
DEF_STD_CMD_A(CmdFemConstraintPressure);
|
||||||
|
|
||||||
|
CmdFemConstraintPressure::CmdFemConstraintPressure()
|
||||||
|
: Command("Fem_ConstraintPressure")
|
||||||
|
{
|
||||||
|
sAppModule = "Fem";
|
||||||
|
sGroup = QT_TR_NOOP("Fem");
|
||||||
|
sMenuText = QT_TR_NOOP("Create FEM pressure constraint");
|
||||||
|
sToolTipText = QT_TR_NOOP("Create FEM constraint for a pressure acting on a face");
|
||||||
|
sWhatsThis = "Fem_ConstraintPressure";
|
||||||
|
sStatusTip = sToolTipText;
|
||||||
|
sPixmap = "Fem_ConstraintPressure";
|
||||||
|
}
|
||||||
|
|
||||||
|
void CmdFemConstraintPressure::activated(int iMsg)
|
||||||
|
{
|
||||||
|
Fem::FemAnalysis *Analysis;
|
||||||
|
|
||||||
|
if(getConstraintPrerequisits(&Analysis))
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string FeatName = getUniqueObjectName("FemConstraintPressure");
|
||||||
|
|
||||||
|
openCommand("Make FEM constraint pressure on face");
|
||||||
|
doCommand(Doc,"App.activeDocument().addObject(\"Fem::ConstraintPressure\",\"%s\")",FeatName.c_str());
|
||||||
|
doCommand(Doc,"App.activeDocument().%s.Pressure = 0.0",FeatName.c_str());
|
||||||
|
doCommand(Doc,"App.activeDocument().%s.Member = App.activeDocument().%s.Member + [App.activeDocument().%s]",
|
||||||
|
Analysis->getNameInDocument(),Analysis->getNameInDocument(),FeatName.c_str());
|
||||||
|
updateActive();
|
||||||
|
|
||||||
|
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CmdFemConstraintPressure::isActive(void)
|
||||||
|
{
|
||||||
|
return hasActiveDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=====================================================================================
|
||||||
|
|
||||||
DEF_STD_CMD_A(CmdFemConstraintGear);
|
DEF_STD_CMD_A(CmdFemConstraintGear);
|
||||||
|
|
||||||
CmdFemConstraintGear::CmdFemConstraintGear()
|
CmdFemConstraintGear::CmdFemConstraintGear()
|
||||||
|
@ -607,6 +647,7 @@ void CreateFemCommands(void)
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintBearing());
|
rcCmdMgr.addCommand(new CmdFemConstraintBearing());
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintFixed());
|
rcCmdMgr.addCommand(new CmdFemConstraintFixed());
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintForce());
|
rcCmdMgr.addCommand(new CmdFemConstraintForce());
|
||||||
|
rcCmdMgr.addCommand(new CmdFemConstraintPressure());
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintGear());
|
rcCmdMgr.addCommand(new CmdFemConstraintGear());
|
||||||
rcCmdMgr.addCommand(new CmdFemConstraintPulley());
|
rcCmdMgr.addCommand(new CmdFemConstraintPulley());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<file>icons/Fem_Analysis.svg</file>
|
<file>icons/Fem_Analysis.svg</file>
|
||||||
<file>icons/Fem_ConstraintForce.svg</file>
|
<file>icons/Fem_ConstraintForce.svg</file>
|
||||||
<file>icons/Fem_ConstraintFixed.svg</file>
|
<file>icons/Fem_ConstraintFixed.svg</file>
|
||||||
|
<file>icons/Fem_ConstraintPressure.svg</file>
|
||||||
<file>icons/Fem_ConstraintBearing.svg</file>
|
<file>icons/Fem_ConstraintBearing.svg</file>
|
||||||
<file>icons/Fem_ConstraintGear.svg</file>
|
<file>icons/Fem_ConstraintGear.svg</file>
|
||||||
<file>icons/Fem_ConstraintPulley.svg</file>
|
<file>icons/Fem_ConstraintPulley.svg</file>
|
||||||
|
|
216
src/Mod/Fem/Gui/Resources/icons/Fem_ConstraintPressure.svg
Normal file
216
src/Mod/Fem/Gui/Resources/icons/Fem_ConstraintPressure.svg
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="64px"
|
||||||
|
height="64px"
|
||||||
|
id="svg2860"
|
||||||
|
sodipodi:version="0.32"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="Fem_ConstraintPressure.svg"
|
||||||
|
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||||
|
version="1.1">
|
||||||
|
<defs
|
||||||
|
id="defs2862">
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3377"
|
||||||
|
id="radialGradient3703"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
cx="135.38333"
|
||||||
|
cy="97.369568"
|
||||||
|
fx="135.38333"
|
||||||
|
fy="97.369568"
|
||||||
|
r="19.467436"
|
||||||
|
gradientTransform="matrix(-0.34791909,0.31825551,-0.73405476,-0.58464457,117.5429,55.266368)" />
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3377">
|
||||||
|
<stop
|
||||||
|
id="stop3379"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#faff2b;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3381"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#ffaa00;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3377"
|
||||||
|
id="radialGradient3705"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
cx="148.88333"
|
||||||
|
cy="81.869568"
|
||||||
|
fx="148.88333"
|
||||||
|
fy="81.869568"
|
||||||
|
r="19.467436"
|
||||||
|
gradientTransform="matrix(-0.33630263,0.52883839,-0.4357335,-0.19166171,87.82801,-13.379033)" />
|
||||||
|
<inkscape:perspective
|
||||||
|
sodipodi:type="inkscape:persp3d"
|
||||||
|
inkscape:vp_x="0 : 32 : 1"
|
||||||
|
inkscape:vp_y="0 : 1000 : 0"
|
||||||
|
inkscape:vp_z="64 : 32 : 1"
|
||||||
|
inkscape:persp3d-origin="32 : 21.333333 : 1"
|
||||||
|
id="perspective2868" />
|
||||||
|
<radialGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#linearGradient3377-4"
|
||||||
|
id="radialGradient3703-8"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
cx="135.38333"
|
||||||
|
cy="97.369568"
|
||||||
|
fx="135.38333"
|
||||||
|
fy="97.369568"
|
||||||
|
r="19.467436"
|
||||||
|
gradientTransform="matrix(0.97435,0.2250379,-0.4623105,2.0016728,48.487554,-127.99883)" />
|
||||||
|
<linearGradient
|
||||||
|
id="linearGradient3377-4">
|
||||||
|
<stop
|
||||||
|
id="stop3379-3"
|
||||||
|
offset="0"
|
||||||
|
style="stop-color:#faff2b;stop-opacity:1;" />
|
||||||
|
<stop
|
||||||
|
id="stop3381-0"
|
||||||
|
offset="1"
|
||||||
|
style="stop-color:#ffaa00;stop-opacity:1;" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="4.515625"
|
||||||
|
inkscape:cx="61.041238"
|
||||||
|
inkscape:cy="21.137803"
|
||||||
|
inkscape:current-layer="g4169"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:grid-bbox="true"
|
||||||
|
inkscape:window-width="1366"
|
||||||
|
inkscape:window-height="702"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="27"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata2865">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<g
|
||||||
|
id="g4169"
|
||||||
|
transform="translate(38.754325,-9.0795848)">
|
||||||
|
<path
|
||||||
|
style="display:inline;overflow:visible;visibility:visible;fill:url(#radialGradient3705);fill-opacity:1;fill-rule:evenodd;stroke:#7b5600;stroke-width:1.29527438;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
|
||||||
|
d="m 2.8548824,66.174155 3.3533408,-19.532906 -10.9863517,6.39333 -16.4257865,-6.20804 1.154129,17.108671 c 2.254077,5.463471 7.595779,9.555825 15.0631528,8.332532 3.7268739,-1.076774 5.86986138,-2.23012 7.8415156,-6.093587 z"
|
||||||
|
id="rect3522"
|
||||||
|
sodipodi:nodetypes="ccccccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="display:inline;overflow:visible;visibility:visible;fill:url(#radialGradient3703);fill-opacity:1;fill-rule:evenodd;stroke:#0004ff;stroke-width:1.29508853;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
|
||||||
|
d="M 4.9484269,43.03421 C 6.4343949,49.115554 4.4005224,55.606103 -6.1407308,57.481768 -18.903242,56.783022 -19.889252,51.67224 -20.161156,46.500242 c 0.214596,-4.873277 5.179803,-9.956006 12.7905232,-10.296351 5.862898,-0.01498 10.687814,2.085857 12.3190597,6.830319 z"
|
||||||
|
id="rect3520"
|
||||||
|
sodipodi:nodetypes="ccccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
style="fill:#0000ff;stroke:#000cff;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 43.627414,39.846312 24.992268,29.09331"
|
||||||
|
id="path2390"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:#0000ff;stroke:#000cff;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 38.464163,46.047548 19.694379,35.01827"
|
||||||
|
id="path2400"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.3952297;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 37.549764,61.77018 c 0.207634,-2.3892 0.731714,-11.247212 1.021756,-14.769777"
|
||||||
|
id="path2412"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.39408788;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 30.040717,63.211493 C 29.985544,63.088376 28.999725,49.377774 29.134181,48.4674"
|
||||||
|
id="path2414"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.39406565;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 23.637739,60.605814 C 23.413002,58.970609 22.614068,48.949151 22.491576,46.609742"
|
||||||
|
id="path2418"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#0300ff;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 41.970178,31.21334 28.786676,47.446732"
|
||||||
|
id="path2424"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#0300ff;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 22.753314,44.627485 36.257177,27.705052"
|
||||||
|
id="path2432"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.47040084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 43.549606,49.009987 c -1.1137,3.681043 -5.914807,5.908879 -9.461287,6.829796 -2.776583,0.364479 -11.664583,1.5675 -15.599159,-8.195413"
|
||||||
|
id="path2424-3"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc" />
|
||||||
|
<path
|
||||||
|
style="fill:#0000ff;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 19.187275,13.848165 -0.390076,6.878307 c -0.0024,2.027434 -0.01603,2.722904 -0.04785,4.720922 3.020801,0.115904 4.386372,-0.281197 7.539143,-0.50791 -5.414745,4.558714 -6.954506,5.502746 -12.045082,9.227222 L 1.0250475,26.171496 c 3.640107,-0.138921 4.63113,-0.340872 7.884758,-0.784888 0.128957,-2.330108 0.138585,-3.549603 0.167974,-5.810458 l -0.00702,-6.134386 c 4.4521631,0.263431 6.1637191,0.181171 10.1165131,0.406401 z"
|
||||||
|
id="path3802"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccccccccc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.47040084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 42.519277,56.064294 C 39.516338,61.46742 37.89557,61.951453 33.935853,63.145212 31.15927,63.509691 23.038407,65.155619 19.10383,55.392705"
|
||||||
|
id="path2424-3-5"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccc" />
|
||||||
|
<path
|
||||||
|
style="display:inline;overflow:visible;visibility:visible;fill:none;stroke:#7b5600;stroke-width:0.92551678;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
|
||||||
|
d="m 44.826525,35.160348 c 1.63436,7.920271 -3.156259,12.051144 -12.301741,13.529578 -8.115987,0.516662 -13.724096,-2.842198 -15.056091,-9.068378 0.221988,-6.344032 5.621035,-12.951063 13.914934,-13.378639 6.389786,-0.0076 11.653465,2.737346 13.442898,8.917439 z"
|
||||||
|
id="rect3520-8"
|
||||||
|
sodipodi:nodetypes="ccccc"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#0000ff;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 38.130895,1.3206036 -0.390076,6.878307 c -0.0024,2.0274334 -0.01603,2.7229034 -0.04785,4.7209214 3.020801,0.115904 4.386372,-0.281197 7.539143,-0.50791 -5.414745,4.558714 -6.954506,5.502746 -12.045082,9.227222 l -13.218362,-7.99521 c 3.640107,-0.138921 4.63113,-0.340872 7.884758,-0.784888 0.128957,-2.330108 0.138585,-3.5496024 0.167974,-5.8104574 L 28.0144,0.91420257 C 32.466563,1.1776336 34.178119,1.0953736 38.130913,1.3206036 Z"
|
||||||
|
id="path3802-6"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccccccccc" />
|
||||||
|
<path
|
||||||
|
style="fill:#0000ff;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 56.732972,12.171814 -0.390076,6.878307 c -0.0024,2.027434 -0.01603,2.722904 -0.04785,4.720922 3.020801,0.115904 4.386372,-0.281197 7.539143,-0.50791 -5.414745,4.558714 -6.954506,5.502746 -12.045082,9.227222 l -13.218363,-7.99521 c 3.640107,-0.138921 4.63113,-0.340872 7.884758,-0.784888 0.128957,-2.330108 0.138585,-3.549603 0.167974,-5.810458 l -0.007,-6.134386 c 4.452164,0.263431 6.16372,0.181171 10.116514,0.406401 z"
|
||||||
|
id="path3802-0"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccccccccc" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 11 KiB |
275
src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp
Normal file
275
src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp
Normal file
|
@ -0,0 +1,275 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2015 FreeCAD Developers *
|
||||||
|
* Author: Przemo Firszt <przemo@firszt.eu> *
|
||||||
|
* Based on Force constraint by Jan Rheinländer *
|
||||||
|
* This file is part of the FreeCAD CAx development system. *
|
||||||
|
* *
|
||||||
|
* This library is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
* License as published by the Free Software Foundation; either *
|
||||||
|
* version 2 of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This library 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 Library General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Library General Public *
|
||||||
|
* License along with this library; see the file COPYING.LIB. If not, *
|
||||||
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||||
|
* Suite 330, Boston, MA 02111-1307, USA *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "PreCompiled.h"
|
||||||
|
|
||||||
|
#ifndef _PreComp_
|
||||||
|
# include <BRepAdaptor_Curve.hxx>
|
||||||
|
# include <BRepAdaptor_Surface.hxx>
|
||||||
|
# include <Geom_Line.hxx>
|
||||||
|
# include <Geom_Plane.hxx>
|
||||||
|
# include <Precision.hxx>
|
||||||
|
# include <QMessageBox>
|
||||||
|
# include <QRegExp>
|
||||||
|
# include <QTextStream>
|
||||||
|
# include <TopoDS.hxx>
|
||||||
|
# include <gp_Ax1.hxx>
|
||||||
|
# include <gp_Lin.hxx>
|
||||||
|
# include <gp_Pln.hxx>
|
||||||
|
# include <sstream>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Mod/Fem/App/FemConstraintPressure.h"
|
||||||
|
#include "TaskFemConstraintPressure.h"
|
||||||
|
#include "ui_TaskFemConstraintPressure.h"
|
||||||
|
#include <App/Application.h>
|
||||||
|
#include <Gui/Command.h>
|
||||||
|
|
||||||
|
using namespace FemGui;
|
||||||
|
using namespace Gui;
|
||||||
|
|
||||||
|
/* TRANSLATOR FemGui::TaskFemConstraintPressure */
|
||||||
|
|
||||||
|
TaskFemConstraintPressure::TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent)
|
||||||
|
: TaskFemConstraint(ConstraintView, parent, "Fem_ConstraintPressure")
|
||||||
|
{
|
||||||
|
proxy = new QWidget(this);
|
||||||
|
ui = new Ui_TaskFemConstraintPressure();
|
||||||
|
ui->setupUi(proxy);
|
||||||
|
QMetaObject::connectSlotsByName(this);
|
||||||
|
|
||||||
|
QAction* action = new QAction(tr("Delete"), ui->lw_references);
|
||||||
|
action->connect(action, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
|
||||||
|
ui->lw_references->addAction(action);
|
||||||
|
ui->lw_references->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
|
||||||
|
connect(ui->if_pressure, SIGNAL(valueChanged(Base::Quantity)),
|
||||||
|
this, SLOT(onPressureChanged(Base::Quantity)));
|
||||||
|
connect(ui->b_add_reference, SIGNAL(pressed()),
|
||||||
|
this, SLOT(onButtonReference()));
|
||||||
|
connect(ui->cb_reverse_direction, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(onCheckReverse(bool)));
|
||||||
|
|
||||||
|
this->groupLayout()->addWidget(proxy);
|
||||||
|
|
||||||
|
// Temporarily prevent unnecessary feature recomputes
|
||||||
|
ui->if_pressure->blockSignals(true);
|
||||||
|
ui->lw_references->blockSignals(true);
|
||||||
|
ui->b_add_reference->blockSignals(true);
|
||||||
|
ui->cb_reverse_direction->blockSignals(true);
|
||||||
|
|
||||||
|
// Get the feature data
|
||||||
|
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
|
||||||
|
double f = pcConstraint->Pressure.getValue();
|
||||||
|
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||||
|
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||||
|
bool reversed = pcConstraint->Reversed.getValue();
|
||||||
|
|
||||||
|
// Fill data into dialog elements
|
||||||
|
ui->if_pressure->setMinimum(0);
|
||||||
|
ui->if_pressure->setMaximum(FLOAT_MAX);
|
||||||
|
//1000 because FreeCAD used kPa internally
|
||||||
|
Base::Quantity p = Base::Quantity(1000 * f, Base::Unit::Stress);
|
||||||
|
double val = p.getValueAs(Base::Quantity::MegaPascal);
|
||||||
|
ui->if_pressure->setValue(p);
|
||||||
|
ui->lw_references->clear();
|
||||||
|
for (std::size_t i = 0; i < Objects.size(); i++) {
|
||||||
|
ui->lw_references->addItem(makeRefText(Objects[i], SubElements[i]));
|
||||||
|
}
|
||||||
|
if (Objects.size() > 0) {
|
||||||
|
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||||
|
}
|
||||||
|
ui->cb_reverse_direction->setChecked(reversed);
|
||||||
|
|
||||||
|
ui->if_pressure->blockSignals(false);
|
||||||
|
ui->lw_references->blockSignals(false);
|
||||||
|
ui->b_add_reference->blockSignals(false);
|
||||||
|
ui->cb_reverse_direction->blockSignals(false);
|
||||||
|
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskFemConstraintPressure::~TaskFemConstraintPressure()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintPressure::updateUI()
|
||||||
|
{
|
||||||
|
if (ui->lw_references->model()->rowCount() == 0) {
|
||||||
|
// Go into reference selection mode if no reference has been selected yet
|
||||||
|
onButtonReference(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintPressure::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
|
{
|
||||||
|
if ((msg.Type != Gui::SelectionChanges::AddSelection) ||
|
||||||
|
// Don't allow selection in other document
|
||||||
|
(strcmp(msg.pDocName, ConstraintView->getObject()->getDocument()->getName()) != 0) ||
|
||||||
|
// Don't allow selection mode none
|
||||||
|
(selectionMode != selref) ||
|
||||||
|
// Don't allow empty smenu/submenu
|
||||||
|
(!msg.pSubName || msg.pSubName[0] == '\0')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string subName(msg.pSubName);
|
||||||
|
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
|
||||||
|
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(msg.pObjectName);
|
||||||
|
|
||||||
|
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
|
||||||
|
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
|
||||||
|
|
||||||
|
if (subName.substr(0,4) != "Face") {
|
||||||
|
QMessageBox::warning(this, tr("Selection error"), tr("Only faces can be picked"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Avoid duplicates
|
||||||
|
std::size_t pos = 0;
|
||||||
|
for (; pos < Objects.size(); pos++)
|
||||||
|
if (obj == Objects[pos])
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (pos != Objects.size())
|
||||||
|
if (subName == SubElements[pos])
|
||||||
|
return;
|
||||||
|
|
||||||
|
// add the new reference
|
||||||
|
Objects.push_back(obj);
|
||||||
|
SubElements.push_back(subName);
|
||||||
|
pcConstraint->References.setValues(Objects,SubElements);
|
||||||
|
ui->lw_references->addItem(makeRefText(obj, subName));
|
||||||
|
|
||||||
|
// Turn off reference selection mode
|
||||||
|
onButtonReference(false);
|
||||||
|
Gui::Selection().clearSelection();
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintPressure::onPressureChanged(const Base::Quantity& f)
|
||||||
|
{
|
||||||
|
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
|
||||||
|
double val = f.getValueAs(Base::Quantity::MegaPascal);
|
||||||
|
pcConstraint->Pressure.setValue(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintPressure::onReferenceDeleted() {
|
||||||
|
int row = ui->lw_references->currentIndex().row();
|
||||||
|
TaskFemConstraint::onReferenceDeleted(row);
|
||||||
|
ui->lw_references->model()->removeRow(row);
|
||||||
|
ui->lw_references->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintPressure::onCheckReverse(const bool pressed)
|
||||||
|
{
|
||||||
|
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(ConstraintView->getObject());
|
||||||
|
pcConstraint->Reversed.setValue(pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string TaskFemConstraintPressure::getReferences() const
|
||||||
|
{
|
||||||
|
int rows = ui->lw_references->model()->rowCount();
|
||||||
|
std::vector<std::string> items;
|
||||||
|
for (int r = 0; r < rows; r++) {
|
||||||
|
items.push_back(ui->lw_references->item(r)->text().toStdString());
|
||||||
|
}
|
||||||
|
return TaskFemConstraint::getReferences(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
double TaskFemConstraintPressure::getPressure(void) const
|
||||||
|
{
|
||||||
|
Base::Quantity pressure = ui->if_pressure->getQuantity();
|
||||||
|
double pressure_in_MPa = pressure.getValueAs(Base::Quantity::MegaPascal);
|
||||||
|
return pressure_in_MPa;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskFemConstraintPressure::getReverse() const
|
||||||
|
{
|
||||||
|
return ui->cb_reverse_direction->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskFemConstraintPressure::changeEvent(QEvent *e)
|
||||||
|
{
|
||||||
|
TaskBox::changeEvent(e);
|
||||||
|
if (e->type() == QEvent::LanguageChange) {
|
||||||
|
ui->if_pressure->blockSignals(true);
|
||||||
|
ui->retranslateUi(proxy);
|
||||||
|
ui->if_pressure->blockSignals(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//**************************************************************************
|
||||||
|
// TaskDialog
|
||||||
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
TaskDlgFemConstraintPressure::TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView)
|
||||||
|
{
|
||||||
|
this->ConstraintView = ConstraintView;
|
||||||
|
assert(ConstraintView);
|
||||||
|
this->parameter = new TaskFemConstraintPressure(ConstraintView);;
|
||||||
|
|
||||||
|
Content.push_back(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//==== calls from the TaskView ===============================================================
|
||||||
|
|
||||||
|
void TaskDlgFemConstraintPressure::open()
|
||||||
|
{
|
||||||
|
// a transaction is already open at creation time of the panel
|
||||||
|
if (!Gui::Command::hasPendingCommand()) {
|
||||||
|
QString msg = QObject::tr("Constraint normal stress");
|
||||||
|
Gui::Command::openCommand((const char*)msg.toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskDlgFemConstraintPressure::accept()
|
||||||
|
{
|
||||||
|
std::string name = ConstraintView->getObject()->getNameInDocument();
|
||||||
|
const TaskFemConstraintPressure* parameterPressure = static_cast<const TaskFemConstraintPressure*>(parameter);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Pressure = %f",
|
||||||
|
name.c_str(), parameterPressure->getPressure());
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %s",
|
||||||
|
name.c_str(), parameterPressure->getReverse() ? "True" : "False");
|
||||||
|
}
|
||||||
|
catch (const Base::Exception& e) {
|
||||||
|
QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TaskDlgFemConstraint::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskDlgFemConstraintPressure::reject()
|
||||||
|
{
|
||||||
|
Gui::Command::abortCommand();
|
||||||
|
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||||
|
Gui::Command::updateActive();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_TaskFemConstraintPressure.cpp"
|
78
src/Mod/Fem/Gui/TaskFemConstraintPressure.h
Normal file
78
src/Mod/Fem/Gui/TaskFemConstraintPressure.h
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2015 Przemo Firszt <przemo@firszt.eu> *
|
||||||
|
* Based on Force constraint *
|
||||||
|
* This file is part of the FreeCAD CAx development system. *
|
||||||
|
* *
|
||||||
|
* This library is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
* License as published by the Free Software Foundation; either *
|
||||||
|
* version 2 of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This library 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 Library General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Library General Public *
|
||||||
|
* License along with this library; see the file COPYING.LIB. If not, *
|
||||||
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||||
|
* Suite 330, Boston, MA 02111-1307, USA *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GUI_TASKVIEW_TaskFemConstraintPressure_H
|
||||||
|
#define GUI_TASKVIEW_TaskFemConstraintPressure_H
|
||||||
|
|
||||||
|
#include <Gui/TaskView/TaskView.h>
|
||||||
|
#include <Gui/Selection.h>
|
||||||
|
#include <Gui/TaskView/TaskDialog.h>
|
||||||
|
#include <Base/Quantity.h>
|
||||||
|
|
||||||
|
#include "TaskFemConstraint.h"
|
||||||
|
#include "ViewProviderFemConstraintPressure.h"
|
||||||
|
|
||||||
|
class Ui_TaskFemConstraintPressure;
|
||||||
|
|
||||||
|
namespace App {
|
||||||
|
class Property;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Gui {
|
||||||
|
class ViewProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FemGui {
|
||||||
|
class TaskFemConstraintPressure : public TaskFemConstraint {
|
||||||
|
Q_OBJECT public:
|
||||||
|
TaskFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView,QWidget *parent = 0);
|
||||||
|
virtual ~TaskFemConstraintPressure();
|
||||||
|
double getPressure(void) const;
|
||||||
|
virtual const std::string getReferences() const;
|
||||||
|
bool getReverse(void) const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onReferenceDeleted(void);
|
||||||
|
void onPressureChanged(const Base::Quantity & f);
|
||||||
|
void onCheckReverse(bool);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void changeEvent(QEvent *e);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||||
|
void updateUI();
|
||||||
|
Ui_TaskFemConstraintPressure* ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TaskDlgFemConstraintPressure : public TaskDlgFemConstraint {
|
||||||
|
Q_OBJECT public:
|
||||||
|
TaskDlgFemConstraintPressure(ViewProviderFemConstraintPressure *ConstraintView);
|
||||||
|
virtual void open();
|
||||||
|
virtual bool accept();
|
||||||
|
virtual bool reject();
|
||||||
|
|
||||||
|
};
|
||||||
|
} //namespace FemGui
|
||||||
|
|
||||||
|
#endif // GUI_TASKVIEW_TaskFemConstraintPressure_H
|
79
src/Mod/Fem/Gui/TaskFemConstraintPressure.ui
Normal file
79
src/Mod/Fem/Gui/TaskFemConstraintPressure.ui
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TaskFemConstraintPressure</class>
|
||||||
|
<widget class="QWidget" name="TaskFemConstraintPressure">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>257</width>
|
||||||
|
<height>250</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="b_add_reference">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add reference</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="lw_references"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layoutPressure">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="l_pressure">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pressure</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Gui::InputField" name="if_pressure">
|
||||||
|
<property name="text">
|
||||||
|
<string>1 MPa</string>
|
||||||
|
</property>
|
||||||
|
<property name="unit" stdset="0">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_reverse_direction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reverse direction</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>17</width>
|
||||||
|
<height>56</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Gui::InputField</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>Gui/InputField.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
143
src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp
Normal file
143
src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2015 FreeCAD Developers *
|
||||||
|
* Author: Przemo Firszt <przemo@firszt.eu> *
|
||||||
|
* Based on Force constraint by Jan Rheinländer *
|
||||||
|
* This file is part of the FreeCAD CAx development system. *
|
||||||
|
* *
|
||||||
|
* This library is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
* License as published by the Free Software Foundation; either *
|
||||||
|
* version 2 of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This library 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 Library General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Library General Public *
|
||||||
|
* License along with this library; see the file COPYING.LIB. If not, *
|
||||||
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||||
|
* Suite 330, Boston, MA 02111-1307, USA *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "PreCompiled.h"
|
||||||
|
|
||||||
|
#ifndef _PreComp_
|
||||||
|
# include <Standard_math.hxx>
|
||||||
|
# include <Inventor/nodes/SoSeparator.h>
|
||||||
|
# include <Inventor/nodes/SoTranslation.h>
|
||||||
|
# include <Inventor/nodes/SoRotation.h>
|
||||||
|
# include <Inventor/nodes/SoMultipleCopy.h>
|
||||||
|
# include <Precision.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Mod/Fem/App/FemConstraintPressure.h"
|
||||||
|
#include "TaskFemConstraintPressure.h"
|
||||||
|
#include "ViewProviderFemConstraintPressure.h"
|
||||||
|
#include <Base/Console.h>
|
||||||
|
#include <Gui/Control.h>
|
||||||
|
|
||||||
|
using namespace FemGui;
|
||||||
|
|
||||||
|
PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintPressure, FemGui::ViewProviderFemConstraint)
|
||||||
|
|
||||||
|
ViewProviderFemConstraintPressure::ViewProviderFemConstraintPressure()
|
||||||
|
{
|
||||||
|
sPixmap = "Fem_ConstraintPressure";
|
||||||
|
ADD_PROPERTY(FaceColor,(0.0f,0.2f,0.8f));
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewProviderFemConstraintPressure::~ViewProviderFemConstraintPressure()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME setEdit needs a careful review
|
||||||
|
bool ViewProviderFemConstraintPressure::setEdit(int ModNum)
|
||||||
|
{
|
||||||
|
if (ModNum == ViewProvider::Default) {
|
||||||
|
// When double-clicking on the item for this constraint the
|
||||||
|
// object unsets and sets its edit mode without closing
|
||||||
|
// the task panel
|
||||||
|
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||||
|
TaskDlgFemConstraintPressure *constrDlg = qobject_cast<TaskDlgFemConstraintPressure *>(dlg);
|
||||||
|
if (constrDlg && constrDlg->getConstraintView() != this)
|
||||||
|
constrDlg = 0; // another constraint left open its task panel
|
||||||
|
if (dlg && !constrDlg) {
|
||||||
|
if (constraintDialog != NULL) {
|
||||||
|
// Ignore the request to open another dialog
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
constraintDialog = new TaskFemConstraintPressure(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear the selection (convenience)
|
||||||
|
Gui::Selection().clearSelection();
|
||||||
|
|
||||||
|
// start the edit dialog
|
||||||
|
if (constrDlg)
|
||||||
|
Gui::Control().showDialog(constrDlg);
|
||||||
|
else
|
||||||
|
Gui::Control().showDialog(new TaskDlgFemConstraintPressure(this));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ViewProviderDocumentObject::setEdit(ModNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ARROWLENGTH 5
|
||||||
|
#define ARROWHEADRADIUS 3
|
||||||
|
|
||||||
|
void ViewProviderFemConstraintPressure::updateData(const App::Property* prop)
|
||||||
|
{
|
||||||
|
// Gets called whenever a property of the attached object changes
|
||||||
|
Fem::ConstraintPressure* pcConstraint = static_cast<Fem::ConstraintPressure*>(this->getObject());
|
||||||
|
|
||||||
|
if (pShapeSep->getNumChildren() == 0) {
|
||||||
|
// Set up the nodes
|
||||||
|
SoMultipleCopy* cp = new SoMultipleCopy();
|
||||||
|
cp->ref();
|
||||||
|
cp->matrix.setNum(0);
|
||||||
|
cp->addChild((SoNode*)createArrow(ARROWLENGTH, ARROWHEADRADIUS));
|
||||||
|
pShapeSep->addChild(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(prop->getName(),"Points") == 0) {
|
||||||
|
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
|
||||||
|
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
|
||||||
|
if (points.size() != normals.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
|
||||||
|
|
||||||
|
SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
|
||||||
|
cp->matrix.setNum(points.size());
|
||||||
|
SbMatrix* matrices = cp->matrix.startEditing();
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
|
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
|
||||||
|
SbVec3f base(p->x, p->y, p->z);
|
||||||
|
SbVec3f dir(n->x, n->y, n->z);
|
||||||
|
double rev;
|
||||||
|
if (pcConstraint->Reversed.getValue()) {
|
||||||
|
base = base + dir * ARROWLENGTH;
|
||||||
|
rev = 1;
|
||||||
|
} else {
|
||||||
|
rev = -1;
|
||||||
|
}
|
||||||
|
SbRotation rot(SbVec3f(0, rev, 0), dir);
|
||||||
|
SbMatrix m;
|
||||||
|
m.setTransform(base, rot, SbVec3f(1,1,1));
|
||||||
|
matrices[idx] = m;
|
||||||
|
idx++;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
cp->matrix.finishEditing();
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewProviderFemConstraint::updateData(prop);
|
||||||
|
}
|
52
src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.h
Normal file
52
src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2015 FreeCAD Developers *
|
||||||
|
* Author: Przemo Firszt <przemo@firszt.eu> *
|
||||||
|
* Based on Force constraint by Jan Rheinländer *
|
||||||
|
* This file is part of the FreeCAD CAx development system. *
|
||||||
|
* *
|
||||||
|
* This library is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
* License as published by the Free Software Foundation; either *
|
||||||
|
* version 2 of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This library 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 Library General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Library General Public *
|
||||||
|
* License along with this library; see the file COPYING.LIB. If not, *
|
||||||
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||||
|
* Suite 330, Boston, MA 02111-1307, USA *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef GUI_VIEWPROVIDERFEMCONSTRAINTPRESSURE_H
|
||||||
|
#define GUI_VIEWPROVIDERFEMCONSTRAINTPRESSURE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include "ViewProviderFemConstraint.h"
|
||||||
|
|
||||||
|
namespace Gui {
|
||||||
|
class View3DInventorViewer;
|
||||||
|
namespace TaskView {
|
||||||
|
class TaskDialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace FemGui {
|
||||||
|
class FemGuiExport ViewProviderFemConstraintPressure : public FemGui::ViewProviderFemConstraint {
|
||||||
|
PROPERTY_HEADER(FemGui::ViewProviderFemConstraintPressure);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ViewProviderFemConstraintPressure();
|
||||||
|
virtual ~ViewProviderFemConstraintPressure();
|
||||||
|
virtual void updateData(const App::Property*);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool setEdit(int ModNum);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GUI_VIEWPROVIDERFEMCONSTRAINTPRESSURE_H
|
|
@ -63,6 +63,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||||
<< "Separator"
|
<< "Separator"
|
||||||
<< "Fem_ConstraintFixed"
|
<< "Fem_ConstraintFixed"
|
||||||
<< "Fem_ConstraintForce"
|
<< "Fem_ConstraintForce"
|
||||||
|
<< "Fem_ConstraintPressure"
|
||||||
<< "Fem_ConstraintBearing"
|
<< "Fem_ConstraintBearing"
|
||||||
<< "Fem_ConstraintGear"
|
<< "Fem_ConstraintGear"
|
||||||
<< "Fem_ConstraintPulley"
|
<< "Fem_ConstraintPulley"
|
||||||
|
@ -87,6 +88,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||||
<< "Separator"
|
<< "Separator"
|
||||||
<< "Fem_ConstraintFixed"
|
<< "Fem_ConstraintFixed"
|
||||||
<< "Fem_ConstraintForce"
|
<< "Fem_ConstraintForce"
|
||||||
|
<< "Fem_ConstraintPressure"
|
||||||
<< "Fem_ConstraintBearing"
|
<< "Fem_ConstraintBearing"
|
||||||
<< "Fem_ConstraintGear"
|
<< "Fem_ConstraintGear"
|
||||||
<< "Fem_ConstraintPulley"
|
<< "Fem_ConstraintPulley"
|
||||||
|
|
|
@ -377,7 +377,7 @@ class _JobControlTaskPanel:
|
||||||
try:
|
try:
|
||||||
import ccxInpWriter as iw
|
import ccxInpWriter as iw
|
||||||
inp_writer = iw.inp_writer(self.TempDir, self.MeshObject, self.MaterialObjects,
|
inp_writer = iw.inp_writer(self.TempDir, self.MeshObject, self.MaterialObjects,
|
||||||
self.FixedObjects, self.ForceObjects)
|
self.FixedObjects, self.ForceObjects, self.PressureObjects)
|
||||||
self.base_name = inp_writer.write_calculix_input_file()
|
self.base_name = inp_writer.write_calculix_input_file()
|
||||||
if self.base_name != "":
|
if self.base_name != "":
|
||||||
self.femConsoleMessage("Write completed.")
|
self.femConsoleMessage("Write completed.")
|
||||||
|
@ -435,8 +435,16 @@ class _JobControlTaskPanel:
|
||||||
if i.isDerivedFrom("Fem::ConstraintForce"):
|
if i.isDerivedFrom("Fem::ConstraintForce"):
|
||||||
ForceObjectDict['Object'] = i
|
ForceObjectDict['Object'] = i
|
||||||
self.ForceObjects.append(ForceObjectDict)
|
self.ForceObjects.append(ForceObjectDict)
|
||||||
if not self.ForceObjects:
|
|
||||||
QtGui.QMessageBox.critical(None, "Missing prerequisite", "No force-constraint nodes defined in the Analysis")
|
self.PressureObjects = [] # [{'Object':PressureObject, 'xxxxxxxx':value}, {}, ...]
|
||||||
|
for i in FemGui.getActiveAnalysis().Member:
|
||||||
|
PressureObjectDict = {}
|
||||||
|
if i.isDerivedFrom("Fem::ConstraintPressure"):
|
||||||
|
PressureObjectDict['Object'] = i
|
||||||
|
self.PressureObjects.append(PressureObjectDict)
|
||||||
|
|
||||||
|
if not (self.ForceObjects or self.PressureObjects):
|
||||||
|
QtGui.QMessageBox.critical(None, "Missing prerequisite", "No force-constraint or pressure-constraint defined in the Analysis")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,12 @@ import sys
|
||||||
|
|
||||||
|
|
||||||
class inp_writer:
|
class inp_writer:
|
||||||
def __init__(self, dir_name, mesh_obj, mat_obj, fixed_obj, force_obj):
|
def __init__(self, dir_name, mesh_obj, mat_obj, fixed_obj, force_obj, pressure_obj):
|
||||||
self.mesh_object = mesh_obj
|
self.mesh_object = mesh_obj
|
||||||
self.material_objects = mat_obj
|
self.material_objects = mat_obj
|
||||||
self.fixed_objects = fixed_obj
|
self.fixed_objects = fixed_obj
|
||||||
self.force_objects = force_obj
|
self.force_objects = force_obj
|
||||||
|
self.pressure_objects = pressure_obj
|
||||||
self.base_name = dir_name + '/' + self.mesh_object.Name
|
self.base_name = dir_name + '/' + self.mesh_object.Name
|
||||||
self.file_name = self.base_name + '.inp'
|
self.file_name = self.base_name + '.inp'
|
||||||
print 'CalculiX .inp file will be written to: ', self.file_name
|
print 'CalculiX .inp file will be written to: ', self.file_name
|
||||||
|
@ -29,7 +30,7 @@ class inp_writer:
|
||||||
self.write_step_begin(inpfile)
|
self.write_step_begin(inpfile)
|
||||||
self.write_constraints_fixed(inpfile)
|
self.write_constraints_fixed(inpfile)
|
||||||
self.write_constraints_force(inpfile)
|
self.write_constraints_force(inpfile)
|
||||||
#self.write_face_load(inpfile)
|
self.write_face_load(inpfile)
|
||||||
self.write_outputs_types(inpfile)
|
self.write_outputs_types(inpfile)
|
||||||
self.write_step_end(inpfile)
|
self.write_step_end(inpfile)
|
||||||
self.write_footer(inpfile)
|
self.write_footer(inpfile)
|
||||||
|
@ -306,16 +307,17 @@ class inp_writer:
|
||||||
f.write('\n***********************************************************\n')
|
f.write('\n***********************************************************\n')
|
||||||
f.write('** Element + CalculiX face + load in [MPa]\n')
|
f.write('** Element + CalculiX face + load in [MPa]\n')
|
||||||
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||||
for fobj in self.force_objects:
|
for fobj in self.pressure_objects:
|
||||||
frc_obj = fobj['Object']
|
prs_obj = fobj['Object']
|
||||||
f.write('*DLOAD\n')
|
f.write('*DLOAD\n')
|
||||||
for o, e in frc_obj.References:
|
for o, e in prs_obj.References:
|
||||||
|
rev = -1 if prs_obj.Reversed else 1
|
||||||
elem = o.Shape.getElement(e)
|
elem = o.Shape.getElement(e)
|
||||||
if elem.ShapeType == 'Face':
|
if elem.ShapeType == 'Face':
|
||||||
v = self.mesh_object.FemMesh.getccxVolumesByFace(elem)
|
v = self.mesh_object.FemMesh.getccxVolumesByFace(elem)
|
||||||
f.write("** Load on face {}\n".format(e))
|
f.write("** Load on face {}\n".format(e))
|
||||||
for i in v:
|
for i in v:
|
||||||
f.write("{},P{},{}\n".format(i[0], i[1], frc_obj.Force))
|
f.write("{},P{},{}\n".format(i[0], i[1], rev * prs_obj.Pressure))
|
||||||
|
|
||||||
def write_outputs_types(self, f):
|
def write_outputs_types(self, f):
|
||||||
f.write('\n***********************************************************\n')
|
f.write('\n***********************************************************\n')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user