smesh: port to version 9.6

This commit is contained in:
wmayer
2021-01-20 19:49:56 +01:00
parent 67f6353046
commit b431987ea3
8 changed files with 680 additions and 6 deletions

View File

@@ -50,7 +50,7 @@
# include <SMESHDS_GroupBase.hxx>
# include <SMESHDS_Group.hxx>
# include <SMESHDS_Mesh.hxx>
# include <SMDS_PolyhedralVolumeOfNodes.hxx>
//# include <SMDS_PolyhedralVolumeOfNodes.hxx>
# include <SMDS_VolumeTool.hxx>
# include <StdMeshers_MaxLength.hxx>
# include <StdMeshers_LocalLength.hxx>
@@ -93,7 +93,9 @@ using namespace Fem;
using namespace Base;
using namespace boost;
#if SMESH_VERSION_MAJOR < 9
static int StatCount = 0;
#endif
SMESH_Gen* FemMesh::_mesh_gen = 0;
@@ -103,12 +105,20 @@ FemMesh::FemMesh()
{
//Base::Console().Log("FemMesh::FemMesh():%p (id=%i)\n",this,StatCount);
// create a mesh always with new StudyId to avoid overlapping destruction
#if SMESH_VERSION_MAJOR >= 9
myMesh = getGenerator()->CreateMesh(false);
#else
myMesh = getGenerator()->CreateMesh(StatCount++,false);
#endif
}
FemMesh::FemMesh(const FemMesh& mesh)
{
#if SMESH_VERSION_MAJOR >= 9
myMesh = getGenerator()->CreateMesh(false);
#else
myMesh = getGenerator()->CreateMesh(StatCount++,false);
#endif
copyMeshData(mesh);
}
@@ -130,7 +140,11 @@ FemMesh::~FemMesh()
FemMesh &FemMesh::operator=(const FemMesh& mesh)
{
if (this != &mesh) {
#if SMESH_VERSION_MAJOR >= 9
myMesh = getGenerator()->CreateMesh(true);
#else
myMesh = getGenerator()->CreateMesh(0,true);
#endif
copyMeshData(mesh);
}
return *this;
@@ -176,10 +190,17 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
int ID = elem->GetID();
switch (elem->GetEntityType()) {
case SMDSEntity_Polyhedra:
#if SMESH_VERSION_MAJOR >= 9
editor.GetMeshDS()->
AddPolyhedralVolumeWithID(nodes,
static_cast<const SMDS_MeshVolume*>(elem)->GetQuantities(),
ID);
#else
editor.GetMeshDS()->
AddPolyhedralVolumeWithID(nodes,
static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities(),
ID);
#endif
break;
case SMDSEntity_Ball:
{
@@ -239,7 +260,7 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
// Make a new group
if (!groupElems.empty()) {
int aId;
int aId = -1;
SMESH_Group* newGroupObj = this->myMesh->AddGroup(groupType, group->GetName(), aId);
SMESHDS_Group* newGroupDS = dynamic_cast<SMESHDS_Group*>(newGroupObj->GetGroupDS());
if (newGroupDS) {
@@ -512,6 +533,41 @@ void FemMesh::setStandardHypotheses()
{
if (!hypoth.empty())
return;
#if SMESH_VERSION_MAJOR >= 9
int hyp=0;
SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, getGenerator()));
static_cast<StdMeshers_MaxLength*>(len.get())->SetLength(1.0);
hypoth.push_back(len);
SMESH_HypothesisPtr loc(new StdMeshers_LocalLength(hyp++, getGenerator()));
static_cast<StdMeshers_LocalLength*>(loc.get())->SetLength(1.0);
hypoth.push_back(loc);
SMESH_HypothesisPtr area(new StdMeshers_MaxElementArea(hyp++, getGenerator()));
static_cast<StdMeshers_MaxElementArea*>(area.get())->SetMaxArea(1.0);
hypoth.push_back(area);
SMESH_HypothesisPtr segm(new StdMeshers_NumberOfSegments(hyp++, getGenerator()));
static_cast<StdMeshers_NumberOfSegments*>(segm.get())->SetNumberOfSegments(1);
hypoth.push_back(segm);
SMESH_HypothesisPtr defl(new StdMeshers_Deflection1D(hyp++, getGenerator()));
static_cast<StdMeshers_Deflection1D*>(defl.get())->SetDeflection(0.01);
hypoth.push_back(defl);
SMESH_HypothesisPtr reg(new StdMeshers_Regular_1D(hyp++, getGenerator()));
hypoth.push_back(reg);
//SMESH_HypothesisPtr sel(new StdMeshers_StartEndLength(hyp++, getGenerator()));
//static_cast<StdMeshers_StartEndLength*>(sel.get())->SetLength(1.0, true);
//hypoth.push_back(sel);
SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++,getGenerator()));
hypoth.push_back(qdp);
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++,getGenerator()));
hypoth.push_back(q2d);
#else
int hyp=0;
SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, 1, getGenerator()));
static_cast<StdMeshers_MaxLength*>(len.get())->SetLength(1.0);
@@ -545,6 +601,7 @@ void FemMesh::setStandardHypotheses()
SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++,1,getGenerator()));
hypoth.push_back(q2d);
#endif
// Apply hypothesis
for (int i=0; i<hyp;i++)
@@ -579,7 +636,12 @@ std::list<std::pair<int, int> > FemMesh::getVolumesByFace(const TopoDS_Face &fac
SMDS_VolumeIteratorPtr vol_iter = myMesh->GetMeshDS()->volumesIterator();
while (vol_iter->more()) {
const SMDS_MeshVolume* vol = vol_iter->next();
#if SMESH_VERSION_MAJOR >= 9
throw Base::NotImplementedError("Port FemMesh::getVolumesByFace to smesh >= 9.x");
SMDS_ElemIteratorPtr face_iter = nullptr; //TODO:
#else
SMDS_ElemIteratorPtr face_iter = vol->facesIterator();
#endif
while (face_iter && face_iter->more()) {
const SMDS_MeshFace* face = static_cast<const SMDS_MeshFace*>(face_iter->next());