IPAL52905: NETGEN 1D-2D-3D creates sliver elements in case of finer sub-meshes

This commit is contained in:
eap 2015-10-06 14:36:06 +03:00
parent 129557feea
commit 28e133bb1f
2 changed files with 24 additions and 7 deletions

View File

@ -700,16 +700,23 @@ double NETGENPlugin_Mesher::GetDefaultMinSize(const TopoDS_Shape& geom,
void NETGENPlugin_Mesher::RestrictLocalSize(netgen::Mesh& ngMesh, void NETGENPlugin_Mesher::RestrictLocalSize(netgen::Mesh& ngMesh,
const gp_XYZ& p, const gp_XYZ& p,
const double size, double size,
const bool overrideMinH) const bool overrideMinH)
{ {
if ( size <= std::numeric_limits<double>::min() ) if ( size <= std::numeric_limits<double>::min() )
return; return;
if ( overrideMinH && netgen::mparam.minh > size ) if ( netgen::mparam.minh > size )
{
if ( overrideMinH )
{ {
ngMesh.SetMinimalH( size ); ngMesh.SetMinimalH( size );
netgen::mparam.minh = size; netgen::mparam.minh = size;
} }
else
{
size = netgen::mparam.minh;
}
}
netgen::Point3d pi(p.X(), p.Y(), p.Z()); netgen::Point3d pi(p.X(), p.Y(), p.Z());
ngMesh.RestrictLocalH( pi, size ); ngMesh.RestrictLocalH( pi, size );
} }
@ -968,7 +975,7 @@ bool NETGENPlugin_Mesher::FillNgMesh(netgen::OCCGeometry& occgeom,
netgen::Element2d tri(3); netgen::Element2d tri(3);
tri.SetIndex ( faceNgID ); tri.SetIndex ( faceNgID );
SMESH_TNodeXYZ xyz[3];
#ifdef DUMP_TRIANGLES #ifdef DUMP_TRIANGLES
cout << "SMESH face " << helper.GetMeshDS()->ShapeToIndex( geomFace ) cout << "SMESH face " << helper.GetMeshDS()->ShapeToIndex( geomFace )
@ -987,7 +994,7 @@ bool NETGENPlugin_Mesher::FillNgMesh(netgen::OCCGeometry& occgeom,
if ( const TopoDS_Shape * solid = solidIt->next() ) if ( const TopoDS_Shape * solid = solidIt->next() )
sm = _mesh->GetSubMesh( *solid ); sm = _mesh->GetSubMesh( *solid );
SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle submesh")); smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle sub-mesh"));
smError->myBadElements.push_back( f ); smError->myBadElements.push_back( f );
return false; return false;
} }
@ -995,14 +1002,17 @@ bool NETGENPlugin_Mesher::FillNgMesh(netgen::OCCGeometry& occgeom,
for ( int i = 0; i < 3; ++i ) for ( int i = 0; i < 3; ++i )
{ {
const SMDS_MeshNode* node = f->GetNode( i ), * inFaceNode=0; const SMDS_MeshNode* node = f->GetNode( i ), * inFaceNode=0;
xyz[i].Set( node );
// get node UV on face // get node UV on face
int shapeID = node->getshapeId(); int shapeID = node->getshapeId();
if ( helper.IsSeamShape( shapeID )) if ( helper.IsSeamShape( shapeID ))
{
if ( helper.IsSeamShape( f->GetNodeWrap( i+1 )->getshapeId() )) if ( helper.IsSeamShape( f->GetNodeWrap( i+1 )->getshapeId() ))
inFaceNode = f->GetNodeWrap( i-1 ); inFaceNode = f->GetNodeWrap( i-1 );
else else
inFaceNode = f->GetNodeWrap( i+1 ); inFaceNode = f->GetNodeWrap( i+1 );
}
gp_XY uv = helper.GetNodeUV( geomFace, node, inFaceNode ); gp_XY uv = helper.GetNodeUV( geomFace, node, inFaceNode );
int ind = reverse ? 3-i : i+1; int ind = reverse ? 3-i : i+1;
@ -1011,6 +1021,13 @@ bool NETGENPlugin_Mesher::FillNgMesh(netgen::OCCGeometry& occgeom,
tri.PNum (ind) = ngNodeId( node, ngMesh, nodeNgIdMap ); tri.PNum (ind) = ngNodeId( node, ngMesh, nodeNgIdMap );
} }
// pass a triangle size to NG size-map
double size = ( ( xyz[0] - xyz[1] ).Modulus() +
( xyz[1] - xyz[2] ).Modulus() +
( xyz[2] - xyz[0] ).Modulus() ) / 3;
gp_XYZ gc = ( xyz[0] + xyz[1] + xyz[2] ) / 3;
RestrictLocalSize( ngMesh, gc, size, /*overrideMinH=*/false );
ngMesh.AddSurfaceElement (tri); ngMesh.AddSurfaceElement (tri);
#ifdef DUMP_TRIANGLES #ifdef DUMP_TRIANGLES
cout << tri << endl; cout << tri << endl;

View File

@ -135,7 +135,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
static void RestrictLocalSize(netgen::Mesh& ngMesh, static void RestrictLocalSize(netgen::Mesh& ngMesh,
const gp_XYZ& p, const gp_XYZ& p,
const double size, double size,
const bool overrideMinH=true); const bool overrideMinH=true);
static int FillSMesh(const netgen::OCCGeometry& occgeom, static int FillSMesh(const netgen::OCCGeometry& occgeom,