-// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 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
#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;
namespace
{
+ inline void NOOP_Deleter(void *) { ; }
+
//=============================================================================
/*!
* Link - a pair of integer numbers
list< TopoDS_Edge > getConnectedEdges( const TopoDS_Edge& edge,
const TopoDS_Face& face,
- const set< SMESH_subMesh* > & computedSM,
+ const set< SMESH_subMesh* > & /*computedSM*/,
const SMESH_MesherHelper& helper,
map< SMESH_subMesh*, set< int > >& addedEdgeSM2Faces)
{
SMESH_subMesh* sm = helper.GetMesh()->GetSubMesh( *eItFwd );
bool connected = TopExp::CommonVertex( *ePrev, *eItFwd, vCommon );
- bool computed = sm->IsMeshComputed();
+ bool computed = !sm->IsEmpty();
bool added = addedEdgeSM2Faces[ sm ].count( helper.GetSubShapeID() );
bool doubled = !eAdded.Add( *eItFwd );
bool orientOK = (( ePrev ->Orientation() < TopAbs_INTERNAL ) ==
SMESH_subMesh* sm = helper.GetMesh()->GetSubMesh( *eItBack );
bool connected = TopExp::CommonVertex( *ePrev, *eItBack, vCommon );
- bool computed = sm->IsMeshComputed();
+ bool computed = !sm->IsEmpty();
bool added = addedEdgeSM2Faces[ sm ].count( helper.GetSubShapeID() );
bool doubled = !eAdded.Add( *eItBack );
bool orientOK = (( ePrev ->Orientation() < TopAbs_INTERNAL ) ==
OCC_CATCH_SIGNALS;
BRepMesh_IncrementalMesh e(shape, 0.01, true);
}
- catch (Standard_Failure)
+ catch (Standard_Failure&)
{
}
// updated.erase( triangulation.operator->() );
_fineness = NETGENPlugin_Hypothesis::GetDefaultFineness();
mparams.uselocalh = NETGENPlugin_Hypothesis::GetDefaultSurfaceCurvature();
netgen::merge_solids = NETGENPlugin_Hypothesis::GetDefaultFuseEdges();
+
+#ifdef NETGEN_V6
+
+ mparams.nthreads = std::thread::hardware_concurrency();
+
+ if ( getenv( "SALOME_NETGEN_DISABLE_MULTITHREADING" ))
+ {
+ mparams.nthreads = 1;
+ mparams.parallel_meshing = false;
+ }
+
+#endif
}
//=============================================================================
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() )
{
double val = (*it).second;
// --
GEOM::GEOM_Object_var aGeomObj;
- SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( entry.c_str() );
if ( !aSObj->_is_nil() ) {
CORBA::Object_var obj = aSObj->GetObject();
aGeomObj = GEOM::GEOM_Object::_narrow(obj);
}
}
}
+
+#ifdef NETGEN_V6
+
+ netgen::mparam.closeedgefac = 2;
+
+#endif
}
//=============================================================================
int faceNgID = occgeo.fmap.FindIndex(shape);
if ( faceNgID >= 1 )
{
+#ifdef NETGEN_V6
+ occgeo.SetFaceMaxH(faceNgID-1, val, netgen::mparam);
+#else
occgeo.SetFaceMaxH(faceNgID, val);
+#endif
for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() )
setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, ngMesh );
}
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, netgen::mparam );
+#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() )
const vector<UVPtStruct>& points = fSide.GetUVPtStruct();
if ( points.empty() )
return false; // invalid node params?
- int i, nbSeg = fSide.NbSegments();
+ smIdType i, nbSeg = fSide.NbSegments();
// remember EDGEs of fSide to treat only once
for ( int iE = 0; iE < fSide.NbEdges(); ++iE )
if ( id ) solidSMDSIDs[ bool( solidSMDSIDs[0] )] = meshDS->ShapeToIndex( *solid );
}
}
+ bool isShrunk = true;
if ( proxyMesh && proxyMesh->GetProxySubMesh( geomFace ))
{
// if a proxy sub-mesh contains temporary faces, then these faces
// should be used to mesh only one SOLID
- bool hasTmp = false;
smDS = proxyMesh->GetSubMesh( geomFace );
SMDS_ElemIteratorPtr faces = smDS->GetElements();
while ( faces->more() )
const SMDS_MeshElement* f = faces->next();
if ( proxyMesh->IsTemporary( f ))
{
- hasTmp = true;
+ isShrunk = false;
if ( solidSMDSIDs[1] && proxyMesh->HasPrismsOnTwoSides( meshDS->MeshElements( geomFace )))
break;
else
}
}
const int fID = occgeom.fmap.FindIndex( geomFace );
- if ( !hasTmp ) // shrunk mesh
+ if ( isShrunk ) // shrunk mesh
{
// move netgen points according to moved nodes
SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true);
{
solidSMDSIDs[1] = 0;
}
- const bool hasVLOn2Sides = ( solidSMDSIDs[1] > 0 );
+ const bool hasVLOn2Sides = ( solidSMDSIDs[1] > 0 && !isShrunk );
// Add ng face descriptors of meshed faces
faceNgID++;
const SMDS_MeshElement* f = faces->next();
if ( f->NbNodes() % 3 != 0 ) // not triangle
{
- PShapeIteratorPtr solidIt=helper.GetAncestors(geomFace,*sm->GetFather(),TopAbs_SOLID);
+ PShapeIteratorPtr solidIt = helper.GetAncestors( geomFace,*sm->GetFather(),TopAbs_SOLID);
if ( const TopoDS_Shape * solid = solidIt->next() )
sm = _mesh->GetSubMesh( *solid );
SMESH_BadInputElements* badElems =
// ----------------------------
// Check wires and count nodes
// ----------------------------
- int nbNodes = 0;
+ smIdType nbNodes = 0;
for ( size_t iW = 0; iW < wires.size(); ++iW )
{
StdMeshers_FaceSidePtr wire = wires[ iW ];
{
StdMeshers_FaceSidePtr wire = wires[ iW ];
const vector<UVPtStruct>& uvPtVec = wire->GetUVPtStruct();
- const int nbSegments = wire->NbPoints() - 1;
+ const smIdType nbSegments = wire->NbPoints() - 1;
// assure the 1st node to be in node2ngID, which is needed to correctly
// "close chain of segments" (see below) in case if the 1st node is not
SMESH_TNodeXYZ np1( n ), np2( uvPtVec[ i+1 ].node );
// get an average size of adjacent segments to avoid sharp change of
// element size (regression on issue 0020452, note 0010898)
- int iPrev = SMESH_MesherHelper::WrapIndex( i-1, nbSegments );
- int iNext = SMESH_MesherHelper::WrapIndex( i+1, nbSegments );
+ int iPrev = SMESH_MesherHelper::WrapIndex( i-1, (int) nbSegments );
+ int iNext = SMESH_MesherHelper::WrapIndex( i+1, (int) nbSegments );
double sumH = segLen[ iPrev ] + segLen[ i ] + segLen[ iNext ];
int nbSeg = ( int( segLen[ iPrev ] > sumH / 100.) +
int( segLen[ i ] > sumH / 100.) +
if ( quadHelper && !quadHelper->GetIsQuadratic() && quadHelper->GetTLinkNodeMap().empty() )
quadHelper = 0;
- int i, nbInitNod = initState._nbNodes;
+ int ngID, nbInitNod = initState._nbNodes;
if ( initState._elementsRemoved )
{
// PAL23427. Update nodeVec to track removal of netgen free points as a result
// of removal of faces in FillNgMesh() in the case of a shrunk sub-mesh
- int ngID, nodeVecSize = nodeVec.size();
+ size_t i, nodeVecSize = nodeVec.size();
const double eps = std::numeric_limits<double>::min();
- for ( ngID = i = 1; i < nodeVecSize; ++ngID, ++i )
+ for ( i = ngID = 1; i < nodeVecSize; ++ngID, ++i )
{
gp_Pnt ngPnt( NGPOINT_COORDS( ngMesh.Point( ngID )));
gp_Pnt node ( SMESH_NodeXYZ (nodeVec_ACCESS(i) ));
// Create and insert nodes into nodeVec
// -------------------------------------
- nodeVec.resize( nbNod + 1 );
- for ( i = nbInitNod+1; i <= nbNod; ++i )
+ if ( nbNod > nbInitNod )
+ nodeVec.resize( nbNod + 1 );
+ for ( int i = nbInitNod+1; i <= nbNod; ++i )
{
const netgen::MeshPoint& ngPoint = ngMesh.Point(i);
SMDS_MeshNode* node = NULL;
// -------------------------------------------
int nbInitSeg = initState._nbSegments;
- for (i = nbInitSeg+1; i <= nbSeg; ++i )
+ for ( int i = nbInitSeg+1; i <= nbSeg; ++i )
{
const netgen::Segment& seg = ngMesh.LineSegment(i);
TopoDS_Edge aEdge;
ngMesh.AddFaceDescriptor (netgen::FaceDescriptor(quadFaceID, /*solid1=*/0, /*solid2=*/0, 0));
vector<const SMDS_MeshNode*> nodes;
- for (i = nbInitFac+1; i <= nbFac; ++i )
+ for ( int i = nbInitFac+1; i <= nbFac; ++i )
{
const netgen::Element2d& elem = ngMesh.SurfaceElement(i);
const int aGeomFaceInd = elem.GetIndex();
// Create tetrahedra
// ------------------
- for ( i = 1; i <= nbVol; ++i )
+ for ( int i = 1; i <= nbVol; ++i )
{
const netgen::Element& elem = ngMesh.VolumeElement(i);
int aSolidInd = elem.GetIndex();
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;
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
{
// Pass 1D simple parameters to NETGEN
// --------------------------------
- int nbSeg = _simpleHyp->GetNumberOfSegments();
+ double nbSeg = (double) _simpleHyp->GetNumberOfSegments();
double segSize = _simpleHyp->GetLocalLength();
for ( int iE = 1; iE <= occgeo.emap.Extent(); ++iE )
{
//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
// 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)
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);
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);
comment << text(ex);
//err = 1; -- try to make volumes anyway
}
- catch (netgen::NgException exc)
+ catch (netgen::NgException& exc)
{
comment << text(exc);
//err = 1; -- try to make volumes anyway
FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment, &quadHelper );
// compute prismatic boundary volumes
- int nbQuad = _mesh->NbQuadrangles();
+ smIdType nbQuad = _mesh->NbQuadrangles();
SMESH_ProxyMesh::Ptr viscousMesh;
if ( _viscousLayersHyp )
{
// fill _ngMesh with faces of sub-meshes
err = ! ( FillNgMesh(occgeo, *_ngMesh, nodeVec, meshedSM[ MeshDim_2D ], &quadHelper));
initState = NETGENPlugin_ngMeshInfo(_ngMesh, /*checkRemovedElems=*/true);
- // toPython( _ngMesh );
+ // toPython( _ngMesh )
}
if (!err && _isVolume)
{
}
_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() )
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
comment << text(ex);
err = 1;
}
- catch (netgen::NgException exc)
+ catch (netgen::NgException& exc)
{
if ( comment.empty() ) // do not overwrite a previous error
comment << text(exc);
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
if ( comment.empty() ) // do not overwrite a previous error
comment << text(ex);
}
- catch (netgen::NgException exc)
+ catch (netgen::NgException& exc)
{
if ( comment.empty() ) // do not overwrite a previous error
comment << text(exc);
_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 )
if ( comment.empty() ) // do not overwrite a previous error
comment << "Exception in netgen at passing to 2nd order ";
}
- catch (netgen::NgException exc)
+ catch (netgen::NgException& exc)
{
if ( comment.empty() ) // do not overwrite a previous error
comment << exc.What();
bool smComputed = nbVol && !sm->IsEmpty();
if ( smComputed && internals.hasInternalVertexInSolid( sm->GetId() ))
{
- int nbIntV = internals.getSolidsWithVertices().find( sm->GetId() )->second.size();
+ size_t nbIntV = internals.getSolidsWithVertices().find( sm->GetId() )->second.size();
SMESHDS_SubMesh* smDS = sm->GetSubMeshDS();
- smComputed = ( smDS->NbElements() > 0 || smDS->NbNodes() > nbIntV );
+ smComputed = ( smDS->NbElements() > 0 || smDS->NbNodes() > (smIdType) nbIntV );
}
SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
if ( !smComputed && ( !smError || smError->IsOK() ))
// 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;
// }
// calculate total nb of segments and length of edges
double fullLen = 0.0;
- int fullNbSeg = 0;
+ smIdType fullNbSeg = 0;
int entity = mparams.secondorder > 0 ? SMDSEntity_Quad_Edge : SMDSEntity_Edge;
TopTools_DataMapOfShapeInteger Edge2NbSeg;
for (TopExp_Explorer exp(_shape, TopAbs_EDGE); exp.More(); exp.Next())
double aLen = SMESH_Algo::EdgeLength(E);
fullLen += aLen;
- vector<int>& aVec = aResMap[_mesh->GetSubMesh(E)];
+ vector<smIdType>& aVec = aResMap[_mesh->GetSubMesh(E)];
if ( aVec.empty() )
aVec.resize( SMDSEntity_Last, 0);
else
int aGeomEdgeInd = seg.epgeominfo[0].edgenr;
if (aGeomEdgeInd > 0 && aGeomEdgeInd <= occgeo.emap.Extent())
{
- vector<int>& aVec = aResMap[_mesh->GetSubMesh(occgeo.emap(aGeomEdgeInd))];
+ vector<smIdType>& aVec = aResMap[_mesh->GetSubMesh(occgeo.emap(aGeomEdgeInd))];
aVec[ entity ]++;
}
}
TopTools_DataMapIteratorOfDataMapOfShapeInteger Edge2NbSegIt(Edge2NbSeg);
for (; Edge2NbSegIt.More(); Edge2NbSegIt.Next())
{
- vector<int>& aVec = aResMap[_mesh->GetSubMesh(Edge2NbSegIt.Key())];
+ vector<smIdType>& aVec = aResMap[_mesh->GetSubMesh(Edge2NbSegIt.Key())];
if ( aVec[ entity ] > 1 && aVec[ SMDSEntity_Node ] == 0 )
aVec[SMDSEntity_Node] = mparams.secondorder > 0 ? 2*aVec[ entity ]-1 : aVec[ entity ]-1;
fullNbSeg += aVec[ entity ];
- Edge2NbSeg( Edge2NbSegIt.Key() ) = aVec[ entity ];
+ Edge2NbSeg( Edge2NbSegIt.Key() ) = (int) aVec[ entity ];
}
if ( fullNbSeg == 0 )
return false;
}
else {
// length from edges
- mparams.maxh = fullLen/fullNbSeg;
+ mparams.maxh = fullLen / double( fullNbSeg );
mparams.grading = 0.2; // slow size growth
}
}
mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 );
- mparams.maxh = min( mparams.maxh, fullLen/fullNbSeg * (1. + mparams.grading));
+ mparams.maxh = min( mparams.maxh, fullLen / double( fullNbSeg ) * (1. + mparams.grading));
for (TopExp_Explorer exp(_shape, TopAbs_FACE); exp.More(); exp.Next())
{
int nbFaces = tooManyElems ? hugeNb : int( 4*anArea / (mparams.maxh*mparams.maxh*sqrt(3.)));
int nbNodes = tooManyElems ? hugeNb : (( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 );
- vector<int> aVec(SMDSEntity_Last, 0);
+ vector<smIdType> aVec(SMDSEntity_Last, 0);
if( mparams.secondorder > 0 ) {
int nb1d_in = (nbFaces*3 - nb1d) / 2;
aVec[SMDSEntity_Node] = nbNodes + nb1d_in;
// using previous length from faces
}
mparams.grading = 0.4;
- mparams.maxh = min( mparams.maxh, fullLen/fullNbSeg * (1. + mparams.grading));
+ mparams.maxh = min( mparams.maxh, fullLen / double( fullNbSeg ) * (1. + mparams.grading));
}
GProp_GProps G;
BRepGProp::VolumeProperties(_shape,G);
tooManyElems = tooManyElems || ( aVolume/hugeNb > tetrVol );
int nbVols = tooManyElems ? hugeNb : int(aVolume/tetrVol);
int nb1d_in = int(( nbVols*6 - fullNbSeg ) / 6 );
- vector<int> aVec(SMDSEntity_Last, 0 );
+ vector<smIdType> aVec(SMDSEntity_Last, 0 );
if ( tooManyElems ) // avoid FPE
{
aVec[SMDSEntity_Node] = hugeNb;
return true;
}
-double NETGENPlugin_Mesher::GetProgress(const SMESH_Algo* holder,
+double NETGENPlugin_Mesher::GetProgress(const SMESH_Algo* /*holder*/,
const int * algoProgressTic,
const double * algoProgress) const
{
vector<int> two(2);
vector<int> three1(3), three2(3);
const char* badEdgeStr = " multiple times in surface mesh";
- const int badEdgeStrLen = strlen( badEdgeStr );
- const int nbNodes = nodeVec.size();
+ const int badEdgeStrLen = (int) strlen( badEdgeStr );
+ const int nbNodes = (int) nodeVec.size();
while( !file.eof() )
{
two[0] < nbNodes && two[1] < nbNodes )
{
err->myBadElements.push_back( new SMDS_LinearEdge( nodeVec[ two[0]], nodeVec[ two[1]] ));
- file += badEdgeStrLen;
+ file += (int) badEdgeStrLen;
}
else if ( strncmp( file, "Intersecting: ", 14 ) == 0 )
{
ok = ok && file.getInts( three2 );
for ( int i = 0; ok && i < 3; ++i )
ok = ( three1[i] < nbNodes && nodeVec[ three1[i]]);
- for ( int i = 0; ok && i < 3; ++i )
+ for ( int i = 0; ok && i < 3; ++i )
ok = ( three2[i] < nbNodes && nodeVec[ three2[i]]);
if ( ok )
{
<< "mesh = smesh.Mesh()" << std::endl << std::endl;
using namespace netgen;
+
+#ifdef NETGEN_V6
+
+ for ( int i = 1; i <= ngMesh->GetNP(); i++)
+ {
+ const Point3d & p = ngMesh->Point(i);
+ outfile << "mesh.AddNode( ";
+ outfile << p.X() << ", ";
+ outfile << p.Y() << ", ";
+ outfile << p.Z() << ") ## "<< i << std::endl;
+ }
+
+ int nbDom = ngMesh->GetNDomains();
+ for ( int i = 0; i < nbDom; ++i )
+ outfile<< "grp" << i+1 << " = mesh.CreateEmptyGroup( SMESH.FACE, 'domain"<< i+1 << "')"<< std::endl;
+
+ int nbDel = 0;
+ for (int i = 1; i <= ngMesh->GetNSE(); i++)
+ {
+ outfile << "mesh.AddFace([ ";
+ Element2d sel = ngMesh->SurfaceElement(i);
+ for (int j = 1; j <= sel.GetNP(); j++)
+ outfile << sel.PNum(j) << ( j < sel.GetNP() ? ", " : " ])");
+ if ( sel.IsDeleted() ) outfile << " ## IsDeleted ";
+ outfile << std::endl;
+ nbDel += sel.IsDeleted();
+
+ if (sel.GetIndex())
+ {
+ if ( int dom1 = ngMesh->GetFaceDescriptor(sel.GetIndex ()).DomainIn())
+ outfile << "grp"<< dom1 <<".Add([ " << i - nbDel << " ])" << std::endl;
+ if ( int dom2 = ngMesh->GetFaceDescriptor(sel.GetIndex ()).DomainOut())
+ outfile << "grp"<< dom2 <<".Add([ " << i - nbDel << " ])" << std::endl;
+ }
+ }
+
+ for (int i = 1; i <= ngMesh->GetNE(); i++)
+ {
+ Element el = ngMesh->VolumeElement(i);
+ outfile << "mesh.AddVolume([ ";
+ for (int j = 1; j <= el.GetNP(); j++)
+ outfile << el.PNum(j) << ( j < el.GetNP() ? ", " : " ])");
+ outfile << std::endl;
+ }
+
+ for (int i = 1; i <= ngMesh->GetNSeg(); i++)
+ {
+ const Segment & seg = ngMesh->LineSegment (i);
+ outfile << "mesh.AddEdge([ "
+ << seg[0]+1 << ", "
+ << seg[1]+1 << " ])" << std::endl;
+ }
+
+#else //////// V 5
+
PointIndex pi;
for (pi = PointIndex::BASE;
pi < ngMesh->GetNP()+PointIndex::BASE; pi++)
for ( int i = 0; i < nbDom; ++i )
outfile<< "grp" << i+1 << " = mesh.CreateEmptyGroup( SMESH.FACE, 'domain"<< i+1 << "')"<< std::endl;
+ int nbDel = 0;
SurfaceElementIndex sei;
for (sei = 0; sei < ngMesh->GetNSE(); sei++)
{
outfile << sel[j] << ( j+1 < sel.GetNP() ? ", " : " ])");
if ( sel.IsDeleted() ) outfile << " ## IsDeleted ";
outfile << std::endl;
+ nbDel += sel.IsDeleted();
if ((*ngMesh)[sei].GetIndex())
{
if ( int dom1 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainIn())
- outfile << "grp"<< dom1 <<".Add([ " << (int)sei+1 << " ])" << std::endl;
+ outfile << "grp"<< dom1 <<".Add([ " << (int)sei+1 - nbDel << " ])" << std::endl;
if ( int dom2 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainOut())
- outfile << "grp"<< dom2 <<".Add([ " << (int)sei+1 << " ])" << std::endl;
+ outfile << "grp"<< dom2 <<".Add([ " << (int)sei+1 - nbDel << " ])" << std::endl;
}
}
<< seg[0] << ", "
<< seg[1] << " ])" << std::endl;
}
+
+#endif
+
std::cout << "Write " << pyFile << std::endl;
}
{
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 ];
*/
//================================================================================
-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();
#endif
}
- _ngMesh = Ng_NewMesh();
+ setMesh( Ng_NewMesh() );
}
//================================================================================
{
--instanceCounter();
- Ng_DeleteMesh( _ngMesh );
+ Ng_DeleteMesh( ngMesh() );
Ng_Exit();
RemoveTmpFiles();
if ( _coutBuffer )
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;
+ if ( !ngMesh )
+ ngMesh = new netgen::Mesh;
+
+#ifdef NETGEN_V6
+
+ 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
}
//================================================================================
{
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();