#18711 [CEA 18704] COTECH action 117.4: NETGEN 6 Integration in SALOME

This commit is contained in:
eap 2020-12-10 13:14:25 +03:00
parent ea5e046236
commit 0f6a0216f7
6 changed files with 178 additions and 115 deletions

View File

@ -84,12 +84,6 @@
#include <meshing.hpp> #include <meshing.hpp>
//#include <ngexception.hpp> //#include <ngexception.hpp>
namespace netgen { namespace netgen {
#ifdef NETGEN_V5
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
#else
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
#endif
//extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
NETGENPLUGIN_DLL_HEADER NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam; extern MeshingParameters mparam;
@ -142,6 +136,8 @@ std::set<int> ShapesWithControlPoints; // <-- allows calling SetLocalSize() seve
namespace namespace
{ {
inline void NOOP_Deleter(void *) { ; }
//============================================================================= //=============================================================================
/*! /*!
* Link - a pair of integer numbers * Link - a pair of integer numbers
@ -644,8 +640,13 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)
mparams.checkchartboundary = hyp->GetCheckChartBoundary(); mparams.checkchartboundary = hyp->GetCheckChartBoundary();
_simpleHyp = NULL; _simpleHyp = NULL;
// mesh size file // mesh size file
#ifdef NETGEN_V6
// std::string
mparams.meshsizefilename = hyp->GetMeshSizeFile();
#else
// const char*
mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str(); mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
#endif
const NETGENPlugin_Hypothesis::TLocalSize& localSizes = hyp->GetLocalSizesAndEntries(); const NETGENPlugin_Hypothesis::TLocalSize& localSizes = hyp->GetLocalSizesAndEntries();
if ( !localSizes.empty() ) if ( !localSizes.empty() )
{ {
@ -730,7 +731,11 @@ void NETGENPlugin_Mesher::SetLocalSize( netgen::OCCGeometry& occgeo,
int faceNgID = occgeo.fmap.FindIndex(shape); int faceNgID = occgeo.fmap.FindIndex(shape);
if ( faceNgID >= 1 ) if ( faceNgID >= 1 )
{ {
#ifdef NETGEN_V6
occgeo.SetFaceMaxH(faceNgID-1, val);
#else
occgeo.SetFaceMaxH(faceNgID, val); occgeo.SetFaceMaxH(faceNgID, val);
#endif
for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() ) for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() )
setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, ngMesh ); setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, ngMesh );
} }
@ -795,7 +800,11 @@ void NETGENPlugin_Mesher::SetLocalSizeForChordalError( netgen::OCCGeometry& occg
surfProp.SetParameters( 0, 0 ); surfProp.SetParameters( 0, 0 );
double maxCurv = Max( Abs( surfProp.MaxCurvature()), Abs( surfProp.MinCurvature() )); double maxCurv = Max( Abs( surfProp.MaxCurvature()), Abs( surfProp.MinCurvature() ));
double size = elemSizeForChordalError( _chordalError, 1 / maxCurv ); double size = elemSizeForChordalError( _chordalError, 1 / maxCurv );
#ifdef NETGEN_V6
occgeo.SetFaceMaxH( i-1, size * sizeCoef );
#else
occgeo.SetFaceMaxH( i, size * sizeCoef ); occgeo.SetFaceMaxH( i, size * sizeCoef );
#endif
// limit size one edges // limit size one edges
TopTools_MapOfShape edgeMap; TopTools_MapOfShape edgeMap;
for ( TopExp_Explorer eExp( face, TopAbs_EDGE ); eExp.More(); eExp.Next() ) for ( TopExp_Explorer eExp( face, TopAbs_EDGE ); eExp.More(); eExp.Next() )
@ -2906,19 +2915,14 @@ bool NETGENPlugin_Mesher::Compute()
occgeo.face_maxh = mparams.maxh; occgeo.face_maxh = mparams.maxh;
// Let netgen create _ngMesh and calculate element size on not meshed shapes // Let netgen create _ngMesh and calculate element size on not meshed shapes
#ifndef NETGEN_V5
char *optstr = 0;
#endif
int startWith = netgen::MESHCONST_ANALYSE; int startWith = netgen::MESHCONST_ANALYSE;
int endWith = netgen::MESHCONST_ANALYSE; int endWith = netgen::MESHCONST_ANALYSE;
try try
{ {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith); err = ngLib.GenerateMesh(occgeo, startWith, endWith, _ngMesh);
#else
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr);
#endif
if(netgen::multithread.terminate) if(netgen::multithread.terminate)
return false; return false;
@ -2931,7 +2935,12 @@ bool NETGENPlugin_Mesher::Compute()
catch (netgen::NgException & ex) catch (netgen::NgException & ex)
{ {
comment << text(ex); comment << text(ex);
if ( mparams.meshsizefilename ) #ifdef NETGEN_V6
bool hasSizeFile = !mparams.meshsizefilename.empty();
#else
bool hasSizeFile = mparams.meshsizefilename;
#endif
if ( hasSizeFile )
throw SMESH_ComputeError(COMPERR_BAD_PARMETERS, comment ); throw SMESH_ComputeError(COMPERR_BAD_PARMETERS, comment );
} }
err = 0; //- MESHCONST_ANALYSE isn't so important step err = 0; //- MESHCONST_ANALYSE isn't so important step
@ -2984,12 +2993,9 @@ bool NETGENPlugin_Mesher::Compute()
//OCCSetLocalMeshSize(intOccgeo, *_ngMesh); it deletes _ngMesh->localH //OCCSetLocalMeshSize(intOccgeo, *_ngMesh); it deletes _ngMesh->localH
// let netgen create a temporary mesh // let netgen create a temporary mesh
#ifdef NETGEN_V5 ngLib.GenerateMesh(intOccgeo, startWith, endWith, tmpNgMesh);
netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, mparams, startWith, endWith);
#else if ( netgen::multithread.terminate )
netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, startWith, endWith, optstr);
#endif
if(netgen::multithread.terminate)
return false; return false;
// copy LocalH from the main to temporary mesh // copy LocalH from the main to temporary mesh
@ -2997,11 +3003,8 @@ bool NETGENPlugin_Mesher::Compute()
// compute mesh on internal edges // compute mesh on internal edges
startWith = endWith = netgen::MESHCONST_MESHEDGES; startWith = endWith = netgen::MESHCONST_MESHEDGES;
#ifdef NETGEN_V5 err = ngLib.GenerateMesh(intOccgeo, startWith, endWith, tmpNgMesh);
err = netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, mparams, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, startWith, endWith, optstr);
#endif
comment << text(err); comment << text(err);
} }
catch (Standard_Failure& ex) catch (Standard_Failure& ex)
@ -3034,12 +3037,10 @@ bool NETGENPlugin_Mesher::Compute()
try try
{ {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith); err = ngLib.GenerateMesh(occgeo, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr); if ( netgen::multithread.terminate )
#endif
if(netgen::multithread.terminate)
return false; return false;
comment << text(err); comment << text(err);
@ -3148,12 +3149,10 @@ bool NETGENPlugin_Mesher::Compute()
try try
{ {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith); err = ngLib.GenerateMesh(occgeo, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr); if ( netgen::multithread.terminate )
#endif
if(netgen::multithread.terminate)
return false; return false;
comment << text (err); comment << text (err);
@ -3249,11 +3248,7 @@ bool NETGENPlugin_Mesher::Compute()
} }
_ngMesh->SetGlobalH (mparams.maxh); _ngMesh->SetGlobalH (mparams.maxh);
mparams.grading = 0.4; mparams.grading = 0.4;
#ifdef NETGEN_V5 ngLib.CalcLocalH( ngLib._ngMesh );
_ngMesh->CalcLocalH(mparams.grading);
#else
_ngMesh->CalcLocalH();
#endif
} }
// Care of vertices internal in solids and internal faces (issue 0020676) // Care of vertices internal in solids and internal faces (issue 0020676)
if ( internals.hasInternalVertexInSolid() || internals.hasInternalFaces() ) if ( internals.hasInternalVertexInSolid() || internals.hasInternalFaces() )
@ -3272,12 +3267,10 @@ bool NETGENPlugin_Mesher::Compute()
try try
{ {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith); err = ngLib.GenerateMesh(occgeo, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr); if ( netgen::multithread.terminate )
#endif
if(netgen::multithread.terminate)
return false; return false;
if ( comment.empty() ) // do not overwrite a previous error if ( comment.empty() ) // do not overwrite a previous error
@ -3304,12 +3297,10 @@ bool NETGENPlugin_Mesher::Compute()
try try
{ {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith); err = ngLib.GenerateMesh(occgeo, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr); if ( netgen::multithread.terminate )
#endif
if(netgen::multithread.terminate)
return false; return false;
if ( comment.empty() ) // do not overwrite a previous error if ( comment.empty() ) // do not overwrite a previous error
@ -3347,8 +3338,11 @@ bool NETGENPlugin_Mesher::Compute()
_ngMesh->Compress(); _ngMesh->Compress();
} }
// convert to quadratic // convert to quadratic
netgen::OCCRefinementSurfaces ref (occgeo); #ifdef NETGEN_V6
ref.MakeSecondOrder (*_ngMesh); occgeo.GetRefinement().MakeSecondOrder(*_ngMesh);
#else
netgen::OCCRefinementSurfaces(occgeo).MakeSecondOrder(*_ngMesh);
#endif
// care of elements already loaded to SMESH // care of elements already loaded to SMESH
// if ( initState._nbSegments > 0 ) // if ( initState._nbSegments > 0 )
@ -3524,16 +3518,9 @@ bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap)
// let netgen create _ngMesh and calculate element size on not meshed shapes // let netgen create _ngMesh and calculate element size on not meshed shapes
NETGENPlugin_NetgenLibWrapper ngLib; NETGENPlugin_NetgenLibWrapper ngLib;
netgen::Mesh *ngMesh = NULL; netgen::Mesh *ngMesh = NULL;
#ifndef NETGEN_V5
char *optstr = 0;
#endif
int startWith = netgen::MESHCONST_ANALYSE; int startWith = netgen::MESHCONST_ANALYSE;
int endWith = netgen::MESHCONST_MESHEDGES; int endWith = netgen::MESHCONST_MESHEDGES;
#ifdef NETGEN_V5 int err = ngLib.GenerateMesh(occgeo, startWith, endWith, ngMesh);
int err = netgen::OCCGenerateMesh(occgeo, ngMesh, mparams, startWith, endWith);
#else
int err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
if(netgen::multithread.terminate) if(netgen::multithread.terminate)
return false; return false;
@ -3968,11 +3955,7 @@ void NETGENPlugin_ngMeshInfo::transferLocalH( netgen::Mesh* fromMesh,
{ {
if ( !fromMesh->LocalHFunctionGenerated() ) return; if ( !fromMesh->LocalHFunctionGenerated() ) return;
if ( !toMesh->LocalHFunctionGenerated() ) if ( !toMesh->LocalHFunctionGenerated() )
#ifdef NETGEN_V5 NETGENPlugin_NetgenLibWrapper::CalcLocalH( toMesh );
toMesh->CalcLocalH(netgen::mparam.grading);
#else
toMesh->CalcLocalH();
#endif
const size_t size = sizeof( netgen::LocalH ); const size_t size = sizeof( netgen::LocalH );
_copyOfLocalH = new char[ size ]; _copyOfLocalH = new char[ size ];
@ -4358,10 +4341,15 @@ int& NETGENPlugin_NetgenLibWrapper::instanceCounter()
*/ */
//================================================================================ //================================================================================
NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper() NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper():
_ngMesh(0)
{ {
if ( instanceCounter() == 0 ) if ( instanceCounter() == 0 )
{
Ng_Init(); Ng_Init();
if ( !netgen::testout )
netgen::testout = new ofstream( "test.out" );
}
++instanceCounter(); ++instanceCounter();
@ -4385,7 +4373,7 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
#endif #endif
} }
_ngMesh = Ng_NewMesh(); setMesh( Ng_NewMesh() );
} }
//================================================================================ //================================================================================
@ -4398,7 +4386,7 @@ NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
{ {
--instanceCounter(); --instanceCounter();
Ng_DeleteMesh( _ngMesh ); Ng_DeleteMesh( ngMesh() );
Ng_Exit(); Ng_Exit();
RemoveTmpFiles(); RemoveTmpFiles();
if ( _coutBuffer ) if ( _coutBuffer )
@ -4418,8 +4406,65 @@ NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
void NETGENPlugin_NetgenLibWrapper::setMesh( Ng_Mesh* mesh ) void NETGENPlugin_NetgenLibWrapper::setMesh( Ng_Mesh* mesh )
{ {
if ( _ngMesh ) if ( _ngMesh )
Ng_DeleteMesh( _ngMesh ); Ng_DeleteMesh( ngMesh() );
_ngMesh = mesh; _ngMesh = (netgen::Mesh*) mesh;
}
//================================================================================
/*!
* \brief Perform a step of mesh generation
* \param [inout] occgeo - geometry to mesh
* \param [inout] startWith - start step
* \param [inout] endWith - end step
* \param [inout] ngMesh - netgen mesh
* \return int - is error
*/
//================================================================================
int NETGENPlugin_NetgenLibWrapper::GenerateMesh( netgen::OCCGeometry& occgeo,
int startWith, int endWith,
netgen::Mesh* & ngMesh )
{
int err = 0;
#ifdef NETGEN_V6
if ( !ngMesh )
ngMesh = new netgen::Mesh;
ngMesh->SetGeometry( shared_ptr<netgen::NetgenGeometry>( &occgeo, &NOOP_Deleter ));
netgen::mparam.perfstepsstart = startWith;
netgen::mparam.perfstepsend = endWith;
std::shared_ptr<netgen::Mesh> meshPtr( ngMesh, &NOOP_Deleter );
err = occgeo.GenerateMesh( meshPtr, netgen::mparam );
#else
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
#else
char *optstr = 0;
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
#endif
return err;
}
//================================================================================
/*!
* \brief Create a mesh size tree
*/
//================================================================================
void NETGENPlugin_NetgenLibWrapper::CalcLocalH( netgen::Mesh * ngMesh )
{
#if defined( NETGEN_V5 ) || defined( NETGEN_V6 )
ngMesh->CalcLocalH(netgen::mparam.grading);
#else
ngMesh->CalcLocalH();
#endif
} }
//================================================================================ //================================================================================
@ -4432,7 +4477,7 @@ std::string NETGENPlugin_NetgenLibWrapper::getOutputFileName()
{ {
std::string aTmpDir = SALOMEDS_Tool::GetTmpDir(); std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str(); TCollection_AsciiString aGenericName = aTmpDir.c_str();
aGenericName += "NETGEN_"; aGenericName += "NETGEN_";
#ifndef WIN32 #ifndef WIN32
aGenericName += getpid(); aGenericName += getpid();

View File

@ -84,12 +84,21 @@ struct NETGENPlugin_ngMeshInfo
struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
{ {
bool _isComputeOk; bool _isComputeOk;
nglib::Ng_Mesh * _ngMesh; netgen::Mesh * _ngMesh;
NETGENPlugin_NetgenLibWrapper(); NETGENPlugin_NetgenLibWrapper();
~NETGENPlugin_NetgenLibWrapper(); ~NETGENPlugin_NetgenLibWrapper();
void setMesh( nglib::Ng_Mesh* mesh ); void setMesh( nglib::Ng_Mesh* mesh );
nglib::Ng_Mesh* ngMesh() { return (nglib::Ng_Mesh*)(void*)_ngMesh; }
static int GenerateMesh(netgen::OCCGeometry& occgeo, int startWith, int endWith,
netgen::Mesh* & ngMesh);
int GenerateMesh(netgen::OCCGeometry& occgeo, int startWith, int endWith )
{
return GenerateMesh( occgeo, startWith, endWith, _ngMesh );
}
static void CalcLocalH( netgen::Mesh * ngMesh );
static void RemoveTmpFiles(); static void RemoveTmpFiles();
static int& instanceCounter(); static int& instanceCounter();

View File

@ -63,11 +63,6 @@ namespace nglib {
#include <meshing.hpp> #include <meshing.hpp>
//#include <meshtype.hpp> //#include <meshtype.hpp>
namespace netgen { namespace netgen {
#ifdef NETGEN_V5
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
#else
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
#endif
NETGENPLUGIN_DLL_HEADER NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam; extern MeshingParameters mparam;
extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh); extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
@ -284,15 +279,20 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh ); netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh );
} }
// set local size depending on curvature and NOT closeness of EDGEs // set local size depending on curvature and NOT closeness of EDGEs
#ifdef NETGEN_V6
const double factor = *netgen::mparam.closeedgefac;
netgen::mparam.closeedgefac = std::nullopt;
#else
const double factor = netgen::occparam.resthcloseedgefac;
netgen::occparam.resthcloseedgeenable = false; netgen::occparam.resthcloseedgeenable = false;
//netgen::occparam.resthcloseedgefac = 1.0 + netgen::mparam.grading; //netgen::occparam.resthcloseedgefac = 1.0 + netgen::mparam.grading;
#endif
occgeoComm.face_maxh = netgen::mparam.maxh; occgeoComm.face_maxh = netgen::mparam.maxh;
netgen::OCCSetLocalMeshSize( occgeoComm, *ngMeshes[0] ); netgen::OCCSetLocalMeshSize( occgeoComm, *ngMeshes[0] );
occgeoComm.emap.Clear(); occgeoComm.emap.Clear();
occgeoComm.vmap.Clear(); occgeoComm.vmap.Clear();
// set local size according to size of existing segments // set local size according to size of existing segments
const double factor = netgen::occparam.resthcloseedgefac;
TopTools_IndexedMapOfShape edgeMap; TopTools_IndexedMapOfShape edgeMap;
TopExp::MapShapes( aMesh.GetShapeToMesh(), TopAbs_EDGE, edgeMap ); TopExp::MapShapes( aMesh.GetShapeToMesh(), TopAbs_EDGE, edgeMap );
for ( int iE = 1; iE <= edgeMap.Extent(); ++iE ) for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
@ -486,12 +486,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
try { try {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5 err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh);
err = netgen::OCCGenerateMesh(occgeom, ngMesh, netgen::mparam, startWith, endWith);
#else
char *optstr = 0;
err = netgen::OCCGenerateMesh(occgeom, ngMesh, startWith, endWith, optstr);
#endif
if ( netgen::multithread.terminate ) if ( netgen::multithread.terminate )
return false; return false;
if ( err ) if ( err )

View File

@ -71,7 +71,14 @@
#define OCCGEOMETRY #define OCCGEOMETRY
#endif #endif
#include <occgeom.hpp> #include <occgeom.hpp>
#ifdef NETGEN_V5
#include <ngexception.hpp> #include <ngexception.hpp>
#endif
#ifdef NETGEN_V6
#include <exception.hpp>
#endif
namespace nglib { namespace nglib {
#include <nglib.h> #include <nglib.h>
} }
@ -208,7 +215,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
int Netgen_triangle[3]; int Netgen_triangle[3];
NETGENPlugin_NetgenLibWrapper ngLib; NETGENPlugin_NetgenLibWrapper ngLib;
Ng_Mesh * Netgen_mesh = ngLib._ngMesh; Ng_Mesh * Netgen_mesh = (Ng_Mesh*)ngLib._ngMesh;
// vector of nodes in which node index == netgen ID // vector of nodes in which node index == netgen ID
vector< const SMDS_MeshNode* > nodeVec; vector< const SMDS_MeshNode* > nodeVec;
@ -347,7 +354,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
// Generate the volume mesh // Generate the volume mesh
// ------------------------- // -------------------------
return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, Netgen_mesh)); return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, ngLib ));
} }
// namespace // namespace
@ -431,16 +438,14 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh, bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
SMESH_MesherHelper& helper, SMESH_MesherHelper& helper,
vector< const SMDS_MeshNode* >& nodeVec, vector< const SMDS_MeshNode* >& nodeVec,
Ng_Mesh * Netgen_mesh) NETGENPlugin_NetgenLibWrapper& ngLib)
{ {
netgen::multithread.terminate = 0; netgen::multithread.terminate = 0;
netgen::Mesh* ngMesh = (netgen::Mesh*)Netgen_mesh; netgen::Mesh* ngMesh = ngLib._ngMesh;
int Netgen_NbOfNodes = Ng_GetNP(Netgen_mesh); Ng_Mesh* Netgen_mesh = ngLib.ngMesh();
int Netgen_NbOfNodes = Ng_GetNP( Netgen_mesh );
#ifndef NETGEN_V5
char *optstr = 0;
#endif
int startWith = netgen::MESHCONST_MESHVOLUME; int startWith = netgen::MESHCONST_MESHVOLUME;
int endWith = netgen::MESHCONST_OPTVOLUME; int endWith = netgen::MESHCONST_OPTVOLUME;
int err = 1; int err = 1;
@ -498,13 +503,9 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
{ {
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5 ngLib.CalcLocalH(ngMesh);
ngMesh->CalcLocalH(netgen::mparam.grading); err = ngLib.GenerateMesh(occgeo, startWith, endWith);
err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
#else
ngMesh->CalcLocalH();
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
if(netgen::multithread.terminate) if(netgen::multithread.terminate)
return false; return false;
if ( err ) if ( err )
@ -614,7 +615,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
int Netgen_triangle[3]; int Netgen_triangle[3];
NETGENPlugin_NetgenLibWrapper ngLib; NETGENPlugin_NetgenLibWrapper ngLib;
Ng_Mesh * Netgen_mesh = ngLib._ngMesh; Ng_Mesh * Netgen_mesh = ngLib.ngMesh();
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh )); SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
if ( aMesh.NbQuadrangles() > 0 ) if ( aMesh.NbQuadrangles() > 0 )
@ -677,7 +678,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
// Generate the volume mesh // Generate the volume mesh
// ------------------------- // -------------------------
return ( ngLib._isComputeOk = compute( aMesh, *aHelper, nodeVec, Netgen_mesh)); return ( ngLib._isComputeOk = compute( aMesh, *aHelper, nodeVec, ngLib ));
} }
void NETGENPlugin_NETGEN_3D::CancelCompute() void NETGENPlugin_NETGEN_3D::CancelCompute()

View File

@ -40,6 +40,7 @@
class StdMeshers_ViscousLayers; class StdMeshers_ViscousLayers;
class StdMeshers_MaxElementVolume; class StdMeshers_MaxElementVolume;
class NETGENPlugin_Hypothesis; class NETGENPlugin_Hypothesis;
class NETGENPlugin_NetgenLibWrapper;
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
{ {
@ -70,7 +71,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
bool compute(SMESH_Mesh& mesh, bool compute(SMESH_Mesh& mesh,
SMESH_MesherHelper& helper, SMESH_MesherHelper& helper,
std::vector< const SMDS_MeshNode* >& nodeVec, std::vector< const SMDS_MeshNode* >& nodeVec,
nglib::Ng_Mesh* ngMesh); NETGENPlugin_NetgenLibWrapper& ngLib);
double _maxElementVolume; double _maxElementVolume;

View File

@ -54,6 +54,9 @@ using namespace nglib;
namespace netgen { namespace netgen {
NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
NETGENPLUGIN_DLL_HEADER NETGENPLUGIN_DLL_HEADER
extern STLParameters stlparam; extern STLParameters stlparam;
@ -649,8 +652,10 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
netgen::stlparam.resthchartdistenable = hyp->GetRestHChartDistEnable(); netgen::stlparam.resthchartdistenable = hyp->GetRestHChartDistEnable();
netgen::stlparam.resthlinelengthfac = hyp->GetRestHLineLengthFactor(); netgen::stlparam.resthlinelengthfac = hyp->GetRestHLineLengthFactor();
netgen::stlparam.resthlinelengthenable = hyp->GetRestHLineLengthEnable(); netgen::stlparam.resthlinelengthenable = hyp->GetRestHLineLengthEnable();
#ifndef NETGEN_V6
netgen::stlparam.resthcloseedgefac = hyp->GetRestHCloseEdgeFactor(); netgen::stlparam.resthcloseedgefac = hyp->GetRestHCloseEdgeFactor();
netgen::stlparam.resthcloseedgeenable = hyp->GetRestHCloseEdgeEnable(); netgen::stlparam.resthcloseedgeenable = hyp->GetRestHCloseEdgeEnable();
#endif
netgen::stlparam.resthsurfcurvfac = hyp->GetRestHSurfCurvFactor(); netgen::stlparam.resthsurfcurvfac = hyp->GetRestHSurfCurvFactor();
netgen::stlparam.resthsurfcurvenable = hyp->GetRestHSurfCurvEnable(); netgen::stlparam.resthsurfcurvenable = hyp->GetRestHSurfCurvEnable();
netgen::stlparam.resthedgeanglefac = hyp->GetRestHEdgeAngleFactor(); netgen::stlparam.resthedgeanglefac = hyp->GetRestHEdgeAngleFactor();
@ -675,6 +680,15 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
netgen::STLGeometry* stlGeom = (netgen::STLGeometry*)ngStlGeo; netgen::STLGeometry* stlGeom = (netgen::STLGeometry*)ngStlGeo;
// the following code is taken from STLMeshing() method // the following code is taken from STLMeshing() method
#ifdef NETGEN_V6
stlGeom->Clear();
stlGeom->BuildEdges( netgen::stlparam );
stlGeom->MakeAtlas( *ngMesh, netgen::mparam, netgen::stlparam );
stlGeom->CalcFaceNums();
stlGeom->AddFaceEdges();
fixNodes( fixedEdges->GetGroupDS(), stlGeom );
stlGeom->LinkEdges( netgen::stlparam );
#else
stlGeom->Clear(); stlGeom->Clear();
stlGeom->BuildEdges(); stlGeom->BuildEdges();
stlGeom->MakeAtlas( *ngMesh ); stlGeom->MakeAtlas( *ngMesh );
@ -682,7 +696,7 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
stlGeom->AddFaceEdges(); stlGeom->AddFaceEdges();
fixNodes( fixedEdges->GetGroupDS(), stlGeom ); fixNodes( fixedEdges->GetGroupDS(), stlGeom );
stlGeom->LinkEdges(); stlGeom->LinkEdges();
#endif
ngMesh->ClearFaceDescriptors(); ngMesh->ClearFaceDescriptors();
for (int i = 1; i <= stlGeom->GetNOFaces(); i++) for (int i = 1; i <= stlGeom->GetNOFaces(); i++)
ngMesh->AddFaceDescriptor (netgen::FaceDescriptor (i, 1, 0, 0)); ngMesh->AddFaceDescriptor (netgen::FaceDescriptor (i, 1, 0, 0));
@ -691,7 +705,7 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
} }
else else
{ {
Ng_STL_MakeEdges( ngStlGeo, ngLib._ngMesh, &ngParams ); Ng_STL_MakeEdges( ngStlGeo, ngLib.ngMesh(), &ngParams );
} }
netgen::mparam = savedParams; netgen::mparam = savedParams;
@ -707,13 +721,10 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
netgen::OCCGeometry occgeo; netgen::OCCGeometry occgeo;
mesher.SetLocalSize( occgeo, *ngMesh ); mesher.SetLocalSize( occgeo, *ngMesh );
// const char* optStr = "SmSmSm";//"smsmsmSmSmSm";
// netgen::mparam.optimize2d = optStr;
// meshing // meshing
try try
{ {
ng_res = Ng_STL_GenerateSurfaceMesh( ngStlGeo, ngLib._ngMesh, &ngParams ); ng_res = Ng_STL_GenerateSurfaceMesh( ngStlGeo, ngLib.ngMesh(), &ngParams );
} }
catch (netgen::NgException & ex) catch (netgen::NgException & ex)
{ {