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 // SMESH DriverMED : tool to split groups on families
24 // File : DriverMED_Family.hxx
25 // Author : Julia DOROVSKIKH
29 #ifndef _INCLUDE_DRIVERMED_FAMILY
30 #define _INCLUDE_DRIVERMED_FAMILY
32 #include "SMESH_DriverMED.hxx"
34 #include "SMDS_Mesh.hxx"
35 #include "SMESHDS_GroupBase.hxx"
36 #include "SMESHDS_SubMesh.hxx"
37 #include "MED_Common.hxx"
39 #include <boost/shared_ptr.hpp>
42 #define REST_NODES_FAMILY 1
43 #define FIRST_NODE_FAMILY 2
45 #define REST_EDGES_FAMILY -1
46 #define REST_FACES_FAMILY -2
47 #define REST_VOLUMES_FAMILY -3
48 #define REST_0DELEM_FAMILY -4
49 #define REST_BALL_FAMILY -5
50 #define FIRST_ELEM_FAMILY -6
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;
59 class MESHDRIVERMED_EXPORT DriverMED_Family
65 //! Methods for groups storing to MED
67 Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes>
68 on some parts (families) on the basis of the elements membership in other groups
69 from <theGroups> and other sub-meshes from <theSubMeshes>.
70 Resulting families have no common elements.
73 DriverMED_FamilyPtrList
74 MakeFamilies (const SMESHDS_SubMeshPtrMap& theSubMeshes,
75 const SMESHDS_GroupBasePtrList& theGroups,
76 const bool doGroupOfNodes,
77 const bool doGroupOfEdges,
78 const bool doGroupOfFaces,
79 const bool doGroupOfVolumes,
80 const bool doGroupOf0DElems,
81 const bool doGroupOfBalls);
83 //! Create TFamilyInfo for this family
85 GetFamilyInfo (const MED::PWrapper& theWrapper,
86 const MED::PMeshInfo& theMeshInfo) const;
88 //! Returns elements of this family
89 const ElementsSet& GetElements () const;
91 //! Returns a family ID
95 void SetId (const int theId);
99 // Methods for groups reading from MED
101 void AddElement(const SMDS_MeshElement* theElement);
103 const MED::TStringSet& GetGroupNames() const;
104 void AddGroupName(std::string theGroupName);
106 void SetType(const SMDSAbs_ElementType theType);
107 SMDSAbs_ElementType GetType();
108 const std::set< SMDSAbs_ElementType >& GetTypes() const;
110 bool MemberOf(std::string theGroupName) const;
112 int GetGroupAttributVal() const;
113 void SetGroupAttributVal( int theValue);
116 //! Initialize the tool by SMESHDS_GroupBase
117 void Init (SMESHDS_GroupBase* group);
119 //! Split <theSubMesh> on some parts (families) on the basis of the elements type.
121 DriverMED_FamilyPtrList
122 SplitByType(SMESHDS_SubMesh* theSubMesh,
126 /*! Remove from <Elements> elements, common with <by>,
127 Remove from <by> elements, common with <Elements>,
128 Create family <common> from common elements, with combined groups list.
130 void Split (DriverMED_FamilyPtr by,
131 DriverMED_FamilyPtr common);
133 //! Check, if this family has empty list of elements
134 bool IsEmpty () const;
139 SMDSAbs_ElementType myType;
140 ElementsSet myElements;
141 MED::TStringSet myGroupNames;
142 int myGroupAttributVal;
143 std::set<SMDSAbs_ElementType> myTypes; // Issue 0020576