src/DriverMED/DriverMED_Family.h

Go to the documentation of this file.
00001 //  SMESH DriverMED : tool to split groups on families
00002 //
00003 //  Copyright (C) 2003  CEA
00004 // 
00005 //  This library is free software; you can redistribute it and/or 
00006 //  modify it under the terms of the GNU Lesser General Public 
00007 //  License as published by the Free Software Foundation; either 
00008 //  version 2.1 of the License. 
00009 // 
00010 //  This library is distributed in the hope that it will be useful, 
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00013 //  Lesser General Public License for more details. 
00014 // 
00015 //  You should have received a copy of the GNU Lesser General Public 
00016 //  License along with this library; if not, write to the Free Software 
00017 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
00018 // 
00019 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00020 //
00021 //
00022 //
00023 //  File   : DriverMED_Family.hxx
00024 //  Author : Julia DOROVSKIKH
00025 //  Module : SMESH
00026 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/DriverMED/DriverMED_Family.h,v 1.10 2006/06/01 11:39:15 jfa Exp $
00027 
00028 #ifndef _INCLUDE_DRIVERMED_FAMILY
00029 #define _INCLUDE_DRIVERMED_FAMILY
00030 
00031 #include "SMDS_Mesh.hxx"
00032 #include "SMESHDS_GroupBase.hxx"
00033 #include "SMESHDS_SubMesh.hxx"
00034 #include "MED_Common.hxx"
00035 
00036 #include <boost/shared_ptr.hpp>
00037 #include <set>
00038 
00039 #define REST_NODES_FAMILY 1
00040 #define REST_EDGES_FAMILY -1
00041 #define REST_FACES_FAMILY -2
00042 #define REST_VOLUMES_FAMILY -3
00043 #define FIRST_NODE_FAMILY 2
00044 #define FIRST_ELEM_FAMILY -4
00045 
00046 class DriverMED_Family;
00047 typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr;
00048 typedef std::list<DriverMED_FamilyPtr> DriverMED_FamilyPtrList;
00049 typedef std::map<int,SMESHDS_SubMesh*> SMESHDS_SubMeshPtrMap;
00050 typedef std::list<SMESHDS_GroupBase*> SMESHDS_GroupBasePtrList;
00051 typedef std::set<const SMDS_MeshElement*> ElementsSet;
00052 
00053 class DriverMED_Family
00054 {
00055  public:
00056 
00057   DriverMED_Family();
00058 
00060 
00066   static 
00067   DriverMED_FamilyPtrList
00068   MakeFamilies (const SMESHDS_SubMeshPtrMap& theSubMeshes,
00069           const SMESHDS_GroupBasePtrList& theGroups,
00070           const bool doGroupOfNodes,
00071           const bool doGroupOfEdges,
00072           const bool doGroupOfFaces,
00073           const bool doGroupOfVolumes);
00074 
00076   MED::PFamilyInfo 
00077   GetFamilyInfo (const MED::PWrapper& theWrapper, 
00078            const MED::PMeshInfo& theMeshInfo) const;
00079 
00081   const ElementsSet& GetElements () const;
00082 
00084   int GetId () const;
00085 
00087   void SetId (const int theId);
00088 
00089  public:
00090 
00091   // Methods for groups reading from MED
00092 
00093   void AddElement(const SMDS_MeshElement* theElement);
00094 
00095   const MED::TStringSet& GetGroupNames() const;
00096   void AddGroupName(std::string theGroupName);
00097 
00098   void SetType(const SMDSAbs_ElementType theType);
00099   SMDSAbs_ElementType GetType();
00100 
00101   bool MemberOf(std::string theGroupName) const;
00102 
00103   int GetGroupAttributVal() const;
00104   void SetGroupAttributVal( int theValue);
00105 
00106  private:
00108   void Init (SMESHDS_GroupBase* group);
00109 
00111   static
00112   DriverMED_FamilyPtrList 
00113   SplitByType(SMESHDS_SubMesh* theSubMesh,
00114            const int        theId);
00115 
00116 
00121   void Split (DriverMED_FamilyPtr by,
00122            DriverMED_FamilyPtr common);
00123 
00125   bool IsEmpty () const;
00126 
00127 
00128  private:
00129   int                           myId;
00130   SMDSAbs_ElementType           myType;
00131   ElementsSet                   myElements;
00132   MED::TStringSet               myGroupNames;
00133   int                           myGroupAttributVal;
00134 };
00135 
00136 #endif