From: eap Date: Wed, 23 Apr 2014 11:31:14 +0000 (+0400) Subject: Meshing in Salome 7.3.0 (partly) worse than in Salome 7.2.0 X-Git-Tag: V7_4_0rc1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=67c76bbea8f0110691a64d70dadd7c2c84330bd7;p=plugins%2Fnetgenplugin.git Meshing in Salome 7.3.0 (partly) worse than in Salome 7.2.0 http://www.salome-platform.org/forum/forum_12/177188362 Speed-up a bit and fix a bug that _hypParameters in not nullified in CheckHypothesis() --- diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index b517fdb..9ef97d7 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -128,6 +128,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh, _hypMaxElementArea = 0; _hypLengthFromEdges = 0; _hypQuadranglePreference = 0; + _hypParameters = 0; _progressByTic = -1; const list& hyps = GetUsedHypothesis(aMesh, aShape, false); @@ -324,26 +325,34 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, if ( problem && !problem->IsOK() ) return error( problem ); - // limit element size near existing segments - TopTools_IndexedMapOfShape edgeMap, faceMap; - TopExp::MapShapes( aMesh.GetShapeToMesh(), TopAbs_EDGE, edgeMap ); - for ( int iE = 1; iE <= edgeMap.Extent(); ++iE ) + if ( iLoop == 0 ) { - const TopoDS_Shape& edge = edgeMap( iE ); - if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge )) || - helper.IsSubShape( edge, aShape )) - continue; - SMESHDS_SubMesh* smDS = aMesh.GetMeshDS()->MeshElements( edge ); - if ( !smDS ) continue; - SMDS_ElemIteratorPtr segIt = smDS->GetElements(); - while ( segIt->more() ) + // limit element size near existing segments + TopTools_IndexedMapOfShape edgeMap; + PShapeIteratorPtr solidIt = helper.GetAncestors( F, aMesh, TopAbs_SOLID ); + while ( const TopoDS_Shape* solid = solidIt->next() ) { - const SMDS_MeshElement* seg = segIt->next(); - SMESH_TNodeXYZ n1 = seg->GetNode(0); - SMESH_TNodeXYZ n2 = seg->GetNode(1); - gp_XYZ p = 0.5 * ( n1 + n2 ); - netgen::Point3d pi(p.X(), p.Y(), p.Z()); - ngMesh->RestrictLocalH( pi, Max(( n1 - n2 ).Modulus(), netgen::mparam.minh )); + TopExp_Explorer eExp( *solid, TopAbs_EDGE ); + for ( ; eExp.More(); eExp.Next() ) + { + const TopoDS_Shape& edge = eExp.Current(); + if (( SMESH_Algo::isDegenerated( TopoDS::Edge( edge ))) || + ( helper.IsSubShape( edge, aShape )) || + ( !edgeMap.Add( edge ))) + continue; + SMESHDS_SubMesh* smDS = aMesh.GetMeshDS()->MeshElements( edge ); + if ( !smDS ) continue; + SMDS_ElemIteratorPtr segIt = smDS->GetElements(); + while ( segIt->more() ) + { + const SMDS_MeshElement* seg = segIt->next(); + SMESH_TNodeXYZ n1 = seg->GetNode(0); + SMESH_TNodeXYZ n2 = seg->GetNode(1); + gp_XYZ p = 0.5 * ( n1 + n2 ); + netgen::Point3d pi(p.X(), p.Y(), p.Z()); + ngMesh->RestrictLocalH( pi, Max(( n1 - n2 ).Modulus(), netgen::mparam.minh )); + } + } } } @@ -383,7 +392,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, error(str); err = 1; } - if ( err /*&& isMESHCONST_ANALYSE*/ && iLoop == 0 ) + if ( err /*&& !isMESHCONST_ANALYSE*/ && iLoop == 0 ) { netgen::mparam.minh = netgen::mparam.maxh; netgen::mparam.maxh = 0; @@ -391,14 +400,14 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, { StdMeshers_FaceSidePtr wire = wires[ iW ]; const vector& uvPtVec = wire->GetUVPtStruct(); - for ( size_t iP = 0; iP < uvPtVec.size(); ++iP ) + for ( size_t iP = 1; iP < uvPtVec.size(); ++iP ) { - netgen::Point3d p( uvPtVec[iP].node->X(), - uvPtVec[iP].node->Y(), - uvPtVec[iP].node->Z()); - double size = ngMesh->GetH( p ); + SMESH_TNodeXYZ p( uvPtVec[ iP ].node ); + netgen::Point3d np( p.X(),p.Y(),p.Z()); + double segLen = p.Distance( uvPtVec[ iP-1 ].node ); + double size = ngMesh->GetH( np ); netgen::mparam.minh = Min( netgen::mparam.minh, size ); - netgen::mparam.maxh = Max( netgen::mparam.maxh, size ); + netgen::mparam.maxh = Max( netgen::mparam.maxh, segLen ); } } //cerr << "min " << netgen::mparam.minh << " max " << netgen::mparam.maxh << endl;