X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_FaceSide.cxx;h=9a3ba489342b069252b3b4a63d99ef0cb7881b93;hb=0a447a3701c9274833f0964516261bcdfe7bbbb5;hp=9f5929e3681a9a4bcb5b2957c64bf752ac1781f6;hpb=55290963c776b86cb15aea30629389d503c1d3b9;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index 9f5929e36..9a3ba4893 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.cxx +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 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 @@ -32,10 +32,11 @@ #include "SMESHDS_Mesh.hxx" #include "SMESHDS_SubMesh.hxx" #include "SMESH_Algo.hxx" +#include "SMESH_Block.hxx" +#include "SMESH_ComputeError.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_MeshEditor.hxx" #include "SMESH_MesherHelper.hxx" -#include "SMESH_ComputeError.hxx" -#include "SMESH_Block.hxx" #include #include @@ -88,13 +89,13 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, */ //================================================================================ -StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, - std::list& theEdges, - SMESH_Mesh* theMesh, - const bool theIsForward, - const bool theIgnoreMediumNodes, - SMESH_MesherHelper* theFaceHelper, - SMESH_ProxyMesh::Ptr theProxyMesh) +StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, + const std::list& theEdges, + SMESH_Mesh* theMesh, + const bool theIsForward, + const bool theIgnoreMediumNodes, + SMESH_MesherHelper* theFaceHelper, + SMESH_ProxyMesh::Ptr theProxyMesh) { int nbEdges = theEdges.size(); myEdge.resize ( nbEdges ); @@ -125,7 +126,7 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS(); int nbDegen = 0; - std::list::iterator edge = theEdges.begin(); + std::list::const_iterator edge = theEdges.begin(); for ( int index = 0; edge != theEdges.end(); ++index, ++edge ) { int i = theIsForward ? index : nbEdges-index-1; @@ -166,12 +167,55 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, myC3dAdaptor[i].Load( C3d, 0, 0.5 * BRep_Tool::Tolerance( V )); } } + else if ( myEdgeLength[i] > DBL_MIN ) + { + Handle(Geom_Curve) C3d = BRep_Tool::Curve(myEdge[i],myFirst[i], myLast[i] ); + myC3dAdaptor[i].Load( C3d, myFirst[i], myLast[i] ); + if ( myEdge[i].Orientation() == TopAbs_REVERSED ) + std::swap( myFirst[i], myLast[i] ); + } + // reverse a proxy sub-mesh if ( !theIsForward ) reverseProxySubmesh( myEdge[i] ); } // loop on edges + // orient seam edges (#19982) + const double tol = Precision::Confusion(); + if ( NbEdges() > 1 && !myC2d[0].IsNull() ) + for ( int i = 0; i < NbEdges(); ++i ) + { + int iPrev = SMESH_MesherHelper::WrapIndex( i - 1, NbEdges() ); + if ( !BRep_Tool::IsClosed( myEdge[i], myFace ) || !myC2d[iPrev] ) + continue; + gp_Pnt2d pLastPrev = myC2d[iPrev]->Value( myLast[iPrev] ); + gp_Pnt2d pFirst = myC2d[i]->Value( myFirst[i] ); + if ( pLastPrev.IsEqual( pFirst, tol )) + continue; // OK + pFirst = myC2d[i]->Value( myLast[i] ); + if ( pLastPrev.IsEqual( pFirst, tol )) + { + std::swap( myFirst[i], myLast[i] ); + continue; + } + TopoDS_Edge E = myEdge[i]; + E.Reverse(); + Handle(Geom2d_Curve) c2dRev = BRep_Tool::CurveOnSurface( E, myFace, myFirst[i], myLast[i] ); + pFirst = c2dRev->Value( myFirst[i] ); + if ( pLastPrev.IsEqual( pFirst, tol )) + { + myC2d[i] = c2dRev; + continue; + } + pFirst = c2dRev->Value( myLast[i] ); + if ( pLastPrev.IsEqual( pFirst, tol )) + { + myC2d[i] = c2dRev; + std::swap( myFirst[i], myLast[i] ); + } + } + // count nodes and segments NbPoints( /*update=*/true ); @@ -441,6 +485,7 @@ const std::vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXCons for ( size_t j = 0; j < u2nodeVec.size(); ++j ) u2node.insert( u2node.end(), u2nodeVec[j] ); } + continue; } // loop on myEdge's // Add 2nd VERTEX node for a last EDGE @@ -541,8 +586,7 @@ const std::vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXCons uvPt.normParam = u_node->first; uvPt.x = uvPt.y = uvPt.normParam; // -- U ---------------------------------------------- - const SMDS_EdgePosition* epos = - dynamic_cast(uvPt.node->GetPosition()); + SMDS_EdgePositionPtr epos = uvPt.node->GetPosition(); if ( epos && uvPt.node->getshapeId() == myEdgeID[iE] ) { uvPt.param = epos->GetUParameter(); } @@ -657,7 +701,7 @@ std::vector StdMeshers_FaceSide::GetOrderedNodes(int theEd iE = theEdgeInd % NbEdges(); iEnd = iE + 1; } - for ( iE = 0; iE < iEnd; ++iE ) + for ( ; iE < iEnd; ++iE ) { double prevNormPar = ( iE == 0 ? 0 : myNormPar[ iE-1 ]); // normalized param @@ -791,7 +835,7 @@ bool StdMeshers_FaceSide::GetEdgeNodes(size_t i, if ( mesh->HasModificationsToDiscard() ) // check nb of nodes on the EDGE sub-mesh { int iQuad = sm->NbElements() ? sm->GetElements()->next()->IsQuadratic() : 0; - int nbExpect = sm->NbElements() - 1 + iQuad * sm->NbElements(); + smIdType nbExpect = sm->NbElements() - 1 + iQuad * sm->NbElements(); if ( nbExpect != sm->NbNodes() ) // some nodes are moved from the EDGE by MergeNodes() { // add nodes of all segments @@ -1001,7 +1045,7 @@ void StdMeshers_FaceSide::SetIgnoreMediumNodes(bool toIgnore) // since creation of this side //======================================================================= -int StdMeshers_FaceSide::NbPoints(const bool update) const +smIdType StdMeshers_FaceSide::NbPoints(const bool update) const { if ( !myPoints.empty() ) return myPoints.size(); @@ -1068,7 +1112,7 @@ int StdMeshers_FaceSide::NbPoints(const bool update) const // since creation of this side //======================================================================= -int StdMeshers_FaceSide::NbSegments(const bool update) const +smIdType StdMeshers_FaceSide::NbSegments(const bool update) const { return NbPoints( update ), myNbSegments; } @@ -1132,6 +1176,8 @@ void StdMeshers_FaceSide::dump(const char* msg) const MESSAGE_ADD ( "\tF: "<myLast[i] ? -1. : 1.); + double aLen3dU = r * myEdgeLength[i] * ( myFirst[i] > myLast[i] ? -1. : 1. ); GCPnts_AbscissaPoint AbPnt ( const_cast( myC3dAdaptor[i]), aLen3dU, myFirst[i] ); if( AbPnt.IsDone() ) {