Salome HOME
6e4d037f0646621040a7c4f0861474341cdb5ad9
[modules/paravis.git] / src / Plugins / MedReader / IO / vtkMedEntityArray.h
1 // Copyright (C) 2010-2013  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.
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
20 #ifndef __vtkMedEntityArray_h_
21 #define __vtkMedEntityArray_h_
22
23 #include "vtkObject.h"
24 #include "vtkMedSetGet.h"
25 #include "vtkMedUtilities.h"
26 #include "vtkMed.h"
27 #include "vtkMedFilter.h"
28
29 class vtkMedIntArray;
30 class vtkFamilyIdSet;
31 class vtkMedFamily;
32 class vtkMedFamilyOnEntity;
33 class vtkMedMesh;
34 class vtkMedGrid;
35 class vtkIdList;
36 class vtkMedStructElement;
37 class vtkMedVariableAttribute;
38
39 class VTK_EXPORT vtkMedEntityArray: public vtkObject
40 {
41 public:
42   static vtkMedEntityArray* New();
43   vtkTypeMacro(vtkMedEntityArray, vtkObject)
44   void PrintSelf(ostream& os, vtkIndent indent);
45
46   // Description:
47   // This is the number of cells of this entity type.
48   vtkSetMacro(NumberOfEntity, vtkIdType);
49   vtkGetMacro(NumberOfEntity, vtkIdType);
50
51   // Description:
52   // the support of the cells : one of
53   void  SetEntity(const vtkMedEntity& entity){this->Entity = entity;}
54   const vtkMedEntity& GetEntity(){return this->Entity;}
55
56   // Description:
57   // This connectivity type of this entity : one of
58   // MED_NODAL, MED_DESCENDING, MED_NO_CMODE
59   vtkSetMacro(Connectivity, med_connectivity_mode);
60   vtkGetMacro(Connectivity, med_connectivity_mode);
61
62   // Description:
63   // This array stores the family ids of each entity.
64   virtual void SetConnectivityArray(vtkMedIntArray*);
65   vtkGetObjectMacro(ConnectivityArray, vtkMedIntArray);
66
67   // Description:
68   // This array stores the connectivity array for this entity.
69   virtual void SetFamilyIds(vtkMedIntArray*);
70   virtual med_int GetFamilyId(med_int id);
71
72   // Description:
73   // This array stores the global Ids of the entities.
74   virtual void SetGlobalIds(vtkMedIntArray*);
75   vtkGetObjectMacro(GlobalIds, vtkMedIntArray);
76
77   // Description:
78   // For polygons, this array stores the index of each edge described in
79   // the connectivity array
80   // For polyhedrons, this arrays stores the index of each face described
81   // in the NodeIndex array
82   virtual void SetFaceIndex(vtkMedIntArray*);
83   vtkGetObjectMacro(FaceIndex, vtkMedIntArray);
84
85   // Description:
86   // For polyhedrons, this arrays can store either
87   // the index of each node of each face described in the Index1 array
88   // (node connectivity) or the type each face described in the Index1
89   // array (hierarchical connectivity)
90   virtual void SetNodeIndex(vtkMedIntArray*);
91   vtkGetObjectMacro(NodeIndex, vtkMedIntArray);
92
93   // Description:
94   // Arrays of entities are partitionned over families.
95   vtkSetObjectVectorMacro(FamilyOnEntity, vtkMedFamilyOnEntity);
96   vtkGetObjectVectorMacro(FamilyOnEntity, vtkMedFamilyOnEntity);
97
98   // Description:
99   // For polyhedrons, this arrays can store either
100   // the index of each node of each face described in the Index1 array
101   // (node connectivity) or the type each face described in the Index1
102   // array (hierarchical connectivity)
103   virtual void  SetParentGrid(vtkMedGrid*);
104   vtkGetObjectMacro(ParentGrid, vtkMedGrid);
105
106   // Description:
107   // Compute the list of families that are on this array
108   virtual void  ComputeFamilies();
109
110   // Description:
111   // returns true if there are cells of the given family on this entity.
112   virtual int HasFamily(vtkMedFamily*);
113
114   // Description:
115   // returns 1 if the connectivity array is set and matches the number of
116   // connectivity elements.
117   virtual int IsConnectivityLoaded();
118
119   // Description:
120   // returns 1 if the family ids is set and matches the number of entities.
121   virtual int IsFamilyIdsLoaded();
122
123   // Description:
124   // returns 1 if the global ids is set and matches the number of entities.
125   virtual int IsGlobalIdsLoaded();
126
127   // Description :
128   // This gives the global id of the first element of this array.
129   vtkSetMacro(InitialGlobalId, vtkIdType);
130   vtkGetMacro(InitialGlobalId, vtkIdType);
131
132   // Description :
133   // resets all to default status, release memory
134   virtual void Initialize();
135
136   // Description:
137   // Get the indices of the vertices used by a given cell.
138   void  GetCellVertices(vtkIdType, vtkIdList*);
139
140   virtual void  LoadConnectivity();
141
142   // Descritpion:
143   // This is a pointer to the StructElement object if any
144   // This pointer is set during the LinkMedInfo pass
145   virtual void  SetStructElement(vtkMedStructElement*);
146   vtkGetObjectMacro(StructElement, vtkMedStructElement);
147
148   void  SetVariableAttributeValues(vtkMedVariableAttribute*,
149                                    vtkAbstractArray*);
150   vtkAbstractArray* GetVariableAttributeValue(vtkMedVariableAttribute*);
151
152   // Description:
153   // Get/Set of the MED Filter for parallel reading.
154   void  SetFilter(vtkMedFilter* filter){this->Filter = filter;}
155   vtkMedFilter* GetFilter(){return this->Filter;}
156
157 protected:
158   vtkMedEntityArray();
159   virtual ~vtkMedEntityArray();
160
161   vtkIdType NumberOfEntity;
162   vtkMedEntity Entity;
163
164   vtkMedFilter* Filter;
165
166   med_connectivity_mode Connectivity;
167   vtkIdType InitialGlobalId;
168
169   vtkMedGrid* ParentGrid;
170
171   vtkMedIntArray* FamilyIds;
172   vtkMedIntArray* GlobalIds;
173   vtkMedIntArray* ConnectivityArray;
174   vtkMedIntArray* FaceIndex;
175   vtkMedIntArray* NodeIndex;
176
177   vtkMedStructElement* StructElement;
178
179   int FamilyIdStatus;
180   enum{
181     FAMILY_ID_NOT_LOADED,
182     FAMILY_ID_IMPLICIT,
183     FAMILY_ID_EXPLICIT
184   };
185
186   //BTX
187   vtkObjectVector<vtkMedFamilyOnEntity>* FamilyOnEntity;
188
189   std::map<vtkMedVariableAttribute*, vtkSmartPointer<vtkAbstractArray> >
190       VariableAttributeValue;
191   //ETX
192
193   int Valid;
194
195 private:
196   vtkMedEntityArray(const vtkMedEntityArray&); // Not implemented.
197   void operator=(const vtkMedEntityArray&); // Not implemented.
198 };
199
200 #endif //__vtkMedEntityArray_h_