Add mesh parameters and Some fixes

This commit is contained in:
jriegel 2013-04-23 00:16:47 +02:00
parent 8a28382848
commit 527a6f5562
8 changed files with 75 additions and 12 deletions

BIN
data/examples/Fem2.FCStd Normal file

Binary file not shown.

View File

@ -38,6 +38,7 @@
#include <SMDS_VolumeTool.hxx>
#include <NETGENPlugin_SimpleHypothesis_3D.hxx>
#include <NETGENPlugin_Hypothesis.hxx>
#include <NETGENPlugin_Mesher.hxx>
#include <BRepBuilderAPI_Copy.hxx>
@ -48,10 +49,19 @@ using namespace App;
PROPERTY_SOURCE(Fem::FemMeshShapeNetgenObject, Fem::FemMeshShapeObject)
const char* FininessEnums[]= {"VeryCoarse","Coarse","Moderate","Fine","VeryFine","UserDefined",NULL};
FemMeshShapeNetgenObject::FemMeshShapeNetgenObject()
{
//ADD_PROPERTY_TYPE(Shape,(0), "Shape",Prop_None,"Shape for the analysis");
ADD_PROPERTY_TYPE(MaxSize,(1000), "MeshParams",Prop_None,"Maximum element size");
ADD_PROPERTY_TYPE(SecondOrder,(false), "MeshParams",Prop_None,"Create quadric elements");
ADD_PROPERTY_TYPE(Fininess,(2), "MeshParams",Prop_None,"Fininess level of the mesh");
Fininess.setEnums(FininessEnums);
ADD_PROPERTY_TYPE(GrothRate,(0.3), "MeshParams",Prop_None," allows to define how much the linear dimensions of two adjacent cells can differ");
ADD_PROPERTY_TYPE(NbSegsPerEdge,(1), "MeshParams",Prop_None,"allows to define the minimum number of mesh segments in which edges will be split");
ADD_PROPERTY_TYPE(NbSegsPerRadius,(2), "MeshParams",Prop_None,"allows to define the minimum number of mesh segments in which radiuses will be split");
ADD_PROPERTY_TYPE(Optimize,(true), "MeshParams",Prop_None,"Shape for the analysis");
}
FemMeshShapeNetgenObject::~FemMeshShapeNetgenObject()
@ -60,12 +70,19 @@ FemMeshShapeNetgenObject::~FemMeshShapeNetgenObject()
App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
{
Fem::FemMesh newMesh;
Part::Feature *feat = Shape.getValue<Part::Feature*>();
TopoDS_Shape shape = feat->Shape.getValue();
if(shape.IsNull())
return App::DocumentObject::StdReturn;
newMesh.getSMesh()->ShapeToMesh(shape);
SMESH_Gen *myGen = newMesh.getGenerator();
int hyp=0;
NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(),shape,true);
@ -80,9 +97,17 @@ App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void)
//static_cast<NETGENPlugin_SimpleHypothesis_3D*>(tet.get())->SetMaxElementVolume(0.1);
//myNetGenMesher.SetParameters( tet);
NETGENPlugin_Hypothesis* tet= new NETGENPlugin_Hypothesis(hyp++,1,myGen);
tet->SetMaxSize(MaxSize.getValue());
tet->SetSecondOrder(SecondOrder.getValue());
tet->SetOptimize(Optimize.getValue());
tet->SetFineness((NETGENPlugin_Hypothesis::Fineness)Fininess.getValue());
tet->SetGrowthRate(GrothRate.getValue());
tet->SetNbSegPerEdge(NbSegsPerEdge.getValue());
tet->SetNbSegPerRadius(NbSegsPerRadius.getValue());
myNetGenMesher.SetParameters( tet);
myNetGenMesher.Compute();
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(newMesh.getSMesh())->GetMeshDS();
const SMDS_MeshInfo& info = data->GetMeshInfo();

View File

@ -27,6 +27,7 @@
#include "FemMesh.h"
#include "FemMeshShapeObject.h"
#include <App/PropertyStandard.h>
namespace Fem
{
@ -40,6 +41,14 @@ public:
FemMeshShapeNetgenObject(void);
virtual ~FemMeshShapeNetgenObject();
App::PropertyFloat MaxSize;
App::PropertyBool SecondOrder;
App::PropertyEnumeration Fininess;
App::PropertyFloat GrothRate;
App::PropertyInteger NbSegsPerEdge;
App::PropertyInteger NbSegsPerRadius;
App::PropertyBool Optimize;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
return "FemGui::ViewProviderFemMeshShapeNetgen";

View File

@ -34,7 +34,7 @@
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/Command.h>
#include "ViewProviderFemMesh.h"
#include "ViewProviderFemMeshShapeNetgen.h"
#include <Mod/Fem/App/FemMeshShapeNetgenObject.h>
#include "TaskTetParameter.h"
@ -47,10 +47,11 @@ using namespace FemGui;
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgMeshShapeNetgen::TaskDlgMeshShapeNetgen(Fem::FemMeshShapeNetgenObject *obj)
: TaskDialog(),FemMeshShapeNetgenObject(obj)
TaskDlgMeshShapeNetgen::TaskDlgMeshShapeNetgen(FemGui::ViewProviderFemMeshShapeNetgen *obj)
: TaskDialog(),ViewProviderFemMeshShapeNetgen(obj)
{
param = new TaskTetParameter(obj);
FemMeshShapeNetgenObject = dynamic_cast<Fem::FemMeshShapeNetgenObject *>(obj->getObject());
param = new TaskTetParameter(FemMeshShapeNetgenObject);
Content.push_back(param);
}

View File

@ -34,6 +34,7 @@ namespace Fem {
namespace FemGui {
class TaskTetParameter;
class ViewProviderFemMeshShapeNetgen;
/// simulation dialog for the TaskView
class TaskDlgMeshShapeNetgen : public Gui::TaskView::TaskDialog
@ -41,7 +42,7 @@ class TaskDlgMeshShapeNetgen : public Gui::TaskView::TaskDialog
Q_OBJECT
public:
TaskDlgMeshShapeNetgen(Fem::FemMeshShapeNetgenObject *);
TaskDlgMeshShapeNetgen(FemGui::ViewProviderFemMeshShapeNetgen *);
~TaskDlgMeshShapeNetgen();
public:
@ -61,7 +62,8 @@ public:
protected:
TaskTetParameter *param;
Fem::FemMeshShapeNetgenObject *FemMeshShapeNetgenObject;
Fem::FemMeshShapeNetgenObject *FemMeshShapeNetgenObject;
FemGui::ViewProviderFemMeshShapeNetgen *ViewProviderFemMeshShapeNetgen;
};

View File

@ -55,7 +55,6 @@ ViewProviderFemConstraintBearing::~ViewProviderFemConstraintBearing()
bool ViewProviderFemConstraintBearing::setEdit(int ModNum)
{
Base::Console().Error("ViewProviderFemConstraintBearing::setEdit()\n");
if (ModNum == ViewProvider::Default ) {
// When double-clicking on the item for this constraint the

View File

@ -29,7 +29,9 @@
#endif
#include "ViewProviderFemMeshShapeNetgen.h"
#include "TaskDlgMeshShapeNetgen.h"
#include "Gui/Control.h"
using namespace FemGui;
@ -52,3 +54,24 @@ ViewProviderFemMeshShapeNetgen::~ViewProviderFemMeshShapeNetgen()
}
bool ViewProviderFemMeshShapeNetgen::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
// clear the selection (convenience)
Gui::Selection().clearSelection();
Gui::Control().showDialog(new TaskDlgMeshShapeNetgen(this));
return true;
}
else {
return ViewProviderDocumentObject::setEdit(ModNum);
}
}
void ViewProviderFemMeshShapeNetgen::updateData(const App::Property* prop)
{
ViewProviderFemMeshShape::updateData(prop);
}

View File

@ -49,6 +49,10 @@ public:
/// destructor.
~ViewProviderFemMeshShapeNetgen();
virtual void updateData(const App::Property*);
protected:
virtual bool setEdit(int ModNum);
};