Version: 6.3.1

src/StdMeshers/StdMeshers_FaceSide.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 <Geom2d_Curve.hxx>
00032 #include <GeomAdaptor_Curve.hxx>
00033 #include <TopoDS_Edge.hxx>
00034 #include <TopoDS_Vertex.hxx>
00035 #include <gp_Pnt2d.hxx>
00036 
00037 #include "SMESH_StdMeshers.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 boost::shared_ptr< uvPtStruct > UVPtStructPtr;
00066 typedef std::vector< StdMeshers_FaceSidePtr > TSideVector;
00067 typedef boost::shared_ptr< SMESH_ComputeError > TError;
00068 
00069 //================================================================================
00074 //================================================================================
00075 
00076 class STDMESHERS_EXPORT StdMeshers_FaceSide
00077 {
00078 public:
00082   StdMeshers_FaceSide(const TopoDS_Face& theFace,
00083                       const TopoDS_Edge& theEdge,
00084                       SMESH_Mesh*        theMesh,
00085                       const bool         theIsForward,
00086                       const bool         theIgnoreMediumNodes);
00090   StdMeshers_FaceSide(const TopoDS_Face& theFace,
00091                       std::list<TopoDS_Edge>& theEdges,
00092                       SMESH_Mesh*        theMesh,
00093                       const bool         theIsForward,
00094                       const bool         theIgnoreMediumNodes);
00098   StdMeshers_FaceSide(const SMDS_MeshNode* theNode,
00099                       const gp_Pnt2d thePnt2d,
00100                       const StdMeshers_FaceSide* theSide);
00104   static TSideVector GetFaceWires(const TopoDS_Face& theFace,
00105                                   SMESH_Mesh &       theMesh,
00106                                   const bool         theIgnoreMediumNodes,
00107                                   TError &           theError);  
00108 
00112   void Reverse();
00116   int NbPoints() const { return myNbPonits; }
00120   int NbSegments() const { return myNbSegments; }
00124   SMESH_Mesh* GetMesh() const { return myMesh; }
00128   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;
00148   inline double Parameter(double U, TopoDS_Edge & edge) const;
00152   gp_Pnt2d Value2d(double U) const;
00156   Adaptor2d_Curve2d* GetCurve2d() const;
00160   BRepAdaptor_CompCurve* GetCurve3d() const;
00164   int NbEdges() const { return myEdge.size(); }
00168   const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
00172   TopoDS_Vertex FirstVertex(int i=0) const;
00176   TopoDS_Vertex LastVertex(int i=-1) const;
00180   inline double FirstParameter(int i) const;
00184   inline double LastParameter(int i) const;
00188   double Length() const { return myLength; }
00192   inline int EdgeIndex( double U ) const;
00193 
00194   //virtual gp_Pnt Value(double U) const;
00195   
00196   void dump(const char* msg=0) const;
00197   
00198 
00199 protected:
00200 
00201   // DON't FORGET tO update Reverse() when adding one more vector!
00202   std::vector<uvPtStruct>           myPoints, myFalsePoints;
00203   std::vector<TopoDS_Edge>          myEdge;
00204   std::vector<int>                  myEdgeID;
00205   std::vector<Handle(Geom2d_Curve)> myC2d;
00206   std::vector<GeomAdaptor_Curve>    myC3dAdaptor;
00207   std::vector<double>               myFirst, myLast;
00208   std::vector<double>               myNormPar;
00209   std::vector<double>               myEdgeLength;
00210   std::vector<double>               myIsUniform;
00211   double                            myLength;
00212   int                               myNbPonits, myNbSegments;
00213   SMESH_Mesh*                       myMesh;
00214   bool                              myMissingVertexNodes, myIgnoreMediumNodes;
00215   gp_Pnt2d                          myDefaultPnt2d;
00216 };
00217 
00218 
00219 //================================================================================
00225 //================================================================================
00226 
00227 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
00228 {
00229   int i = myNormPar.size() - 1;
00230   while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
00231   return i;
00232 }
00233 
00234 //================================================================================
00240 //================================================================================
00241 
00242 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
00243 {
00244   int i = EdgeIndex( U );
00245   edge = myEdge[ i ];
00246   double prevU = i ? myNormPar[ i-1 ] : 0;
00247   double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
00248   return myFirst[i] * ( 1 - r ) + myLast[i] * r;
00249 }
00250 
00251 //================================================================================
00255 //================================================================================
00256 
00257 inline double StdMeshers_FaceSide::FirstParameter(int i) const
00258 {
00259   return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.;
00260 }
00261 
00262 //================================================================================
00266 //================================================================================
00267 
00268 inline double StdMeshers_FaceSide::LastParameter(int i) const
00269 {
00270   return i<myNormPar.size() ? myNormPar[i] : 1;
00271 }
00272 
00273 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS