SALOME - SMESH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
StdMeshers_FaceSide.hxx
Go to the documentation of this file.
00001 //  Copyright (C) 2007-2008  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 //  SMESH SMESH : implementaion of SMESH idl descriptions
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 <gp_Pnt2d.hxx>
00032 #include <TopoDS_Edge.hxx>
00033 #include <TopoDS_Vertex.hxx>
00034 #include <Geom2d_Curve.hxx>
00035 #include <TopExp.hxx>
00036 
00037 #include "SMESH_StdMeshers.hxx"
00038 #include "SMESH_Algo.hxx"
00039 
00040 #include <vector>
00041 #include <list>
00042 #include <boost/shared_ptr.hpp>
00043 
00044 class SMDS_MeshNode;
00045 class SMESH_Mesh;
00046 class Adaptor2d_Curve2d;
00047 class Adaptor3d_Curve;
00048 class BRepAdaptor_CompCurve;
00049 class TopoDS_Face;
00050 struct SMESH_ComputeError;
00051 
00052 typedef struct uvPtStruct
00053 {
00054   double param;
00055   //int    curvIndex;
00056   double normParam;
00057   double u; // original 2d parameter
00058   double v;
00059   double x; // 2d parameter, normalized [0,1]
00060   double y;
00061   const SMDS_MeshNode * node;
00062 } UVPtStruct;
00063 
00064 class StdMeshers_FaceSide;
00065 typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr;
00066 typedef boost::shared_ptr< uvPtStruct > UVPtStructPtr;
00067 typedef std::vector< StdMeshers_FaceSidePtr > TSideVector;
00068 typedef boost::shared_ptr< SMESH_ComputeError > TError;
00069 
00070 //================================================================================
00075 //================================================================================
00076 
00077 class STDMESHERS_EXPORT StdMeshers_FaceSide
00078 {
00079 public:
00083   StdMeshers_FaceSide(const TopoDS_Face& theFace,
00084                       const TopoDS_Edge& theEdge,
00085                       SMESH_Mesh*        theMesh,
00086                       const bool         theIsForward,
00087                       const bool         theIgnoreMediumNodes);
00091   StdMeshers_FaceSide(const TopoDS_Face& theFace,
00092                       std::list<TopoDS_Edge>& theEdges,
00093                       SMESH_Mesh*        theMesh,
00094                       const bool         theIsForward,
00095                       const bool         theIgnoreMediumNodes);
00099   StdMeshers_FaceSide(const SMDS_MeshNode* theNode,
00100                       const gp_Pnt2d thePnt2d,
00101                       const StdMeshers_FaceSide* theSide);
00105   static TSideVector GetFaceWires(const TopoDS_Face& theFace,
00106                                   SMESH_Mesh &       theMesh,
00107                                   const bool         theIgnoreMediumNodes,
00108                                   TError &           theError);  
00109 
00113   void Reverse();
00117   int NbPoints() const { return myNbPonits; }
00121   int NbSegments() const { return myNbSegments; }
00125   SMESH_Mesh* GetMesh() const { return myMesh; }
00129   bool MissVertexNode() const { return myMissingVertexNodes; }
00137   const std::vector<UVPtStruct>& GetUVPtStruct(bool isXConst =0, double constValue =0) const;
00143   const std::vector<UVPtStruct>& SimulateUVPtStruct(int    nbSeg,
00144                                                bool   isXConst   = 0,
00145                                                double constValue = 0) const;
00149   inline double Parameter(double U, TopoDS_Edge & edge) const;
00153   gp_Pnt2d Value2d(double U) const;
00157   Adaptor2d_Curve2d* GetCurve2d() const;
00161   BRepAdaptor_CompCurve* GetCurve3d() const;
00165   int NbEdges() const { return myEdge.size(); }
00169   const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
00173   inline TopoDS_Vertex FirstVertex(int i=0) const;
00177   inline TopoDS_Vertex LastVertex(int i=-1) const;
00181   inline double FirstParameter(int i) const;
00185   inline double LastParameter(int i) const;
00189   double Length() const { return myLength; }
00193   inline int EdgeIndex( double U ) const;
00194 
00195   //virtual gp_Pnt Value(double U) const;
00196   
00197   void dump(const char* msg=0) const;
00198   
00199 
00200 protected:
00201   std::vector<uvPtStruct>           myPoints, myFalsePoints;
00202   std::vector<TopoDS_Edge>          myEdge;
00203   std::vector<Handle(Geom2d_Curve)> myC2d;
00204   std::vector<double>               myFirst, myLast;
00205   std::vector<double>               myNormPar;
00206   double                            myLength;
00207   int                               myNbPonits, myNbSegments;
00208   SMESH_Mesh*                       myMesh;
00209   bool                              myMissingVertexNodes, myIgnoreMediumNodes;
00210   gp_Pnt2d                          myDefaultPnt2d;
00211 };
00212 
00213 
00214 //================================================================================
00220 //================================================================================
00221 
00222 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
00223 {
00224   int i = myNormPar.size() - 1;
00225   while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
00226   return i;
00227 }
00228 
00229 //================================================================================
00235 //================================================================================
00236 
00237 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
00238 {
00239   int i = EdgeIndex( U );
00240   edge = myEdge[ i ];
00241   double prevU = i ? myNormPar[ i-1 ] : 0;
00242   double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
00243   return myFirst[i] * ( 1 - r ) + myLast[i] * r;
00244 }
00245 
00246 //================================================================================
00250 //================================================================================
00251 
00252 inline TopoDS_Vertex StdMeshers_FaceSide::FirstVertex(int i) const
00253 {
00254   return i < myEdge.size() ? TopExp::FirstVertex( myEdge[i], 1 ) : TopoDS_Vertex();
00255 }
00256 
00257 //================================================================================
00261 //================================================================================
00262 
00263 inline TopoDS_Vertex StdMeshers_FaceSide::LastVertex(int i) const
00264 {
00265   return i<0 ? TopExp::LastVertex( myEdge.back(), 1) : i<myEdge.size() ? TopExp::LastVertex( myEdge[i], 1 ) : TopoDS_Vertex();
00266 }
00267 
00268 //================================================================================
00272 //================================================================================
00273 
00274 inline double StdMeshers_FaceSide::FirstParameter(int i) const
00275 {
00276   return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.;
00277 }
00278 
00279 //================================================================================
00283 //================================================================================
00284 
00285 inline double StdMeshers_FaceSide::LastParameter(int i) const
00286 {
00287   return i<myNormPar.size() ? myNormPar[i] : 1;
00288 }
00289 
00290 #endif