Salome HOME
Merge from V6_main 01/04/2013
[modules/visu.git] / src / CONVERTOR / VISU_TableReader.hxx
1 // Copyright (C) 2007-2013  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     vtkAlgorithmOutput*
85     GetOutputPort() { return NULL; }
86
87     virtual
88     long unsigned int
89     GetMemorySize();
90
91     void
92     SetXAxisPosition( vtkIdType theAxisPosition );
93
94     vtkIdType
95     GetXAxisPosition();
96
97   protected:
98     vtkIdType myXAxisPosition;
99     vtkPolyData* myOutput;
100   };
101   typedef MED::SharedPtr<TTableIDMapper> PTableIDMapper;
102   
103
104   //---------------------------------------------------------------
105   typedef std::vector<PTableIDMapper> TTableContainer;
106   VISU_CONVERTOR_EXPORT 
107     void ImportTables( const char* theFileName, TTableContainer& theContainer,
108                        bool theFirstStrAsTitle = false);
109
110   void ImportCSVTable(const char* theFileName,
111                       TTableContainer& theContainer,
112                       bool theFirstStrAsTitle,
113                       const char theSeparator);
114
115   //---------------------------------------------------------------
116 }
117
118 #endif