update smesh-netgen interface to netgen version 6.1
This commit is contained in:
parent
77cfdfffa6
commit
73b6fdfed7
|
@ -39,10 +39,13 @@
|
|||
namespace nglib {
|
||||
#include <nglib.h>
|
||||
}
|
||||
#include <meshing.hpp>
|
||||
#include <occgeom.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
|
||||
class SMESHDS_Mesh;
|
||||
class SMESH_Comment;
|
||||
|
@ -53,10 +56,10 @@ class TopoDS_Shape;
|
|||
class NETGENPlugin_Hypothesis;
|
||||
class NETGENPlugin_SimpleHypothesis_2D;
|
||||
class NETGENPlugin_Internals;
|
||||
namespace netgen {
|
||||
class OCCGeometry;
|
||||
class Mesh;
|
||||
}
|
||||
// namespace netgen {
|
||||
// class OCCGeometry;
|
||||
// class Mesh;
|
||||
// }
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Struct storing nb of entities in netgen mesh
|
||||
|
@ -82,7 +85,11 @@ struct NETGENPlugin_ngMeshInfo
|
|||
struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
|
||||
{
|
||||
bool _isComputeOk;
|
||||
#if NETGEN_VERSION < 6
|
||||
nglib::Ng_Mesh * _ngMesh;
|
||||
#else
|
||||
std::shared_ptr<nglib::Ng_Mesh> _ngMesh;
|
||||
#endif
|
||||
|
||||
NETGENPlugin_NetgenLibWrapper();
|
||||
~NETGENPlugin_NetgenLibWrapper();
|
||||
|
@ -197,7 +204,11 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
|
|||
bool _optimize;
|
||||
int _fineness;
|
||||
bool _isViscousLayers2D;
|
||||
#if NETGEN_VERSION < 6
|
||||
netgen::Mesh* _ngMesh;
|
||||
#else
|
||||
std::shared_ptr<netgen::Mesh> _ngMesh;
|
||||
#endif
|
||||
netgen::OCCGeometry* _occgeom;
|
||||
|
||||
int _curShapeIndex;
|
||||
|
|
|
@ -164,7 +164,9 @@ NETGENPlugin_Mesher::~NETGENPlugin_Mesher()
|
|||
if ( _ptrToMe )
|
||||
*_ptrToMe = NULL;
|
||||
_ptrToMe = 0;
|
||||
#if NETGEN_VERSION < 6
|
||||
_ngMesh = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
|
@ -2456,8 +2458,11 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
// -------------------------
|
||||
// Generate the mesh
|
||||
// -------------------------
|
||||
|
||||
#if NETGEN_VERSION < 6
|
||||
_ngMesh = NULL;
|
||||
// #else
|
||||
// _ngMesh = std::make_shared<netgen::Mesh>();
|
||||
#endif
|
||||
NETGENPlugin_ngMeshInfo initState; // it remembers size of ng mesh equal to size of Smesh
|
||||
|
||||
SMESH_Comment comment;
|
||||
|
@ -2501,6 +2506,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -2518,7 +2524,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
err = 0; //- MESHCONST_ANALYSE isn't so important step
|
||||
if ( !_ngMesh )
|
||||
return false;
|
||||
ngLib.setMesh(( Ng_Mesh*) _ngMesh );
|
||||
ngLib.setMesh(( Ng_Mesh*) _ngMesh.get() );
|
||||
|
||||
_ngMesh->ClearFaceDescriptors(); // we make descriptors our-self
|
||||
|
||||
|
@ -2581,7 +2587,11 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
intOccgeo.shape = occgeo.shape;
|
||||
intOccgeo.face_maxh.SetSize(intOccgeo.fmap.Extent());
|
||||
intOccgeo.face_maxh = netgen::mparam.maxh;
|
||||
#if NETGEN_VERSION < 6
|
||||
netgen::Mesh *tmpNgMesh = NULL;
|
||||
#else
|
||||
std::shared_ptr<netgen::Mesh> tmpNgMesh; // = std::make_shared<netgen::Mesh>();
|
||||
#endif
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
@ -2589,6 +2599,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
//OCCSetLocalMeshSize(intOccgeo, *_ngMesh); it deletes _ngMesh->localH
|
||||
|
||||
// let netgen create a temporary mesh
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -2598,10 +2609,15 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
return false;
|
||||
|
||||
// copy LocalH from the main to temporary mesh
|
||||
#if NETGEN_VERSION < 6
|
||||
initState.transferLocalH( _ngMesh, tmpNgMesh );
|
||||
|
||||
#else
|
||||
initState.transferLocalH( _ngMesh.get(), tmpNgMesh.get() );
|
||||
#endif
|
||||
// compute mesh on internal edges
|
||||
startWith = endWith = netgen::MESHCONST_MESHEDGES;
|
||||
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
err = netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -2614,7 +2630,11 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
comment << text(ex);
|
||||
err = 1;
|
||||
}
|
||||
#if NETGEN_VERSION < 6
|
||||
initState.restoreLocalH( tmpNgMesh );
|
||||
#else
|
||||
initState.restoreLocalH( tmpNgMesh.get() );
|
||||
#endif
|
||||
|
||||
// fill SMESH by netgen mesh
|
||||
vector< const SMDS_MeshNode* > tmpNodeVec;
|
||||
|
@ -2622,6 +2642,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
err = ( err || !comment.empty() );
|
||||
|
||||
#if NETGEN_VERSION > 5
|
||||
// nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)tmpNgMesh.get());
|
||||
tmpNgMesh.reset();
|
||||
#else
|
||||
nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)tmpNgMesh);
|
||||
|
@ -2634,7 +2655,11 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
err = ! ( FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_0D ]) &&
|
||||
FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_1D ], &quadHelper));
|
||||
}
|
||||
#if NETGEN_VERSION < 6
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
|
||||
#else
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh.get());
|
||||
#endif
|
||||
|
||||
// Compute 1d mesh
|
||||
if (!err)
|
||||
|
@ -2643,6 +2668,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -2710,7 +2736,11 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment );
|
||||
// add segments to faces with internal vertices
|
||||
AddIntVerticesInFaces( occgeo, *_ngMesh, nodeVec, internals );
|
||||
#if NETGEN_VERSION < 6
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
|
||||
#else
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh.get());
|
||||
#endif
|
||||
}
|
||||
|
||||
// Build viscous layers
|
||||
|
@ -2718,7 +2748,11 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
{
|
||||
if ( !internals.hasInternalVertexInFace() ) {
|
||||
FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment );
|
||||
#if NETGEN_VERSION < 6
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
|
||||
#else
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh.get());
|
||||
#endif
|
||||
}
|
||||
SMESH_ProxyMesh::Ptr viscousMesh;
|
||||
SMESH_MesherHelper helper( *_mesh );
|
||||
|
@ -2744,7 +2778,11 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
|
||||
if ( !error ) error = SMESH_ComputeError::New();
|
||||
}
|
||||
#if NETGEN_VERSION < 6
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
|
||||
#else
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh.get());
|
||||
#endif
|
||||
}
|
||||
|
||||
// Let netgen compute 2D mesh
|
||||
|
@ -2753,6 +2791,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -2760,7 +2799,6 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
#endif
|
||||
if(netgen::multithread.terminate)
|
||||
return false;
|
||||
|
||||
comment << text (err);
|
||||
}
|
||||
catch (Standard_Failure& ex)
|
||||
|
@ -2812,7 +2850,12 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
}
|
||||
// fill _ngMesh with faces of sub-meshes
|
||||
err = ! ( FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_2D ], &quadHelper));
|
||||
|
||||
#if NETGEN_VERSION < 6
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
|
||||
#else
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh.get());
|
||||
#endif
|
||||
//toPython( _ngMesh, "/tmp/ngPython.py");
|
||||
}
|
||||
if (!err && _isVolume)
|
||||
|
@ -2832,6 +2875,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
}
|
||||
_ngMesh->SetGlobalH (mparams.maxh);
|
||||
mparams.grading = 0.4;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
_ngMesh->CalcLocalH(mparams.grading);
|
||||
#else
|
||||
|
@ -2848,13 +2892,18 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
AddIntVerticesInSolids( occgeo, *_ngMesh, nodeVec, internals );
|
||||
// duplicate mesh faces on internal faces
|
||||
FixIntFaces( occgeo, *_ngMesh, internals );
|
||||
#if NETGEN_VERSION < 6
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh);
|
||||
#else
|
||||
initState = NETGENPlugin_ngMeshInfo(_ngMesh.get());
|
||||
#endif
|
||||
}
|
||||
// Let netgen compute 3D mesh
|
||||
startWith = endWith = netgen::MESHCONST_MESHVOLUME;
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -2887,6 +2936,7 @@ bool NETGENPlugin_Mesher::Compute()
|
|||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -3099,16 +3149,17 @@ bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap)
|
|||
|
||||
// let netgen create _ngMesh and calculate element size on not meshed shapes
|
||||
NETGENPlugin_NetgenLibWrapper ngLib;
|
||||
#if NETGEN_VERSION > 5
|
||||
shared_ptr<netgen::Mesh> ngMesh = NULL;
|
||||
#else
|
||||
#if NETGEN_VERSION < 6
|
||||
netgen::Mesh *ngMesh = NULL;
|
||||
#else
|
||||
std::shared_ptr<netgen::Mesh> ngMesh; // = std::make_shared<netgen::Mesh>();
|
||||
#endif
|
||||
#if NETGEN_VERSION < 5
|
||||
char *optstr = 0;
|
||||
#endif
|
||||
int startWith = netgen::MESHCONST_ANALYSE;
|
||||
int endWith = netgen::MESHCONST_MESHEDGES;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
int err = netgen::OCCGenerateMesh(occgeo, ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
|
@ -3117,8 +3168,11 @@ bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap)
|
|||
|
||||
if(netgen::multithread.terminate)
|
||||
return false;
|
||||
|
||||
ngLib.setMesh(( Ng_Mesh*) ngMesh );
|
||||
#if NETGEN_VERSION < 6
|
||||
ngLib.setMesh(( Ng_Mesh*) ngMesh);
|
||||
#else
|
||||
ngLib.setMesh(( Ng_Mesh*) ngMesh.get());
|
||||
#endif
|
||||
if (err) {
|
||||
if ( SMESH_subMesh* sm = _mesh->GetSubMeshContaining( _shape ))
|
||||
sm->GetComputeError().reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED ));
|
||||
|
@ -3976,8 +4030,11 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
|
|||
std::cout.rdbuf( netgen::mycout->rdbuf() );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NETGEN_VERSION < 6
|
||||
_ngMesh = Ng_NewMesh();
|
||||
#else
|
||||
_ngMesh = std::make_shared<Ng_Mesh>();
|
||||
#endif
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
|
@ -3988,10 +4045,10 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
|
|||
|
||||
NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
|
||||
{
|
||||
#if NETGEN_VERSION > 5
|
||||
_ngMesh.reset();
|
||||
#else
|
||||
#if NETGEN_VERSION < 6
|
||||
Ng_DeleteMesh( _ngMesh );
|
||||
#else
|
||||
_ngMesh.reset();
|
||||
#endif
|
||||
Ng_Exit();
|
||||
NETGENPlugin_Mesher::RemoveTmpFiles();
|
||||
|
@ -4012,11 +4069,11 @@ NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
|
|||
void NETGENPlugin_NetgenLibWrapper::setMesh( Ng_Mesh* mesh )
|
||||
{
|
||||
if ( _ngMesh )
|
||||
#if NETGEN_VERSION > 5
|
||||
_ngMesh.reset(mesh);
|
||||
#else
|
||||
#if NETGEN_VERSION < 6
|
||||
Ng_DeleteMesh( _ngMesh );
|
||||
_ngMesh = mesh;
|
||||
#else
|
||||
_ngMesh = std::make_shared<Ng_Mesh>(mesh);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace nglib {
|
|||
}
|
||||
#include <meshing.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <utilities.h>
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
|
||||
|
@ -234,7 +235,6 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
|
|||
{
|
||||
netgen::multithread.terminate = 0;
|
||||
//netgen::multithread.task = "Surface meshing";
|
||||
|
||||
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
|
||||
SMESH_MesherHelper helper(aMesh);
|
||||
helper.SetElementsOnShape( true );
|
||||
|
@ -243,7 +243,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
|
|||
ngLib._isComputeOk = false;
|
||||
|
||||
netgen::Mesh ngMeshNoLocSize;
|
||||
#if NETGEN_VERSION < 6
|
||||
netgen::Mesh * ngMeshes[2] = { (netgen::Mesh*) ngLib._ngMesh, & ngMeshNoLocSize };
|
||||
#else
|
||||
netgen::Mesh * ngMeshes[2] = { (netgen::Mesh*) ngLib._ngMesh.get(), & ngMeshNoLocSize };
|
||||
#endif
|
||||
netgen::OCCGeometry occgeoComm;
|
||||
|
||||
// min / max sizes are set as follows:
|
||||
|
@ -474,7 +478,10 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
|
|||
try {
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
#if NETGEN_VERSION >=6
|
||||
std::shared_ptr<netgen::Mesh> mesh_ptr(ngMesh, [](netgen::Mesh*){});
|
||||
err = netgen::OCCGenerateMesh(occgeom, mesh_ptr, netgen::mparam, startWith, endWith);
|
||||
#elif NETGEN_VERSION > 4
|
||||
err = netgen::OCCGenerateMesh(occgeom, ngMesh, netgen::mparam, startWith, endWith);
|
||||
#else
|
||||
char *optstr = 0;
|
||||
|
|
|
@ -75,7 +75,9 @@ namespace nglib {
|
|||
#include <nglib.h>
|
||||
}
|
||||
namespace netgen {
|
||||
#if NETGEN_VERSION > 4
|
||||
#if NETGEN_VERSION > 5
|
||||
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry&, shared_ptr<Mesh>&, MeshingParameters&, int, int);
|
||||
#elif NETGEN_VERSION > 4
|
||||
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
|
||||
#else
|
||||
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
|
||||
|
@ -208,7 +210,11 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
|
|||
int Netgen_triangle[3];
|
||||
|
||||
NETGENPlugin_NetgenLibWrapper ngLib;
|
||||
#if NETGEN_VERSION < 6
|
||||
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
|
||||
#else
|
||||
Ng_Mesh * Netgen_mesh = ngLib._ngMesh.get();
|
||||
#endif
|
||||
|
||||
// vector of nodes in which node index == netgen ID
|
||||
vector< const SMDS_MeshNode* > nodeVec;
|
||||
|
@ -470,7 +476,10 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
|
|||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#if NETGEN_VERSION > 4
|
||||
#if NETGEN_VERSION >=6
|
||||
std::shared_ptr<netgen::Mesh> mesh_ptr(ngMesh, [](netgen::Mesh*){});
|
||||
err = netgen::OCCGenerateMesh(occgeo, mesh_ptr, netgen::mparam, startWith, endWith);
|
||||
#elif NETGEN_VERSION > 4
|
||||
ngMesh->CalcLocalH(netgen::mparam.grading);
|
||||
err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
|
||||
#else
|
||||
|
@ -595,7 +604,11 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
|
|||
int Netgen_tetrahedron[4];
|
||||
|
||||
NETGENPlugin_NetgenLibWrapper ngLib;
|
||||
#if NETGEN_VERSION < 6
|
||||
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
|
||||
#else
|
||||
Ng_Mesh * Netgen_mesh = ngLib._ngMesh.get();
|
||||
#endif
|
||||
|
||||
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
|
||||
if ( aMesh.NbQuadrangles() > 0 )
|
||||
|
|
Loading…
Reference in New Issue
Block a user