-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014 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
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
if ( !_importMeshSubDS ) return;
SMDS_ElemIteratorPtr eIt = _importMeshSubDS->GetElements();
while ( eIt->more() )
- meshDS->RemoveFreeElement( eIt->next(), _importMeshSubDS, /*fromGroups=*/false );
+ meshDS->RemoveFreeElement( eIt->next(), 0, /*fromGroups=*/false );
SMDS_NodeIteratorPtr nIt = _importMeshSubDS->GetNodes();
while ( nIt->more() )
- meshDS->RemoveFreeNode( nIt->next(), _importMeshSubDS, /*fromGroups=*/false );
+ meshDS->RemoveFreeNode( nIt->next(), 0, /*fromGroups=*/false );
+ _importMeshSubDS->Clear();
_n2n.clear();
_e2e.clear();
}
switch ( sm->GetSubShape().ShapeType() )
{
case TopAbs_EDGE:
+ if ( SMESH_Algo::isDegenerated( TopoDS::Edge( sm->GetSubShape() )))
+ continue;
case TopAbs_FACE:
_subM.insert( sm );
if ( !sm->IsEmpty() )
const SMESH_Hypothesis* hyp);
void removeSubmesh( SMESH_subMesh* sm, _ListenerData* data );
void clearSubmesh ( SMESH_subMesh* sm, _ListenerData* data, bool clearAllSub );
+ void clearN2N ( SMESH_Mesh* tgtMesh );
// mark sm as missing src hyp with valid groups
static void waitHypModification(SMESH_subMesh* sm)
}
}
//--------------------------------------------------------------------------------
+ /*!
+ * \brief Clear _ImportData::_n2n.
+ * _n2n is usefull within one mesh.Compute() only
+ */
+ void _Listener::clearN2N( SMESH_Mesh* tgtMesh )
+ {
+ list< _ImportData >& dList = get()->_tgtMesh2ImportData[tgtMesh];
+ list< _ImportData >::iterator d = dList.begin();
+ for ( ; d != dList.end(); ++d )
+ d->_n2n.clear();
+ }
+ //--------------------------------------------------------------------------------
/*!
* \brief Clear submeshes and remove imported mesh and/or groups if necessary
* \param sm - cleared submesh
default:;
}
}
+ if ( !data->mySubMeshes.empty() )
+ clearN2N( data->mySubMeshes.front()->GetFather() );
}
else // event of Import submesh
{
d->_computedSubM.insert( *smIt);
}
}
+ // Clear _ImportData::_n2n if it's no more useful, i.e. when
+ // the event is not within mesh.Compute()
+ if ( SMESH_subMesh::ALGO_EVENT == eventType )
+ clearN2N( subMesh->GetFather() );
}
}
aBuilder.MakeCompound( comp );
shapeForSrcMesh = comp;
for ( int iSub = 0; iSub < nbSubShapes; ++iSub )
- aBuilder.Add( comp, pseudoSubShapes( subIndex+iSub ));
+ if ( subIndex+iSub <= pseudoSubShapes.Extent() )
+ aBuilder.Add( comp, pseudoSubShapes( subIndex+iSub ));
TopExp_Explorer vExp( tgtMeshDS->ShapeToMesh(), TopAbs_VERTEX );
aBuilder.Add( comp, vExp.Current() );
}
{
if ( !_sourceHyp ) return false;
- const vector<SMESH_Group*>& srcGroups = _sourceHyp->GetGroups();
+ //MESSAGE("---------> StdMeshers_Import_1D::Compute");
+ const vector<SMESH_Group*>& srcGroups = _sourceHyp->GetGroups(/*loaded=*/true);
if ( srcGroups.empty() )
return error("Invalid source groups");
{
_gen->Compute(theMesh,v,/*anUpward=*/true);
n = SMESH_Algo::VertexNode( v, tgtMesh );
+ //MESSAGE("_gen->Compute " << n);
if ( !n ) return false; // very strange
}
vertexNodes.push_back( SMESH_TNodeXYZ( n ));
+ //MESSAGE("SMESH_Algo::VertexNode " << n->GetID() << " " << n->X() << " " << n->Y() << " " << n->Z() );
}
// import edges from groups
SMDS_ElemIteratorPtr srcElems = srcGroup->GetElements();
vector<const SMDS_MeshNode*> newNodes;
SMDS_MeshNode *tmpNode = helper.AddNode(0,0,0);
- double u = 0;
+ double u = 0.314159; // "random" value between 0 and 1, avoid 0 and 1, false detection possible on edge restrictions
while ( srcElems->more() ) // loop on group contents
{
const SMDS_MeshElement* edge = srcElems->next();
// find or create nodes of a new edge
newNodes.resize( edge->NbNodes() );
+ //MESSAGE("edge->NbNodes " << 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;
+ //mytol = max(1.E-5, 10*edgeTol); // too strict and not necessary
//MESSAGE("mytol = " << mytol);
for ( unsigned i = 0; i < newNodes.size(); ++i, ++node )
{
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 <<" "<<vNIt->X()<<" "<<vNIt->Y()<<" "<<vNIt->Z());
(*n2nIt).second = vNIt->_node;
vertexNodes.erase( vNIt );
break;
}
+ else if ( vNIt->SquareDistance( *node ) < 10*checktol)
+ MESSAGE("SquareDistance missed" << vNIt->SquareDistance( *node ) << " checktol " << checktol <<" "<<vNIt->X()<<" "<<vNIt->Y()<<" "<<vNIt->Z());
}
if ( !n2nIt->second )
{
// find out if node lies on theShape
+ //double dxyz[4];
tmpNode->setXYZ( (*node)->X(), (*node)->Y(), (*node)->Z());
- if ( helper.CheckNodeU( geomEdge, tmpNode, u, mytol, /*force=*/true ))
+ if ( helper.CheckNodeU( geomEdge, tmpNode, u, mytol, /*force=*/true)) // , dxyz )) // dxyz used for debug purposes
{
SMDS_MeshNode* newNode = tgtMesh->AddNode( (*node)->X(), (*node)->Y(), (*node)->Z());
n2nIt->second = newNode;
tgtMesh->SetNodeOnEdge( newNode, shapeID, u );
+ //MESSAGE("u=" << u << " " << newNode->X()<< " " << newNode->Y()<< " " << newNode->Z());
+ //MESSAGE("d=" << dxyz[0] << " " << dxyz[1] << " " << dxyz[2] << " " << dxyz[3]);
}
}
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 " << newNodes[0]->GetID() << " " << newNodes[1]->GetID());
tgtMesh->SetMeshElementOnShape( newEdge, shapeID );
e2e->insert( make_pair( edge, newEdge ));
}
e2e = &iData->_e2e;
if ( iData->_copyMeshSubM.empty() )
{
- n2n->clear();
+ // n2n->clear(); -- for sharing nodes on EDGEs
e2e->clear();
}
}