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