X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_RadialQuadrangle_1D2D.cxx;h=feb4e6d255c797808607f2dc3a5b847d7d7ac525;hp=2b8805003293302e04191c3d5c61e649c7d8ef52;hb=4b5fd249abfca52265832f10435f18f5bb9c69ae;hpb=4104f2658907b593ce3e7ddfd7b3a6713f29826b diff --git a/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx b/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx index 2b8805003..feb4e6d25 100644 --- a/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx +++ b/src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESH : implementaion of SMESH idl descriptions // File : StdMeshers_RadialQuadrangle_1D2D.cxx // Module : SMESH @@ -52,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -542,12 +541,12 @@ bool StdMeshers_RadialQuadrangle_1D2D::Compute(SMESH_Mesh& aMesh, if ( !algo1d->ComputeCircularEdge( aMesh, CircEdge )) return error( algo1d->GetComputeError() ); map< double, const SMDS_MeshNode* > theNodes; - if ( !GetSortedNodesOnEdge(aMesh.GetMeshDS(),CircEdge,true,theNodes) || - theNodes.size()%2 == 0 ) + if ( !GetSortedNodesOnEdge(aMesh.GetMeshDS(),CircEdge,true,theNodes) ) return error("Circular edge is incorrectly meshed"); - - CNodes.clear(); + map< double, const SMDS_MeshNode* >::iterator itn = theNodes.begin(); + CNodes.clear(); + CNodes.push_back( itn->second ); double fang = (*itn).first; itn++; for(; itn != theNodes.end(); itn++ ) { @@ -559,7 +558,6 @@ bool StdMeshers_RadialQuadrangle_1D2D::Compute(SMESH_Mesh& aMesh, } const SMDS_MeshNode* NF = theNodes.begin()->second; const SMDS_MeshNode* NL = theNodes.rbegin()->second; - CNodes.push_back( NF ); P1 = gp_Pnt( NF->X(), NF->Y(), NF->Z() ); gp_Pnt P2( NL->X(), NL->Y(), NL->Z() ); P0 = aCirc->Location(); @@ -573,6 +571,8 @@ bool StdMeshers_RadialQuadrangle_1D2D::Compute(SMESH_Mesh& aMesh, if (!GetSortedNodesOnEdge(aMesh.GetMeshDS(),LinEdge1,true,theNodes)) return error("Invalid mesh on a straight edge"); + Nodes1.resize( myLayerPositions.size()+1 ); + Nodes2.resize( myLayerPositions.size()+1 ); vector< const SMDS_MeshNode* > *pNodes1 = &Nodes1, *pNodes2 = &Nodes2; bool nodesFromP0ToP1 = ( theNodes.rbegin()->second == NF ); if ( !nodesFromP0ToP1 ) std::swap( pNodes1, pNodes2 ); @@ -583,8 +583,8 @@ bool StdMeshers_RadialQuadrangle_1D2D::Compute(SMESH_Mesh& aMesh, { (*pNodes1)[i] = ritn->second; (*pNodes2)[i] = itn->second; - Points.Append( gpXYZ( Nodes1[i])); - Pnts2d1.Append( myHelper->GetNodeUV( F, Nodes1[i])); + Points.Prepend( gpXYZ( Nodes1[i])); + Pnts2d1.Prepend( myHelper->GetNodeUV( F, Nodes1[i])); } NC = const_cast( itn->second ); Points.Remove( Nodes1.size() ); @@ -1000,13 +1000,14 @@ bool StdMeshers_RadialQuadrangle_1D2D::computeLayerPositions(const gp_Pnt& } if ( hyp1D ) // try to compute with hyp1D { - if ( !TNodeDistributor::GetDistributor(*mesh)->Compute( myLayerPositions,p1,p2,*mesh,hyp1D )) + if ( !TNodeDistributor::GetDistributor(*mesh)->Compute( myLayerPositions,p1,p2,*mesh,hyp1D )) { if ( myDistributionHypo ) { // bad hyp assigned return error( TNodeDistributor::GetDistributor(*mesh)->GetComputeError() ); } else { // bad hyp found, its Ok, lets try with default nb of segnents } + } } if ( myLayerPositions.empty() ) // try to use nb of layers @@ -1033,9 +1034,25 @@ bool StdMeshers_RadialQuadrangle_1D2D::computeLayerPositions(const gp_Pnt& vector< double > nodeParams; GetNodeParamOnEdge( mesh->GetMeshDS(), linEdge, nodeParams ); + // nb of present nodes must be different in cases of 1 and 2 straight edges + + TopoDS_Vertex VV[2]; + TopExp::Vertices( linEdge, VV[0], VV[1]); + const gp_Pnt* points[] = { &p1, &p2 }; + gp_Pnt vPoints[] = { BRep_Tool::Pnt(VV[0]), BRep_Tool::Pnt(VV[1]) }; + const double tol[] = { BRep_Tool::Tolerance(VV[0]), BRep_Tool::Tolerance(VV[1]) }; + bool pointsAreOnVertices = true; + for ( int iP = 0; iP < 2 && pointsAreOnVertices; ++iP ) + pointsAreOnVertices = ( points[iP]->Distance( vPoints[0] ) < tol[0] || + points[iP]->Distance( vPoints[1] ) < tol[1] ); + + int nbNodes = nodeParams.size() - 2; // 2 straight edges + if ( !pointsAreOnVertices ) + nbNodes = ( nodeParams.size() - 3 ) / 2; // 1 straight edge + if ( myLayerPositions.empty() ) { - myLayerPositions.resize( nodeParams.size() - 2 ); + myLayerPositions.resize( nbNodes ); } else if ( myDistributionHypo || myNbLayerHypo ) { @@ -1051,8 +1068,10 @@ bool StdMeshers_RadialQuadrangle_1D2D::computeLayerPositions(const gp_Pnt& mesh->GetSubMesh( linEdge )->ComputeStateEngine( SMESH_subMesh::CLEAN ); if ( linEdgeComputed ) *linEdgeComputed = false; } - else if ( myLayerPositions.size() != nodeParams.size()-2 ) { - return error("Radial edge is meshed by other algorithm"); + else { + + if ( myLayerPositions.size() != nbNodes ) + return error("Radial edge is meshed by other algorithm"); } } }