5ab4ceacd784a03d00f4a1106d5d6b27e6cb8793
[occt.git] / src / Quantity / Quantity_Convert.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <Quantity_Array1OfCoefficient.hxx>
17 #include <Quantity_Convert.hxx>
18 #include <TCollection_AsciiString.hxx>
19
20 Standard_EXPORT Quantity_Array1OfCoefficient ConvertTable(1,68);
21 static Standard_CString theEnums[] = {      // En attendant la methode "Elements" de Standard_Type
22 "Quantity_MASS", 
23 "Quantity_PLANEANGLE", 
24 "Quantity_SOLIDANGLE", 
25 "Quantity_LENGTH", 
26 "Quantity_AREA", 
27 "Quantity_VOLUME", 
28 "Quantity_SPEED", 
29 "Quantity_VELOCITY", 
30 "Quantity_ACCELERATION", 
31 "Quantity_ANGULARVELOCITY", 
32 "Quantity_FREQUENCY", 
33 "Quantity_TEMPERATURE", 
34 "Quantity_AMOUNTOFSUBSTANCE", 
35 "Quantity_DENSITY", 
36 "Quantity_MASSFLOW", 
37 "Quantity_VOLUMEFLOW", 
38 "Quantity_CONSUMPTION", 
39 "Quantity_MOMENTUM", 
40 "Quantity_KINETICMOMENT", 
41 "Quantity_MOMENTOFINERTIA", 
42 "Quantity_FORCE", 
43 "Quantity_MOMENTOFAFORCE", 
44 "Quantity_TORQUE", 
45 "Quantity_WEIGHT", 
46 "Quantity_PRESSURE", 
47 "Quantity_VISCOSITY", 
48 "Quantity_KINEMATICVISCOSITY", 
49 "Quantity_ENERGY", 
50 "Quantity_WORK", 
51 "Quantity_POWER", 
52 "Quantity_SURFACETENSION", 
53 "Quantity_COEFFICIENTOFEXPANSION", 
54 "Quantity_THERMALCONDUCTIVITY", 
55 "Quantity_SPECIFICHEATCAPACITY", 
56 "Quantity_ENTROPY", 
57 "Quantity_ENTHALPY", 
58 "Quantity_LUMINOUSINTENSITY", 
59 "Quantity_LUMINOUSFLUX", 
60 "Quantity_LUMINANCE", 
61 "Quantity_ILLUMINANCE", 
62 "Quantity_LUMINOUSEXPOSITION", 
63 "Quantity_LUMINOUSEFFICACITY", 
64 "Quantity_ELECTRICCHARGE", 
65 "Quantity_ELECTRICCURRENT", 
66 "Quantity_ELECTRICFIELDSTRENGTH", 
67 "Quantity_ELECTRICPOTENTIAL", 
68 "Quantity_ELECTRICCAPACITANCE", 
69 "Quantity_MAGNETICFLUX", 
70 "Quantity_MAGNETICFLUXDENSITY", 
71 "Quantity_MAGNETICFIELDSTRENGTH", 
72 "Quantity_RELUCTANCE", 
73 "Quantity_RESISTANCE", 
74 "Quantity_INDUCTANCE", 
75 "Quantity_CAPACITANCE", 
76 "Quantity_IMPEDANCE", 
77 "Quantity_ADMITTANCE", 
78 "Quantity_RESISTIVITY", 
79 "Quantity_CONDUCTIVITY", 
80 "Quantity_MOLARMASS", 
81 "Quantity_MOLARVOLUME", 
82 "Quantity_CONCENTRATION", 
83 "Quantity_MOLARCONCENTRATION", 
84 "Quantity_MOLARITY", 
85 "Quantity_SOUNDINTENSITY", 
86 "Quantity_ACOUSTICINTENSITY", 
87 "Quantity_ACTIVITY", 
88 "Quantity_ABSORBEDDOSE", 
89 "Quantity_DOSEEQUIVALENT" };
90
91 //----------------------------------------------------------------------------
92 //  Create
93 //----------------------------------------------------------------------------
94 Quantity_Convert::Quantity_Convert () {
95 // ...On se fixe sur un nombre de grandeurs physiques egal a 68 (temporaire)
96 // ...Initialisation de la table de correspondance a 1 (Coefficient de conversion
97 // ...par defaut)
98    for (Standard_Integer i = 1 ; i <= 68 ; i++) ConvertTable(i) = 1;
99 }
100
101
102 //----------------------------------------------------------------------------
103 //  IsPhysicalQuantity
104 //----------------------------------------------------------------------------
105 Standard_Boolean Quantity_Convert::IsPhysicalQuantity 
106         (const TCollection_AsciiString& aTypeName, TCollection_AsciiString& anEnum) 
107 {
108 //     ... Fabriquer le nom de l'enumeration (Quantity_LENGTH par exemple).
109    TCollection_AsciiString aPrefixe("Quantity_");
110    anEnum = aTypeName;
111    anEnum.UpperCase();
112    anEnum.Prepend(aPrefixe);
113 // ... Rechercher si il existe existe une valeur d'enum correspondante a <aTypeName>
114    Standard_Integer i = 1;
115    Standard_Boolean Find = Standard_False; 
116    while (i <= 68 && !Find) 
117    {
118       if (IsEqual(anEnum.ToCString(),theEnums[i-1])) 
119          Find = Standard_True;
120       else 
121          i++;
122    }
123    return Find; 
124
125 }
126
127