Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / ParaMEDCorba / plugin / ParaMEDMEM2VTK / VTKMEDCouplingMultiFieldsClient.hxx
1 // Copyright (C) 2010-2022  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
20 #ifndef __VTKMEDCOUPLINGMULTIFIELDSCLIENT_HXX__
21 #define __VTKMEDCOUPLINGMULTIFIELDSCLIENT_HXX__
22
23 #include "ParaMEDMEM2VTK_defines.hxx"
24 #include "ParaMEDCouplingCorbaServant.hh"
25
26 #include <vector>
27 #include <string>
28
29 class vtkDataSet;
30 class vtkDoubleArray;
31
32 namespace ParaMEDMEM2VTK
33 {
34   /*!
35    * Stores all info on field without consideration of time
36    */
37   class TinyInfoOnField
38   {
39   public:
40     int _type;//ON_CELLS = 0, ON_NODES = 1, ON_GAUSS_PT = 2, ON_GAUSS_NE = 3
41     std::string _name;
42   };
43
44   class ParaMEDMEM2VTK_EXPORT MEDCouplingMultiFieldsFetcher
45   {
46   public:
47     MEDCouplingMultiFieldsFetcher(int bufferingPolicy, SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr mfieldsPtr);
48     ~MEDCouplingMultiFieldsFetcher();
49     std::vector<double> getTimeStepsForPV();
50     void fetchRegardingPolicy();
51     vtkDataSet *buildDataSetOnTime(double time);
52   private:
53     void appendFieldValueOnAlreadyFetchedData(vtkDataSet *ds, int fieldId);
54     int getPosGivenTimeLabel(double t);
55   private://CORBA Fetching
56     void retrievesMainTinyInfo();
57     void fetchAll();
58     void fetchMeshes();
59     void fetchDataIfNeeded(int fieldId);
60     void unregisterRemoteServantIfAllFetched();
61     void applyBufferingPolicy();
62   private:
63     int _effective_pol;
64     SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_var _mfields_ptr;
65     bool _mfields_ptr_released;
66   private:
67     std::vector<TinyInfoOnField> _info_per_field;
68     std::vector<double> _time_label_per_field;
69     std::vector<int> _time_discr_per_field;
70     std::vector<int> _mesh_id_per_field;
71     std::vector< std::vector<int> > _array_ids_per_field;
72     std::vector< std::vector<double> > _time_def_per_field;
73   private:
74     int _field_id_previous;
75     int _arr_pos_previous;
76     double _time_field_id_previous;
77     int _arr_id_previous;
78     int _mesh_id_previous;
79   private:
80     std::vector<vtkDataSet *> _meshes;
81     std::vector<bool> _is_meshes_polyhedron;//to correct bug of polyhedrons in VTK on DeepCopy. BUG id :0011860
82     std::vector<vtkDoubleArray *> _arrays;
83   private:
84     static const double EPS_TIME;
85   };
86 }
87
88 #endif