X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_FaceSide.hxx;h=67ce0b30192f4cd7724d989f80c19678408bc97d;hb=1fb3ff621ac19da15742a5e8b9253b594977d14a;hp=e34dfe51235aea00329542e008410156a0fe90cb;hpb=79b1ac2b6df9117f16f11d444b1f165d477a1813;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_FaceSide.hxx b/src/StdMeshers/StdMeshers_FaceSide.hxx index e34dfe512..67ce0b301 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.hxx +++ b/src/StdMeshers/StdMeshers_FaceSide.hxx @@ -1,72 +1,60 @@ -// SMESH SMESH : implementaion of SMESH idl descriptions +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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, 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : StdMeshers_FaceSide.hxx // Created : Wed Jan 31 18:41:25 2007 // Author : Edward AGAPOV (eap) // Module : SMESH - +// #ifndef StdMeshers_FaceSide_HeaderFile #define StdMeshers_FaceSide_HeaderFile -#include +#include "SMESH_StdMeshers.hxx" + +#include "SMESH_ProxyMesh.hxx" + +#include +#include #include +#include #include -#include -#include - -#include "SMESH_StdMeshers.hxx" -#include "SMESH_Algo.hxx" +#include #include #include #include -class SMDS_MeshNode; -class SMESH_Mesh; class Adaptor2d_Curve2d; class Adaptor3d_Curve; class BRepAdaptor_CompCurve; -class TopoDS_Face; -class SMESH_ComputeError; - -typedef struct uvPtStruct -{ - double param; - //int curvIndex; - double normParam; - double u; // original 2d parameter - double v; - double x; // 2d parameter, normalized [0,1] - double y; - const SMDS_MeshNode * node; -} UVPtStruct; - +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; -typedef boost::shared_ptr< uvPtStruct > UVPtStructPtr; -typedef std::vector< StdMeshers_FaceSidePtr > TSideVector; -typedef boost::shared_ptr< SMESH_ComputeError > TError; +typedef std::vector< StdMeshers_FaceSidePtr > TSideVector; //================================================================================ /*! @@ -78,75 +66,184 @@ typedef boost::shared_ptr< SMESH_ComputeError > TError; class STDMESHERS_EXPORT StdMeshers_FaceSide { public: + + enum { ALL_EDGES = -1, LAST_EDGE = -1 }; //!< constants + /*! * \brief Wrap one edge */ - StdMeshers_FaceSide(const TopoDS_Face& theFace, - const TopoDS_Edge& theEdge, - SMESH_Mesh* theMesh, - const bool theIsForward, - const bool theIgnoreMediumNodes); + StdMeshers_FaceSide(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + 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, - list& theEdges, - SMESH_Mesh* theMesh, - const bool theIsForward, - const bool theIgnoreMediumNodes); + 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.); + /*! + * \brief Create a side from an UVPtStructVec + */ + StdMeshers_FaceSide(UVPtStructVec& theSideNodes, + 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, + const TopoDS_Edge& Edge, + 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,FaceHelper,ProxyMesh )); + } + 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,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.) + { 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_Edge& theEdge = TopoDS_Edge(), + SMESH_Mesh* theMesh = 0) + { + return StdMeshers_FaceSidePtr( new StdMeshers_FaceSide( theSideNodes, theFace, theEdge, theMesh )); + } /*! * \brief Return wires of a face as StdMeshers_FaceSide's */ - static TSideVector GetFaceWires(const TopoDS_Face& theFace, - SMESH_Mesh & theMesh, - const bool theIgnoreMediumNodes, - TError & theError); - + static TSideVector GetFaceWires(const TopoDS_Face& theFace, + SMESH_Mesh & theMesh, + const bool theIgnoreMediumNodes, + TError & theError, + SMESH_MesherHelper* theFaceHelper = NULL, + SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr(), + const bool theCheckVertexNodes = true); /*! * \brief Change orientation of side geometry */ void Reverse(); /*! - * \brief Return nb nodes on edges and vertices (+1 to be == GetUVPtStruct().size() ) + * \brief Make ignore medium nodes + */ + void SetIgnoreMediumNodes(bool toIgnore); + + /*! + * \brief 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 NbPoints() const { return myNbPonits; } + int NbPoints(const bool update = false) const; /*! * \brief Return nb edges + * Call it with update == true if mesh of this side can be recomputed + * since creation of this side */ - int NbSegments() const { return myNbSegments; } + int NbSegments(const bool update = false) const; /*! * \brief Return mesh */ - SMESH_Mesh* GetMesh() const { return myMesh; } + SMESH_Mesh* GetMesh() const { return myProxyMesh->GetMesh(); } /*! - * \brief Return true if there vertices without nodes + * \brief Return true if there are vertices without nodes */ bool MissVertexNode() const { return myMissingVertexNodes; } + /*! * \brief Return detailed data on nodes * \param isXConst - true if normalized parameter X is constant * \param constValue - constant parameter value * - * Missing nodes are allowed only on internal vertices + * Missing nodes are allowed only on internal vertices. + * For a closed side, the 1st point repeats at end */ - const vector& 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 * \param constValue - constant parameter value */ - const vector& SimulateUVPtStruct(int nbSeg, - bool isXConst = 0, - double constValue = 0) const; + const UVPtStructVec& SimulateUVPtStruct(int nbSeg, + bool isXConst = 0, + double constValue = 0) const; + /*! + * \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( 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 */ gp_Pnt2d Value2d(double U) const; + /*! + * \brief Return XYZ by normalized parameter + */ + gp_Pnt Value3d(double U) const; /*! * \brief Creates a Adaptor2d_Curve2d to be used in SMESH_Block */ @@ -160,25 +257,29 @@ public: */ int NbEdges() const { return myEdge.size(); } /*! - * \brief Return i-th wrapped edge (count starts from zero) + * \brief Return i-th edge (count starts from zero) */ const TopoDS_Edge& Edge(int i) const { return myEdge[i]; } /*! - * \brief Return 1st vertex of the i-the edge (count starts from zero) + * \brief Return all edges */ - inline TopoDS_Vertex FirstVertex(int i=0) const; + const std::vector& Edges() const { return myEdge; } /*! - * \brief Return last vertex of the i-the edge (count starts from zero) + * \brief Return the FACE */ - inline TopoDS_Vertex LastVertex(int i=-1) const; + const TopoDS_Face& Face() const { return myFace; } /*! - * \brief Return first normalized parameter of the i-the edge (count starts from zero) + * \brief Return 1st vertex of the i-th edge (count starts from zero) */ - inline double FirstParameter(int i) const; + TopoDS_Vertex FirstVertex(int i=0) const; /*! - * \brief Return ast normalized parameter of the i-the edge (count starts from zero) + * \brief Return last vertex of the i-th edge (count starts from zero) */ - inline double LastParameter(int i) 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 */ @@ -188,21 +289,68 @@ public: */ inline int EdgeIndex( double U ) const; - //virtual gp_Pnt Value(double U) const; - void dump(const char* msg=0) const; + /*! + * \brief Return ID of i-th wrapped edge (count starts from zero) + */ + inline int EdgeID(int i) const; + /*! + * \brief Return p-curve of i-th wrapped edge (count starts from zero) + */ + inline Handle(Geom2d_Curve) Curve2d(int i) const; + /*! + * \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-th edge (count starts from zero) + */ + inline double LastParameter(int i) const; + /*! + * \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-th edge (count starts from zero). + * EDGE orientation is taken into account + */ + inline double LastU(int i) const; + /*! + * \brief Return length of i-th wrapped edge (count starts from zero) + */ + inline double EdgeLength(int i) const; + /*! + * \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: - vector myPoints, myFalsePoints; - vector myEdge; - vector myC2d; - vector myFirst, myLast; - vector myNormPar; - double myLength; - int myNbPonits, myNbSegments; - SMESH_Mesh* myMesh; - bool myMissingVertexNodes, myIgnoreMediumNodes; + + 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; + std::vector myC2d; + std::vector myC3dAdaptor; + std::vector myFirst, myLast; + std::vector myNormPar; + std::vector myEdgeLength; + std::vector myIsUniform; + double myLength; + int myNbPonits, myNbSegments; + SMESH_ProxyMesh::Ptr myProxyMesh; + bool myMissingVertexNodes, myIgnoreMediumNodes; + gp_Pnt2d myDefaultPnt2d; + SMESH_MesherHelper* myHelper; }; @@ -223,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 */ //================================================================================ @@ -240,46 +390,109 @@ inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const //================================================================================ /*! - * \brief Return 1st vertex 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 TopoDS_Vertex StdMeshers_FaceSide::FirstVertex(int i) const +inline double StdMeshers_FaceSide::Parameter(double U, int & edgeID) const { - return i < myEdge.size() ? TopExp::FirstVertex( myEdge[i], 1 ) : TopoDS_Vertex(); + 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 last vertex of the i-the edge + * \brief Return first normalized parameter of the i-th edge */ //================================================================================ -inline TopoDS_Vertex StdMeshers_FaceSide::LastVertex(int i) const +inline double StdMeshers_FaceSide::FirstParameter(int i) const { - return i<0 ? TopExp::LastVertex( myEdge.back(), 1) : i myLast[i]; } #endif