X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_FaceSide.cxx;h=4e5e0478af102aa743419d1065ede20a14e6f9e1;hb=26a602248d57062471f1a9c6a2c8c7aaf7b1495f;hp=4d72e2f68bcab49d12faab351cc4564b4539ae49;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index 4d72e2f68..4e5e0478a 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.cxx +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -51,6 +51,7 @@ #include #include +#include #include "utilities.h" @@ -202,36 +203,92 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace, //================================================================================ /*! * \brief Constructor of a side for vertex using data from other FaceSide - * \param theVertex - the vertex - * \param theSide - the side + * \param theVertex - the vertex + * \param theSide - the side */ //================================================================================ -StdMeshers_FaceSide::StdMeshers_FaceSide(const SMDS_MeshNode* theNode, - const gp_Pnt2d thePnt2d, - const StdMeshers_FaceSide* theSide) +StdMeshers_FaceSide::StdMeshers_FaceSide(const StdMeshers_FaceSide* theSide, + const SMDS_MeshNode* theNode, + const gp_Pnt2d* thePnt2d1, + const gp_Pnt2d* thePnt2d2, + const Handle(Geom2d_Curve)& theC2d, + const double theUFirst, + const double theULast) { - myC2d.resize(1); + myC2d.push_back ( theC2d ); + myFirst.push_back ( theUFirst ); + myLast.push_back ( theULast ); + myNormPar.push_back ( 1. ); + myIsUniform.push_back( true ); + myEdgeID.push_back ( 0 ); myLength = 0; myProxyMesh = theSide->myProxyMesh; - myDefaultPnt2d = thePnt2d; - - myPoints = theSide->GetUVPtStruct(); - myNbPonits = myPoints.size(); - myNbSegments = theSide->myNbSegments; - std::vector::iterator it = myPoints.begin(); - for(; it!=myPoints.end(); it++) { - (*it).u = thePnt2d.X(); - (*it).v = thePnt2d.Y(); - (*it).y = 0.0; - (*it).node = theNode; + myDefaultPnt2d = *thePnt2d1; + myPoints = theSide->GetUVPtStruct(); + myNbPonits = myPoints.size(); + myNbSegments = theSide->myNbSegments; + if ( thePnt2d2 ) + for ( size_t i = 0; i < myPoints.size(); ++i ) + { + double r = i / ( myPoints.size() - 1. ); + myPoints[i].u = (1-r) * thePnt2d1->X() + r * thePnt2d2->X(); + myPoints[i].v = (1-r) * thePnt2d1->Y() + r * thePnt2d2->Y(); + myPoints[i].node = theNode; + } + else + for ( size_t i = 0; i < myPoints.size(); ++i ) + { + myPoints[i].u = thePnt2d1->X(); + myPoints[i].v = thePnt2d1->Y(); + myPoints[i].node = theNode; + } +} + +//================================================================================ +/* + * Create a side from an UVPtStructVec + */ +//================================================================================ + +StdMeshers_FaceSide::StdMeshers_FaceSide(UVPtStructVec& theSideNodes) +{ + myEdge.resize( 1 ); + myEdgeID.resize( 1, -1 ); + myC2d.resize( 1 ); + myC3dAdaptor.resize( 1 ); + myFirst.resize( 1, 0. ); + myLast.resize( 1, 1. ); + myNormPar.resize( 1, 1. ); + myIsUniform.resize( 1, 1 ); + myMissingVertexNodes = myIgnoreMediumNodes = false; + myDefaultPnt2d.SetCoord( 1e100, 1e100 ); + + myPoints = theSideNodes; + myNbPonits = myPoints.size(); + myNbSegments = myNbPonits + 1; + + myLength = 0; + if ( !myPoints.empty() ) + { + myPoints[0].normParam = 0; + gp_Pnt pPrev = SMESH_TNodeXYZ( myPoints[0].node ); + for ( size_t i = 1; i < myPoints.size(); ++i ) + { + gp_Pnt p = SMESH_TNodeXYZ( myPoints[i].node ); + myLength += ( myPoints[i].normParam = p.Distance( pPrev )); + pPrev = p; + } + if ( myLength > std::numeric_limits::min() ) + for ( size_t i = 1; i < myPoints.size(); ++i ) + myPoints[i].normParam /= myLength; } + myEdgeLength.resize( 1, myLength ); } //================================================================================ -/*! - * \brief Return info on nodes on the side - * \retval UVPtStruct* - array of data structures +/* + * Return info on nodes on the side */ //================================================================================ @@ -358,13 +415,22 @@ const vector& 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 } @@ -579,7 +645,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]; } @@ -597,10 +664,33 @@ 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 ) {