X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Quadrangle_2D.cxx;h=250948ddce0b899f6021831584db70a597070787;hp=98b3ddc622c2baf664e6c48c5b4e827635efa1ac;hb=d9d385cc066b218b812bd8d5f83782e82ab84f78;hpb=a004160516ecca64687bea560810c414afcfea1f diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 98b3ddc62..250948ddc 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -119,6 +119,13 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus) { + myTriaVertexID = -1; + myQuadType = QUAD_STANDARD; + myQuadranglePreference = false; + myTrianglePreference = false; + myQuadStruct.reset(); + myHelper = NULL; + bool isOk = true; aStatus = SMESH_Hypothesis::HYP_OK; @@ -126,12 +133,6 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis GetUsedHypothesis(aMesh, aShape, false); const SMESHDS_Hypothesis * aHyp = 0; - myTriaVertexID = -1; - myQuadType = QUAD_STANDARD; - myQuadranglePreference = false; - myTrianglePreference = false; - myQuadStruct.reset(); - bool isFirstParams = true; // First assigned hypothesis (if any) is processed now @@ -205,10 +206,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) { const TopoDS_Face& F = TopoDS::Face(aShape); - Handle(Geom_Surface) S = BRep_Tool::Surface(F); - - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - aMesh.GetSubMesh(aShape); + aMesh.GetSubMesh( F ); SMESH_MesherHelper helper (aMesh); myHelper = &helper; @@ -220,59 +218,79 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, _quadraticMesh = myHelper->IsQuadraticSubMesh(aShape); myNeedSmooth = false; - FaceQuadStruct::Ptr quad = CheckNbEdges(aMesh, aShape); + FaceQuadStruct::Ptr quad = CheckNbEdges( aMesh, F, /*considerMesh=*/true ); if (!quad) return false; myQuadStruct = quad; - if (myQuadranglePreference) { - int n1 = quad->side[0]->NbPoints(); - int n2 = quad->side[1]->NbPoints(); - int n3 = quad->side[2]->NbPoints(); - int n4 = quad->side[3]->NbPoints(); + bool ok = false; + if (myQuadranglePreference) + { + int n1 = quad->side[0]->NbPoints(); + int n2 = quad->side[1]->NbPoints(); + int n3 = quad->side[2]->NbPoints(); + int n4 = quad->side[3]->NbPoints(); int nfull = n1+n2+n3+n4; - int ntmp = nfull/2; + int ntmp = nfull/2; ntmp = ntmp*2; - if (nfull == ntmp && ((n1 != n3) || (n2 != n4))) { - // special path for using only quandrangle faces - bool ok = ComputeQuadPref(aMesh, aShape, quad); - if ( ok && myNeedSmooth ) - Smooth( quad ); - return ok; - } - } - else if (myQuadType == QUAD_REDUCED) { - int n1 = quad->side[0]->NbPoints(); - int n2 = quad->side[1]->NbPoints(); - int n3 = quad->side[2]->NbPoints(); - int n4 = quad->side[3]->NbPoints(); - int n13 = n1 - n3; - int n24 = n2 - n4; + if (nfull == ntmp && ((n1 != n3) || (n2 != n4))) + { + // special path genarating only quandrangle faces + ok = computeQuadPref( aMesh, F, quad ); + } + } + else if (myQuadType == QUAD_REDUCED) + { + int n1 = quad->side[0]->NbPoints(); + int n2 = quad->side[1]->NbPoints(); + int n3 = quad->side[2]->NbPoints(); + int n4 = quad->side[3]->NbPoints(); + int n13 = n1 - n3; + int n24 = n2 - n4; int n13tmp = n13/2; n13tmp = n13tmp*2; int n24tmp = n24/2; n24tmp = n24tmp*2; if ((n1 == n3 && n2 != n4 && n24tmp == n24) || - (n2 == n4 && n1 != n3 && n13tmp == n13)) { - bool ok = ComputeReduced(aMesh, aShape, quad); - if ( ok && myNeedSmooth ) - Smooth( quad ); - return ok; + (n2 == n4 && n1 != n3 && n13tmp == n13)) + { + ok = computeReduced( aMesh, F, quad ); } - if ( n1 != n3 && n2 != n4 ) - error( COMPERR_WARNING, - "To use 'Reduced' transition, " - "two opposite sides should have same number of segments, " - "but actual number of segments is different on all sides. " - "'Standard' transion has been used."); else - error( COMPERR_WARNING, - "To use 'Reduced' transition, " - "two opposite sides should have an even difference in number of segments. " - "'Standard' transion has been used."); + { + if ( n1 != n3 && n2 != n4 ) + error( COMPERR_WARNING, + "To use 'Reduced' transition, " + "two opposite sides should have same number of segments, " + "but actual number of segments is different on all sides. " + "'Standard' transion has been used."); + else + error( COMPERR_WARNING, + "To use 'Reduced' transition, " + "two opposite sides should have an even difference in number of segments. " + "'Standard' transion has been used."); + } } + ok = computeQuadDominant( aMesh, F, quad ); + + if ( ok && myNeedSmooth ) + smooth( quad ); + + return ok; +} + +//================================================================================ +/*! + * \brief Compute quadrangles and possibly triangles + */ +//================================================================================ + +bool StdMeshers_Quadrangle_2D::computeQuadDominant(SMESH_Mesh& aMesh, + const TopoDS_Face& aFace, + FaceQuadStruct::Ptr quad) +{ // set normalized grid on unit square in parametric domain - - if (!SetNormalizedGrid(aMesh, aShape, quad)) + + if (!setNormalizedGrid(aMesh, aFace, quad)) return false; // --- compute 3D values on points, store points & quadrangles @@ -287,7 +305,9 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, int nbvertic = Min(nbright, nbleft); // internal mesh nodes - int i, j, geomFaceID = meshDS->ShapeToIndex(F); + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + Handle(Geom_Surface) S = BRep_Tool::Surface(aFace); + int i, j, geomFaceID = meshDS->ShapeToIndex(aFace); for (i = 1; i < nbhoriz - 1; i++) { for (j = 1; j < nbvertic - 1; j++) { int ij = j * nbhoriz + i; @@ -423,7 +443,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, if (face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { - SplitQuad(meshDS, geomFaceID, a, b, c, d); + splitQuad(meshDS, geomFaceID, a, b, c, d); } // if node d is not at position g - make additional triangles @@ -510,7 +530,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, if (face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { - SplitQuad(meshDS, geomFaceID, a, b, c, d); + splitQuad(meshDS, geomFaceID, a, b, c, d); } if (near + 1 < g) { // if d not is at g - make additional triangles @@ -583,7 +603,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, if (face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { - SplitQuad(meshDS, geomFaceID, a, b, c, d); + splitQuad(meshDS, geomFaceID, a, b, c, d); } if (near - 1 > g) { // if d not is at g - make additional triangles @@ -652,7 +672,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, if (face) meshDS->SetMeshElementOnShape(face, geomFaceID); } else { - SplitQuad(meshDS, geomFaceID, a, b, c, d); + splitQuad(meshDS, geomFaceID, a, b, c, d); } if (near + 1 < g) { // if d not is at g - make additional triangles @@ -672,9 +692,6 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, } } - if ( myNeedSmooth ) - Smooth( quad ); - bool isOk = true; return isOk; } @@ -686,19 +703,19 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, */ //============================================================================= -bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, - MapShapeNbElems& aResMap) +bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aFace, + MapShapeNbElems& aResMap) { - aMesh.GetSubMesh(aShape); + aMesh.GetSubMesh(aFace); std::vector aNbNodes(4); bool IsQuadratic = false; - if (!CheckNbEdgesForEvaluate(aMesh, aShape, aResMap, aNbNodes, IsQuadratic)) { + if (!checkNbEdgesForEvaluate(aMesh, aFace, aResMap, aNbNodes, IsQuadratic)) { std::vector aResVec(SMDSEntity_Last); for (int i=SMDSEntity_Node; iGetComputeError(); smError.reset(new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this)); @@ -715,7 +732,7 @@ bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh& aMesh, ntmp = ntmp*2; if (nfull==ntmp && ((n1!=n3) || (n2!=n4))) { // special path for using only quandrangle faces - return EvaluateQuadPref(aMesh, aShape, aNbNodes, aResMap, IsQuadratic); + return evaluateQuadPref(aMesh, aFace, aNbNodes, aResMap, IsQuadratic); //return true; } } @@ -767,7 +784,7 @@ bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh& aMesh, aVec[SMDSEntity_Quadrangle] = nbFaces4 - aNbNodes[3] + 1; } } - SMESH_subMesh * sm = aMesh.GetSubMesh(aShape); + SMESH_subMesh * sm = aMesh.GetSubMesh(aFace); aResMap.insert(std::make_pair(sm,aVec)); return true; @@ -802,7 +819,8 @@ static bool twoEdgesMeatAtVertex(const TopoDS_Edge& e1, //============================================================================= FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh, - const TopoDS_Shape & aShape) + const TopoDS_Shape & aShape, + const bool considerMesh) { if ( myQuadStruct && myQuadStruct->face.IsSame( aShape )) return myQuadStruct; @@ -822,7 +840,7 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & // find corner vertices of the quad vector corners; - int nbDegenEdges, nbSides = GetCorners( F, aMesh, edges, corners, nbDegenEdges ); + int nbDegenEdges, nbSides = getCorners( F, aMesh, edges, corners, nbDegenEdges, considerMesh ); if ( nbSides == 0 ) { return FaceQuadStruct::Ptr(); @@ -871,7 +889,7 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & while ( edgeIt != edges.end() && !nextSideV.IsSame( myHelper->IthVertex( 0, *edgeIt ))) { - if ( SMESH_Algo::isDegenerated( *edgeIt )) + if ( SMESH_Algo::isDegenerated( *edgeIt ) ) { if ( myNeedSmooth ) { @@ -902,6 +920,13 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & ignoreMediumNodes, myProxyMesh)); ++iSide; } + else if ( !SMESH_Algo::isDegenerated( *edgeIt ) && // closed EDGE + myHelper->IthVertex( 0, *edgeIt ).IsSame( myHelper->IthVertex( 1, *edgeIt ))) + { + quad->side.push_back(new StdMeshers_FaceSide(F, *edgeIt++, &aMesh, iSide < QUAD_TOP_SIDE, + ignoreMediumNodes, myProxyMesh)); + ++iSide; + } if ( nbLoops > 8 ) { error(TComm("Bug: infinite loop in StdMeshers_Quadrangle_2D::CheckNbEdges()")); @@ -909,7 +934,7 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & break; } } - if ( quad->side.size() != 4 ) + if ( quad && quad->side.size() != 4 ) { error(TComm("Bug: ") << quad->side.size() << " sides found instead of 4"); quad.reset(); @@ -926,11 +951,11 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & */ //============================================================================= -bool StdMeshers_Quadrangle_2D::CheckNbEdgesForEvaluate(SMESH_Mesh& aMesh, +bool StdMeshers_Quadrangle_2D::checkNbEdgesForEvaluate(SMESH_Mesh& aMesh, const TopoDS_Shape & aShape, - MapShapeNbElems& aResMap, - std::vector& aNbNodes, - bool& IsQuadratic) + MapShapeNbElems& aResMap, + std::vector& aNbNodes, + bool& IsQuadratic) { const TopoDS_Face & F = TopoDS::Face(aShape); @@ -1122,7 +1147,7 @@ StdMeshers_Quadrangle_2D::CheckAnd2Dcompute (SMESH_Mesh & aMesh, if ( quad ) { // set normalized grid on unit square in parametric domain - if (!SetNormalizedGrid(aMesh, aShape, quad)) + if ( ! setNormalizedGrid( aMesh, TopoDS::Face( aShape ), quad)) quad.reset(); } return quad; @@ -1179,8 +1204,8 @@ namespace */ //============================================================================= -bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, - const TopoDS_Shape& aShape, +bool StdMeshers_Quadrangle_2D::setNormalizedGrid (SMESH_Mesh & aMesh, + const TopoDS_Face& aFace, FaceQuadStruct::Ptr & quad) { // Algorithme décrit dans "Génération automatique de maillages" @@ -1188,11 +1213,6 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, // traitement dans le domaine paramétrique 2d u,v // transport - projection sur le carré unité -// MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid"); -// const TopoDS_Face& F = TopoDS::Face(aShape); - - // 1 --- find orientation of the 4 edges, by test on extrema - // max min 0 x1 1 // |<----north-2-------^ a3 -------------> a2 // | | ^1 1^ @@ -1205,9 +1225,7 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, // =down // - // 3 --- 2D normalized values on unit square [0..1][0..1] - - UpdateDegenUV( quad ); + updateDegenUV( quad ); int nbhoriz = Min(quad->side[0]->NbPoints(), quad->side[2]->NbPoints()); int nbvertic = Min(quad->side[1]->NbPoints(), quad->side[3]->NbPoints()); @@ -1229,48 +1247,48 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, return error(COMPERR_BAD_INPUT_MESH); // copy data of face boundary - /*if (! quad->isEdgeOut[0])*/ { + { const int j = 0; for (int i = 0; i < nbhoriz; i++) // down uv_grid[ j * nbhoriz + i ] = uv_e0[i]; } - /*if (! quad->isEdgeOut[1])*/ { + { const int i = nbhoriz - 1; for (int j = 0; j < nbvertic; j++) // right uv_grid[ j * nbhoriz + i ] = uv_e1[j]; } - /*if (! quad->isEdgeOut[2])*/ { + { const int j = nbvertic - 1; for (int i = 0; i < nbhoriz; i++) // up uv_grid[ j * nbhoriz + i ] = uv_e2[i]; } - /*if (! quad->isEdgeOut[3])*/ { - int i = 0; + { + const int i = 0; for (int j = 0; j < nbvertic; j++) // left uv_grid[ j * nbhoriz + i ] = uv_e3[j]; } // normalized 2d parameters on grid + for (int i = 0; i < nbhoriz; i++) { for (int j = 0; j < nbvertic; j++) { int ij = j * nbhoriz + i; // --- droite i cste : x = x0 + y(x1-x0) - double x0 = uv_e0[i].normParam; // bas - sud + double x0 = uv_e0[i].normParam; // bas - sud double x1 = uv_e2[i].normParam; // haut - nord // --- droite j cste : y = y0 + x(y1-y0) - double y0 = uv_e3[j].normParam; // gauche-ouest + double y0 = uv_e3[j].normParam; // gauche - ouest double y1 = uv_e1[j].normParam; // droite - est // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0) double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0)); double y = y0 + x * (y1 - y0); uv_grid[ij].x = x; uv_grid[ij].y = y; - //MESSAGE("-xy-01 "<shift( num, /*ori=*/true ); } @@ -1311,7 +1329,7 @@ static void shiftQuad(FaceQuadStruct::Ptr& quad, const int num, bool) //================================================================================ /*! * \brief Rotate sides of a quad by nb - * \param nb - number of rotation quartes + * \param nb - number of rotation quartes * \param ori - to keep orientation of sides as in an unit quad or not */ //================================================================================ @@ -1332,7 +1350,7 @@ void FaceQuadStruct::shift( size_t nb, bool ori ) //======================================================================= //function : calcUV -//purpose : auxilary function for ComputeQuadPref +//purpose : auxilary function for computeQuadPref //======================================================================= static gp_UV calcUV(double x0, double x1, double y0, double y1, @@ -1355,7 +1373,7 @@ static gp_UV calcUV(double x0, double x1, double y0, double y1, //======================================================================= //function : calcUV2 -//purpose : auxilary function for ComputeQuadPref +//purpose : auxilary function for computeQuadPref //======================================================================= static gp_UV calcUV2(double x, double y, @@ -1380,24 +1398,21 @@ static gp_UV calcUV2(double x, double y, */ //======================================================================= -bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, - const TopoDS_Shape& aShape, +bool StdMeshers_Quadrangle_2D::computeQuadPref (SMESH_Mesh & aMesh, + const TopoDS_Face& aFace, FaceQuadStruct::Ptr quad) { // Auxilary key in order to keep old variant // of meshing after implementation new variant // for bug 0016220 from Mantis. - bool OldVersion = false; - if (myQuadType == QUAD_QUADRANGLE_PREF_REVERSED) - OldVersion = true; + bool OldVersion = (myQuadType == QUAD_QUADRANGLE_PREF_REVERSED); - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - const TopoDS_Face& F = TopoDS::Face(aShape); - Handle(Geom_Surface) S = BRep_Tool::Surface(F); + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + Handle(Geom_Surface) S = BRep_Tool::Surface(aFace); bool WisF = true; - int i,j,geomFaceID = meshDS->ShapeToIndex(F); + int i,j,geomFaceID = meshDS->ShapeToIndex(aFace); - UpdateDegenUV( quad ); + updateDegenUV( quad ); int nb = quad->side[0]->NbPoints(); int nr = quad->side[1]->NbPoints(); @@ -1406,26 +1421,12 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, int dh = abs(nb-nt); int dv = abs(nr-nl); - if (dh>=dv) { - if (nt>nb) { - // it is a base case => not shift quad but me be replacement is need - shiftQuad(quad,0,WisF); - } - else { - // we have to shift quad on 2 - shiftQuad(quad,2,WisF); - } - } - else { - if (nr>nl) { - // we have to shift quad on 1 - shiftQuad(quad,1,WisF); - } - else { - // we have to shift quad on 3 - shiftQuad(quad,3,WisF); - } - } + // rotate sides to be as in the picture below and to have + // dh >= dv and nt > nb + if ( dh >= dv ) + shiftQuad( quad, ( nt > nb ) ? 0 : 2 ); + else + shiftQuad( quad, ( nr > nl ) ? 1 : 3 ); nb = quad->side[0]->NbPoints(); nr = quad->side[1]->NbPoints(); @@ -1434,7 +1435,7 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, dh = abs(nb-nt); dv = abs(nr-nl); int nbh = Max(nb,nt); - int nbv = Max(nr,nl); + int nbv = Max(nr,nl); int addh = 0; int addv = 0; @@ -1455,7 +1456,7 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, // ----------- New version --------------- // 0 top 1 // 1------------1 - // | |_C__| | + // | |__| | // | / \ | // | / C \ | // left |/________\| rigth @@ -1465,13 +1466,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, // 0------------0 // 0 bottom 1 - if (dh>dv) { + if ( dh > dv ) { addv = (dh-dv)/2; - nbv = nbv + addv; + nbv = nbv + addv; } - else { // dv>=dh + else { // dv >= dh addh = (dv-dh)/2; - nbh = nbh + addh; + nbh = nbh + addh; } const vector& uv_eb = quad->side[0]->GetUVPtStruct(true,0); @@ -1482,6 +1483,11 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh, if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl) return error(COMPERR_BAD_INPUT_MESH); + if ( !OldVersion ) + { + // dh/2, Min(nb,nt), dh - dh/2, dv + } + // arrays for normalized params TColStd_SequenceOfReal npb, npr, npt, npl; for (i=0; i& aNbNodes, - MapShapeNbElems& aResMap, - bool IsQuadratic) + std::vector& aNbNodes, + MapShapeNbElems& aResMap, + bool IsQuadratic) { // Auxilary key in order to keep old variant // of meshing after implementation new variant @@ -2048,32 +2054,30 @@ bool StdMeshers_Quadrangle_2D::EvaluateQuadPref(SMESH_Mesh & aMesh, return true; } - //============================================================================= /*! Split quadrangle in to 2 triangles by smallest diagonal * */ //============================================================================= -void StdMeshers_Quadrangle_2D::SplitQuad(SMESHDS_Mesh *theMeshDS, - int theFaceID, + +void StdMeshers_Quadrangle_2D::splitQuad(SMESHDS_Mesh * theMeshDS, + int theFaceID, const SMDS_MeshNode* theNode1, const SMDS_MeshNode* theNode2, const SMDS_MeshNode* theNode3, const SMDS_MeshNode* theNode4) { - gp_Pnt a(theNode1->X(),theNode1->Y(),theNode1->Z()); - gp_Pnt b(theNode2->X(),theNode2->Y(),theNode2->Z()); - gp_Pnt c(theNode3->X(),theNode3->Y(),theNode3->Z()); - gp_Pnt d(theNode4->X(),theNode4->Y(),theNode4->Z()); SMDS_MeshFace* face; - if (a.Distance(c) > b.Distance(d)){ + if ( SMESH_TNodeXYZ( theNode1 ).SquareDistance( theNode3 ) > + SMESH_TNodeXYZ( theNode2 ).SquareDistance( theNode4 ) ) + { face = myHelper->AddFace(theNode2, theNode4 , theNode1); if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID); face = myHelper->AddFace(theNode2, theNode3, theNode4); if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID); - } - else{ + else + { face = myHelper->AddFace(theNode1, theNode2 ,theNode3); if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID); face = myHelper->AddFace(theNode1, theNode3, theNode4); @@ -2264,14 +2268,13 @@ namespace */ //======================================================================= -bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, - const TopoDS_Shape& aShape, +bool StdMeshers_Quadrangle_2D::computeReduced (SMESH_Mesh & aMesh, + const TopoDS_Face& aFace, FaceQuadStruct::Ptr quad) { SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - const TopoDS_Face& F = TopoDS::Face(aShape); - Handle(Geom_Surface) S = BRep_Tool::Surface(F); - int i,j,geomFaceID = meshDS->ShapeToIndex(F); + Handle(Geom_Surface) S = BRep_Tool::Surface(aFace); + int i,j,geomFaceID = meshDS->ShapeToIndex(aFace); int nb = quad->side[0]->NbPoints(); // bottom int nr = quad->side[1]->NbPoints(); // right @@ -2339,7 +2342,7 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, } } - if (MultipleReduce) { // == ComputeQuadPref QUAD_QUADRANGLE_PREF_REVERSED + if (MultipleReduce) { // == computeQuadPref QUAD_QUADRANGLE_PREF_REVERSED //================================================== int dh = abs(nb-nt); int dv = abs(nr-nl); @@ -2347,21 +2350,21 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, if (dh >= dv) { if (nt > nb) { // it is a base case => not shift quad but may be replacement is need - shiftQuad(quad,0,true); + shiftQuad(quad,0); } else { // we have to shift quad on 2 - shiftQuad(quad,2,true); + shiftQuad(quad,2); } } else { if (nr > nl) { // we have to shift quad on 1 - shiftQuad(quad,1,true); + shiftQuad(quad,1); } else { // we have to shift quad on 3 - shiftQuad(quad,3,true); + shiftQuad(quad,3); } } @@ -2393,7 +2396,7 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl) return error(COMPERR_BAD_INPUT_MESH); - UpdateDegenUV( quad ); + updateDegenUV( quad ); // arrays for normalized params TColStd_SequenceOfReal npb, npr, npt, npl; @@ -2627,17 +2630,17 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, } else { // we have to shift quad on 2 - shiftQuad(quad,2,true); + shiftQuad(quad,2); } } else { if (nl > nr) { // we have to shift quad on 1 - shiftQuad(quad,1,true); + shiftQuad(quad,1); } else { // we have to shift quad on 3 - shiftQuad(quad,3,true); + shiftQuad(quad,3); } } @@ -3221,7 +3224,7 @@ namespace // data for smoothing */ //================================================================================ -void StdMeshers_Quadrangle_2D::UpdateDegenUV(FaceQuadStruct::Ptr quad) +void StdMeshers_Quadrangle_2D::updateDegenUV(FaceQuadStruct::Ptr quad) { if ( myNeedSmooth ) @@ -3295,7 +3298,7 @@ void StdMeshers_Quadrangle_2D::UpdateDegenUV(FaceQuadStruct::Ptr quad) */ //================================================================================ -void StdMeshers_Quadrangle_2D::Smooth (FaceQuadStruct::Ptr quad) +void StdMeshers_Quadrangle_2D::smooth (FaceQuadStruct::Ptr quad) { if ( !myNeedSmooth ) return; @@ -3457,15 +3460,18 @@ void StdMeshers_Quadrangle_2D::Smooth (FaceQuadStruct::Ptr quad) * \param [out] theVertices - the found corner vertices in the order corresponding to * the order of EDGEs in \a theWire * \param [out] theNbDegenEdges - nb of degenerated EDGEs in theFace + * \param [in] theConsiderMesh - if \c true, only meshed VERTEXes are considered + * as possible corners * \return int - number of quad sides found: 0, 3 or 4 */ //================================================================================ -int StdMeshers_Quadrangle_2D::GetCorners(const TopoDS_Face& theFace, +int StdMeshers_Quadrangle_2D::getCorners(const TopoDS_Face& theFace, SMESH_Mesh & theMesh, std::list& theWire, std::vector& theVertices, - int & theNbDegenEdges) + int & theNbDegenEdges, + const bool theConsiderMesh) { theNbDegenEdges = 0; @@ -3493,7 +3499,7 @@ int StdMeshers_Quadrangle_2D::GetCorners(const TopoDS_Face& theFace, continue; } TopoDS_Vertex v = helper.IthVertex( 0, *edge ); - if ( SMESH_Algo::VertexNode( v, helper.GetMeshDS() )) + if ( !theConsiderMesh || SMESH_Algo::VertexNode( v, helper.GetMeshDS() )) { double angle = SMESH_MesherHelper::GetAngle( prevE, *edge, theFace ); vertexByAngle.insert( make_pair( angle, v ));