+ // Check if node projection to a face is needed
+ Bnd_B2d uvBox;
+ SMDS_ElemIteratorPtr faceIt = srcSubMesh->GetSubMeshDS()->GetElements();
+ int nbFaceNodes = 0;
+ for ( ; nbFaceNodes < 3 && faceIt->more(); ) {
+ const SMDS_MeshElement* face = faceIt->next();
+ SMDS_ElemIteratorPtr nodeIt = face->nodesIterator();
+ while ( nodeIt->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_FACE ) {
+ nbFaceNodes++;
+ uvBox.Add( helper.GetNodeUV( srcFace, node ));
+ }
+ }
+ }
+ const bool toProjectNodes =
+ ( nbFaceNodes > 0 && ( uvBox.IsVoid() || uvBox.SquareExtent() < DBL_MIN ));
+
+ // Load pattern from the source face
+ SMESH_Pattern mapper;
+ mapper.Load( srcMesh, srcFace, toProjectNodes );
+ if ( mapper.GetErrorCode() != SMESH_Pattern::ERR_OK )
+ return error(COMPERR_BAD_INPUT_MESH,"Can't load mesh pattern from the source face");
+
+ // Find the first target vertex corresponding to first vertex of the <mapper>
+ // and <theReverse> flag needed to call mapper.Apply()
+
+ TopoDS_Vertex srcV1 = TopoDS::Vertex( mapper.GetSubShape( 1 ));
+ if ( srcV1.IsNull() )
+ RETURN_BAD_RESULT("Mesh is not bound to the face");
+ if ( !shape2ShapeMap.IsBound( srcV1, /*isSrc=*/true ))
+ RETURN_BAD_RESULT("Not associated vertices, srcV1 " << srcV1.TShape().operator->() );
+ TopoDS_Vertex tgtV1 = TopoDS::Vertex( shape2ShapeMap( srcV1, /*isSrc=*/true ));
+
+ if ( !SMESH_MesherHelper::IsSubShape( srcV1, srcFace ))
+ RETURN_BAD_RESULT("Wrong srcV1 " << srcV1.TShape().operator->());
+ if ( !SMESH_MesherHelper::IsSubShape( tgtV1, tgtFace ))
+ RETURN_BAD_RESULT("Wrong tgtV1 " << tgtV1.TShape().operator->());
+
+ // try to find out orientation by order of edges
+ bool reverse = false;
+ list< TopoDS_Edge > tgtEdges, srcEdges;
+ list< int > nbEdgesInWires;
+ SMESH_Block::GetOrderedEdges( tgtFace, tgtV1, tgtEdges, nbEdgesInWires);
+ SMESH_Block::GetOrderedEdges( srcFace, srcV1, srcEdges, nbEdgesInWires);
+ if ( nbEdgesInWires.front() > 1 ) // possible to find out
+ {
+ TopoDS_Edge srcE1 = srcEdges.front(), tgtE1 = tgtEdges.front();
+ TopoDS_Shape srcE1bis = shape2ShapeMap( tgtE1 );
+ reverse = ( ! srcE1.IsSame( srcE1bis ));
+ }
+ else if ( nbEdgesInWires.front() == 1 )
+ {
+ // TODO::Compare orientation of curves in a sole edge
+ //RETURN_BAD_RESULT("Not implemented case");
+ }
+ else
+ {
+ RETURN_BAD_RESULT("Bad result from SMESH_Block::GetOrderedEdges()");
+ }