From 8b7bc04906f817d809565c023b48c039aa06dca2 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 17 Dec 2013 08:19:07 +0000 Subject: [PATCH] 0022362: EDF SMESH: Quadrangle (mapping) algorithm: enforced vertices 1) + StdMeshers_FaceSide(UVPtStructVec& theSideNodes, + const TopoDS_Face& theFace = TopoDS_Face()); 2) + static creator methods New() --- src/StdMeshers/StdMeshers_FaceSide.cxx | 55 +++++++++++++++++++++++--- src/StdMeshers/StdMeshers_FaceSide.hxx | 40 ++++++++++++++++++- 2 files changed, 87 insertions(+), 8 deletions(-) diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index 4e5e0478a..5382b7e87 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.cxx +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -251,7 +251,8 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const StdMeshers_FaceSide* theSide, */ //================================================================================ -StdMeshers_FaceSide::StdMeshers_FaceSide(UVPtStructVec& theSideNodes) +StdMeshers_FaceSide::StdMeshers_FaceSide(UVPtStructVec& theSideNodes, + const TopoDS_Face& theFace) { myEdge.resize( 1 ); myEdgeID.resize( 1, -1 ); @@ -272,12 +273,42 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(UVPtStructVec& theSideNodes) if ( !myPoints.empty() ) { myPoints[0].normParam = 0; - gp_Pnt pPrev = SMESH_TNodeXYZ( myPoints[0].node ); - for ( size_t i = 1; i < myPoints.size(); ++i ) + if ( myPoints[0].node && + myPoints.back().node && + myPoints[ myNbPonits/2 ].node ) { - gp_Pnt p = SMESH_TNodeXYZ( myPoints[i].node ); - myLength += ( myPoints[i].normParam = p.Distance( pPrev )); - pPrev = p; + 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 += p.Distance( pPrev ); + myPoints[i].normParam = myLength; + pPrev = p; + } + } + else if ( !theFace.IsNull() ) + { + TopLoc_Location loc; + Handle(Geom_Surface) surf = BRep_Tool::Surface( theFace, loc ); + gp_Pnt pPrev = surf->Value( myPoints[0].u, myPoints[0].v ); + for ( size_t i = 1; i < myPoints.size(); ++i ) + { + gp_Pnt p = surf->Value( myPoints[i].u, myPoints[i].v ); + myLength += p.Distance( pPrev ); + myPoints[i].normParam = myLength; + pPrev = p; + } + } + else + { + gp_Pnt2d pPrev = myPoints[0].UV(); + for ( size_t i = 1; i < myPoints.size(); ++i ) + { + gp_Pnt2d p = myPoints[i].UV(); + myLength += p.Distance( pPrev ); + myPoints[i].normParam = myLength; + pPrev = p; + } } if ( myLength > std::numeric_limits::min() ) for ( size_t i = 1; i < myPoints.size(); ++i ) @@ -926,6 +957,18 @@ 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; } diff --git a/src/StdMeshers/StdMeshers_FaceSide.hxx b/src/StdMeshers/StdMeshers_FaceSide.hxx index 4f714d4bf..c08d75cc3 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.hxx +++ b/src/StdMeshers/StdMeshers_FaceSide.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,6 @@ class SMESH_Mesh; class Adaptor2d_Curve2d; class Adaptor3d_Curve; class BRepAdaptor_CompCurve; -class TopoDS_Face; struct SMESH_ComputeError; class StdMeshers_FaceSide; @@ -96,7 +96,43 @@ public: /*! * \brief Create a side from an UVPtStructVec */ - StdMeshers_FaceSide(UVPtStructVec& theSideNodes); + StdMeshers_FaceSide(UVPtStructVec& theSideNodes, + const TopoDS_Face& theFace = TopoDS_Face()); + + // static "consrtuctors" + static StdMeshers_FaceSidePtr New(const TopoDS_Face& Face, + const TopoDS_Edge& Edge, + SMESH_Mesh* Mesh, + const bool IsForward, + const bool IgnoreMediumNodes, + SMESH_ProxyMesh::Ptr ProxyMesh = SMESH_ProxyMesh::Ptr()) + { return StdMeshers_FaceSidePtr + ( new StdMeshers_FaceSide( Face,Edge,Mesh,IsForward,IgnoreMediumNodes,ProxyMesh )); + } + static StdMeshers_FaceSidePtr New (const TopoDS_Face& Face, + std::list& Edges, + SMESH_Mesh* Mesh, + const bool IsForward, + const bool IgnoreMediumNodes, + SMESH_ProxyMesh::Ptr ProxyMesh = SMESH_ProxyMesh::Ptr()) + { return StdMeshers_FaceSidePtr + ( new StdMeshers_FaceSide( Face,Edges,Mesh,IsForward,IgnoreMediumNodes,ProxyMesh )); + } + static StdMeshers_FaceSidePtr New (const StdMeshers_FaceSide* Side, + const SMDS_MeshNode* Node, + const gp_Pnt2d* Pnt2d1, + const gp_Pnt2d* Pnt2d2=NULL, + const Handle(Geom2d_Curve)& C2d=NULL, + const double UFirst=0., + const double ULast=1.) + { return StdMeshers_FaceSidePtr + ( new StdMeshers_FaceSide( Side,Node,Pnt2d1,Pnt2d2,C2d,UFirst,ULast )); + } + static StdMeshers_FaceSidePtr New (UVPtStructVec& theSideNodes, + const TopoDS_Face& theFace = TopoDS_Face()) + { + return StdMeshers_FaceSidePtr( new StdMeshers_FaceSide( theSideNodes, theFace )); + } /*! * \brief Return wires of a face as StdMeshers_FaceSide's