-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013 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
_ListenerData(const StdMeshers_ImportSource1D* h, _ListenerDataType type=SRC_HYP):
SMESH_subMeshEventListenerData(/*isDeletable=*/true), _srcHyp(h)
{
- myType = type;
+ myType = type;
}
};
//================================================================================
TopExp::MapShapes( SMESH_Mesh::PseudoShape(), pseudoSubShapes );
// index of pseudoSubShapes corresponding to srcMeshDS
- int subIndex = srcMeshDS->GetPersistentId() % pseudoSubShapes.Extent();
+ int subIndex = 1 + srcMeshDS->GetPersistentId() % pseudoSubShapes.Extent();
int nbSubShapes = 1 + srcMeshDS->GetPersistentId() / pseudoSubShapes.Extent();
// try to find already present shapeForSrcMesh
//=============================================================================
/*!
- * Import elements from the other mesh
+ * Import elements from the other mesh
*/
//=============================================================================
{
if ( !_sourceHyp ) return false;
- const vector<SMESH_Group*>& srcGroups = _sourceHyp->GetGroups();
+ const vector<SMESH_Group*>& srcGroups = _sourceHyp->GetGroups(/*loaded=*/true);
if ( srcGroups.empty() )
return error("Invalid source groups");
subShapeIDs.insert( shapeID );
// get nodes on vertices
- list < SMESH_TNodeXYZ > vertexNodes;
- list < SMESH_TNodeXYZ >::iterator vNIt;
+ list < SMESH_TNodeXYZ > vertexNodes;
+ list < SMESH_TNodeXYZ >::iterator vNIt;
TopExp_Explorer vExp( theShape, TopAbs_VERTEX );
for ( ; vExp.More(); vExp.Next() )
{
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();
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;
else
{
// find an existing vertex node
+ double checktol = max(1.E-10, 10*edgeTol*edgeTol);
for ( vNIt = vertexNodes.begin(); vNIt != vertexNodes.end(); ++vNIt)
- if ( vNIt->SquareDistance( *node ) < 10 * edgeTol * edgeTol)
+ if ( vNIt->SquareDistance( *node ) < checktol)
{
+ //MESSAGE("SquareDistance " << vNIt->SquareDistance( *node ) << " checktol " << checktol);
(*n2nIt).second = vNIt->_node;
vertexNodes.erase( vNIt );
break;
{
// 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;
tgtMesh->SetNodeOnEdge( newNode, shapeID, u );
+ //MESSAGE("u=" << u);
}
}
if ( !(newNodes[i] = n2nIt->second ))
break;
}
if ( !newNodes.back() )
+ {
+ //MESSAGE("not all nodes of edge lie on theShape");
continue; // not all nodes of edge lie on theShape
+ }
// make a new edge
SMDS_MeshElement * newEdge;
newEdge = tgtMesh->AddEdge( newNodes[0], newNodes[1], newNodes[2] );
else
newEdge = tgtMesh->AddEdge( newNodes[0], newNodes[1]);
+ //MESSAGE("add Edge");
tgtMesh->SetMeshElementOnShape( newEdge, shapeID );
e2e->insert( make_pair( edge, newEdge ));
}
*/
//=============================================================================
-void StdMeshers_Import_1D::setEventListener(SMESH_subMesh* subMesh,
+void StdMeshers_Import_1D::setEventListener(SMESH_subMesh* subMesh,
StdMeshers_ImportSource1D* sourceHyp)
{
if ( sourceHyp )
e2e = &iData->_e2e;
if ( iData->_copyMeshSubM.empty() )
{
- n2n->clear();
+ // n2n->clear(); -- for sharing nodes on EDGEs
e2e->clear();
}
}