From ccd189545b02cebaf3e370f3b331c678a47f90af Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 29 May 2013 13:41:51 +0000 Subject: [PATCH] 0022136: EDF 2345 SMESH: Improving documentation of Quadrangle mapping with the type "Reduced" 1) Send a warning if Reduced transition can't be used. 2) Fix SIGSEGV for the case of nbRows = 1, nbTop = 4, nbBot = 16 --- src/StdMeshers/StdMeshers_Quadrangle_2D.cxx | 47 +++++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 23512af43..ef7e6100b 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -254,6 +254,17 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, Smooth( quad ); return ok; } + 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."); } // set normalized grid on unit square in parametric domain @@ -2316,19 +2327,20 @@ namespace * Implementation of Reduced algorithm (meshing with quadrangles only) */ //======================================================================= + bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, const TopoDS_Shape& aShape, FaceQuadStruct::Ptr quad) { - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - const TopoDS_Face& F = TopoDS::Face(aShape); + 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); + int i,j,geomFaceID = meshDS->ShapeToIndex(F); - int nb = quad->side[0]->NbPoints(); - int nr = quad->side[1]->NbPoints(); - int nt = quad->side[2]->NbPoints(); - int nl = quad->side[3]->NbPoints(); + int nb = quad->side[0]->NbPoints(); // bottom + int nr = quad->side[1]->NbPoints(); // right + int nt = quad->side[2]->NbPoints(); // top + int nl = quad->side[3]->NbPoints(); // left // Simple Reduce 10->8->6->4 (3 steps) Multiple Reduce 10->4 (1 step) // @@ -2374,13 +2386,21 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, } // number of rows and columns - int nrows = nr1 - 1; + int nrows = nr1 - 1; int ncol_top = nt1 - 1; int ncol_bot = nb1 - 1; // number of rows needed to reduce ncol_bot to ncol_top using simple 3->1 "tree" (see below) - int nrows_tree31 = int( log( (double)(ncol_bot / ncol_top) ) / log((double) 3 )); // = log x base 3 + int nrows_tree31 = + int( ceil( log( double(ncol_bot) / ncol_top) / log( 3.))); // = log x base 3 if ( nrows < nrows_tree31 ) + { MultipleReduce = true; + error( COMPERR_WARNING, + SMESH_Comment("To use 'Reduced' transition, " + "number of face rows should be at least ") + << nrows_tree31 << ". Actual number of face rows is " << nrows << ". " + "'Quadrangle preference (reversed)' transion has been used."); + } } if (MultipleReduce) { // == ComputeQuadPref QUAD_QUADRANGLE_PREF_REVERSED @@ -2624,7 +2644,7 @@ bool StdMeshers_Quadrangle_2D::ComputeReduced (SMESH_Mesh & aMesh, // add bottom nodes (first columns) for (i=2; iAddFace(NodesC.Value(i,j), NodesC.Value(i+1,j), + SMDS_MeshFace* F = + myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j), NodesC.Value(i+1,j+1), NodesC.Value(i,j+1)); - if (F) meshDS->SetMeshElementOnShape(F, geomFaceID); + if (F) meshDS->SetMeshElementOnShape(F, geomFaceID); } } - // TODO ??? } // end Multiple Reduce implementation else { // Simple Reduce (!MultipleReduce) //========================================================= -- 2.39.2