1 // SMESH DriverMED : tool to split groups on families
3 // Copyright (C) 2003 CEA
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.
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.
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
19 // See http://www.salome-platform.org or email : webmaster.salome@opencascade.org
23 // File : DriverMED_Family.hxx
24 // Author : Julia DOROVSKIKH
28 #ifndef _INCLUDE_DRIVERMED_FAMILY
29 #define _INCLUDE_DRIVERMED_FAMILY
31 #include "SMDS_Mesh.hxx"
32 #include "SMESHDS_GroupBase.hxx"
33 #include "SMESHDS_SubMesh.hxx"
34 #include "MEDA_Wrapper.hxx"
36 #include <boost/shared_ptr.hpp>
39 #define REST_NODES_FAMILY 1
40 #define REST_EDGES_FAMILY -1
41 #define REST_FACES_FAMILY -2
42 #define REST_VOLUMES_FAMILY -3
43 #define FIRST_NODE_FAMILY 2
44 #define FIRST_ELEM_FAMILY -4
46 class DriverMED_Family;
47 typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr;
49 class DriverMED_Family
53 // Methods for groups storing to MED
55 static std::list<DriverMED_FamilyPtr> MakeFamilies (const std::map <int, SMESHDS_SubMesh*>& theSubMeshes,
56 const std::list<SMESHDS_GroupBase*>& theGroups,
57 const bool doGroupOfNodes,
58 const bool doGroupOfEdges,
59 const bool doGroupOfFaces,
60 const bool doGroupOfVolumes);
61 // Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes>
62 // on some parts (families) on the basis of the elements membership in other groups
63 // from <theGroups> and other sub-meshes from <theSubMeshes>.
64 // Resulting families have no common elements.
66 MEDA::PFamilyInfo GetFamilyInfo (const MEDA::PMeshInfo& theMeshInfo) const;
67 // Create TFamilyInfo for this family
69 const std::set<const SMDS_MeshElement *>& GetElements () const { return myElements; }
70 // Returns elements of this family
72 int GetId () const { return myId; }
73 // Returns a family ID
77 // Methods for groups reading from MED
79 void AddElement (const SMDS_MeshElement* theElement) { myElements.insert(theElement); }
81 void AddGroupName (std::string theGroupName) { myGroupNames.insert(theGroupName); }
83 void SetType (const SMDSAbs_ElementType theType) { myType = theType; }
84 SMDSAbs_ElementType GetType () { return myType; }
86 bool MemberOf (std::string theGroupName) const
87 { return (myGroupNames.find(theGroupName) != myGroupNames.end()); }
89 const MED::TStringSet& GetGroupNames () const { return myGroupNames; }
92 void Init (SMESHDS_GroupBase* group);
93 // Initialize the tool by SMESHDS_GroupBase
95 static std::list<DriverMED_FamilyPtr> SplitByType (SMESHDS_SubMesh* theSubMesh,
97 // Split <theSubMesh> on some parts (families)
98 // on the basis of the elements type.
100 void Split (DriverMED_FamilyPtr by,
101 DriverMED_FamilyPtr common);
102 // Remove from <Elements> elements, common with <by>,
103 // Remove from <by> elements, common with <Elements>,
104 // Create family <common> from common elements, with combined groups list.
106 void SetId (const int theId) { myId = theId; }
109 bool IsEmpty () const { return myElements.empty(); }
110 // Check, if this family has empty list of elements
114 SMDSAbs_ElementType myType;
115 std::set<const SMDS_MeshElement *> myElements;
116 MED::TStringSet myGroupNames;