Salome HOME
7d16f4e47fe3367113af8cb75f087de937b48a30
[modules/paravis.git] / src / Plugins / MEDReader / plugin / MEDLoaderForPV / ExtractGroupHelper.h
1 // Copyright (C) 2020-2023  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #pragma once
22
23 #include <sstream>
24 #include <vector>
25 #include <set>
26 #include <map>
27
28 #include "MEDLoaderForPV.h"
29
30 class MEDLOADERFORPV_EXPORT ExtractGroupStatus
31 {
32 public:
33   ExtractGroupStatus():_status(false) { }
34   ExtractGroupStatus(const char *name);
35   bool getStatus() const { return _status; }
36   void setStatus(bool status) const { _status=status; }
37   void cpyStatusFrom(const ExtractGroupStatus& other) { _status=other._status; }
38   std::string getName() const { return _name; }
39   void resetStatus() const { _status=false; }
40   const char *getKeyOfEntry() const { return _ze_key_name.c_str(); }
41   virtual void printMySelf(std::ostream& os) const;
42   virtual bool isSameAs(const ExtractGroupStatus& other) const;
43 protected:
44 mutable bool _status;
45 std::string _name;
46 std::string _ze_key_name;
47 };
48
49 class MEDLOADERFORPV_EXPORT ExtractGroupGrp : public ExtractGroupStatus
50 {
51 public:
52   ExtractGroupGrp(const char *name):ExtractGroupStatus(name) { std::ostringstream oss; oss << START << name; _ze_key_name=oss.str(); }
53   void setFamilies(const std::vector<std::string>& fams) { _fams=fams; }
54   const std::vector<std::string>& getFamiliesLyingOn() const { return _fams; }
55   bool isSameAs(const ExtractGroupGrp& other) const;
56 public:
57   static const char START[];
58   std::vector<std::string> _fams;
59 };
60
61 class MEDLOADERFORPV_EXPORT ExtractGroupFam : public ExtractGroupStatus
62 {
63 public:
64   ExtractGroupFam(const char *name);
65   void printMySelf(std::ostream& os) const;
66   void fillIdsToKeep(std::set<int>& s) const;
67   int getId() const { return _id; }
68   bool isSameAs(const ExtractGroupFam& other) const;
69 public:
70   static const char START[];
71 private:
72   int _id;
73 };
74
75 class vtkInformationDataObjectMetaDataKey;
76 class vtkMutableDirectedGraph;
77 class vtkInformation;
78
79 class MEDLOADERFORPV_EXPORT ExtractGroupInternal
80 {
81 public:
82   void loadFrom(vtkMutableDirectedGraph *sil);
83   int getNumberOfEntries() const;
84   const char *getMeshName() const;
85   const char *getKeyOfEntry(int i) const;
86   bool getStatusOfEntryStr(const char *entry) const;
87   void setStatusOfEntryStr(const char *entry, bool status);
88   void printMySelf(std::ostream& os) const;
89   std::set<int> getIdsToKeep() const;
90   std::vector< std::pair<std::string,std::vector<int> > > getAllGroups() const;
91   void clearSelection() const;
92   int getIdOfFamily(const std::string& famName) const;
93   static bool IndependantIsInformationOK(vtkInformationDataObjectMetaDataKey *medReaderMetaData, vtkInformation *info);
94 private:
95   std::map<std::string,int> computeFamStrIdMap() const;
96   const ExtractGroupStatus& getEntry(const char *entry) const;
97   ExtractGroupStatus& getEntry(const char *entry);
98 private:
99   std::vector<ExtractGroupGrp> _groups;
100   std::vector<ExtractGroupFam> _fams;
101   mutable std::vector< std::pair<std::string,bool> > _selection;
102   std::string _mesh_name;
103 };
104