X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_FaceSide.hxx;h=86fe12c62d6b3f393ca5ef1727ff49df8b3cc790;hp=30166d441e9bb11659a1373819779c8d712031f3;hb=f7712f9c03c5553fc299b9bd9d28d81ce1c83666;hpb=ae32dcd34f98b91cdb4f5800063a394feb0df408 diff --git a/src/StdMeshers/StdMeshers_FaceSide.hxx b/src/StdMeshers/StdMeshers_FaceSide.hxx index 30166d441..86fe12c62 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.hxx +++ b/src/StdMeshers/StdMeshers_FaceSide.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -43,13 +43,14 @@ #include #include -class SMDS_MeshNode; -class SMESH_Mesh; class Adaptor2d_Curve2d; class Adaptor3d_Curve; class BRepAdaptor_CompCurve; -struct SMESH_ComputeError; +class SMDS_MeshNode; +class SMESH_Mesh; +class SMESH_MesherHelper; class StdMeshers_FaceSide; +struct SMESH_ComputeError; typedef boost::shared_ptr< SMESH_ComputeError > TError; typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr; @@ -65,6 +66,9 @@ typedef std::vector< StdMeshers_FaceSidePtr > TSideVector; class STDMESHERS_EXPORT StdMeshers_FaceSide { public: + + enum { ALL_EDGES = -1, LAST_EDGE = -1 }; //!< constants + /*! * \brief Wrap one edge */ @@ -73,31 +77,37 @@ public: SMESH_Mesh* theMesh, const bool theIsForward, const bool theIgnoreMediumNodes, + SMESH_MesherHelper* theFaceHelper = NULL, SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr()); /*! * \brief Wrap several edges. Edges must be properly ordered and oriented. */ - StdMeshers_FaceSide(const TopoDS_Face& theFace, - std::list& theEdges, - SMESH_Mesh* theMesh, - const bool theIsForward, - const bool theIgnoreMediumNodes, - SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr()); + StdMeshers_FaceSide(const TopoDS_Face& theFace, + const std::list& theEdges, + SMESH_Mesh* theMesh, + const bool theIsForward, + const bool theIgnoreMediumNodes, + SMESH_MesherHelper* theFaceHelper = NULL, + SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr()); /*! * \brief Simulate a side from a vertex using data from other FaceSide */ StdMeshers_FaceSide(const StdMeshers_FaceSide* theSide, const SMDS_MeshNode* theNode, const gp_Pnt2d* thePnt2d1, - const gp_Pnt2d* thePnt2d2=NULL, - const Handle(Geom2d_Curve)& theC2d=NULL, - const double theUFirst=0., - const double theULast=1.); + const gp_Pnt2d* thePnt2d2 = NULL, + const Handle(Geom2d_Curve)& theC2d = NULL, + const double theUFirst = 0., + const double theULast = 1.); /*! * \brief Create a side from an UVPtStructVec */ StdMeshers_FaceSide(UVPtStructVec& theSideNodes, - const TopoDS_Face& theFace = TopoDS_Face()); + const TopoDS_Face& theFace = TopoDS_Face(), + const TopoDS_Edge& theEdge = TopoDS_Edge(), + SMESH_Mesh* theMesh = 0); + + ~StdMeshers_FaceSide(); // static "consrtuctors" static StdMeshers_FaceSidePtr New(const TopoDS_Face& Face, @@ -105,33 +115,37 @@ public: SMESH_Mesh* Mesh, const bool IsForward, const bool IgnoreMediumNodes, + SMESH_MesherHelper* FaceHelper = NULL, SMESH_ProxyMesh::Ptr ProxyMesh = SMESH_ProxyMesh::Ptr()) { return StdMeshers_FaceSidePtr - ( new StdMeshers_FaceSide( Face,Edge,Mesh,IsForward,IgnoreMediumNodes,ProxyMesh )); + ( new StdMeshers_FaceSide( Face,Edge,Mesh,IsForward,IgnoreMediumNodes,FaceHelper,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()) + static StdMeshers_FaceSidePtr New (const TopoDS_Face& Face, + const std::list& Edges, + SMESH_Mesh* Mesh, + const bool IsForward, + const bool IgnoreMediumNodes, + SMESH_MesherHelper* FaceHelper = NULL, + SMESH_ProxyMesh::Ptr ProxyMesh = SMESH_ProxyMesh::Ptr()) { return StdMeshers_FaceSidePtr - ( new StdMeshers_FaceSide( Face,Edges,Mesh,IsForward,IgnoreMediumNodes,ProxyMesh )); + ( new StdMeshers_FaceSide( Face,Edges,Mesh,IsForward,IgnoreMediumNodes,FaceHelper,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.) + 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()) + const TopoDS_Face& theFace = TopoDS_Face(), + const TopoDS_Edge& theEdge = TopoDS_Edge(), + SMESH_Mesh* theMesh = 0) { - return StdMeshers_FaceSidePtr( new StdMeshers_FaceSide( theSideNodes, theFace )); + return StdMeshers_FaceSidePtr( new StdMeshers_FaceSide( theSideNodes, theFace, theEdge, theMesh )); } /*! @@ -141,8 +155,9 @@ public: SMESH_Mesh & theMesh, const bool theIgnoreMediumNodes, TError & theError, + SMESH_MesherHelper* theFaceHelper = NULL, SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr(), - const bool theCheckVertexNodes=true); + const bool theCheckVertexNodes = true); /*! * \brief Change orientation of side geometry */ @@ -181,7 +196,7 @@ public: * Missing nodes are allowed only on internal vertices. * For a closed side, the 1st point repeats at end */ - const UVPtStructVec& GetUVPtStruct(bool isXConst =0, double constValue =0) const; + const UVPtStructVec& GetUVPtStruct( bool isXConst = 0, double constValue = 0 ) const; /*! * \brief Simulates detailed data on nodes * \param isXConst - true if normalized parameter X is constant @@ -191,15 +206,36 @@ public: bool isXConst = 0, double constValue = 0) const; /*! - * \brief Return nodes in the order they encounter while walking along the side. - * For a closed side, the 1st point repeats at end + * \brief Return nodes in the order they encounter while walking along + * the whole side or a specified EDGE. For a closed side, the 1st point repeats at end. + * \param iE - index of the EDGE. Default is "all EDGEs". */ - std::vector GetOrderedNodes() const; + std::vector GetOrderedNodes( int iE = ALL_EDGES ) const; /*! + * \brief Return nodes of the i-th EDGE. + * Nodes moved to other geometry by MergeNodes() are also returned. + * \retval bool - is OK + */ + bool GetEdgeNodes(const size_t i, + std::vector& nodes, + bool inlude1stVertex=true, + bool inludeLastVertex=true) const; + + /*! + * \brief Return a node from the i-th VERTEX (count starts from zero) + * Nodes moved to other geometry by MergeNodes() are also returned. + */ + const SMDS_MeshNode* VertexNode(std::size_t i, bool* isMoved = 0) const; + + /* * \brief Return edge and parameter on edge by normalized parameter */ inline double Parameter(double U, TopoDS_Edge & edge) const; + /* + * \brief Return edge ID and parameter on edge by normalized parameter + */ + inline double Parameter(double U, int & edgeID) const; /*! * \brief Return UV by normalized parameter */ @@ -229,13 +265,21 @@ public: */ const std::vector& Edges() const { return myEdge; } /*! - * \brief Return 1st vertex of the i-the edge (count starts from zero) + * \brief Return the FACE + */ + const TopoDS_Face& Face() const { return myFace; } + /*! + * \brief Return 1st vertex of the i-th edge (count starts from zero) */ TopoDS_Vertex FirstVertex(int i=0) const; /*! - * \brief Return last vertex of the i-the edge (count starts from zero) + * \brief Return last vertex of the i-th edge (count starts from zero) */ - TopoDS_Vertex LastVertex(int i=-1) const; + TopoDS_Vertex LastVertex(int i = LAST_EDGE) const; + /*! + * \brief Return \c true if the chain of EDGEs is closed + */ + bool IsClosed() const; /*! * \brief Return side length */ @@ -245,8 +289,6 @@ public: */ inline int EdgeIndex( double U ) const; - //virtual gp_Pnt Value(double U) const; - void dump(const char* msg=0) const; /*! @@ -258,20 +300,20 @@ public: */ inline Handle(Geom2d_Curve) Curve2d(int i) const; /*! - * \brief Return first normalized parameter of the i-the edge (count starts from zero) + * \brief Return first normalized parameter of the i-th edge (count starts from zero) */ inline double FirstParameter(int i) const; /*! - * \brief Return last normalized parameter of the i-the edge (count starts from zero) + * \brief Return last normalized parameter of the i-th edge (count starts from zero) */ inline double LastParameter(int i) const; /*! - * \brief Return first parameter of the i-the edge (count starts from zero). + * \brief Return first parameter of the i-th edge (count starts from zero). * EDGE orientation is taken into account */ inline double FirstU(int i) const; /*! - * \brief Return last parameter of the i-the edge (count starts from zero). + * \brief Return last parameter of the i-th edge (count starts from zero). * EDGE orientation is taken into account */ inline double LastU(int i) const; @@ -283,12 +325,17 @@ public: * \brief Return orientation of i-th wrapped edge (count starts from zero) */ inline bool IsReversed(int i) const; + /*! + * \brief Return a helper initialized with the FACE + */ + SMESH_MesherHelper* FaceHelper() const; protected: void reverseProxySubmesh( const TopoDS_Edge& E ); // DON't FORGET to update Reverse() when adding one more vector! + TopoDS_Face myFace; std::vector myPoints, myFalsePoints; std::vector myEdge; std::vector myEdgeID; @@ -303,6 +350,7 @@ protected: SMESH_ProxyMesh::Ptr myProxyMesh; bool myMissingVertexNodes, myIgnoreMediumNodes; gp_Pnt2d myDefaultPnt2d; + SMESH_MesherHelper* myHelper; }; @@ -323,9 +371,11 @@ inline int StdMeshers_FaceSide::EdgeIndex( double U ) const //================================================================================ /*! - * \brief Return edge and parameter on edge by normalized parameter - * \param U - the parameter + * \brief Return an edge and parameter on the edge by a normalized parameter + * \param U - normalized parameter * \retval double - pameter on a curve + * \ warning The returned parameter can be inaccurate if the edge is non-uniformly + * parametrized. Use Value2d() to get a precise point on the edge */ //================================================================================ @@ -340,7 +390,26 @@ inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const //================================================================================ /*! - * \brief Return first normalized parameter of the i-the edge + * \brief Return an edge ID and parameter on the edge by a normalized parameter + * \param U - normalized parameter + * \retval double - pameter on a curve + * \ warning The returned parameter can be inaccurate if the edge is non-uniformly + * parametrized. Use Value2d() to get a precise point on the edge + */ +//================================================================================ + +inline double StdMeshers_FaceSide::Parameter(double U, int & edgeID) const +{ + int i = EdgeIndex( U ); + edgeID = myEdgeID[ i ]; + double prevU = i ? myNormPar[ i-1 ] : 0; + double r = ( U - prevU )/ ( myNormPar[ i ] - prevU ); + return myFirst[i] * ( 1 - r ) + myLast[i] * r; +} + +//================================================================================ +/*! + * \brief Return first normalized parameter of the i-th edge */ //================================================================================ @@ -351,7 +420,7 @@ inline double StdMeshers_FaceSide::FirstParameter(int i) const //================================================================================ /*! - * \brief Return ast normalized parameter of the i-the edge + * \brief Return ast normalized parameter of the i-th edge */ //================================================================================ @@ -362,7 +431,7 @@ inline double StdMeshers_FaceSide::LastParameter(int i) const //================================================================================ /*! - * \brief Return first parameter of the i-the edge + * \brief Return first parameter of the i-th edge */ //================================================================================ @@ -373,7 +442,7 @@ inline double StdMeshers_FaceSide::FirstU(int i) const //================================================================================ /*! - * \brief Return last parameter of the i-the edge + * \brief Return last parameter of the i-th edge */ //================================================================================