PR: tools for crack meshing : when importing a mesh, use a tolerance relative to the edge size.

This commit is contained in:
prascle 2012-09-04 14:00:14 +00:00
parent 1f2c6e16a4
commit 16fcf4dea0

View File

@ -638,7 +638,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
// get nodes on vertices
list < SMESH_TNodeXYZ > vertexNodes;
list < SMESH_TNodeXYZ >::iterator vNIt;
list < SMESH_TNodeXYZ >::iterator vNIt;
TopExp_Explorer vExp( theShape, TopAbs_VERTEX );
for ( ; vExp.More(); vExp.Next() )
{
@ -670,7 +670,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
SMDS_ElemIteratorPtr srcElems = srcGroup->GetElements();
vector<const SMDS_MeshNode*> newNodes;
SMDS_MeshNode *tmpNode = helper.AddNode(0,0,0);
double u;
double u = 0;
while ( srcElems->more() ) // loop on group contents
{
const SMDS_MeshElement* edge = srcElems->next();
@ -678,6 +678,10 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
newNodes.resize( edge->NbNodes() );
newNodes.back() = 0;
SMDS_MeshElement::iterator node = edge->begin_nodes();
SMESH_TNodeXYZ a(edge->GetNode(0));
// --- define a tolerance relative to the length of an edge
double mytol = a.Distance(edge->GetNode(edge->NbNodes()-1))/25;
//MESSAGE("mytol = " << mytol);
for ( unsigned i = 0; i < newNodes.size(); ++i, ++node )
{
TNodeNodeMap::iterator n2nIt = n2n->insert( make_pair( *node, (SMDS_MeshNode*)0 )).first;
@ -701,7 +705,7 @@ bool StdMeshers_Import_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & th
{
// find out if node lies on theShape
tmpNode->setXYZ( (*node)->X(), (*node)->Y(), (*node)->Z());
if ( helper.CheckNodeU( geomEdge, tmpNode, u, 10 * edgeTol, /*force=*/true ))
if ( helper.CheckNodeU( geomEdge, tmpNode, u, mytol, /*force=*/true ))
{
SMDS_MeshNode* newNode = tgtMesh->AddNode( (*node)->X(), (*node)->Y(), (*node)->Z());
n2nIt->second = newNode;