1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : StdMeshers_CartesianParameters3D.hxx
24 // Author : Edward AGAPOV
27 #ifndef _SMESH_CartesianParameters3D_HXX_
28 #define _SMESH_CartesianParameters3D_HXX_
30 #include "SMESH_StdMeshers.hxx"
32 #include "SMESH_Hypothesis.hxx"
33 #include "Utils_SALOME_Exception.hxx"
40 // =========================================================
42 * This hypothesis specifies
43 * - Definition of the Cartesian grid
46 // =========================================================
48 class STDMESHERS_EXPORT StdMeshers_CartesianParameters3D: public SMESH_Hypothesis
52 StdMeshers_CartesianParameters3D( int hypId, int studyId, SMESH_Gen * gen );
55 * Sets coordinates of node positions along an axis (countered from 0)
57 void SetGrid(std::vector<double>& xNodes, int axis) throw ( SALOME_Exception );
59 * Return coordinates of node positions along the three axes
61 void GetGrid(std::vector<double>& xNodes, int axis) const throw ( SALOME_Exception );
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
68 * Parameter t of spaceFunction f(t) is a position [0,1] withing bounding box of
71 void SetGridSpacing(std::vector<std::string>& spaceFunctions,
72 std::vector<double>& internalPoints,
73 const int axis) throw ( SALOME_Exception );
75 void GetGridSpacing(std::vector<std::string>& spaceFunctions,
76 std::vector<double>& internalPoints,
77 const int axis) const throw ( SALOME_Exception );
79 bool IsGridBySpacing(const int axis) const throw ( SALOME_Exception );
82 * Set/unset a fixed point, at which a node will be created provided that grid
83 * is defined by spacing in all directions
85 void SetFixedPoint(const double p[3], bool toUnset);
86 bool GetFixedPoint(double p[3]);
89 * \brief Computes node coordinates by spacing functions
90 * \param x0 - lower coordinate
91 * \param x1 - upper coordinate
92 * \param spaceFuns - space functions
93 * \param points - internal points
94 * \param coords - the computed coordinates
96 static void ComputeCoordinates(const double x0,
98 std::vector<std::string>& spaceFuns,
99 std::vector<double>& points,
100 std::vector<double>& coords,
101 const std::string& axis ) throw (SALOME_Exception);
103 * Return coordinates of node positions along the three axes.
104 * If the grid is defined by spacing functions, the coordinates are computed
106 void GetCoordinates(std::vector<double>& xNodes,
107 std::vector<double>& yNodes,
108 std::vector<double>& zNodes,
109 const Bnd_Box& bndBox) const throw ( SALOME_Exception );
112 * \brief Set custom direction of axes
114 void SetAxisDirs(const double* the9DirComps) throw ( SALOME_Exception );
115 const double* GetAxisDirs() const { return _axisDirs; }
117 * \brief Returns axes at which number of hexahedra is maximal
119 static void ComputeOptimalAxesDirs(const TopoDS_Shape& shape,
120 const bool isOrthogonal,
121 double dirCoords[9]);
123 * Set size threshold. A polyhedral cell got by cutting an initial
124 * hexahedron by geometry boundary is considered small and is removed if
125 * it's size is \athreshold times less than the size of the initial hexahedron.
127 void SetSizeThreshold(const double threshold) throw ( SALOME_Exception );
129 * \brief Return size threshold
131 double GetSizeThreshold() const;
134 * \brief Enables implementation of geometrical edges into the mesh. If this feature
135 * is disabled, sharp edges of the shape are lost ("smoothed") in the mesh if
136 * they don't coincide with the grid lines
138 void SetToAddEdges(bool toAdd);
139 bool GetToAddEdges() const;
142 * \brief Return true if parameters are well defined
144 bool IsDefined() const;
147 * \brief Persistence methods
149 virtual std::ostream & SaveTo(std::ostream & save);
150 virtual std::istream & LoadFrom(std::istream & load);
153 * \brief Initialize my parameter values by the mesh built on the geometry
155 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
158 * \brief Initialize my parameter values by default parameters.
160 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
164 std::vector<double> _coords[3];
165 std::vector<std::string> _spaceFunctions[3];
166 std::vector<double> _internalPoints[3];
168 double _axisDirs [9];
169 double _fixedPoint[3];
171 double _sizeThreshold;