X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Quadrangle_2D.cxx;h=ef472e49aedb00e20e3801668428cf71439ef8d4;hb=86ca5611705a674ccb26c7ea2176cf518bec24f5;hp=989a2d50138e93d527ca830c79420a78ea5526e6;hpb=c98d9fcd7f02c1f1f5c24dd3e709ed75228d66c4;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 989a2d501..ef472e49a 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -30,6 +30,7 @@ #include "SMDS_FacePosition.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" +#include "SMESHDS_Mesh.hxx" #include "SMESH_Block.hxx" #include "SMESH_Comment.hxx" #include "SMESH_Gen.hxx" @@ -93,7 +94,6 @@ StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, myQuadType(QUAD_STANDARD), myHelper( NULL ) { - MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D"); _name = "Quadrangle_2D"; _shapeType = (1 << TopAbs_FACE); _compatibleHypothesis.push_back("QuadrangleParams"); @@ -110,7 +110,6 @@ StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D() { - MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D"); } //============================================================================= @@ -160,7 +159,7 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis } else if (strcmp("TrianglePreference", aHyp->GetName()) == 0){ isFirstParams = false; - myTrianglePreference = true; + myTrianglePreference = true; } else { isFirstParams = false; @@ -173,18 +172,18 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis if (isFirstParams) { if (strcmp("QuadranglePreference", aHyp->GetName()) == 0) { myQuadranglePreference = true; - myTrianglePreference = false; + myTrianglePreference = false; myQuadType = QUAD_STANDARD; } else if (strcmp("TrianglePreference", aHyp->GetName()) == 0){ myQuadranglePreference = false; - myTrianglePreference = true; + myTrianglePreference = true; myQuadType = QUAD_STANDARD; } } - else { - const StdMeshers_QuadrangleParams* aHyp2 = - (const StdMeshers_QuadrangleParams*)aHyp; + else if (const StdMeshers_QuadrangleParams* aHyp2 = + dynamic_cast( aHyp )) + { myTriaVertexID = aHyp2->GetTriaVertex(); if (!myQuadranglePreference && !myTrianglePreference) { // priority of hypos @@ -205,7 +204,7 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis //============================================================================= /*! - * + * */ //============================================================================= @@ -231,7 +230,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, myNeedSmooth = false; myCheckOri = false; - FaceQuadStruct::Ptr quad = CheckNbEdges( aMesh, F, /*considerMesh=*/true ); + FaceQuadStruct::Ptr quad = CheckNbEdges( aMesh, F, /*considerMesh=*/true, myHelper ); if (!quad) return false; myQuadList.clear(); @@ -492,7 +491,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, int nbright = (int) uv_e1.size(); int nbleft = (int) uv_e3.size(); - if (quad->nbNodeOut(0) && nbvertic == 2) // this should not occure + if (quad->nbNodeOut(0) && nbvertic == 2) // this should not occur { // Down edge is out // @@ -519,7 +518,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, // for each node of the down edge find nearest node // in the first row of the regular grid and link them for (i = 0; i < stop; i++) { - const SMDS_MeshNode *a, *b, *c, *d; + const SMDS_MeshNode *a, *b, *c=0, *d; a = uv_e0[i].node; b = uv_e0[i + 1].node; gp_Pnt pb (b->X(), b->Y(), b->Z()); @@ -533,6 +532,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, } else { // find in the grid node c, nearest to the b + c = 0; double mind = RealLast(); for (int k = g; k <= iup; k++) { @@ -608,8 +608,8 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, int stop = 0; if ( quad->side[3].grid->Edge(0).IsNull() ) // left side is simulated one { - // quad divided at I but not at J, as nbvertic==nbright==2 - stop++; // we stop at a second node + if ( nbright == 2 ) // quad divided at I but not at J (2D_mesh_QuadranglePreference_01/B1) + stop++; // we stop at a second node } else { @@ -656,7 +656,8 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, } // for each node of the up edge find nearest node // in the first row of the regular grid and link them - for ( ; i > stop; i--) { + for ( ; i > stop; i--) + { a = uv_e2[i].node; b = uv_e2[i - 1].node; gp_Pnt pb = SMESH_TNodeXYZ( b ); @@ -720,7 +721,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, } // right or left boundary quadrangles - if (quad->nbNodeOut( QUAD_RIGHT_SIDE ) && nbhoriz == 2) // this should not occure + if (quad->nbNodeOut( QUAD_RIGHT_SIDE ) && nbhoriz == 2) // this should not occur { int g = 0; // last processed node in the grid int stop = nbright - 1; @@ -734,8 +735,9 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, gp_Pnt pb (b->X(), b->Y(), b->Z()); // find node c in the grid, nearest to the b + c = 0; int near = g; - if (i == stop - 1) { // up bondary reached + if (i == stop - 1) { // up boundary reached c = quad->uv_grid[nbhoriz*(jup + 1) - 2].node; near = jup; } else { @@ -789,8 +791,8 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, } } } else { - if (quad->nbNodeOut(3) && nbhoriz == 2) { -// MESSAGE("left edge is out"); + if (quad->nbNodeOut(3) && nbhoriz == 2) + { int g = nbvertic - 1; // last processed node in the grid int stop = 0; i = quad->side[ QUAD_LEFT_SIDE ].to-1; // nbleft - 1; @@ -835,7 +837,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, // find node c in the grid, nearest to the b int near = g; - if (i == stop + 1) { // down bondary reached + if (i == stop + 1) { // down boundary reached c = quad->uv_grid[nbhoriz*jlow + 1].node; near = jlow; } @@ -1050,7 +1052,8 @@ static bool twoEdgesMeatAtVertex(const TopoDS_Edge& e1, FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, - const bool considerMesh) + const bool considerMesh, + SMESH_MesherHelper* aFaceHelper) { if ( !myQuadList.empty() && myQuadList.front()->face.IsSame( aShape )) return myQuadList.front(); @@ -1069,6 +1072,7 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & } // find corner vertices of the quad + myHelper = ( aFaceHelper && aFaceHelper->GetSubShape() == aShape ) ? aFaceHelper : NULL; vector corners; int nbDegenEdges, nbSides = getCorners( F, aMesh, edges, corners, nbDegenEdges, considerMesh ); if ( nbSides == 0 ) @@ -1094,7 +1098,7 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & sideEdges.push_back( *edgeIt++ ); if ( !sideEdges.empty() ) quad->side.push_back( StdMeshers_FaceSide::New(F, sideEdges, &aMesh, iSide < QUAD_TOP_SIDE, - ignoreMediumNodes, myProxyMesh)); + ignoreMediumNodes, myHelper, myProxyMesh)); else --iSide; } @@ -1148,7 +1152,7 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & { quad->side.push_back ( StdMeshers_FaceSide::New( F, sideEdges, &aMesh, iSide < QUAD_TOP_SIDE, - ignoreMediumNodes, myProxyMesh )); + ignoreMediumNodes, myHelper, myProxyMesh )); ++iSide; } if ( quad->side.size() == 4 ) @@ -1572,7 +1576,7 @@ bool StdMeshers_Quadrangle_2D::setNormalizedGrid (FaceQuadStruct::Ptr quad) //======================================================================= //function : ShiftQuad -//purpose : auxilary function for computeQuadPref +//purpose : auxiliary function for computeQuadPref //======================================================================= void StdMeshers_Quadrangle_2D::shiftQuad(FaceQuadStruct::Ptr& quad, const int num ) @@ -1656,7 +1660,7 @@ void FaceQuadStruct::shift( size_t nb, bool ori, bool keepGrid ) //======================================================================= //function : calcUV -//purpose : auxilary function for computeQuadPref +//purpose : auxiliary function for computeQuadPref //======================================================================= static gp_UV calcUV(double x0, double x1, double y0, double y1, @@ -1679,7 +1683,7 @@ static gp_UV calcUV(double x0, double x1, double y0, double y1, //======================================================================= //function : calcUV2 -//purpose : auxilary function for computeQuadPref +//purpose : auxiliary function for computeQuadPref //======================================================================= static gp_UV calcUV2(double x, double y, @@ -2138,7 +2142,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadPref (SMESH_Mesh & aMesh, npl.Append(uv_el[i].normParam); } - int dl,dr; + int dl = 0, dr = 0; if (OldVersion) { // add some params to right and left after the first param // insert to right @@ -2156,7 +2160,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadPref (SMESH_Mesh & aMesh, } int nnn = Min(nr,nl); - // auxilary sequence of XY for creation nodes + // auxiliary sequence of XY for creation nodes // in the bottom part of central domain // Length of UVL and UVR must be == nbv-nnn TColgp_SequenceOfXY UVL, UVR, UVT; @@ -2380,7 +2384,7 @@ bool StdMeshers_Quadrangle_2D::computeQuadPref (SMESH_Mesh & aMesh, TColgp_SequenceOfXY UVtmp; double drparam = npr.Value(nr) - npr.Value(nnn-1); double dlparam = npl.Value(nnn) - npl.Value(nnn-1); - double y0,y1; + double y0 = 0, y1 = 0; for (i=1; i<=drl; i++) { // add existed nodes from right edge NodesC.SetValue(nb,i+1,uv_er[nnn+i-2].node); @@ -2514,7 +2518,7 @@ bool StdMeshers_Quadrangle_2D::evaluateQuadPref(SMESH_Mesh & aMesh, MapShapeNbElems& aResMap, bool IsQuadratic) { - // Auxilary key in order to keep old variant + // Auxiliary key in order to keep old variant // of meshing after implementation new variant // for bug 0016220 from Mantis. bool OldVersion = false; @@ -3023,7 +3027,7 @@ bool StdMeshers_Quadrangle_2D::computeReduced (SMESH_Mesh & aMesh, gp_XY a3 (uv_et.front().u, uv_et.front().v); int nnn = Min(nr,nl); - // auxilary sequence of XY for creation of nodes + // auxiliary sequence of XY for creation of nodes // in the bottom part of central domain // it's length must be == nbv-nnn-1 TColgp_SequenceOfXY UVL; @@ -3296,7 +3300,11 @@ bool StdMeshers_Quadrangle_2D::computeReduced (SMESH_Mesh & aMesh, vector curr_base = uv_eb, next_base; - UVPtStruct nullUVPtStruct; nullUVPtStruct.node = 0; + UVPtStruct nullUVPtStruct; + nullUVPtStruct.node = 0; + nullUVPtStruct.x = nullUVPtStruct.y = nullUVPtStruct.u = nullUVPtStruct.v = 0; + nullUVPtStruct.param = 0; + int curr_base_len = nb; int next_base_len = 0; @@ -3980,7 +3988,7 @@ void StdMeshers_Quadrangle_2D::smooth (FaceQuadStruct::Ptr quad) } } - // define refernce orientation in 2D + // define reference orientation in 2D TNo2SmooNoMap::iterator n2sn = smooNoMap.begin(); for ( ; n2sn != smooNoMap.end(); ++n2sn ) if ( !n2sn->second._triangles.empty() ) @@ -4104,11 +4112,11 @@ bool StdMeshers_Quadrangle_2D::check() { TError err; TSideVector wireVec = - StdMeshers_FaceSide::GetFaceWires( geomFace, *myHelper->GetMesh(), true, err ); + StdMeshers_FaceSide::GetFaceWires( geomFace, *myHelper->GetMesh(), true, err, myHelper ); StdMeshers_FaceSidePtr wire = wireVec[0]; // find a right angle VERTEX - int iVertex; + int iVertex = 0; double maxAngle = -1e100; for ( int i = 0; i < wire->NbEdges(); ++i ) { @@ -4245,7 +4253,10 @@ int StdMeshers_Quadrangle_2D::getCorners(const TopoDS_Face& theFace, theNbDegenEdges = 0; SMESH_MesherHelper helper( theMesh ); - StdMeshers_FaceSide faceSide( theFace, theWire, &theMesh, /*isFwd=*/true, /*skipMedium=*/true); + if ( myHelper ) + helper.CopySubShapeInfo( *myHelper ); + StdMeshers_FaceSide faceSide( theFace, theWire, &theMesh, + /*isFwd=*/true, /*skipMedium=*/true, &helper ); // sort theVertices by angle multimap vertexByAngle; @@ -4517,7 +4528,7 @@ int StdMeshers_Quadrangle_2D::getCorners(const TopoDS_Face& theFace, // move corners to make sides equal by length int nbEqualV = equVerts.size(); int nbExcessV = nbEqualV - ( 1 + nbC[0] + nbC[1] ); - if ( nbExcessV > 0 ) // there is nbExcessV vertices that can become corners + if ( nbExcessV > 0 ) // there are nbExcessV vertices that can become corners { // calculate normalized length of each "side" enclosed between neighbor equVerts vector< double > accuLength; @@ -4578,6 +4589,7 @@ int StdMeshers_Quadrangle_2D::getCorners(const TopoDS_Face& theFace, if ( iBestEV > iS-1 + nbExcessV ) iBestEV = iS-1 + nbExcessV; theVertices[ iCorner ] = helper.IthVertex( 0, edgeVec[ evVec[ iBestEV ]]); + cornerInd [ iCorner ] = evVec[ iBestEV ]; refinedCorners.insert( evVec[ iBestEV ]); iCorner = helper.WrapIndex( iCorner + 1, cornerInd.size() ); } @@ -5145,6 +5157,8 @@ void StdMeshers_Quadrangle_2D::updateSideUV( FaceQuadStruct::Side& side, for ( iS = 0; iS < q->side.size(); ++iS ) if ( side.grid == q->side[ iS ].grid ) break; + if ( iS == q->side.size() ) + continue; bool isOut; if ( !q->side[ iS ].IsReversed() ) isOut = ( q->side[ iS ].from > iCur || q->side[ iS ].to-1 <= iCur );