X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_FaceSide.cxx;h=b543928dcabd653c2e7adfda7f4f26fca61b11c5;hb=8fff0ccaded5504f785ff689fea994ea208f1490;hp=36f0680cc4267e48bd301fc4ff4df772709f3011;hpb=1067ffa6e7e5c394e3a1b17219d8b355a57607cd;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index 36f0680cc..b543928dc 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 @@ -51,6 +51,7 @@ #include #include +#include #include "utilities.h" @@ -160,11 +161,10 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, double d4 = GCPnts_AbscissaPoint::Length( A2dC, myFirst[i], p4 ); //cout<<"len = "<& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, { const UVPtStructVec& edgeUVPtStruct = proxySubMesh[iE]->GetUVPtStructVec(); std::copy( edgeUVPtStruct.begin(), edgeUVPtStruct.end(), & points[iPt] ); + // check orientation + double du1 = edgeUVPtStruct.back().param - edgeUVPtStruct[0].param; + double du2 = myLast[iE] - myFirst[iE]; + if ( du1 * du2 < 0 ) + { + std::reverse( & points[iPt], & points[iPt + edgeUVPtStruct.size()]); + for ( size_t i = 0; i < edgeUVPtStruct.size(); ++i ) + points[iPt+i].normParam = 1. - points[iPt+i].normParam; + } // update normalized params if ( myEdge.size() > 1 ) { for ( size_t i = 0; i < edgeUVPtStruct.size(); ++i, ++iPt ) { UVPtStruct & uvPt = points[iPt]; - uvPt.normParam = prevNormPar + uvPt.normParam * paramSize; - uvPt.x = uvPt.y = uvPt.normParam; + uvPt.normParam = prevNormPar + uvPt.normParam * paramSize; + uvPt.x = uvPt.y = uvPt.normParam; } --iPt; // to point to the 1st VERTEX of the next EDGE } @@ -578,7 +676,8 @@ void StdMeshers_FaceSide::Reverse() int nbEdges = myEdge.size(); for ( int i = nbEdges-1; i >= 0; --i ) { std::swap( myFirst[i], myLast[i] ); - myEdge[i].Reverse(); + if ( !myEdge[i].IsNull() ) + myEdge[i].Reverse(); if ( i > 0 ) // at the first loop 1. is overwritten myNormPar[i] = 1 - myNormPar[i-1]; } @@ -586,7 +685,7 @@ void StdMeshers_FaceSide::Reverse() reverse( myEdge ); reverse( myEdgeID ); reverse( myC2d ); - reverse( myC3dAdaptor ); + //reverse( myC3dAdaptor ); reverse( myFirst ); reverse( myLast ); reverse( myNormPar ); @@ -596,11 +695,131 @@ void StdMeshers_FaceSide::Reverse() if ( nbEdges > 0 ) { myNormPar[nbEdges-1]=1.; - myPoints.clear(); - myFalsePoints.clear(); - for ( size_t i = 0; i < myEdge.size(); ++i ) - reverseProxySubmesh( myEdge[i] ); + if ( !myEdge[0].IsNull() ) + { + for ( size_t i = 0; i < myEdge.size(); ++i ) + reverseProxySubmesh( myEdge[i] ); + myPoints.clear(); + myFalsePoints.clear(); + } + else + { + for ( size_t i = 0; i < myPoints.size(); ++i ) + { + UVPtStruct & uvPt = myPoints[i]; + uvPt.normParam = 1 - uvPt.normParam; + uvPt.x = 1 - uvPt.x; + uvPt.y = 1 - uvPt.y; + } + reverse( myPoints ); + + for ( size_t i = 0; i < myFalsePoints.size(); ++i ) + { + UVPtStruct & uvPt = myFalsePoints[i]; + uvPt.normParam = 1 - uvPt.normParam; + uvPt.x = 1 - uvPt.x; + uvPt.y = 1 - uvPt.y; + } + reverse( myFalsePoints ); + } + } + for ( size_t i = 0; i < myEdge.size(); ++i ) + { + if ( myEdge[i].IsNull() ) continue; // for a side on points only + double fp,lp; + Handle(Geom_Curve) C3d = BRep_Tool::Curve(myEdge[i],fp,lp); + if ( !C3d.IsNull() ) + myC3dAdaptor[i].Load( C3d, fp,lp ); + } +} + +//======================================================================= +//function : SetIgnoreMediumNodes +//purpose : Make ignore medium nodes +//======================================================================= + +void StdMeshers_FaceSide::SetIgnoreMediumNodes(bool toIgnore) +{ + if ( myIgnoreMediumNodes != toIgnore ) + { + myIgnoreMediumNodes = toIgnore; + + if ( !myPoints.empty() ) + { + UVPtStructVec newPoints; + newPoints.reserve( myPoints.size()/2 + 1 ); + for ( size_t i = 0; i < myPoints.size(); i += 2 ) + newPoints.push_back( myPoints[i] ); + + myPoints.swap( newPoints ); + } + else + { + NbPoints( /*update=*/true ); + } + } +} + +//======================================================================= +//function : NbPoints +//purpose : Return nb nodes on edges and vertices (+1 to be == GetUVPtStruct().size() ) +// Call it with update == true if mesh of this side can be recomputed +// since creation of this side +//======================================================================= + +int StdMeshers_FaceSide::NbPoints(const bool update) const +{ + if ( !myPoints.empty() ) + return myPoints.size(); + + // if ( !myFalsePoints.empty() ) + // return myFalsePoints.size(); + + if ( update && myEdge.size() > 0 ) + { + StdMeshers_FaceSide* me = (StdMeshers_FaceSide*) this; + me->myNbPonits = 0; + me->myNbSegments = 0; + me->myMissingVertexNodes = false; + + for ( int i = 0; i < NbEdges(); ++i ) + { + TopoDS_Vertex v1 = SMESH_MesherHelper::IthVertex( 0, myEdge[i] ); + if ( SMESH_Algo::VertexNode( v1, myProxyMesh->GetMeshDS() )) + me->myNbPonits += 1; // for the first end + else + me->myMissingVertexNodes = true; + + if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( Edge(i) )) { + int nbN = sm->NbNodes(); + if ( myIgnoreMediumNodes ) { + SMDS_ElemIteratorPtr elemIt = sm->GetElements(); + if ( elemIt->more() && elemIt->next()->IsQuadratic() ) + nbN -= sm->NbElements(); + } + me->myNbPonits += nbN; + me->myNbSegments += sm->NbElements(); + } + } + TopoDS_Vertex v1 = SMESH_MesherHelper::IthVertex( 1, Edge( NbEdges()-1 )); + if ( SMESH_Algo::VertexNode( v1, myProxyMesh->GetMeshDS() )) + me->myNbPonits++; // for the last end + else + me->myMissingVertexNodes = true; } + return myNbPonits; +} + +//======================================================================= +//function : NbSegments +//purpose : Return nb edges +// Call it with update == true if mesh of this side can be recomputed +// since creation of this side +//======================================================================= + +int StdMeshers_FaceSide::NbSegments(const bool update) const +{ + return NbPoints( update ), myNbSegments; } //================================================================================ @@ -709,7 +928,6 @@ BRepAdaptor_CompCurve* StdMeshers_FaceSide::GetCurve3d() const return new BRepAdaptor_CompCurve( aWire ); } - //================================================================================ /*! * \brief Return 2D point by normalized parameter @@ -740,9 +958,50 @@ gp_Pnt2d StdMeshers_FaceSide::Value2d(double U) const return myC2d[ i ]->Value(par); } + else if ( !myPoints.empty() ) + { + int i = U * double( myPoints.size()-1 ); + while ( i > 0 && myPoints[ i ].normParam > U ) + --i; + while ( i+1 < myPoints.size() && myPoints[ i+1 ].normParam < U ) + ++i; + double r = (( U - myPoints[ i ].normParam ) / + ( myPoints[ i+1 ].normParam - myPoints[ i ].normParam )); + return ( myPoints[ i ].UV() * ( 1 - r ) + + myPoints[ i+1 ].UV() * r ); + } return myDefaultPnt2d; } +//================================================================================ +/*! + * \brief Return XYZ by normalized parameter + * \param U - normalized parameter value + * \retval gp_Pnt - point + */ +//================================================================================ + +gp_Pnt StdMeshers_FaceSide::Value3d(double U) const +{ + int i = EdgeIndex( U ); + double prevU = i ? myNormPar[ i-1 ] : 0; + double r = ( U - prevU )/ ( myNormPar[ i ] - prevU ); + + double par = myFirst[i] * ( 1 - r ) + myLast[i] * r; + + // check parametrization of curve + if( !myIsUniform[i] ) + { + double aLen3dU = r * myEdgeLength[i] * ( myFirst[i]>myLast[i] ? -1. : 1.); + GCPnts_AbscissaPoint AbPnt + ( const_cast( myC3dAdaptor[i]), aLen3dU, myFirst[i] ); + if( AbPnt.IsDone() ) { + par = AbPnt.Parameter(); + } + } + return myC3dAdaptor[ i ].Value(par); +} + //================================================================================ /*! * \brief Return wires of a face as StdMeshers_FaceSide's @@ -755,10 +1014,9 @@ TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace, TError & theError, SMESH_ProxyMesh::Ptr theProxyMesh) { - TopoDS_Vertex V1; list< TopoDS_Edge > edges, internalEdges; list< int > nbEdgesInWires; - int nbWires = SMESH_Block::GetOrderedEdges (theFace, V1, edges, nbEdgesInWires); + int nbWires = SMESH_Block::GetOrderedEdges (theFace, edges, nbEdgesInWires); // split list of all edges into separate wires TSideVector wires( nbWires );