Back to index

salome-smesh  6.5.0
StdMeshers_FaceSide.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File      : StdMeshers_FaceSide.hxx
00024 // Created   : Wed Jan 31 18:41:25 2007
00025 // Author    : Edward AGAPOV (eap)
00026 // Module    : SMESH
00027 //
00028 #ifndef StdMeshers_FaceSide_HeaderFile
00029 #define StdMeshers_FaceSide_HeaderFile
00030 
00031 #include "SMESH_StdMeshers.hxx"
00032 
00033 #include <Geom2d_Curve.hxx>
00034 #include <GeomAdaptor_Curve.hxx>
00035 #include <TopoDS_Edge.hxx>
00036 #include <TopoDS_Vertex.hxx>
00037 #include <gp_Pnt2d.hxx>
00038 
00039 #include <vector>
00040 #include <list>
00041 #include <boost/shared_ptr.hpp>
00042 
00043 class SMDS_MeshNode;
00044 class SMESH_Mesh;
00045 class Adaptor2d_Curve2d;
00046 class Adaptor3d_Curve;
00047 class BRepAdaptor_CompCurve;
00048 class TopoDS_Face;
00049 struct SMESH_ComputeError;
00050 
00051 typedef struct uvPtStruct
00052 {
00053   double param;
00054   //int    curvIndex;
00055   double normParam;
00056   double u; // original 2d parameter
00057   double v;
00058   double x; // 2d parameter, normalized [0,1]
00059   double y;
00060   const SMDS_MeshNode * node;
00061 } UVPtStruct;
00062 
00063 class StdMeshers_FaceSide;
00064 typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr;
00065 typedef std::vector< StdMeshers_FaceSidePtr >    TSideVector;
00066 typedef boost::shared_ptr< SMESH_ComputeError >  TError;
00067 
00068 //================================================================================
00073 //================================================================================
00074 
00075 class STDMESHERS_EXPORT StdMeshers_FaceSide
00076 {
00077 public:
00081   StdMeshers_FaceSide(const TopoDS_Face& theFace,
00082                       const TopoDS_Edge& theEdge,
00083                       SMESH_Mesh*        theMesh,
00084                       const bool         theIsForward,
00085                       const bool         theIgnoreMediumNodes);
00089   StdMeshers_FaceSide(const TopoDS_Face&      theFace,
00090                       std::list<TopoDS_Edge>& theEdges,
00091                       SMESH_Mesh*             theMesh,
00092                       const bool              theIsForward,
00093                       const bool              theIgnoreMediumNodes);
00097   StdMeshers_FaceSide(const SMDS_MeshNode*       theNode,
00098                       const gp_Pnt2d             thePnt2d,
00099                       const StdMeshers_FaceSide* theSide);
00103   static TSideVector GetFaceWires(const TopoDS_Face& theFace,
00104                                   SMESH_Mesh &       theMesh,
00105                                   const bool         theIgnoreMediumNodes,
00106                                   TError &           theError);  
00107 
00111   void Reverse();
00115   int NbPoints() const { return myNbPonits; }
00119   int NbSegments() const { return myNbSegments; }
00123   SMESH_Mesh* GetMesh() const { return myMesh; }
00127   bool MissVertexNode() const { return myMissingVertexNodes; }
00136   const std::vector<UVPtStruct>& GetUVPtStruct(bool isXConst =0, double constValue =0) const;
00142   const std::vector<UVPtStruct>& SimulateUVPtStruct(int    nbSeg,
00143                                                     bool   isXConst   = 0,
00144                                                     double constValue = 0) const;
00149   std::vector<const SMDS_MeshNode*> GetOrderedNodes() const;
00153   inline double Parameter(double U, TopoDS_Edge & edge) const;
00157   gp_Pnt2d Value2d(double U) const;
00161   Adaptor2d_Curve2d* GetCurve2d() const;
00165   BRepAdaptor_CompCurve* GetCurve3d() const;
00169   int NbEdges() const { return myEdge.size(); }
00173   const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
00177   const std::vector<TopoDS_Edge>& Edges() const { return myEdge; }
00181   TopoDS_Vertex FirstVertex(int i=0) const;
00185   TopoDS_Vertex LastVertex(int i=-1) const;
00189   inline double FirstParameter(int i) const;
00193   inline double LastParameter(int i) const;
00197   double Length() const { return myLength; }
00201   inline int EdgeIndex( double U ) const;
00202 
00203   //virtual gp_Pnt Value(double U) const;
00204   
00205   void dump(const char* msg=0) const;
00206   
00207 
00208 protected:
00209 
00210   // DON't FORGET to update Reverse() when adding one more vector!
00211   std::vector<uvPtStruct>           myPoints, myFalsePoints;
00212   std::vector<TopoDS_Edge>          myEdge;
00213   std::vector<int>                  myEdgeID;
00214   std::vector<Handle(Geom2d_Curve)> myC2d;
00215   std::vector<GeomAdaptor_Curve>    myC3dAdaptor;
00216   std::vector<double>               myFirst, myLast;
00217   std::vector<double>               myNormPar;
00218   std::vector<double>               myEdgeLength;
00219   std::vector<double>               myIsUniform;
00220   double                            myLength;
00221   int                               myNbPonits, myNbSegments;
00222   SMESH_Mesh*                       myMesh;
00223   bool                              myMissingVertexNodes, myIgnoreMediumNodes;
00224   gp_Pnt2d                          myDefaultPnt2d;
00225 };
00226 
00227 
00228 //================================================================================
00234 //================================================================================
00235 
00236 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
00237 {
00238   int i = myNormPar.size() - 1;
00239   while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
00240   return i;
00241 }
00242 
00243 //================================================================================
00249 //================================================================================
00250 
00251 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
00252 {
00253   int i = EdgeIndex( U );
00254   edge = myEdge[ i ];
00255   double prevU = i ? myNormPar[ i-1 ] : 0;
00256   double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
00257   return myFirst[i] * ( 1 - r ) + myLast[i] * r;
00258 }
00259 
00260 //================================================================================
00264 //================================================================================
00265 
00266 inline double StdMeshers_FaceSide::FirstParameter(int i) const
00267 {
00268   return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.;
00269 }
00270 
00271 //================================================================================
00275 //================================================================================
00276 
00277 inline double StdMeshers_FaceSide::LastParameter(int i) const
00278 {
00279   return i<myNormPar.size() ? myNormPar[i] : 1;
00280 }
00281 
00282 #endif