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