Regression of SALOME_TESTS/Grids/smesh/2D_mesh_QuadranglePreference_00/A1

Avoid failure on an edge having a zero-length 3D curve
This commit is contained in:
eap 2016-09-08 14:33:45 +03:00
parent 8103f44f2d
commit 145e217ae6
3 changed files with 26 additions and 34 deletions

View File

@ -584,8 +584,10 @@ bool SMESH_Algo::IsStraight( const TopoDS_Edge & E,
*/ */
//================================================================================ //================================================================================
bool SMESH_Algo::isDegenerated( const TopoDS_Edge & E ) bool SMESH_Algo::isDegenerated( const TopoDS_Edge & E, const bool checkLength )
{ {
if ( checkLength )
return EdgeLength( E ) == 0;
double f,l; double f,l;
TopLoc_Location loc; TopLoc_Location loc;
Handle(Geom_Curve) C = BRep_Tool::Curve( E, loc, f,l ); Handle(Geom_Curve) C = BRep_Tool::Curve( E, loc, f,l );

View File

@ -363,7 +363,7 @@ public:
/*! /*!
* \brief Return true if an edge has no 3D curve * \brief Return true if an edge has no 3D curve
*/ */
static bool isDegenerated( const TopoDS_Edge & E ); static bool isDegenerated( const TopoDS_Edge & E, const bool checkLength=false );
/*! /*!
* \brief Return the node built on a vertex * \brief Return the node built on a vertex

View File

@ -1120,15 +1120,14 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
ASSERT(!VFirst.IsNull()); ASSERT(!VFirst.IsNull());
ASSERT(!VLast.IsNull()); ASSERT(!VLast.IsNull());
const SMDS_MeshNode * idFirst = SMESH_Algo::VertexNode( VFirst, meshDS ); const SMDS_MeshNode * nFirst = SMESH_Algo::VertexNode( VFirst, meshDS );
const SMDS_MeshNode * idLast = SMESH_Algo::VertexNode( VLast, meshDS ); const SMDS_MeshNode * nLast = SMESH_Algo::VertexNode( VLast, meshDS );
if (!idFirst || !idLast) if ( !nFirst || !nLast )
return error( COMPERR_BAD_INPUT_MESH, "No node on vertex"); return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
// remove elements created by e.g. patern mapping (PAL21999) // remove elements created by e.g. patern mapping (PAL21999)
// CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp // CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp
// so TEMPORARY solution is to clean the submesh manually // so TEMPORARY solution is to clean the submesh manually
//theMesh.GetSubMesh(theShape)->ComputeStateEngine( SMESH_subMesh::CLEAN );
if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape)) if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape))
{ {
SMDS_ElemIteratorPtr ite = subMeshDS->GetElements(); SMDS_ElemIteratorPtr ite = subMeshDS->GetElements();
@ -1144,7 +1143,8 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
} }
} }
if (!Curve.IsNull()) double length = EdgeLength( E );
if ( !Curve.IsNull() && length > 0 )
{ {
list< double > params; list< double > params;
bool reversed = false; bool reversed = false;
@ -1167,7 +1167,6 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
reversed = !reversed; reversed = !reversed;
BRepAdaptor_Curve C3d( E ); BRepAdaptor_Curve C3d( E );
double length = EdgeLength( E );
if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) { if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) {
return false; return false;
} }
@ -1176,19 +1175,10 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
// edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex) // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
// only internal nodes receive an edge position with param on curve // only internal nodes receive an edge position with param on curve
const SMDS_MeshNode * idPrev = idFirst; const SMDS_MeshNode * nPrev = nFirst;
double parPrev = f; double parPrev = f;
double parLast = l; double parLast = l;
/* NPAL18025
if (reversed) {
idPrev = idLast;
idLast = idFirst;
idFirst = idPrev;
parPrev = l;
parLast = f;
}
*/
for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) { for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
double param = *itU; double param = *itU;
gp_Pnt P = Curve->Value(param); gp_Pnt P = Curve->Value(param);
@ -1200,18 +1190,18 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
if(_quadraticMesh) { if(_quadraticMesh) {
// create medium node // create medium node
double prm = ( parPrev + param )/2; double prm = ( parPrev + param )/2;
gp_Pnt PM = Curve->Value(prm); gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z()); SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm); meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node, NM); SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node, NM);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
else { else {
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
idPrev = node; nPrev = node;
parPrev = param; parPrev = param;
} }
if(_quadraticMesh) { if(_quadraticMesh) {
@ -1219,11 +1209,11 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
gp_Pnt PM = Curve->Value(prm); gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z()); SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm); meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM); SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast, NM);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
else { else {
SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast); SMDS_MeshEdge* edge = meshDS->AddEdge(nPrev, nLast);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
} }
@ -1236,7 +1226,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
gp_Pnt P = BRep_Tool::Pnt(VFirst); gp_Pnt P = BRep_Tool::Pnt(VFirst);
const SMDS_MeshNode * idPrev = idFirst; const SMDS_MeshNode * nPrev = nFirst;
for (int i = 2; i < NbPoints; i++) { for (int i = 2; i < NbPoints; i++) {
double param = f + (i - 1) * du; double param = f + (i - 1) * du;
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
@ -1245,26 +1235,26 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
double prm = param - du/2.; double prm = param - du/2.;
SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z()); SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm); meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node, NM); SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node, NM);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
else { else {
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, node);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
meshDS->SetNodeOnEdge(node, shapeID, param); meshDS->SetNodeOnEdge(node, shapeID, param);
idPrev = node; nPrev = node;
} }
if(_quadraticMesh) { if(_quadraticMesh) {
// create medium node // create medium node
double prm = l - du/2.; double prm = l - du/2.;
SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z()); SMDS_MeshNode * NM = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm); meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM); SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast, NM);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
else { else {
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast); SMDS_MeshEdge * edge = meshDS->AddEdge(nPrev, nLast);
meshDS->SetMeshElementOnShape(edge, shapeID); meshDS->SetMeshElementOnShape(edge, shapeID);
} }
} }
@ -1306,11 +1296,11 @@ bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh,
std::vector<int> aVec(SMDSEntity_Last,0); std::vector<int> aVec(SMDSEntity_Last,0);
if (!Curve.IsNull()) { double length = EdgeLength( E );
if ( !Curve.IsNull() && length > 0 )
{
list< double > params; list< double > params;
BRepAdaptor_Curve C3d( E ); BRepAdaptor_Curve C3d( E );
double length = EdgeLength( E );
if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, false, true )) { if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, false, true )) {
SMESH_subMesh * sm = theMesh.GetSubMesh(theShape); SMESH_subMesh * sm = theMesh.GetSubMesh(theShape);
aResMap.insert(std::make_pair(sm,aVec)); aResMap.insert(std::make_pair(sm,aVec));
@ -1328,7 +1318,7 @@ bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh,
aVec[SMDSEntity_Node] = params.size(); aVec[SMDSEntity_Node] = params.size();
aVec[SMDSEntity_Edge] = params.size() + 1; aVec[SMDSEntity_Edge] = params.size() + 1;
} }
} }
else { else {
// Edge is a degenerated Edge : We put n = 5 points on the edge. // Edge is a degenerated Edge : We put n = 5 points on the edge.