Salome HOME
44fc5e174ece22fe1c5e9236170d53ddd99be178
[modules/visu.git] / src / CONVERTOR / VISU_TableReader.hxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
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 //  VISU CONVERTOR :
21 //  File   : VISU_TableReader.hxx
22 //  Author : Alexey PETROV
23 //  Module : VISU
24 //
25 #ifndef VISU_TableReader_HeaderFile
26 #define VISU_TableReader_HeaderFile
27
28 /*! 
29   \file VISU_TableReader.hxx
30   \brief The file contains definition of the Table reading functionlity
31 */
32
33 #include "VISUConvertor.hxx"
34
35 #include "VISU_IDMapper.hxx"
36
37 #include <string>
38 #include <vector>
39
40 namespace VISU
41 {
42   //---------------------------------------------------------------
43   struct VISU_CONVERTOR_EXPORT TTable2D 
44   {
45     typedef std::string TValue;
46     typedef std::vector<TValue> TValues;
47     
48     struct TRow
49     {
50       std::string myTitle;
51       std::string myUnit;
52       TValues myValues;
53     };
54     
55     std::string myTitle;
56     std::vector<std::string> myColumnUnits;
57     std::vector<std::string> myColumnTitles;
58     
59     typedef std::vector<TRow> TRows;
60     TRows myRows;
61     
62     int 
63     Check();
64
65     void
66     getColumns( TTable2D& theTable2D ) const;
67   };
68
69
70   //---------------------------------------------------------------
71   class VISU_CONVERTOR_EXPORT TTableIDMapper: 
72     public virtual TPolyDataIDMapper,
73     public virtual TTable2D
74   {
75   public:
76     TTableIDMapper();
77     ~TTableIDMapper();
78     
79     virtual
80     vtkPolyData*
81     GetPolyDataOutput();
82
83     virtual
84     long unsigned int
85     GetMemorySize();
86
87     void
88     SetXAxisPosition( vtkIdType theAxisPosition );
89
90     vtkIdType
91     GetXAxisPosition();
92
93   protected:
94     vtkIdType myXAxisPosition;
95     vtkPolyData* myOutput;
96   };
97   typedef MED::SharedPtr<TTableIDMapper> PTableIDMapper;
98   
99
100   //---------------------------------------------------------------
101   typedef std::vector<PTableIDMapper> TTableContainer;
102   VISU_CONVERTOR_EXPORT 
103     void ImportTables( const char* theFileName, TTableContainer& theContainer,
104                        bool theFirstStrAsTitle = false);
105
106   void ImportCSVTable(const char* theFileName,
107                       TTableContainer& theContainer,
108                       bool theFirstStrAsTitle,
109                       const char theSeparator);
110
111   //---------------------------------------------------------------
112 }
113
114 #endif