#18711 [CEA 18704] COTECH action 117.4: NETGEN 6 Integration in SALOME
This commit is contained in:
parent
ea5e046236
commit
0f6a0216f7
@ -84,12 +84,6 @@
|
||||
#include <meshing.hpp>
|
||||
//#include <ngexception.hpp>
|
||||
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
|
||||
extern MeshingParameters mparam;
|
||||
@ -142,6 +136,8 @@ std::set<int> ShapesWithControlPoints; // <-- allows calling SetLocalSize() seve
|
||||
|
||||
namespace
|
||||
{
|
||||
inline void NOOP_Deleter(void *) { ; }
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* Link - a pair of integer numbers
|
||||
@ -644,8 +640,13 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)
|
||||
mparams.checkchartboundary = hyp->GetCheckChartBoundary();
|
||||
_simpleHyp = NULL;
|
||||
// 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();
|
||||
|
||||
#endif
|
||||
const NETGENPlugin_Hypothesis::TLocalSize& localSizes = hyp->GetLocalSizesAndEntries();
|
||||
if ( !localSizes.empty() )
|
||||
{
|
||||
@ -730,7 +731,11 @@ void NETGENPlugin_Mesher::SetLocalSize( netgen::OCCGeometry& occgeo,
|
||||
int faceNgID = occgeo.fmap.FindIndex(shape);
|
||||
if ( faceNgID >= 1 )
|
||||
{
|
||||
#ifdef NETGEN_V6
|
||||
occgeo.SetFaceMaxH(faceNgID-1, val);
|
||||
#else
|
||||
occgeo.SetFaceMaxH(faceNgID, val);
|
||||
#endif
|
||||
for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() )
|
||||
setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, ngMesh );
|
||||
}
|
||||
@ -795,7 +800,11 @@ void NETGENPlugin_Mesher::SetLocalSizeForChordalError( netgen::OCCGeometry& occg
|
||||
surfProp.SetParameters( 0, 0 );
|
||||
double maxCurv = Max( Abs( surfProp.MaxCurvature()), Abs( surfProp.MinCurvature() ));
|
||||
double size = elemSizeForChordalError( _chordalError, 1 / maxCurv );
|
||||
#ifdef NETGEN_V6
|
||||
occgeo.SetFaceMaxH( i-1, size * sizeCoef );
|
||||
#else
|
||||
occgeo.SetFaceMaxH( i, size * sizeCoef );
|
||||
#endif
|
||||
// limit size one edges
|
||||
TopTools_MapOfShape edgeMap;
|
||||
for ( TopExp_Explorer eExp( face, TopAbs_EDGE ); eExp.More(); eExp.Next() )
|
||||
@ -2906,19 +2915,14 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
occgeo.face_maxh = mparams.maxh;
|
||||
|
||||
// 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 endWith = netgen::MESHCONST_ANALYSE;
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
#ifdef NETGEN_V5
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
|
||||
err = ngLib.GenerateMesh(occgeo, startWith, endWith, _ngMesh);
|
||||
|
||||
if(netgen::multithread.terminate)
|
||||
return false;
|
||||
|
||||
@ -2931,7 +2935,12 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
catch (netgen::NgException & 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 );
|
||||
}
|
||||
err = 0; //- MESHCONST_ANALYSE isn't so important step
|
||||
@ -2984,12 +2993,9 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
//OCCSetLocalMeshSize(intOccgeo, *_ngMesh); it deletes _ngMesh->localH
|
||||
|
||||
// let netgen create a temporary mesh
|
||||
#ifdef NETGEN_V5
|
||||
netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
if(netgen::multithread.terminate)
|
||||
ngLib.GenerateMesh(intOccgeo, startWith, endWith, tmpNgMesh);
|
||||
|
||||
if ( netgen::multithread.terminate )
|
||||
return false;
|
||||
|
||||
// copy LocalH from the main to temporary mesh
|
||||
@ -2997,11 +3003,8 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
|
||||
// compute mesh on internal edges
|
||||
startWith = endWith = netgen::MESHCONST_MESHEDGES;
|
||||
#ifdef NETGEN_V5
|
||||
err = netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
err = netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
err = ngLib.GenerateMesh(intOccgeo, startWith, endWith, tmpNgMesh);
|
||||
|
||||
comment << text(err);
|
||||
}
|
||||
catch (Standard_Failure& ex)
|
||||
@ -3034,12 +3037,10 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
#ifdef NETGEN_V5
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
if(netgen::multithread.terminate)
|
||||
|
||||
err = ngLib.GenerateMesh(occgeo, startWith, endWith);
|
||||
|
||||
if ( netgen::multithread.terminate )
|
||||
return false;
|
||||
|
||||
comment << text(err);
|
||||
@ -3148,12 +3149,10 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
#ifdef NETGEN_V5
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
if(netgen::multithread.terminate)
|
||||
|
||||
err = ngLib.GenerateMesh(occgeo, startWith, endWith);
|
||||
|
||||
if ( netgen::multithread.terminate )
|
||||
return false;
|
||||
|
||||
comment << text (err);
|
||||
@ -3249,11 +3248,7 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
}
|
||||
_ngMesh->SetGlobalH (mparams.maxh);
|
||||
mparams.grading = 0.4;
|
||||
#ifdef NETGEN_V5
|
||||
_ngMesh->CalcLocalH(mparams.grading);
|
||||
#else
|
||||
_ngMesh->CalcLocalH();
|
||||
#endif
|
||||
ngLib.CalcLocalH( ngLib._ngMesh );
|
||||
}
|
||||
// Care of vertices internal in solids and internal faces (issue 0020676)
|
||||
if ( internals.hasInternalVertexInSolid() || internals.hasInternalFaces() )
|
||||
@ -3272,12 +3267,10 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
#ifdef NETGEN_V5
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
if(netgen::multithread.terminate)
|
||||
|
||||
err = ngLib.GenerateMesh(occgeo, startWith, endWith);
|
||||
|
||||
if ( netgen::multithread.terminate )
|
||||
return false;
|
||||
|
||||
if ( comment.empty() ) // do not overwrite a previous error
|
||||
@ -3304,12 +3297,10 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
#ifdef NETGEN_V5
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
err = netgen::OCCGenerateMesh(occgeo, _ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
if(netgen::multithread.terminate)
|
||||
|
||||
err = ngLib.GenerateMesh(occgeo, startWith, endWith);
|
||||
|
||||
if ( netgen::multithread.terminate )
|
||||
return false;
|
||||
|
||||
if ( comment.empty() ) // do not overwrite a previous error
|
||||
@ -3347,8 +3338,11 @@ bool NETGENPlugin_Mesher::Compute()
|
||||
_ngMesh->Compress();
|
||||
}
|
||||
// convert to quadratic
|
||||
netgen::OCCRefinementSurfaces ref (occgeo);
|
||||
ref.MakeSecondOrder (*_ngMesh);
|
||||
#ifdef NETGEN_V6
|
||||
occgeo.GetRefinement().MakeSecondOrder(*_ngMesh);
|
||||
#else
|
||||
netgen::OCCRefinementSurfaces(occgeo).MakeSecondOrder(*_ngMesh);
|
||||
#endif
|
||||
|
||||
// care of elements already loaded to SMESH
|
||||
// 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
|
||||
NETGENPlugin_NetgenLibWrapper ngLib;
|
||||
netgen::Mesh *ngMesh = NULL;
|
||||
#ifndef NETGEN_V5
|
||||
char *optstr = 0;
|
||||
#endif
|
||||
int startWith = netgen::MESHCONST_ANALYSE;
|
||||
int endWith = netgen::MESHCONST_MESHEDGES;
|
||||
#ifdef NETGEN_V5
|
||||
int err = netgen::OCCGenerateMesh(occgeo, ngMesh, mparams, startWith, endWith);
|
||||
#else
|
||||
int err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
int err = ngLib.GenerateMesh(occgeo, startWith, endWith, ngMesh);
|
||||
|
||||
if(netgen::multithread.terminate)
|
||||
return false;
|
||||
@ -3968,11 +3955,7 @@ void NETGENPlugin_ngMeshInfo::transferLocalH( netgen::Mesh* fromMesh,
|
||||
{
|
||||
if ( !fromMesh->LocalHFunctionGenerated() ) return;
|
||||
if ( !toMesh->LocalHFunctionGenerated() )
|
||||
#ifdef NETGEN_V5
|
||||
toMesh->CalcLocalH(netgen::mparam.grading);
|
||||
#else
|
||||
toMesh->CalcLocalH();
|
||||
#endif
|
||||
NETGENPlugin_NetgenLibWrapper::CalcLocalH( toMesh );
|
||||
|
||||
const size_t size = sizeof( netgen::LocalH );
|
||||
_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 )
|
||||
{
|
||||
Ng_Init();
|
||||
if ( !netgen::testout )
|
||||
netgen::testout = new ofstream( "test.out" );
|
||||
}
|
||||
|
||||
++instanceCounter();
|
||||
|
||||
@ -4385,7 +4373,7 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
|
||||
#endif
|
||||
}
|
||||
|
||||
_ngMesh = Ng_NewMesh();
|
||||
setMesh( Ng_NewMesh() );
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -4398,7 +4386,7 @@ NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
|
||||
{
|
||||
--instanceCounter();
|
||||
|
||||
Ng_DeleteMesh( _ngMesh );
|
||||
Ng_DeleteMesh( ngMesh() );
|
||||
Ng_Exit();
|
||||
RemoveTmpFiles();
|
||||
if ( _coutBuffer )
|
||||
@ -4418,8 +4406,65 @@ NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
|
||||
void NETGENPlugin_NetgenLibWrapper::setMesh( Ng_Mesh* mesh )
|
||||
{
|
||||
if ( _ngMesh )
|
||||
Ng_DeleteMesh( _ngMesh );
|
||||
_ngMesh = mesh;
|
||||
Ng_DeleteMesh( ngMesh() );
|
||||
_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();
|
||||
|
||||
TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str();
|
||||
TCollection_AsciiString aGenericName = aTmpDir.c_str();
|
||||
aGenericName += "NETGEN_";
|
||||
#ifndef WIN32
|
||||
aGenericName += getpid();
|
||||
|
@ -84,12 +84,21 @@ struct NETGENPlugin_ngMeshInfo
|
||||
|
||||
struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
|
||||
{
|
||||
bool _isComputeOk;
|
||||
nglib::Ng_Mesh * _ngMesh;
|
||||
bool _isComputeOk;
|
||||
netgen::Mesh * _ngMesh;
|
||||
|
||||
NETGENPlugin_NetgenLibWrapper();
|
||||
~NETGENPlugin_NetgenLibWrapper();
|
||||
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 int& instanceCounter();
|
||||
|
@ -63,11 +63,6 @@ namespace nglib {
|
||||
#include <meshing.hpp>
|
||||
//#include <meshtype.hpp>
|
||||
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
|
||||
extern MeshingParameters mparam;
|
||||
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 );
|
||||
}
|
||||
// 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.resthcloseedgefac = 1.0 + netgen::mparam.grading;
|
||||
#endif
|
||||
occgeoComm.face_maxh = netgen::mparam.maxh;
|
||||
netgen::OCCSetLocalMeshSize( occgeoComm, *ngMeshes[0] );
|
||||
occgeoComm.emap.Clear();
|
||||
occgeoComm.vmap.Clear();
|
||||
|
||||
// set local size according to size of existing segments
|
||||
const double factor = netgen::occparam.resthcloseedgefac;
|
||||
TopTools_IndexedMapOfShape edgeMap;
|
||||
TopExp::MapShapes( aMesh.GetShapeToMesh(), TopAbs_EDGE, edgeMap );
|
||||
for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
|
||||
@ -486,12 +486,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
|
||||
try {
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#ifdef NETGEN_V5
|
||||
err = netgen::OCCGenerateMesh(occgeom, ngMesh, netgen::mparam, startWith, endWith);
|
||||
#else
|
||||
char *optstr = 0;
|
||||
err = netgen::OCCGenerateMesh(occgeom, ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh);
|
||||
|
||||
if ( netgen::multithread.terminate )
|
||||
return false;
|
||||
if ( err )
|
||||
|
@ -71,7 +71,14 @@
|
||||
#define OCCGEOMETRY
|
||||
#endif
|
||||
#include <occgeom.hpp>
|
||||
|
||||
#ifdef NETGEN_V5
|
||||
#include <ngexception.hpp>
|
||||
#endif
|
||||
#ifdef NETGEN_V6
|
||||
#include <exception.hpp>
|
||||
#endif
|
||||
|
||||
namespace nglib {
|
||||
#include <nglib.h>
|
||||
}
|
||||
@ -208,7 +215,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
|
||||
int Netgen_triangle[3];
|
||||
|
||||
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< const SMDS_MeshNode* > nodeVec;
|
||||
@ -347,7 +354,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
|
||||
// Generate the volume mesh
|
||||
// -------------------------
|
||||
|
||||
return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, Netgen_mesh));
|
||||
return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, ngLib ));
|
||||
}
|
||||
|
||||
// namespace
|
||||
@ -431,16 +438,14 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
|
||||
bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
|
||||
SMESH_MesherHelper& helper,
|
||||
vector< const SMDS_MeshNode* >& nodeVec,
|
||||
Ng_Mesh * Netgen_mesh)
|
||||
NETGENPlugin_NetgenLibWrapper& ngLib)
|
||||
{
|
||||
netgen::multithread.terminate = 0;
|
||||
|
||||
netgen::Mesh* ngMesh = (netgen::Mesh*)Netgen_mesh;
|
||||
int Netgen_NbOfNodes = Ng_GetNP(Netgen_mesh);
|
||||
netgen::Mesh* ngMesh = ngLib._ngMesh;
|
||||
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 endWith = netgen::MESHCONST_OPTVOLUME;
|
||||
int err = 1;
|
||||
@ -498,13 +503,9 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
|
||||
#ifdef NETGEN_V5
|
||||
ngMesh->CalcLocalH(netgen::mparam.grading);
|
||||
err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
|
||||
#else
|
||||
ngMesh->CalcLocalH();
|
||||
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
|
||||
#endif
|
||||
ngLib.CalcLocalH(ngMesh);
|
||||
err = ngLib.GenerateMesh(occgeo, startWith, endWith);
|
||||
|
||||
if(netgen::multithread.terminate)
|
||||
return false;
|
||||
if ( err )
|
||||
@ -614,7 +615,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
|
||||
int Netgen_triangle[3];
|
||||
|
||||
NETGENPlugin_NetgenLibWrapper ngLib;
|
||||
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
|
||||
Ng_Mesh * Netgen_mesh = ngLib.ngMesh();
|
||||
|
||||
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
|
||||
if ( aMesh.NbQuadrangles() > 0 )
|
||||
@ -677,7 +678,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
|
||||
// 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()
|
||||
|
@ -40,6 +40,7 @@
|
||||
class StdMeshers_ViscousLayers;
|
||||
class StdMeshers_MaxElementVolume;
|
||||
class NETGENPlugin_Hypothesis;
|
||||
class NETGENPlugin_NetgenLibWrapper;
|
||||
|
||||
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,
|
||||
SMESH_MesherHelper& helper,
|
||||
std::vector< const SMDS_MeshNode* >& nodeVec,
|
||||
nglib::Ng_Mesh* ngMesh);
|
||||
NETGENPlugin_NetgenLibWrapper& ngLib);
|
||||
|
||||
double _maxElementVolume;
|
||||
|
||||
|
@ -54,6 +54,9 @@ using namespace nglib;
|
||||
|
||||
namespace netgen {
|
||||
|
||||
NETGENPLUGIN_DLL_HEADER
|
||||
extern MeshingParameters mparam;
|
||||
|
||||
NETGENPLUGIN_DLL_HEADER
|
||||
extern STLParameters stlparam;
|
||||
|
||||
@ -649,8 +652,10 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
|
||||
netgen::stlparam.resthchartdistenable = hyp->GetRestHChartDistEnable();
|
||||
netgen::stlparam.resthlinelengthfac = hyp->GetRestHLineLengthFactor();
|
||||
netgen::stlparam.resthlinelengthenable = hyp->GetRestHLineLengthEnable();
|
||||
#ifndef NETGEN_V6
|
||||
netgen::stlparam.resthcloseedgefac = hyp->GetRestHCloseEdgeFactor();
|
||||
netgen::stlparam.resthcloseedgeenable = hyp->GetRestHCloseEdgeEnable();
|
||||
#endif
|
||||
netgen::stlparam.resthsurfcurvfac = hyp->GetRestHSurfCurvFactor();
|
||||
netgen::stlparam.resthsurfcurvenable = hyp->GetRestHSurfCurvEnable();
|
||||
netgen::stlparam.resthedgeanglefac = hyp->GetRestHEdgeAngleFactor();
|
||||
@ -675,6 +680,15 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
|
||||
netgen::STLGeometry* stlGeom = (netgen::STLGeometry*)ngStlGeo;
|
||||
|
||||
// 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->BuildEdges();
|
||||
stlGeom->MakeAtlas( *ngMesh );
|
||||
@ -682,7 +696,7 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
|
||||
stlGeom->AddFaceEdges();
|
||||
fixNodes( fixedEdges->GetGroupDS(), stlGeom );
|
||||
stlGeom->LinkEdges();
|
||||
|
||||
#endif
|
||||
ngMesh->ClearFaceDescriptors();
|
||||
for (int i = 1; i <= stlGeom->GetNOFaces(); i++)
|
||||
ngMesh->AddFaceDescriptor (netgen::FaceDescriptor (i, 1, 0, 0));
|
||||
@ -691,7 +705,7 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
|
||||
}
|
||||
else
|
||||
{
|
||||
Ng_STL_MakeEdges( ngStlGeo, ngLib._ngMesh, &ngParams );
|
||||
Ng_STL_MakeEdges( ngStlGeo, ngLib.ngMesh(), &ngParams );
|
||||
}
|
||||
|
||||
netgen::mparam = savedParams;
|
||||
@ -707,13 +721,10 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
|
||||
netgen::OCCGeometry occgeo;
|
||||
mesher.SetLocalSize( occgeo, *ngMesh );
|
||||
|
||||
// const char* optStr = "SmSmSm";//"smsmsmSmSmSm";
|
||||
// netgen::mparam.optimize2d = optStr;
|
||||
|
||||
// meshing
|
||||
try
|
||||
{
|
||||
ng_res = Ng_STL_GenerateSurfaceMesh( ngStlGeo, ngLib._ngMesh, &ngParams );
|
||||
ng_res = Ng_STL_GenerateSurfaceMesh( ngStlGeo, ngLib.ngMesh(), &ngParams );
|
||||
}
|
||||
catch (netgen::NgException & ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user