return true; // done
}
}
- if ( IsClosedEdge( edge1 ) && IsClosedEdge( edge2 ))
+ if ( SMESH_MesherHelper::IsClosedEdge( edge1 ) &&
+ SMESH_MesherHelper::IsClosedEdge( edge2 ))
{
// TODO: find out a proper orientation (is it possible?)
InsertAssociation( edge1, edge2, theMap, bidirect); // insert with a proper orientation
TopTools_IndexedMapOfShape vMap1, vMap2;
TopExp::MapShapes( theShape1, TopAbs_VERTEX, vMap1 );
TopExp::MapShapes( theShape2, TopAbs_VERTEX, vMap2 );
+ TopoDS_Vertex VV1[2], VV2[2];
if ( vMap1.Extent() != vMap2.Extent() )
RETURN_BAD_RESULT("Different nb of vertices");
return FindSubShapeAssociation( theShape1, theMesh1, theShape2, theMesh2, theMap);
}
+ // Try to associate by common vertices of an edge
+ for ( int i = 1; i <= vMap1.Extent(); ++i )
+ {
+ const TopoDS_Shape& v1 = vMap1(i);
+ if ( vMap2.Contains( v1 ))
+ {
+ // find an egde sharing v1 and sharing at the same time another common vertex
+ PShapeIteratorPtr edgeIt = SMESH_MesherHelper::GetAncestors( v1, *theMesh1, TopAbs_EDGE);
+ bool edgeFound = false;
+ while ( edgeIt->more() && !edgeFound )
+ {
+ TopoDS_Edge edge = TopoDS::Edge( edgeIt->next()->Oriented(TopAbs_FORWARD));
+ TopExp::Vertices(edge, VV1[0], VV1[1]);
+ if ( !VV1[0].IsSame( VV1[1] ))
+ edgeFound = ( vMap2.Contains( VV1[ v1.IsSame(VV1[0]) ? 1:0]));
+ }
+ if ( edgeFound )
+ {
+ InsertAssociation( VV1[0], VV1[0], theMap, bidirect );
+ InsertAssociation( VV1[1], VV1[1], theMap, bidirect );
+ if (FindSubShapeAssociation( theShape1, theMesh1, theShape2, theMesh2, theMap ))
+ return true;
+ }
+ }
+ }
+
// Find transformation to make the shapes be of similar size at same location
Bnd_Box box[2];
// Find 2 closest vertices
- TopoDS_Vertex VV1[2], VV2[2];
// get 2 linked vertices of shape 1 not belonging to an inner wire of a face
TopoDS_Shape edge = theShape1;
TopExp_Explorer expF( theShape1, TopAbs_FACE ), expE;
edge.Nullify();
TopoDS_Shape wire = OuterShape( TopoDS::Face( expF.Current() ), TopAbs_WIRE );
for ( expE.Init( wire, TopAbs_EDGE ); edge.IsNull() && expE.More(); expE.Next() )
- if ( !IsClosedEdge( TopoDS::Edge( expE.Current() )))
+ if ( !SMESH_MesherHelper::IsClosedEdge( TopoDS::Edge( expE.Current() )))
edge = expE.Current();
if ( !edge.IsNull() )
break;
} else if (edge.ShapeType() != TopAbs_EDGE) { // no faces
edge.Nullify();
for ( expE.Init( theShape1, TopAbs_EDGE ); edge.IsNull() && expE.More(); expE.Next() )
- if ( !IsClosedEdge( TopoDS::Edge( expE.Current() )))
+ if ( !SMESH_MesherHelper::IsClosedEdge( TopoDS::Edge( expE.Current() )))
edge = expE.Current();
}
if ( edge.IsNull() || edge.ShapeType() != TopAbs_EDGE )
if ( hasNodesOnEdge )
{
int nbNodeToGet = 1;
- if ( IsClosedEdge( edge1 ) || IsClosedEdge( edge2 ) )
+ if ( helper1.IsClosedEdge( edge1 ) || helper2.IsClosedEdge( edge2 ) )
nbNodeToGet = 2;
for ( int is2 = 0; is2 < 2; ++is2 )
{
const SMDS_MeshElement* f = ( iF ? f2 : f1 );
for ( int i = 0; !notSeamNode[ iF ] && i < f->NbNodes(); ++i ) {
const SMDS_MeshNode* node = f->GetNode( i );
- if ( !helper->IsSeamShape( node->GetPosition()->GetShapeId() ))
+ if ( !helper->IsSeamShape( node->getshapeId() ))
notSeamNode[ iF ] = node;
}
}
while ( nIt->more() ) {
const SMDS_MeshNode* node = nIt->next();
const SMDS_EdgePosition* pos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition());
pos2nodes.insert( make_pair( pos->GetUParameter(), node ));
}
if ( pos2nodes.size() != edgeSM->NbNodes() )
return true;
}
-//================================================================================
-/*!
- * \brief Check if the first and last vertices of an edge are the same
- * \param anEdge - the edge to check
- * \retval bool - true if same
- */
-//================================================================================
-
-bool StdMeshers_ProjectionUtils::IsClosedEdge( const TopoDS_Edge& anEdge )
-{
- return TopExp::FirstVertex( anEdge ).IsSame( TopExp::LastVertex( anEdge ));
-}
-
//================================================================================
/*!
* \brief Return any subshape of a face belonging to the outer wire