From: eap Date: Mon, 25 Apr 2011 15:14:58 +0000 (+0000) Subject: 0020452: EDF 1056 SMESH : 2D Projection Issue /regresion/ X-Git-Tag: V6_3_0b1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eab620651d340735155f36f18436668333353557;p=plugins%2Fnetgenplugin.git 0020452: EDF 1056 SMESH : 2D Projection Issue /regresion/ avoid sharp change of Local H caused by short edges --- diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index 883823a..ff7d796 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -169,7 +169,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh, */ //================================================================================ -static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, +static TError addSegmentsToMesh(netgen::Mesh& ngMesh, OCCGeometry& geom, const TSideVector& wires, SMESH_MesherHelper& helper, @@ -225,6 +225,11 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, const vector& uvPtVec = wire->GetUVPtStruct(); const int nbSegments = wire->NbPoints() - 1; + // compute length of every segment + vector segLen( nbSegments ); + for ( int i = 0; i < nbSegments; ++i ) + segLen[i] = SMESH_TNodeXYZ( uvPtVec[ i ].node ).Distance( uvPtVec[ i+1 ].node ); + int edgeID = 1, posID = -2; bool isInternalWire = false; for ( int i = 0; i < nbSegments; ++i ) // loop on segments @@ -295,10 +300,16 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, ngMesh.AddSegment (seg); { + // restrict size of elements near the segment netgen::Point3d ngP1(n->X(), n->Y(), n->Z()); n = uvPtVec[ i+1 ].node; netgen::Point3d ngP2(n->X(), n->Y(), n->Z()); - ngMesh.RestrictLocalH( netgen::Center( ngP1,ngP2), Dist(ngP1,ngP2)); + // 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 ); + double avgH = ( segLen[ iPrev ] + segLen[ i ] + segLen[ iNext ]) / 3; + ngMesh.RestrictLocalH( netgen::Center( ngP1,ngP2), avgH ); } #ifdef DUMP_SEGMENTS cout << "Segment: " << seg.edgenr << endl @@ -426,11 +437,9 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, if ( edgeLength < DBL_MIN ) edgeLength = occgeo.GetBoundingBox().Diam(); - //cout << " edgeLength = " << edgeLength << endl; - netgen::mparam.maxh = edgeLength; netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0; - //ngMesh->SetGlobalH ( edgeLength ); + netgen::mparam.grading = 0.7; // very coarse mesh by default } // ------------------------- @@ -446,7 +455,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, ngMesh->SetGlobalH (netgen::mparam.maxh); vector< const SMDS_MeshNode* > nodeVec; - problem = AddSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec ); + problem = addSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec ); if ( problem && !problem->IsOK() ) return error( problem );