0000340: Make mesh 4-node parabolic instead of plain 3-node

This commit is contained in:
wmayer 2012-04-02 09:11:58 +02:00
parent d6061d30a0
commit 2a3317113f
9 changed files with 472 additions and 39 deletions

View File

@ -579,6 +579,8 @@ void StdMeshers_Deflection1DPy::init_type(PyObject* module)
{
behaviors().name("StdMeshers_Deflection1D");
behaviors().doc("StdMeshers_Deflection1D");
add_varargs_method("setDeflection", &StdMeshers_Deflection1DPy::setDeflection, "setDeflection()");
SMESH_HypothesisPyBase::init_type(module);
}
@ -591,6 +593,13 @@ StdMeshers_Deflection1DPy::~StdMeshers_Deflection1DPy()
{
}
Py::Object StdMeshers_Deflection1DPy::setDeflection(const Py::Tuple& args)
{
double fine = (double)Py::Float(args[0]);
hypothesis<StdMeshers_Deflection1D>()->SetDeflection(fine);
return Py::None();
}
// ----------------------------------------------------------------------------
void StdMeshers_Hexa_3DPy::init_type(PyObject* module)

View File

@ -208,6 +208,8 @@ public:
static void init_type(PyObject*);
StdMeshers_Deflection1DPy(int hypId, int studyId, SMESH_Gen* gen);
~StdMeshers_Deflection1DPy();
Py::Object setDeflection(const Py::Tuple& args);
};
class StdMeshers_Hexa_3DPy : public SMESH_HypothesisPy<StdMeshers_Hexa_3DPy>

View File

@ -28,6 +28,24 @@ if(SMESH_FOUND)
include_directories( ${SMESH_INCLUDE_DIR} )
list( APPEND FemGui_LIBS ${SMESH_LIBRARIES} )
endif(SMESH_FOUND)
set(FemGui_MOC_HDRS
Hypothesis.h
)
fc_wrap_cpp(FemGui_MOC_SRCS ${FemGui_MOC_HDRS})
SOURCE_GROUP("Moc" FILES ${FemGui_MOC_SRCS})
set(FemGui_UIC_SRCS
Hypothesis.ui
)
qt4_wrap_ui(FemGui_UIC_HDRS ${FemGui_UIC_SRCS})
SET(FemGui_DLG_SRCS
${FemGui_UIC_HDRS}
Hypothesis.ui
Hypothesis.cpp
Hypothesis.h
)
SOURCE_GROUP("Dialogs" FILES ${FemGui_DLG_SRCS})
qt4_add_resources(FemResource_SRCS Resources/Fem.qrc)
@ -35,7 +53,7 @@ SOURCE_GROUP("Resources" FILES ${FemResource_SRCS})
SET(FemGui_SRCS
#${FemGui_UIC_HDRS}
${FemGui_DLG_SRCS}
${FemResource_SRCS}
AppFemGui.cpp
AppFemGuiPy.cpp

View File

@ -30,6 +30,7 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/MainWindow.h>
#include <Gui/FileDialog.h>
@ -38,6 +39,7 @@
#include <Mod/Fem/App/FemMeshObject.h>
#include "Hypothesis.h"
using namespace std;
@ -57,46 +59,14 @@ CmdFemCreateFromShape::CmdFemCreateFromShape()
void CmdFemCreateFromShape::activated(int iMsg)
{
Base::Type type = Base::Type::fromName("Part::Feature");
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(type);
openCommand("Create FEM");
doCommand(Doc, "import Fem");
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
App::Document* doc = (*it)->getDocument();
QString name = QString::fromAscii((*it)->getNameInDocument());
QString cmd = QString::fromAscii(
"__fem__=Fem.FemMesh()\n"
"__fem__.setShape(FreeCAD.getDocument(\"%1\").%2.Shape)\n"
"h1=Fem.StdMeshers_MaxLength(0,__fem__)\n"
"h1.setLength(1.0)\n"
"h2=Fem.StdMeshers_LocalLength(1,__fem__)\n"
"h2.setLength(1.0)\n"
"h3=Fem.StdMeshers_QuadranglePreference(2,__fem__)\n"
"h4=Fem.StdMeshers_Quadrangle_2D(3,__fem__)\n"
"h5=Fem.StdMeshers_MaxElementArea(4,__fem__)\n"
"h5.setMaxArea(1.0)\n"
"h6=Fem.StdMeshers_Regular_1D(5,__fem__)\n"
"__fem__.addHypothesis(h1)\n"
"__fem__.addHypothesis(h2)\n"
"__fem__.addHypothesis(h3)\n"
"__fem__.addHypothesis(h4)\n"
"__fem__.addHypothesis(h5)\n"
"__fem__.addHypothesis(h6)\n"
"__fem__.compute()\n"
"FreeCAD.getDocument(\"%1\").addObject"
"(\"Fem::FemMeshObject\",\"%2\").FemMesh=__fem__\n"
"del __fem__,h1,h2,h3,h4,h5,h6\n"
)
.arg(QString::fromAscii(doc->getName()))
.arg(name);
doCommand(Doc, "%s", (const char*)cmd.toAscii());
}
commitCommand();
FemGui::TaskHypothesis* dlg = new FemGui::TaskHypothesis();
Gui::Control().showDialog(dlg);
}
bool CmdFemCreateFromShape::isActive(void)
{
if (Gui::Control().activeDialog())
return false;
Base::Type type = Base::Type::fromName("Part::Feature");
return Gui::Selection().countObjectsOfType(type) > 0;
}

View File

@ -0,0 +1,186 @@
/***************************************************************************
* Copyright (c) 2012 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 <QTextStream>
#endif
#include "Hypothesis.h"
#include "ui_Hypothesis.h"
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Gui/Command.h>
using namespace FemGui;
HypothesisWidget::HypothesisWidget(QWidget* parent)
: QWidget(parent), ui(new Ui_HypothesisWidget)
{
ui->setupUi(this);
}
HypothesisWidget::~HypothesisWidget()
{
delete ui;
}
bool HypothesisWidget::accept()
{
Base::Type type = Base::Type::fromName("Part::Feature");
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(type);
Gui::Command::openCommand("Create FEM");
Gui::Command::doCommand(Gui::Command::Doc, "import Fem");
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
QString cmd;
QTextStream str(&cmd);
App::Document* doc = (*it)->getDocument();
QString doc_name = QString::fromAscii(doc->getName());
QString obj_name = QString::fromAscii((*it)->getNameInDocument());
str << QString::fromAscii(
"__fem__=Fem.FemMesh()\n"
"__fem__.setShape(FreeCAD.getDocument('%1').%2.Shape)\n")
.arg(doc_name).arg(obj_name);
int hyp=0;
if (ui->maxLength->isChecked()) {
str << QString::fromAscii(
"hyp=Fem.StdMeshers_MaxLength(%1,__fem__)\n"
"hyp.setLength(%2)\n"
"__fem__.addHypothesis(hyp)\n")
.arg(hyp++).arg(ui->valMaxLength->value());
}
if (ui->localLength->isChecked()) {
str << QString::fromAscii(
"hyp=Fem.StdMeshers_LocalLength(%1,__fem__)\n"
"hyp.setLength(%2)\n"
"__fem__.addHypothesis(hyp)\n")
.arg(hyp++).arg(ui->valLocalLength->value());
}
if (ui->maxArea->isChecked()) {
str << QString::fromAscii(
"hyp=Fem.StdMeshers_MaxElementArea(%1,__fem__)\n"
"hyp.setMaxArea(%2)\n"
"__fem__.addHypothesis(hyp)\n").
arg(hyp++).arg(ui->valMaxArea->value());
}
#if 0
str << QString::fromAscii(
"hyp=Fem.StdMeshers_NumberOfSegments(%1,__fem__)\n"
"hyp.setNumberOfSegments(1)\n"
"__fem__.addHypothesis(hyp)\n")
.arg(hyp++);
str << QString::fromAscii(
"hyp=Fem.StdMeshers_Deflection1D(%1,__fem__)\n"
"hyp.setDeflection(0.02)\n"
"__fem__.addHypothesis(hyp)\n")
.arg(hyp++);
#endif
str << QString::fromAscii(
"hyp=Fem.StdMeshers_Regular_1D(%1,__fem__)\n"
"__fem__.addHypothesis(hyp)\n")
.arg(hyp++);
if (ui->quadPref->isChecked()) {
str << QString::fromAscii(
"hyp=Fem.StdMeshers_QuadranglePreference(%1,__fem__)\n"
"__fem__.addHypothesis(hyp)\n")
.arg(hyp++);
}
str << QString::fromAscii(
"hyp=Fem.StdMeshers_Quadrangle_2D(%1,__fem__)\n"
"__fem__.addHypothesis(hyp)\n")
.arg(hyp++);
str << QString::fromAscii(
"__fem__.compute()\n"
"FreeCAD.getDocument('%1').addObject"
"(\"Fem::FemMeshObject\",'%2').FemMesh=__fem__\n"
"del __fem__, hyp\n")
.arg(doc_name).arg(obj_name);
Gui::Command::doCommand(Gui::Command::Doc, "%s", (const char*)cmd.toAscii());
}
Gui::Command::commitCommand();
return true;
}
bool HypothesisWidget::reject()
{
return true;
}
void HypothesisWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
}
// -----------------------------------------------
TaskHypothesis::TaskHypothesis()
{
widget = new HypothesisWidget();
taskbox = new Gui::TaskView::TaskBox(
QPixmap(),
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskHypothesis::~TaskHypothesis()
{
}
void TaskHypothesis::open()
{
}
bool TaskHypothesis::accept()
{
try {
return widget->accept();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
return false;
}
catch (...) {
Base::Console().Error("Unknown error\n");
return false;
}
}
bool TaskHypothesis::reject()
{
return widget->reject();
}
#include "moc_Hypothesis.cpp"

View File

@ -0,0 +1,75 @@
/***************************************************************************
* Copyright (c) 2012 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 FEMGUI_HYPOTHESIS_H
#define FEMGUI_HYPOTHESIS_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/TaskView/TaskDialog.h>
namespace FemGui {
class Ui_HypothesisWidget;
class HypothesisWidget : public QWidget
{
Q_OBJECT
public:
HypothesisWidget(QWidget* parent = 0);
~HypothesisWidget();
bool accept();
bool reject();
private:
void changeEvent(QEvent *e);
private:
Ui_HypothesisWidget* ui;
};
class TaskHypothesis : public Gui::TaskView::TaskDialog
{
Q_OBJECT
public:
TaskHypothesis();
~TaskHypothesis();
public:
void open();
bool accept();
bool reject();
QDialogButtonBox::StandardButtons getStandardButtons() const
{ return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; }
bool needsFullSpace() const
{ return true; }
private:
HypothesisWidget* widget;
Gui::TaskView::TaskBox* taskbox;
};
} //namespace FemGui
#endif // FEMGUI_HYPOTHESIS_H

View File

@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FemGui::HypothesisWidget</class>
<widget class="QWidget" name="FemGui::HypothesisWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>299</width>
<height>238</height>
</rect>
</property>
<property name="windowTitle">
<string>Hypothesis</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="quadPref">
<property name="text">
<string>Quadrangle</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="maxLength">
<property name="text">
<string>Maximum length</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="valMaxLength">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="localLength">
<property name="text">
<string>Local length</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="valLocalLength">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="maxArea">
<property name="text">
<string>Maximum element area</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="valMaxArea">
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>65</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>quadPref</tabstop>
<tabstop>maxLength</tabstop>
<tabstop>valMaxLength</tabstop>
<tabstop>localLength</tabstop>
<tabstop>valLocalLength</tabstop>
<tabstop>maxArea</tabstop>
<tabstop>valMaxArea</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>maxLength</sender>
<signal>toggled(bool)</signal>
<receiver>valMaxLength</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>73</x>
<y>92</y>
</hint>
<hint type="destinationlabel">
<x>172</x>
<y>88</y>
</hint>
</hints>
</connection>
<connection>
<sender>localLength</sender>
<signal>toggled(bool)</signal>
<receiver>valLocalLength</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>44</x>
<y>116</y>
</hint>
<hint type="destinationlabel">
<x>186</x>
<y>118</y>
</hint>
</hints>
</connection>
<connection>
<sender>maxArea</sender>
<signal>toggled(bool)</signal>
<receiver>valMaxArea</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>61</x>
<y>144</y>
</hint>
<hint type="destinationlabel">
<x>197</x>
<y>145</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -2,9 +2,15 @@ SUBDIRS=Resources
lib_LTLIBRARIES=libFemGui.la FemGui.la
BUILT_SOURCES=\
ui_Hypothesis.h \
moc_Hypothesis.cpp
libFemGui_la_SOURCES=\
AppFemGuiPy.cpp \
Command.cpp \
Hypothesis.cpp \
Hypothesis.h \
PreCompiled.cpp \
PreCompiled.h \
ViewProviderFemMesh.cpp \
@ -78,5 +84,6 @@ libdir = $(prefix)/Mod/Fem
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
CMakeLists.txt
CMakeLists.txt \
Hypothesis.ui

View File

@ -45,4 +45,4 @@ ParGrp = App.ParamGet("System parameter:Modules").GetGroup("Fem")
FreeCAD.addExportType("TetGen file (*.poly)","convert2TetGen")
FreeCAD.addImportType("FEM formats (*.unv *.med *.dat *.bdf)","Fem")
FreeCAD.addExportType("FEM formats (*.unv *.med *.dat)","Fem")
FreeCAD.addExportType("FEM formats (*.unv *.med *.dat *.inp)","Fem")