Salome HOME
Merge remote branch 'origin/gdd/translations'
[modules/smesh.git] / src / SMESH_I / SMESH_Group_i.hxx
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
24 //  File   : SMESH_Group_i.hxx
25 //  Author : Sergey ANIKIN, OCC
26 //  Module : SMESH
27 //
28 #ifndef SMESH_Group_i_HeaderFile
29 #define SMESH_Group_i_HeaderFile
30
31 #include "SMESH.hxx"
32 #include "SMESH_Mesh_i.hxx"
33 #include "SMESH_Filter_i.hxx"
34
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(SMESH_Group)
37 #include CORBA_SERVER_HEADER(SMESH_Mesh)
38 #include CORBA_CLIENT_HEADER(GEOM_Gen)
39
40 #include "SALOME_GenericObj_i.hh"
41
42 class SMESH_Group;
43 class SMESHDS_GroupBase;
44 class SMESH_PreMeshInfo;
45
46 // ===========
47 // Group Base
48 // ===========
49 class SMESH_I_EXPORT SMESH_GroupBase_i:
50   public virtual POA_SMESH::SMESH_GroupBase,
51   public virtual SALOME::GenericObj_i
52 {
53  public:
54   SMESH_GroupBase_i(PortableServer::POA_ptr thePOA,
55                     SMESH_Mesh_i*           theMeshServant,
56                     const int               theLocalID );
57   virtual ~SMESH_GroupBase_i();
58
59   // CORBA interface implementation
60   void SetName(const char* name);
61   char* GetName();
62   SMESH::ElementType GetType();
63   CORBA::Long Size();
64   CORBA::Boolean IsEmpty();
65   CORBA::Boolean Contains(CORBA::Long elem_id);
66   CORBA::Long GetID(CORBA::Long elem_index);
67   SMESH::long_array* GetListOfID();
68   SMESH::long_array* GetNodeIDs();
69   CORBA::Long GetNumberOfNodes();
70   CORBA::Boolean IsNodeInfoAvailable(); // for gui
71
72   virtual SMESH::SMESH_Mesh_ptr GetMesh();
73
74   /*!
75    * Returns number of mesh elements of each \a EntityType
76    * Result array of number of elements per \a EntityType
77    * Inherited from SMESH_IDSource
78    */
79   virtual SMESH::long_array* GetMeshInfo();
80   /*!
81    * Returns number of mesh elements of each \a ElementType
82    */
83   virtual SMESH::long_array* GetNbElementsByType();
84   /*!
85    * Returns a sequence of all element IDs
86    */
87   virtual SMESH::long_array* GetIDs();
88   /*!
89    * Returns types of elements it contains
90    * Inherited from SMESH_IDSource interface
91    */
92   virtual SMESH::array_of_ElementType* GetTypes();
93   /*!
94    * Returns false if GetMeshInfo() returns incorrect information that may
95    * happen if mesh data is not yet fully loaded from the file of study.
96    */
97   virtual bool IsMeshInfoCorrect();
98   /*!
99    * Returns mesh unstructed grid information.
100    */
101   virtual SALOMEDS::TMPFile* GetVtkUgStream();
102
103   // Internal C++ interface
104   int GetLocalID() const { return myLocalID; }
105   SMESH_Mesh_i* GetMeshServant() const { return myMeshServant; }
106   SMESH_Group* GetSmeshGroup() const;
107   SMESHDS_GroupBase* GetGroupDS() const;
108
109   void SetColor(const SALOMEDS::Color& color);
110   SALOMEDS::Color GetColor();
111
112   void SetColorNumber(CORBA::Long color);
113   CORBA::Long GetColorNumber();
114
115 protected:
116
117   SMESH_PreMeshInfo* & changePreMeshInfo() { return myPreMeshInfo; }
118   SMESH_PreMeshInfo* myPreMeshInfo; // mesh info before full loading from study file
119   friend class SMESH_PreMeshInfo;
120
121   int myNbNodes, myGroupDSTic;
122
123 private:
124   SMESH_Mesh_i* myMeshServant;
125   int myLocalID;
126
127   void changeLocalId(int localId) { myLocalID = localId; }
128   friend class SMESH_Mesh_i;
129 };
130
131 // ======
132 // Group
133 // ======
134
135 class SMESH_I_EXPORT SMESH_Group_i:
136   public virtual POA_SMESH::SMESH_Group,
137   public SMESH_GroupBase_i
138 {
139  public:
140   SMESH_Group_i( PortableServer::POA_ptr thePOA,
141                  SMESH_Mesh_i*           theMeshServant,
142                  const int               theLocalID );
143   // CORBA interface implementation
144   void Clear();
145   CORBA::Long Add( const SMESH::long_array& theIDs );
146   CORBA::Long Remove( const SMESH::long_array& theIDs );
147
148   CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate );
149   CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate );
150
151   CORBA::Long AddFrom( SMESH::SMESH_IDSource_ptr theSource );
152 };
153
154 // =========================
155 // Group linked to geometry
156 // =========================
157
158 class SMESH_I_EXPORT SMESH_GroupOnGeom_i:
159   public virtual POA_SMESH::SMESH_GroupOnGeom,
160   public SMESH_GroupBase_i
161 {
162  public:
163   SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA,
164                        SMESH_Mesh_i*           theMeshServant,
165                        const int               theLocalID );
166   // CORBA interface implementation
167   GEOM::GEOM_Object_ptr GetShape();
168 };
169
170 // =========================
171 // Group deined by filter
172 // =========================
173
174 class SMESH_I_EXPORT SMESH_GroupOnFilter_i:
175   public virtual POA_SMESH::SMESH_GroupOnFilter,
176   public SMESH_GroupBase_i,
177   public SMESH::Filter_i::TPredicateChangeWaiter
178 {
179  public:
180   SMESH_GroupOnFilter_i( PortableServer::POA_ptr thePOA,
181                          SMESH_Mesh_i*           theMeshServant,
182                          const int               theLocalID );
183   ~SMESH_GroupOnFilter_i();
184
185   // Persistence
186   static SMESH::Filter_ptr StringToFilter(const std::string& thePersistentString );
187   std::string FilterToString() const;
188
189   static SMESH_PredicatePtr GetPredicate( SMESH::Filter_ptr );
190
191   // CORBA interface implementation
192   void SetFilter(SMESH::Filter_ptr theFilter);
193   SMESH::Filter_ptr GetFilter();
194   virtual SMESH::long_array* GetListOfID();
195   virtual SMESH::long_array* GetMeshInfo();
196
197   // method of SMESH::Filter_i::TPredicateChangeWaiter
198   virtual void PredicateChanged();
199
200  private:
201   SMESH::Filter_var myFilter;
202 };
203 #endif