Salome HOME
Merging with WPdev
[modules/smesh.git] / src / StdMeshers / StdMeshers_ProjectionSource2D.hxx
1 //  SMESH SMESH : idl implementation based on 'SMESH' unit's calsses
2 //
3 //  Copyright (C) 2003  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 //
24 //  File   : StdMeshers_ProjectionSource2D.hxx
25 //  Author : Edward AGAPOV
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_ProjectionSource2D_HXX_
30 #define _SMESH_ProjectionSource2D_HXX_
31
32 #include "SMESH_StdMeshers.hxx"
33
34 #include "SMESH_Hypothesis.hxx"
35 #include "Utils_SALOME_Exception.hxx"
36
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Vertex.hxx>
39
40 class SMESH_Gen;
41
42 // =========================================================
43 /*!
44  * This hypothesis specifies a meshed face to take a mesh pattern from
45  * and optionally association of vertices between the source face and a
46  * target one (where a hipothesis is assigned to)
47  */
48 // =========================================================
49
50 class STDMESHERS_EXPORT StdMeshers_ProjectionSource2D: public SMESH_Hypothesis
51 {
52 public:
53   // Constructor
54   StdMeshers_ProjectionSource2D( int hypId, int studyId, SMESH_Gen * gen );
55   // Destructor
56   virtual ~StdMeshers_ProjectionSource2D();
57
58   /*!
59    * Sets a source <face> to take a mesh pattern from
60    */
61   void SetSourceFace(const TopoDS_Shape& face)
62     throw ( SALOME_Exception );
63
64   /*!
65    * Returns the source face
66    */
67   TopoDS_Face GetSourceFace() const;
68
69   /*!
70    * Sets source <mesh> to take a mesh pattern from
71    */
72   void SetSourceMesh(SMESH_Mesh* mesh);
73
74   /*!
75    * Return source mesh
76    */
77   SMESH_Mesh* GetSourceMesh() const { return _sourceMesh; }
78
79   /*!
80    * Sets vertex association between the source face and the target one.
81    * This parameter is optional.
82    * Two vertices must belong to one edge of a face
83    */
84   void SetVertexAssociation(const TopoDS_Shape& sourceVertex1,
85                             const TopoDS_Shape& sourceVertex2,
86                             const TopoDS_Shape& targetVertex1,
87                             const TopoDS_Shape& targetVertex2)
88     throw ( SALOME_Exception );
89
90   /*!
91    * Returns the <i>-th source vertex associated with the <i>-th target vertex.
92    * Result may be nil if association not set.
93    * Valid indices are 1 and 2
94    */
95   TopoDS_Vertex GetSourceVertex(int i) const throw ( SALOME_Exception );
96
97   /*!
98    * Returns the <i>-th target vertex associated with the <i>-th source vertex.
99    * Result may be nil if association not set.
100    * Valid indices are 1 and 2
101    */
102   TopoDS_Vertex GetTargetVertex(int i) const throw ( SALOME_Exception );
103
104   /*!
105    * \brief Test if vertex association defined
106     * \retval bool - test result
107    */
108   bool HasVertexAssociation() const
109   { return ( !_sourceVertex1.IsNull() && !_targetVertex1.IsNull() &&
110              !_sourceVertex2.IsNull() && !_targetVertex2.IsNull()); }
111
112   /*!
113    * \brief Return all parameters
114    */
115   void GetStoreParams(TopoDS_Shape& s1,
116                       TopoDS_Shape& s2,
117                       TopoDS_Shape& s3,
118                       TopoDS_Shape& s4,
119                       TopoDS_Shape& s5) const;
120
121   /*!
122    * \brief Set all parameters without notifying on modification
123    */
124   void RestoreParams(const TopoDS_Shape& s1,
125                      const TopoDS_Shape& s2,
126                      const TopoDS_Shape& s3,
127                      const TopoDS_Shape& s4,
128                      const TopoDS_Shape& s5,
129                      SMESH_Mesh*         mesh);
130
131   virtual std::ostream & SaveTo(std::ostream & save);
132   virtual std::istream & LoadFrom(std::istream & load);
133   friend std::ostream & operator <<(std::ostream & save, StdMeshers_ProjectionSource2D & hyp);
134   friend std::istream & operator >>(std::istream & load, StdMeshers_ProjectionSource2D & hyp);
135
136   /*!
137    * \brief Initialize parameters by the mesh built on the geometry
138     * \param theMesh - the built mesh
139     * \param theShape - the geometry of interest
140     * \retval bool - true if parameter values have been successfully defined
141     *
142     * Implementation does noting
143    */
144   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
145
146 protected:
147
148   TopoDS_Face   _sourceFace;
149   SMESH_Mesh*   _sourceMesh;
150   TopoDS_Vertex _sourceVertex1;
151   TopoDS_Vertex _sourceVertex2;
152   TopoDS_Vertex _targetVertex1;
153   TopoDS_Vertex _targetVertex2;
154 };
155
156 #endif
157