From 73dc14d280bcadd0c120f7662def8de8f9d49249 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 21 Feb 2007 17:11:37 +0000 Subject: [PATCH] PAL13615 (EDF PAL 315/31 GEOM SMESH : meshing of a "5 edges quadrangle") fix for degenerated edges --- src/StdMeshers/StdMeshers_FaceSide.cxx | 63 ++++++++------------- src/StdMeshers/StdMeshers_MEFISTO_2D.cxx | 38 +++++++------ src/StdMeshers/StdMeshers_Quadrangle_2D.cxx | 8 ++- 3 files changed, 50 insertions(+), 59 deletions(-) diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index 583fccebb..b83bfb4b0 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.cxx +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -95,11 +95,13 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, SMESHDS_Mesh* meshDS = theMesh->GetMeshDS(); vector len( nbEdges ); + int nbDegen = 0; list::iterator edge = theEdges.begin(); for ( int index = 0; edge != theEdges.end(); ++index, ++edge ) { int i = theIsForward ? index : nbEdges - index - 1; len[i] = SMESH_Algo::EdgeLength( *edge ); + if ( len[i] < DBL_MIN ) nbDegen++; myLength += len[i]; myEdge[i] = *edge; if ( !theIsForward ) myEdge[i].Reverse(); @@ -130,49 +132,21 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, myMissingVertexNodes = true; if ( nbEdges > 1 && myLength > DBL_MIN ) { + const double degenNormLen = 1.e-5; + double totLength = myLength; + if ( nbDegen ) + totLength += myLength * degenNormLen * nbDegen; + double prevNormPar = 0; for ( int i = 0; i < nbEdges; ++i ) { - myNormPar[ i ] = len[i]/myLength; - if ( i > 0 ) - myNormPar[ i ] += myNormPar[ i-1 ]; + if ( len[ i ] < DBL_MIN ) + len[ i ] = myLength * degenNormLen; + myNormPar[ i ] = prevNormPar + len[i]/totLength; + prevNormPar = myNormPar[ i ]; } } myNormPar[nbEdges-1] = 1.; //dump(); } -//================================================================================ -/*! - * \brief First curve parameter - * \retval double - parameter value - */ -//================================================================================ - -// double StdMeshers_FaceSide::First() const -// { -// return 0; -// } -// //================================================================================ -// /*! -// * \brief Last curve parameter -// * \retval double - parameter value -// */ -// //================================================================================ - -// double StdMeshers_FaceSide::Last() const -// { -// return 1; -// } - -// //================================================================================ -// /*! -// * \brief -// * \retval bool - -// */ -// //================================================================================ - -// bool StdMeshers_FaceSide::IsForward() const -// { -// return myIsForward; -// } //================================================================================ /*! @@ -193,6 +167,7 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, // sort nodes of all edges putting them into a map map< double, const SMDS_MeshNode*> u2node; + //int nbOnDegen = 0; for ( int i = 0; i < myEdge.size(); ++i ) { // put 1st vertex node @@ -243,7 +218,8 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, } } if ( u2node.size() != myNbPonits ) { - MESSAGE("Wrong node parameters on edges"); + MESSAGE("Wrong node parameters on edges, u2node.size():" + <& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, #endif paramSize = myNormPar[ EdgeIndex ] - prevNormPar; } - double r = ( uvPt.normParam - prevNormPar )/ paramSize; - uvPt.param = myFirst[EdgeIndex] * ( 1 - r ) + myLast[EdgeIndex] * r; + const SMDS_EdgePosition* epos = + dynamic_cast(uvPt.node->GetPosition().get()); + if ( epos ) { + uvPt.param = epos->GetUParameter(); + } + else { + double r = ( uvPt.normParam - prevNormPar )/ paramSize; + uvPt.param = myFirst[EdgeIndex] * ( 1 - r ) + myLast[EdgeIndex] * r; + } if ( !myC2d[ EdgeIndex ].IsNull() ) { gp_Pnt2d p = myC2d[ EdgeIndex ]->Value( uvPt.param ); uvPt.u = p.X(); diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx index fcaefa535..942f5fa74 100644 --- a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx @@ -263,24 +263,26 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh // correspondence mefisto index --> Nodes vector< const SMDS_MeshNode*> mefistoToDS(nbpnt, (const SMDS_MeshNode*)0); - // fill input points UV - LoadPoints(wires, uvslf, mefistoToDS, scalex, scaley); - - // Compute - aptrte(nutysu, aretmx, - nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr); - bool isOk = false; - if (ierr == 0) - { - MESSAGE("... End Triangulation Generated Triangle Number " << nbt); - MESSAGE(" Node Number " << nbst); - StoreResult(nbst, uvst, nbt, nust, mefistoToDS, scalex, scaley); - isOk = true; - } - else + + // fill input points UV + if ( LoadPoints(wires, uvslf, mefistoToDS, scalex, scaley) ) { - MESSAGE("Error in Triangulation"); + // Compute + aptrte(nutysu, aretmx, + nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr); + + if (ierr == 0) + { + MESSAGE("... End Triangulation Generated Triangle Number " << nbt); + MESSAGE(" Node Number " << nbst); + StoreResult(nbst, uvst, nbt, nust, mefistoToDS, scalex, scaley); + isOk = true; + } + else + { + MESSAGE("Error in Triangulation"); + } } if (nudslf != NULL) delete[]nudslf; if (uvslf != NULL) delete[]uvslf; @@ -507,6 +509,10 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(TWireVector & wires, for ( int iW = 0; iW < wires.size(); ++iW ) { const vector& uvPtVec = wires[ iW ]->GetUVPtStruct(isXConst,constValue); + if ( uvPtVec.size() != wires[ iW ]->NbPoints() ) { + MESSAGE("Wrong nb UVPtStruct: "<