]> SALOME platform Git repositories - modules/visu.git/blob - src/CONVERTOR/VISU_Convertor.cxx
Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/visu.git] / src / CONVERTOR / VISU_Convertor.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //  File:    VISU_Convertor.cxx
24 //  Author:  Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_Convertor.hxx"
28 #include "VISU_ConvertorUtils.hxx"
29
30 #include <qstring.h>
31
32 using namespace std;
33
34 namespace VISU{
35
36   inline
37   int
38   GetNbOfPoints(int theVTKCellType)
39   {
40     switch(theVTKCellType){
41     case VTK_VERTEX : return 1;
42     case VTK_LINE : return 2;
43     case VTK_TRIANGLE : return 3;
44     case VTK_QUAD : return 4;
45     case VTK_TETRA : return 4;
46     case VTK_HEXAHEDRON : return 8;
47     case VTK_WEDGE : return 6;
48     case VTK_PYRAMID : return 5;
49     default: return -1;
50     }
51   }
52 }
53
54
55 const VISU::TMeshMap& 
56 VISU_Convertor
57 ::GetMeshMap() 
58
59   return myMeshMap;
60 }
61
62
63 string
64 VISU_Convertor
65 ::GenerateName(const VISU::TTime& aTime)
66 {
67   static QString aName;
68   const string aUnits = aTime.second, tmp(aUnits.size(),' ');
69   if(aUnits == "" || aUnits == tmp)
70     aName.sprintf("%g, -",aTime.first);
71   else
72     aName.sprintf("%g, %s",aTime.first,aTime.second.c_str());
73   aName = aName.simplifyWhiteSpace();
74   return aName.latin1();
75 }
76
77 string
78 VISU_Convertor
79 ::GenerateName(const string& theName, 
80                unsigned int theTimeId) 
81 {
82   static QString aName;
83   aName = QString(theName.c_str()).simplifyWhiteSpace();
84   int iEnd = strlen(aName);
85   static int VtkHighLevelLength = 12; //25
86   if(iEnd > VtkHighLevelLength) iEnd = VtkHighLevelLength;
87   char aNewName[iEnd+1];
88   aNewName[iEnd] = '\0';
89   strncpy(aNewName,aName,iEnd);
90   replace(aNewName,aNewName+iEnd,' ','_');
91   if(true || theTimeId == 0)
92     aName = aNewName;
93   else
94     aName.sprintf("%s_%d",aNewName,theTimeId);
95   return aName.latin1();
96 }