Salome HOME
Color Number (Color Group) parameter is returned for compatibility
[modules/smesh.git] / src / DriverMED / DriverMED_Family.h
1 //  SMESH DriverMED : tool to split groups on families
2 //
3 //  Copyright (C) 2003  CEA
4 // 
5 //  This library is free software; you can redistribute it and/or 
6 //  modify it under the terms of the GNU Lesser General Public 
7 //  License as published by the Free Software Foundation; either 
8 //  version 2.1 of the License. 
9 // 
10 //  This library is distributed in the hope that it will be useful, 
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 //  Lesser General Public License for more details. 
14 // 
15 //  You should have received a copy of the GNU Lesser General Public 
16 //  License along with this library; if not, write to the Free Software 
17 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 //
22 //
23 //  File   : DriverMED_Family.hxx
24 //  Author : Julia DOROVSKIKH
25 //  Module : SMESH
26 //  $Header$
27
28 #ifndef _INCLUDE_DRIVERMED_FAMILY
29 #define _INCLUDE_DRIVERMED_FAMILY
30
31 #include "SMESH_DriverMED.hxx"
32
33 #include "SMDS_Mesh.hxx"
34 #include "SMESHDS_GroupBase.hxx"
35 #include "SMESHDS_SubMesh.hxx"
36 #include "MED_Common.hxx"
37
38 #include <boost/shared_ptr.hpp>
39 #include <set>
40
41 #include "SALOMEconfig.h"
42 #include CORBA_SERVER_HEADER(SALOMEDS)
43 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
44
45 #define REST_NODES_FAMILY 1
46 #define REST_EDGES_FAMILY -1
47 #define REST_FACES_FAMILY -2
48 #define REST_VOLUMES_FAMILY -3
49 #define FIRST_NODE_FAMILY 2
50 #define FIRST_ELEM_FAMILY -4
51
52 class DriverMED_Family;
53 typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr;
54 typedef std::list<DriverMED_FamilyPtr> DriverMED_FamilyPtrList;
55 typedef std::map<int,SMESHDS_SubMesh*> SMESHDS_SubMeshPtrMap;
56 typedef std::list<SMESHDS_GroupBase*> SMESHDS_GroupBasePtrList;
57 typedef std::set<const SMDS_MeshElement*> ElementsSet;
58 typedef std::map<int,SALOMEDS::Color> ColorMap;
59
60 class MESHDRIVERMED_EXPORT DriverMED_Family
61 {
62  public:
63
64   DriverMED_Family();
65
66   //! Methods for groups storing to MED
67   /*!
68     Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes>
69     on some parts (families) on the basis of the elements membership in other groups
70     from <theGroups> and other sub-meshes from <theSubMeshes>.
71     Resulting families have no common elements.
72   */
73   static 
74   DriverMED_FamilyPtrList
75   MakeFamilies (const SMESHDS_SubMeshPtrMap& theSubMeshes,
76                 const SMESHDS_GroupBasePtrList& theGroups,
77                 const bool doGroupOfNodes,
78                 const bool doGroupOfEdges,
79                 const bool doGroupOfFaces,
80                 const bool doGroupOfVolumes);
81
82   //! Create TFamilyInfo for this family
83   MED::PFamilyInfo 
84   GetFamilyInfo (const MED::PWrapper& theWrapper, 
85                  const MED::PMeshInfo& theMeshInfo) const;
86
87   //! Returns elements of this family
88   const ElementsSet& GetElements () const;
89
90   //! Returns a family ID
91   int GetId () const;
92
93   //! Sets a family ID
94   void SetId (const int theId);
95
96  public:
97
98   // Methods for groups reading from MED
99
100   void AddElement(const SMDS_MeshElement* theElement);
101
102   const MED::TStringSet& GetGroupNames() const;
103   void AddGroupName(std::string theGroupName);
104
105   void SetType(const SMDSAbs_ElementType theType);
106   SMDSAbs_ElementType GetType();
107
108   bool MemberOf(std::string theGroupName) const;
109
110   int GetGroupAttributVal() const;
111   void SetGroupAttributVal( int theValue);
112
113  private:
114   //! Initialize the tool by SMESHDS_GroupBase
115   void Init (SMESHDS_GroupBase* theGroup, const ColorMap& theColorMap);
116
117   //! Split <theSubMesh> on some parts (families) on the basis of the elements type.
118   static
119   DriverMED_FamilyPtrList 
120   SplitByType(SMESHDS_SubMesh* theSubMesh,
121               const int        theId);
122
123
124   /*! Remove from <Elements> elements, common with <by>,
125     Remove from <by> elements, common with <Elements>,
126     Create family <common> from common elements, with combined groups list.
127   */
128   void Split (DriverMED_FamilyPtr by,
129               DriverMED_FamilyPtr common);
130
131   //! Check, if this family has empty list of elements
132   bool IsEmpty () const;
133
134
135  private:
136   int                           myId;
137   SMDSAbs_ElementType           myType;
138   ElementsSet                   myElements;
139   MED::TStringSet               myGroupNames;
140   int                           myGroupAttributVal;
141 };
142
143 #endif