Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / StdMeshers / StdMeshers_CartesianParameters3D.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : StdMeshers_CartesianParameters3D.hxx
24 //  Author : Edward AGAPOV
25 //  Module : SMESH
26 //
27 #ifndef _SMESH_CartesianParameters3D_HXX_
28 #define _SMESH_CartesianParameters3D_HXX_
29
30 #include "SMESH_StdMeshers.hxx"
31
32 #include "SMESH_Hypothesis.hxx"
33 #include "Utils_SALOME_Exception.hxx"
34
35 #include <vector>
36
37 class SMESH_Gen;
38 class Bnd_Box;
39
40 // =========================================================
41 /*!
42  * This hypothesis specifies
43  * - Definition of the Cartesian grid
44  * - Size threshold
45  */
46 // =========================================================
47
48 class STDMESHERS_EXPORT StdMeshers_CartesianParameters3D:  public SMESH_Hypothesis
49 {
50 public:
51   // Constructor
52   StdMeshers_CartesianParameters3D( int hypId, int studyId, SMESH_Gen * gen );
53
54   /*!
55    * Sets coordinates of node positions along an axis (countered from 0)
56    */
57   void SetGrid(std::vector<double>& xNodes, int axis) throw ( SALOME_Exception );
58   /*!
59    * Return coordinates of node positions along the three axes
60    */
61   void GetGrid(std::vector<double>& xNodes, int axis) const throw ( SALOME_Exception );
62
63   /*!
64    * \brief Set grid spacing along the three axes
65    *  \param spaceFunctions - functions defining spacing values at given point on axis
66    *  \param internalPoints - points dividing a grid into parts along each direction
67    *
68    * Parameter t of spaceFunction f(t) is a position [0,1] withing bounding box of
69    * the shape to mesh
70    */
71   void SetGridSpacing(std::vector<std::string>& spaceFunctions,
72                       std::vector<double>&      internalPoints,
73                       const int                 axis) throw ( SALOME_Exception );
74
75   void GetGridSpacing(std::vector<std::string>& spaceFunctions,
76                       std::vector<double>&      internalPoints,
77                       const int                 axis) const throw ( SALOME_Exception );
78
79   bool IsGridBySpacing(const int axis) const throw ( SALOME_Exception );
80
81   /*!
82    * \brief Computes node coordinates by spacing functions
83    *  \param x0 - lower coordinate
84    *  \param x1 - upper coordinate
85    *  \param spaceFuns - space functions
86    *  \param points - internal points
87    *  \param coords - the computed coordinates
88    */
89   static void ComputeCoordinates(const double              x0,
90                                  const double              x1,
91                                  std::vector<std::string>& spaceFuns,
92                                  std::vector<double>&      points,
93                                  std::vector<double>&      coords,
94                                  const std::string&        axis ) throw (SALOME_Exception);
95   /*!
96    * Return coordinates of node positions along the three axes.
97    * If the grid is defined by spacing functions, the coordinates are computed
98    */
99   void GetCoordinates(std::vector<double>& xNodes,
100                       std::vector<double>& yNodes,
101                       std::vector<double>& zNodes,
102                       const Bnd_Box&       bndBox) const throw ( SALOME_Exception );
103   /*!
104    * Set size threshold. A polyhedral cell got by cutting an initial
105    * hexahedron by geometry boundary is considered small and is removed if
106    * it's size is \athreshold times less than the size of the initial hexahedron. 
107    */
108   void SetSizeThreshold(const double threshold) throw ( SALOME_Exception );
109   /*!
110    * \brief Return size threshold
111    */
112   double GetSizeThreshold() const;
113
114   /*!
115    * \brief Return true if parameters are well defined
116    */
117   bool IsDefined() const;
118
119   /*!
120    * \brief Persistence methods
121    */
122   virtual std::ostream & SaveTo(std::ostream & save);
123   virtual std::istream & LoadFrom(std::istream & load);
124
125   /*!
126    * \brief Initialize my parameter values by the mesh built on the geometry
127    */
128   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
129
130   /*!
131    * \brief Initialize my parameter values by default parameters.
132    */
133   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
134
135  protected:
136
137   std::vector<double>      _coords[3];
138   std::vector<std::string> _spaceFunctions[3];
139   std::vector<double>      _internalPoints[3];
140
141   double _sizeThreshold;
142 };
143
144 #endif
145