X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_FaceSide.cxx;h=84884800b0e0b2ee463b7e34e1e1324018cdbdbd;hb=b13aae09cfc72606a138e92f34550ec45b72512e;hp=13c2d626316a46f1d5098e4912b2bffc1e8b5d4a;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index 13c2d6263..84884800b 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.cxx +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 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 @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #include #include +#include #include "utilities.h" @@ -62,14 +64,16 @@ */ //================================================================================ -StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, - const TopoDS_Edge& theEdge, - SMESH_Mesh* theMesh, - const bool theIsForward, - const bool theIgnoreMediumNodes) +StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + SMESH_Mesh* theMesh, + const bool theIsForward, + const bool theIgnoreMediumNodes, + SMESH_ProxyMesh::Ptr theProxyMesh) { list edges(1,theEdge); - *this = StdMeshers_FaceSide( theFace, edges, theMesh, theIsForward, theIgnoreMediumNodes ); + *this = StdMeshers_FaceSide( theFace, edges, theMesh, theIsForward, + theIgnoreMediumNodes, theProxyMesh ); } //================================================================================ @@ -80,11 +84,12 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, */ //================================================================================ -StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, - list& theEdges, - SMESH_Mesh* theMesh, - const bool theIsForward, - const bool theIgnoreMediumNodes) +StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, + list& theEdges, + SMESH_Mesh* theMesh, + const bool theIsForward, + const bool theIgnoreMediumNodes, + SMESH_ProxyMesh::Ptr theProxyMesh) { int nbEdges = theEdges.size(); myEdge.resize ( nbEdges ); @@ -98,13 +103,14 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, myIsUniform.resize ( nbEdges, true ); myLength = 0; myNbPonits = myNbSegments = 0; - myMesh = theMesh; + myProxyMesh = theProxyMesh; myMissingVertexNodes = false; myIgnoreMediumNodes = theIgnoreMediumNodes; myDefaultPnt2d = gp_Pnt2d( 1e+100, 1e+100 ); + if ( !myProxyMesh ) myProxyMesh.reset( new SMESH_ProxyMesh( *theMesh )); if ( nbEdges == 0 ) return; - SMESHDS_Mesh* meshDS = theMesh->GetMeshDS(); + SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS(); int nbDegen = 0; list::iterator edge = theEdges.begin(); @@ -126,7 +132,7 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, if ( myEdge[i].Orientation() == TopAbs_REVERSED ) std::swap( myFirst[i], myLast[i] ); - if ( SMESHDS_SubMesh* sm = meshDS->MeshElements( *edge )) { + if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( *edge )) { int nbN = sm->NbNodes(); if ( theIgnoreMediumNodes ) { SMDS_ElemIteratorPtr elemIt = sm->GetElements(); @@ -136,6 +142,7 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, myNbPonits += nbN; myNbSegments += sm->NbElements(); } + // TopExp::FirstVertex() and TopExp::LastVertex() return NULL from INTERNAL edge vExp.Initialize( *edge ); if ( vExp.Value().Orientation() == TopAbs_REVERSED ) vExp.Next(); @@ -144,26 +151,35 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, else myMissingVertexNodes = true; - // check if edge has non-uniform parametrization (issue 0020705) - if ( !myC2d[i].IsNull() && myEdgeLength[i] > DBL_MIN) + // check if the edge has a non-uniform parametrization (issue 0020705) + if ( !myC2d[i].IsNull() ) { - Geom2dAdaptor_Curve A2dC( myC2d[i], - std::min( myFirst[i], myLast[i] ), - std::max( myFirst[i], myLast[i] )); - double p2 = myFirst[i]+(myLast[i]-myFirst[i])/2., p4 = myFirst[i]+(myLast[i]-myFirst[i])/4.; - double d2 = GCPnts_AbscissaPoint::Length( A2dC, myFirst[i], p2 ); - double d4 = GCPnts_AbscissaPoint::Length( A2dC, myFirst[i], p4 ); - //cout<<"len = "<MeshElements( myEdge[i] )) + if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( myEdge[iE] )) { vector< pair< double, const SMDS_MeshNode*> > u2nodeVec; u2nodeVec.reserve( sm->NbNodes() ); SMDS_NodeIteratorPtr nItr = sm->GetNodes(); - double paramSize = myLast[i] - myFirst[i]; - double r = myNormPar[i] - prevNormPar; - helper.SetSubShape( myEdge[i] ); + double paramSize = myLast[iE] - myFirst[iE]; + double r = myNormPar[iE] - prevNormPar; + helper.SetSubShape( myEdge[iE] ); helper.ToFixNodeParameters( true ); - if ( !myIsUniform[i] ) + if ( !myIsUniform[iE] ) while ( nItr->more() ) { const SMDS_MeshNode* node = nItr->next(); if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge )) continue; - double u = helper.GetNodeU( myEdge[i], node, 0, ¶mOK ); + double u = helper.GetNodeU( myEdge[iE], node, 0, ¶mOK ); double aLenU = GCPnts_AbscissaPoint::Length - ( const_cast( myC3dAdaptor[i]), myFirst[i], u ); - if ( myEdgeLength[i] < aLenU ) // nonregression test "3D_mesh_NETGEN/G6" + ( const_cast( myC3dAdaptor[iE]), myFirst[iE], u ); + if ( myEdgeLength[iE] < aLenU ) // nonregression test "3D_mesh_NETGEN/G6" { u2nodeVec.clear(); break; } - double normPar = prevNormPar + r*aLenU/myEdgeLength[i]; + double normPar = prevNormPar + r*aLenU/myEdgeLength[iE]; u2nodeVec.push_back( make_pair( normPar, node )); } nItr = sm->GetNodes(); @@ -290,18 +409,18 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, const SMDS_MeshNode* node = nItr->next(); if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge )) continue; - double u = helper.GetNodeU( myEdge[i], node, 0, ¶mOK ); + double u = helper.GetNodeU( myEdge[iE], node, 0, ¶mOK ); // paramSize is signed so orientation is taken into account - double normPar = prevNormPar + r * ( u - myFirst[i] ) / paramSize; + double normPar = prevNormPar + r * ( u - myFirst[iE] ) / paramSize; u2nodeVec.push_back( make_pair( normPar, node )); } for ( size_t j = 0; j < u2nodeVec.size(); ++j ) - u2node.insert( u2node.end(), u2nodeVec[j] ); + u2node.insert( u2node.end(), u2nodeVec[j] ); } // Put 2nd vertex node for a last edge - if ( i+1 == myEdge.size() ) { + if ( iE+1 == myEdge.size() ) { node = SMESH_Algo::VertexNode( VV[1], meshDS ); if ( !node ) { MESSAGE(" NO NODE on VERTEX" ); @@ -309,8 +428,11 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, } u2node.insert( u2node.end(), make_pair( 1., node )); } - } - if ( u2node.size() != myNbPonits ) { + } // loop on myEdge's + + if ( u2node.size() + nbProxyNodes != myNbPonits && + u2node.size() + nbProxyNodes != NbPoints( /*update=*/true )) + { MESSAGE("Wrong node parameters on edges, u2node.size():" <& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, // fill array of UVPtStruct - vector* points = const_cast*>( &myPoints ); - points->resize( myNbPonits ); + UVPtStructVec& points = const_cast< UVPtStructVec& >( myPoints ); + points.resize( myNbPonits ); - int EdgeIndex = 0; - double prevNormPar = 0, paramSize = myNormPar[ EdgeIndex ]; + int iPt = 0; + double prevNormPar = 0, paramSize = myNormPar[ 0 ]; map< double, const SMDS_MeshNode*>::iterator u_node = u2node.begin(); - for (int i = 0 ; u_node != u2node.end(); ++u_node, ++i ) { - UVPtStruct & uvPt = (*points)[i]; - uvPt.node = u_node->second; - uvPt.x = uvPt.y = uvPt.normParam = u_node->first; - if ( isXConst ) uvPt.x = constValue; - else uvPt.y = constValue; - const SMDS_EdgePosition* epos = - dynamic_cast(uvPt.node->GetPosition()); - if (( myNormPar[ EdgeIndex ] < uvPt.normParam ) || - ( epos && uvPt.node->getshapeId() != myEdgeID[ EdgeIndex ])) // for myMissingVertexNodes + for ( size_t iE = 0; iE < myEdge.size(); ++iE ) + { + if ( proxySubMesh[ iE ] ) // copy data from a proxy sub-mesh { - prevNormPar = myNormPar[ EdgeIndex ]; - ++EdgeIndex; -#ifdef _DEBUG_ - if ( EdgeIndex >= myEdge.size() ) { - dump("DEBUG"); - MESSAGE ( "WRONg EdgeIndex " << 1+EdgeIndex - << " myNormPar.size()="<IsSame( wireEdges.front() )) { + theError = TError + ( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"No nodes on vertices")); + return TSideVector(0); + } } - } } else if ( *nbE > 1 ) // Issue 0020676 (Face_pb_netgen.brep) - several internal edges in a wire { @@ -720,14 +1063,16 @@ TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace, } StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, wireEdges, &theMesh, - /*isForward=*/true, theIgnoreMediumNodes); + /*isForward=*/true, theIgnoreMediumNodes, + theProxyMesh ); wires[ iW ] = StdMeshers_FaceSidePtr( wire ); from = to; } while ( !internalEdges.empty() ) { StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, internalEdges.back(), &theMesh, - /*isForward=*/true, theIgnoreMediumNodes); + /*isForward=*/true, theIgnoreMediumNodes, + theProxyMesh ); wires.push_back( StdMeshers_FaceSidePtr( wire )); internalEdges.pop_back(); }