00001 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // This library is free software; you can redistribute it and/or 00004 // modify it under the terms of the GNU Lesser General Public 00005 // License as published by the Free Software Foundation; either 00006 // version 2.1 of the License. 00007 // 00008 // This library is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 // Lesser General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU Lesser General Public 00014 // License along with this library; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 // 00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00018 // 00019 00020 // VISU CONVERTOR : 00021 // File : VISU_TableReader.hxx 00022 // Author : Alexey PETROV 00023 // Module : VISU 00024 // 00025 #ifndef VISU_TableReader_HeaderFile 00026 #define VISU_TableReader_HeaderFile 00027 00033 #include "VISUConvertor.hxx" 00034 00035 #include "VISU_IDMapper.hxx" 00036 00037 #include <string> 00038 #include <vector> 00039 00040 namespace VISU 00041 { 00042 //--------------------------------------------------------------- 00043 struct VISU_CONVERTOR_EXPORT TTable2D 00044 { 00045 typedef std::string TValue; 00046 typedef std::vector<TValue> TValues; 00047 00048 struct TRow 00049 { 00050 std::string myTitle; 00051 std::string myUnit; 00052 TValues myValues; 00053 }; 00054 00055 std::string myTitle; 00056 std::vector<std::string> myColumnUnits; 00057 std::vector<std::string> myColumnTitles; 00058 00059 typedef std::vector<TRow> TRows; 00060 TRows myRows; 00061 00062 int 00063 Check(); 00064 00065 void 00066 getColumns( TTable2D& theTable2D ) const; 00067 }; 00068 00069 00070 //--------------------------------------------------------------- 00071 class VISU_CONVERTOR_EXPORT TTableIDMapper: 00072 public virtual TPolyDataIDMapper, 00073 public virtual TTable2D 00074 { 00075 public: 00076 TTableIDMapper(); 00077 ~TTableIDMapper(); 00078 00079 virtual 00080 vtkPolyData* 00081 GetPolyDataOutput(); 00082 00083 virtual 00084 long unsigned int 00085 GetMemorySize(); 00086 00087 void 00088 SetXAxisPosition( vtkIdType theAxisPosition ); 00089 00090 vtkIdType 00091 GetXAxisPosition(); 00092 00093 protected: 00094 vtkIdType myXAxisPosition; 00095 vtkPolyData* myOutput; 00096 }; 00097 typedef MED::SharedPtr<TTableIDMapper> PTableIDMapper; 00098 00099 00100 //--------------------------------------------------------------- 00101 typedef std::vector<PTableIDMapper> TTableContainer; 00102 VISU_CONVERTOR_EXPORT 00103 void ImportTables( const char* theFileName, TTableContainer& theContainer, 00104 bool theFirstStrAsTitle = false); 00105 00106 void ImportCSVTable(const char* theFileName, 00107 TTableContainer& theContainer, 00108 bool theFirstStrAsTitle, 00109 const char theSeparator); 00110 00111 //--------------------------------------------------------------- 00112 } 00113 00114 #endif