-// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "NETGENPlugin_Mesher.hxx"
#include "NETGENPlugin_Hypothesis_2D.hxx"
-#include "NETGENPlugin_Provider.hxx"
#include <SMDS_MeshElement.hxx>
#include <SMDS_MeshNode.hxx>
_hypParameters = 0;
_progressByTic = -1;
-
const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, false);
if (hyps.empty())
bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
- aMesh.Lock();
- SMESH_Hypothesis::Hypothesis_Status hypStatus;
- this->CheckHypothesis(aMesh, aShape, hypStatus);
- aMesh.Unlock();
-
netgen::multithread.terminate = 0;
//netgen::multithread.task = "Surface meshing";
SMESH_MesherHelper helper(aMesh);
helper.SetElementsOnShape( true );
- NETGENPlugin_NetgenLibWrapper *ngLib;
- int id_ngLib = nglib_provider.take(&ngLib);
- ngLib->_isComputeOk = false;
+ NETGENPlugin_NetgenLibWrapper ngLib;
+ ngLib._isComputeOk = false;
netgen::Mesh ngMeshNoLocSize;
- netgen::Mesh * ngMeshes[2] = { (netgen::Mesh*) ngLib->_ngMesh, & ngMeshNoLocSize };
- netgen::OCCGeometry *occgeoComm;
- int id_occgeoComm = occgeom_provider.take(&occgeoComm);
+ netgen::Mesh * ngMeshes[2] = { (netgen::Mesh*) ngLib._ngMesh, & ngMeshNoLocSize };
+ netgen::OCCGeometry occgeoComm;
// min / max sizes are set as follows:
// if ( _hypParameters )
// else
// min = aMesher.GetDefaultMinSize()
// max = max segment len of a FACE
+
NETGENPlugin_Mesher aMesher( &aMesh, aShape, /*isVolume=*/false);
aMesher.SetParameters( _hypParameters ); // _hypParameters -> netgen::mparam
const bool toOptimize = _hypParameters ? _hypParameters->GetOptimize() : true;
if ( isCommonLocalSize ) // compute common local size in ngMeshes[0]
{
//list< SMESH_subMesh* > meshedSM[4]; --> all sub-shapes are added to occgeoComm
- aMesher.PrepareOCCgeometry( *occgeoComm, aShape, aMesh );//, meshedSM );
+ aMesher.PrepareOCCgeometry( occgeoComm, aShape, aMesh );//, meshedSM );
// local size set at MESHCONST_ANALYSE step depends on
// minh, face_maxh, grading and curvaturesafety; find minh if not set by the user
if ( !_hypParameters || netgen::mparam.minh < DBL_MIN )
{
if ( !_hypParameters )
- netgen::mparam.maxh = occgeoComm->GetBoundingBox().Diam() / 3.;
+ netgen::mparam.maxh = occgeoComm.GetBoundingBox().Diam() / 3.;
netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh );
}
// set local size depending on curvature and NOT closeness of EDGEs
netgen::occparam.resthcloseedgeenable = false;
netgen::occparam.resthcloseedgefac = 1.0 + netgen::mparam.grading;
#endif
- occgeoComm->face_maxh = netgen::mparam.maxh;
+ occgeoComm.face_maxh = netgen::mparam.maxh;
#ifdef NETGEN_V6
netgen::OCCParameters occparam;
- netgen::OCCSetLocalMeshSize( *occgeoComm, *ngMeshes[0], netgen::mparam, occparam );
+ netgen::OCCSetLocalMeshSize( occgeoComm, *ngMeshes[0], netgen::mparam, occparam );
#else
- netgen::OCCSetLocalMeshSize( *occgeoComm, *ngMeshes[0] );
+ netgen::OCCSetLocalMeshSize( occgeoComm, *ngMeshes[0] );
#endif
- occgeoComm->emap.Clear();
- occgeoComm->vmap.Clear();
+ occgeoComm.emap.Clear();
+ occgeoComm.vmap.Clear();
// set local size according to size of existing segments
TopTools_IndexedMapOfShape edgeMap;
}
// set local size defined on shapes
- aMesher.SetLocalSize( *occgeoComm, *ngMeshes[0] );
- aMesher.SetLocalSizeForChordalError( *occgeoComm, *ngMeshes[0] );
+ aMesher.SetLocalSize( occgeoComm, *ngMeshes[0] );
+ aMesher.SetLocalSizeForChordalError( occgeoComm, *ngMeshes[0] );
try {
ngMeshes[0]->LoadLocalMeshSize( mparam.meshsizefilename );
} catch (NgException & ex) {
}
}
netgen::mparam.uselocalh = toOptimize; // restore as it is used at surface optimization
+
// ==================
// Loop on all FACEs
// ==================
netgen::mparam.maxh = edgeLength;
}
if ( netgen::mparam.maxh < DBL_MIN )
- netgen::mparam.maxh = occgeoComm->GetBoundingBox().Diam();
+ netgen::mparam.maxh = occgeoComm.GetBoundingBox().Diam();
if ( !isCommonLocalSize )
{
}
// prepare occgeom
- netgen::OCCGeometry *occgeom;
- int id_occgeom = occgeom_provider.take(&occgeom);
- occgeom->shape = F;
- occgeom->fmap.Add( F );
- occgeom->CalcBoundingBox();
- occgeom->facemeshstatus.SetSize(1);
- occgeom->facemeshstatus = 0;
- occgeom->face_maxh_modified.SetSize(1);
- occgeom->face_maxh_modified = 0;
- occgeom->face_maxh.SetSize(1);
- occgeom->face_maxh = netgen::mparam.maxh;
+ netgen::OCCGeometry occgeom;
+ occgeom.shape = F;
+ occgeom.fmap.Add( F );
+ occgeom.CalcBoundingBox();
+ occgeom.facemeshstatus.SetSize(1);
+ occgeom.facemeshstatus = 0;
+ occgeom.face_maxh_modified.SetSize(1);
+ occgeom.face_maxh_modified = 0;
+ occgeom.face_maxh.SetSize(1);
+ occgeom.face_maxh = netgen::mparam.maxh;
// -------------------------
// Fill netgen mesh
{
ngMesh->SetGlobalH ( mparam.maxh );
ngMesh->SetMinimalH( mparam.minh );
- Box<3> bb = occgeom->GetBoundingBox();
+ Box<3> bb = occgeom.GetBoundingBox();
bb.Increase (bb.Diam()/10);
ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
- aMesher.SetLocalSize( *occgeom, *ngMesh );
- aMesher.SetLocalSizeForChordalError( *occgeoComm, *ngMesh );
+ aMesher.SetLocalSize( occgeom, *ngMesh );
+ aMesher.SetLocalSizeForChordalError( occgeoComm, *ngMesh );
try {
ngMesh->LoadLocalMeshSize( mparam.meshsizefilename );
} catch (NgException & ex) {
}
nodeVec.clear();
- faceErr = aMesher.AddSegmentsToMesh( *ngMesh, *occgeom, wires, helper, nodeVec,
+ faceErr = aMesher.AddSegmentsToMesh( *ngMesh, occgeom, wires, helper, nodeVec,
/*overrideMinH=*/!_hypParameters);
if ( faceErr && !faceErr->IsOK() )
break;
SMESH_Comment str;
try {
OCC_CATCH_SIGNALS;
- err = ngLib->GenerateMesh(*occgeom, startWith, endWith, ngMesh);
+
+ err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh);
+
if ( netgen::multithread.terminate )
return false;
if ( err )
}
if ( err )
{
- if ( aMesher.FixFaceMesh( *occgeom, *ngMesh, 1 ))
+ if ( aMesher.FixFaceMesh( occgeom, *ngMesh, 1 ))
break;
if ( iLoop == LOC_SIZE )
{
}
}
- occgeom_provider.release(id_occgeoComm, true);
- occgeom_provider.release(id_occgeom, true);
- aMesh.Lock();
+
// ----------------------------------------------------
// Fill the SMESHDS with the generated nodes and faces
// ----------------------------------------------------
break;
} // two attempts
} // loop on FACEs
- aMesh.Unlock();
- nglib_provider.release(id_ngLib, true);
-
return true;
}