-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
#endif
//extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
-#if defined(NETGEN_V5) && defined(WIN32)
- DLL_HEADER
-#endif
+
+ NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
-#if defined(NETGEN_V5) && defined(WIN32)
- DLL_HEADER
-#endif
+
+ NETGENPLUGIN_DLL_HEADER
extern volatile multithreadt multithread;
-#if defined(NETGEN_V5) && defined(WIN32)
- DLL_HEADER
-#endif
+ NETGENPLUGIN_DLL_HEADER
extern bool merge_solids;
// values used for occgeo.facemeshstatus
//================================================================================
/*!
- * Destuctor
+ * Destructor
*/
//================================================================================
void NETGENPlugin_Mesher::SetDefaultParameters()
{
netgen::MeshingParameters& mparams = netgen::mparam;
+ mparams = netgen::MeshingParameters();
// maximal mesh edge size
mparams.maxh = 0;//NETGENPlugin_Hypothesis::GetDefaultMaxSize();
mparams.minh = 0;
netgen::MeshingParameters& mparams = netgen::mparam;
// Initialize global NETGEN parameters:
// maximal mesh segment size
- mparams.maxh = hyp->GetMaxSize();
+ mparams.maxh = hyp->GetMaxSize();
// maximal mesh element linear size
- mparams.minh = hyp->GetMinSize();
+ mparams.minh = hyp->GetMinSize();
// minimal number of segments per edge
- mparams.segmentsperedge = hyp->GetNbSegPerEdge();
+ mparams.segmentsperedge = hyp->GetNbSegPerEdge();
// rate of growth of size between elements
- mparams.grading = hyp->GetGrowthRate();
+ mparams.grading = hyp->GetGrowthRate();
// safety factor for curvatures (elements per radius)
- mparams.curvaturesafety = hyp->GetNbSegPerRadius();
+ mparams.curvaturesafety = hyp->GetNbSegPerRadius();
// create elements of second order
- mparams.secondorder = hyp->GetSecondOrder() ? 1 : 0;
+ mparams.secondorder = hyp->GetSecondOrder() ? 1 : 0;
// quad-dominated surface meshing
- mparams.quad = hyp->GetQuadAllowed() ? 1 : 0;
- _optimize = hyp->GetOptimize();
- _fineness = hyp->GetFineness();
- mparams.uselocalh = hyp->GetSurfaceCurvature();
- netgen::merge_solids = hyp->GetFuseEdges();
- _chordalError = hyp->GetChordalErrorEnabled() ? hyp->GetChordalError() : -1.;
- _simpleHyp = NULL;
+ mparams.quad = hyp->GetQuadAllowed() ? 1 : 0;
+ _optimize = hyp->GetOptimize();
+ _fineness = hyp->GetFineness();
+ mparams.uselocalh = hyp->GetSurfaceCurvature();
+ netgen::merge_solids = hyp->GetFuseEdges();
+ _chordalError = hyp->GetChordalErrorEnabled() ? hyp->GetChordalError() : -1.;
+ mparams.optsteps2d = _optimize ? hyp->GetNbSurfOptSteps() : 0;
+ mparams.optsteps3d = _optimize ? hyp->GetNbVolOptSteps() : 0;
+ mparams.elsizeweight = hyp->GetElemSizeWeight();
+ mparams.opterrpow = hyp->GetWorstElemMeasure();
+ mparams.delaunay = hyp->GetUseDelauney();
+ mparams.checkoverlap = hyp->GetCheckOverlapping();
+ mparams.checkchartboundary = hyp->GetCheckChartBoundary();
+ _simpleHyp = NULL;
// mesh size file
mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
const NETGENPlugin_Hypothesis::TLocalSize& localSizes = hyp->GetLocalSizesAndEntries();
if ( !localSizes.empty() )
{
- SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
- CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
- SALOMEDS::Study_var myStudy = aStudyMgr->GetStudyByID(hyp->GetStudyId());
- if ( !myStudy->_is_nil() )
+ SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+ NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
+ for ( ; it != localSizes.end() ; it++)
{
- NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
- for ( ; it != localSizes.end() ; it++)
- {
- std::string entry = (*it).first;
- double val = (*it).second;
- // --
- GEOM::GEOM_Object_var aGeomObj;
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
- if ( !aSObj->_is_nil() ) {
- CORBA::Object_var obj = aSObj->GetObject();
- aGeomObj = GEOM::GEOM_Object::_narrow(obj);
- aSObj->UnRegister();
- }
- TopoDS_Shape S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
- ::SetLocalSize(S, val);
+ std::string entry = (*it).first;
+ double val = (*it).second;
+ // --
+ GEOM::GEOM_Object_var aGeomObj;
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
+ if ( !aSObj->_is_nil() ) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+ aSObj->UnRegister();
}
+ TopoDS_Shape S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
+ ::SetLocalSize(S, val);
}
}
}
if ( shape.ShapeType() != TopAbs_VERTEX )
shape = subShapes( subShapes.FindIndex( shape ));// shape -> index -> oriented shape
if ( shape.Orientation() >= TopAbs_INTERNAL )
- shape.Orientation( TopAbs_FORWARD ); // isuue 0020676
+ shape.Orientation( TopAbs_FORWARD ); // issue 0020676
switch ( shape.ShapeType() ) {
case TopAbs_FACE : occgeo.fmap.Add( shape ); break;
case TopAbs_EDGE : occgeo.emap.Add( shape ); break;
bool isForwad = ( fOri == eNotSeam.Orientation() || fOri >= TopAbs_INTERNAL );
// get all nodes from connected <edges>
- const bool isQuad = smDS->IsQuadratic();
- StdMeshers_FaceSide fSide( face, edges, _mesh, isForwad, isQuad, &helper );
+ const bool skipMedium = netgen::mparam.secondorder;//smDS->IsQuadratic();
+ StdMeshers_FaceSide fSide( face, edges, _mesh, isForwad, skipMedium, &helper );
const vector<UVPtStruct>& points = fSide.GetUVPtStruct();
if ( points.empty() )
return false; // invalid node params?
struct TIntVData
{
gp_XY uv; //!< UV in face parametric space
- int ngId; //!< ng id of corrsponding node
+ int ngId; //!< ng id of corresponding node
gp_XY uvClose; //!< UV of closest boundary node
int ngIdClose; //!< ng id of closest boundary node
};
}
}
+ ngMesh.CalcSurfacesOfNode();
}
//================================================================================
ofstream py(DUMP_TRIANGLES_SCRIPT);
py << "import SMESH"<< endl
<< "from salome.smesh import smeshBuilder"<<endl
- << "smesh = smeshBuilder.New(salome.myStudy)"<<endl
+ << "smesh = smeshBuilder.New()"<<endl
<< "m = smesh.Mesh(name='triangles')" << endl;
#endif
if ((int) nodeVec.size() < ngMesh.GetNP() )
for ( ngID = i = 1; i < nodeVecSize; ++ngID, ++i )
{
gp_Pnt ngPnt( NGPOINT_COORDS( ngMesh.Point( ngID )));
- gp_Pnt node ( SMESH_NodeXYZ ( nodeVec[ i ]));
+ gp_Pnt node ( SMESH_NodeXYZ (nodeVec_ACCESS(i) ));
if ( ngPnt.SquareDistance( node ) < eps )
{
nodeVec[ ngID ] = nodeVec[ i ];
if(netgen::multithread.terminate)
return false;
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << text(err);
}
catch (Standard_Failure& ex)
{
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << text(ex);
err = 1;
}
catch (netgen::NgException exc)
{
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << text(exc);
err = 1;
}
if(netgen::multithread.terminate)
return false;
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << text(err);
}
catch (Standard_Failure& ex)
{
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << text(ex);
}
catch (netgen::NgException exc)
{
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << text(exc);
}
}
{
const netgen::Segment & seg = _ngMesh->LineSegment (i);
if ( seg.epgeominfo[ 0 ].edgenr == 0 )
+ {
_ngMesh->DeleteSegment( i );
+ initState._nbSegments--;
+ }
}
_ngMesh->Compress();
}
}
catch (Standard_Failure& ex)
{
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << "Exception in netgen at passing to 2nd order ";
}
catch (netgen::NgException exc)
{
- if ( comment.empty() ) // do not overwrite a previos error
+ if ( comment.empty() ) // do not overwrite a previous error
comment << exc.What();
}
}
FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment, &quadHelper );
if ( quadHelper.GetIsQuadratic() ) // remove free nodes
+ {
for ( size_t i = 0; i < nodeVec.size(); ++i )
if ( nodeVec[i] && nodeVec[i]->NbInverseElements() == 0 )
+ {
_mesh->GetMeshDS()->RemoveFreeNode( nodeVec[i], 0, /*fromGroups=*/false );
+ nodeVec[i]=0;
+ }
+ for ( size_t i = nodeVec.size()-1; i > 0; --i ) // remove trailing removed nodes
+ if ( !nodeVec[i] )
+ nodeVec.resize( i );
+ else
+ break;
+ }
}
SMESH_ComputeErrorPtr readErr = ReadErrors(nodeVec);
if ( readErr && readErr->HasBadElems() )
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
if ( !smComputed && ( !smError || smError->IsOK() ))
{
- smError.reset( new SMESH_ComputeError( *error ));
+ smError = error;
if ( nbVol && SMESH_Algo::GetMeshError( sm ) == SMESH_Algo::MEr_OK )
{
smError->myName = COMPERR_WARNING;
// Prepare OCC geometry
// -------------------------
netgen::OCCGeometry occgeo;
- list< SMESH_subMesh* > meshedSM[4]; // for 0-3 dimensions
NETGENPlugin_Internals internals( *_mesh, _shape, _isVolume );
- PrepareOCCgeometry( occgeo, _shape, *_mesh, meshedSM, &internals );
+ PrepareOCCgeometry( occgeo, _shape, *_mesh, 0, &internals );
bool tooManyElems = false;
const int hugeNb = std::numeric_limits<int>::max() / 100;
ofstream outfile( pyFile, ios::out );
if ( !outfile ) return;
- outfile << "import salome, SMESH" << endl
- << "from salome.smesh import smeshBuilder" << endl
- << "smesh = smeshBuilder.New(salome.myStudy)" << endl
- << "mesh = smesh.Mesh()" << endl << endl;
+ outfile << "import salome, SMESH" << std::endl
+ << "from salome.smesh import smeshBuilder" << std::endl
+ << "smesh = smeshBuilder.New()" << std::endl
+ << "mesh = smesh.Mesh()" << std::endl << std::endl;
using namespace netgen;
PointIndex pi;
outfile << "mesh.AddNode( ";
outfile << (*ngMesh)[pi](0) << ", ";
outfile << (*ngMesh)[pi](1) << ", ";
- outfile << (*ngMesh)[pi](2) << ") ## "<< pi << endl;
+ outfile << (*ngMesh)[pi](2) << ") ## "<< pi << std::endl;
}
int nbDom = ngMesh->GetNDomains();
for ( int i = 0; i < nbDom; ++i )
- outfile<< "grp" << i+1 << " = mesh.CreateEmptyGroup( SMESH.FACE, 'domain"<< i+1 << "')"<< endl;
+ outfile<< "grp" << i+1 << " = mesh.CreateEmptyGroup( SMESH.FACE, 'domain"<< i+1 << "')"<< std::endl;
SurfaceElementIndex sei;
for (sei = 0; sei < ngMesh->GetNSE(); sei++)
for (int j = 0; j < sel.GetNP(); j++)
outfile << sel[j] << ( j+1 < sel.GetNP() ? ", " : " ])");
if ( sel.IsDeleted() ) outfile << " ## IsDeleted ";
- outfile << endl;
+ outfile << std::endl;
if ((*ngMesh)[sei].GetIndex())
{
if ( int dom1 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainIn())
- outfile << "grp"<< dom1 <<".Add([ " << (int)sei+1 << " ])" << endl;
+ outfile << "grp"<< dom1 <<".Add([ " << (int)sei+1 << " ])" << std::endl;
if ( int dom2 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainOut())
- outfile << "grp"<< dom2 <<".Add([ " << (int)sei+1 << " ])" << endl;
+ outfile << "grp"<< dom2 <<".Add([ " << (int)sei+1 << " ])" << std::endl;
}
}
outfile << "mesh.AddVolume([ ";
for (int j = 0; j < el.GetNP(); j++)
outfile << el[j] << ( j+1 < el.GetNP() ? ", " : " ])");
- outfile << endl;
+ outfile << std::endl;
}
for (int i = 1; i <= ngMesh->GetNSeg(); i++)
const Segment & seg = ngMesh->LineSegment (i);
outfile << "mesh.AddEdge([ "
<< seg[0] << ", "
- << seg[1] << " ])" << endl;
+ << seg[1] << " ])" << std::endl;
}
- cout << "Write " << pyFile << endl;
+ std::cout << "Write " << pyFile << std::endl;
}
//================================================================================
netgen::myerr = netgen::mycout;
_coutBuffer = std::cout.rdbuf();
#ifdef _DEBUG_
- cout << "NOTE: netgen output is redirected to file " << _outputFileName << endl;
+ std::cout << "NOTE: netgen output is redirected to file " << _outputFileName << std::endl;
#else
std::cout.rdbuf( netgen::mycout->rdbuf() );
#endif
}
string tmpDir = SALOMEDS_Tool::GetDirFromPath ( _outputFileName );
string aFileName = SALOMEDS_Tool::GetNameFromPath( _outputFileName ) + ".out";
- SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
- aFiles->length(1);
- aFiles[0] = aFileName.c_str();
+ SALOMEDS_Tool::ListOfFiles aFiles;
+ aFiles.reserve(1);
+ aFiles.push_back(aFileName.c_str());
- SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles.in(), true );
+ SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles, true );
}
}