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. |
b311480e |
14 | |
42cf5bc1 |
15 | |
16 | #include <OSD_Environment.hxx> |
17 | #include <Resource_Manager.hxx> |
18 | #include <Standard_NoSuchObject.hxx> |
19 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
20 | #include <Units.hxx> |
42cf5bc1 |
21 | #include <Units_Dimensions.hxx> |
7fd59977 |
22 | #include <Units_Quantity.hxx> |
42cf5bc1 |
23 | #include <Units_Unit.hxx> |
7fd59977 |
24 | #include <Units_UnitsSystem.hxx> |
42cf5bc1 |
25 | #include <UnitsAPI.hxx> |
7fd59977 |
26 | |
27 | static Handle(Resource_Manager) CurrentUnits,SICurrentUnits,MDTVCurrentUnits; |
28 | static Units_UnitsSystem LocalSystemUnits,SILocalSystemUnits,MDTVLocalSystemUnits; |
29 | static TCollection_AsciiString rstring; |
30 | static UnitsAPI_SystemUnits localSystem = UnitsAPI_SI; |
31 | static UnitsAPI_SystemUnits currentSystem = UnitsAPI_DEFAULT; |
7fd59977 |
32 | |
33 | //======================================================================= |
34 | //function : CheckLoading |
35 | //purpose : |
36 | //======================================================================= |
37 | |
38 | void UnitsAPI::CheckLoading (const UnitsAPI_SystemUnits aSystemUnits) |
39 | { |
40 | if( currentSystem != aSystemUnits || CurrentUnits.IsNull()) { |
7fd59977 |
41 | switch (aSystemUnits) { |
42 | case UnitsAPI_DEFAULT : |
43 | if( !CurrentUnits.IsNull() ) break; |
44 | case UnitsAPI_SI : |
45 | currentSystem = UnitsAPI_SI; |
46 | if( SICurrentUnits.IsNull() ) { |
57c28b61 |
47 | #ifdef _WIN32 |
46802936 |
48 | OSD_Environment env3("CSF_CurrentUnits"); |
7fd59977 |
49 | TCollection_AsciiString csfcurrent (env3.Value()); |
50 | if( csfcurrent.Length() > 0 ) |
51 | SICurrentUnits = new Resource_Manager(csfcurrent.ToCString()); |
52 | else |
53 | SICurrentUnits = new Resource_Manager("CurrentUnits"); |
54 | #else |
55 | SICurrentUnits = new Resource_Manager("CurrentUnits"); |
56 | #endif |
57 | } |
58 | CurrentUnits = SICurrentUnits; |
59 | LocalSystemUnits = SILocalSystemUnits; |
60 | break; |
61 | case UnitsAPI_MDTV : |
62 | currentSystem = UnitsAPI_MDTV; |
63 | if( MDTVCurrentUnits.IsNull() ) { |
57c28b61 |
64 | #ifdef _WIN32 |
46802936 |
65 | OSD_Environment env4("CSF_MDTVCurrentUnits"); |
7fd59977 |
66 | TCollection_AsciiString csfmdtvcurrent (env4.Value()); |
67 | if( csfmdtvcurrent.Length() > 0 ) |
68 | MDTVCurrentUnits = new Resource_Manager(csfmdtvcurrent.ToCString()); |
69 | else |
70 | MDTVCurrentUnits = new Resource_Manager("MDTVCurrentUnits"); |
71 | #else |
72 | MDTVCurrentUnits = new Resource_Manager("MDTVCurrentUnits"); |
73 | #endif |
74 | } |
75 | CurrentUnits = MDTVCurrentUnits; |
76 | if( MDTVLocalSystemUnits.IsEmpty() ) { |
77 | MDTVLocalSystemUnits.Specify("LENGTH","mm"); |
78 | MDTVLocalSystemUnits.Specify("AREA","mm\xB2"); |
79 | MDTVLocalSystemUnits.Specify("VOLUME","mm\xB3"); |
80 | MDTVLocalSystemUnits.Specify("INERTIA","mm**4"); |
81 | MDTVLocalSystemUnits.Specify("SPEED","mm/s"); |
82 | MDTVLocalSystemUnits.Specify("ACCELERATION","mm/s\xB2"); |
83 | MDTVLocalSystemUnits.Specify("VOLUMIC MASS","kg/mm\xB3"); |
84 | MDTVLocalSystemUnits.Specify("VOLUME FLOW","mm\xB3/s"); |
85 | MDTVLocalSystemUnits.Specify("CONSUMPTION","mm\xB2"); |
86 | MDTVLocalSystemUnits.Specify("QUANTITY OF MOVEMENT","kg*mm/s"); |
87 | MDTVLocalSystemUnits.Specify("KINETIC MOMENT","kg*mm\xB2/s"); |
88 | MDTVLocalSystemUnits.Specify("MOMENT OF INERTIA","kg*mm\xB2"); |
89 | MDTVLocalSystemUnits.Specify("FORCE","kg*mm/s\xB2"); |
90 | MDTVLocalSystemUnits.Specify("LINEIC FORCE","kg/s\xB2"); |
91 | MDTVLocalSystemUnits.Specify("MOMENT OF A FORCE","kg*mm\xB2/s\xB2"); |
92 | MDTVLocalSystemUnits.Specify("PRESSURE","kg/(mm*s\xB2)"); |
93 | MDTVLocalSystemUnits.Specify("DYNAMIC VISCOSITY","kg/(mm*s)"); |
94 | MDTVLocalSystemUnits.Specify("KINETIC VISCOSITY","mm\xB2/s"); |
95 | MDTVLocalSystemUnits.Specify("TENSION SUPERFICIELLE","mm/s\xB2"); |
96 | MDTVLocalSystemUnits.Specify("ENERGY","kg*mm\xB2/s\xB2"); |
97 | MDTVLocalSystemUnits.Specify("POWER","kg*mm\xB2/s\xB3"); |
98 | MDTVLocalSystemUnits.Specify("LINEIC POWER","kg*mm/s\xB3"); |
99 | MDTVLocalSystemUnits.Specify("SURFACIC POWER","kg/s\xB3"); |
100 | MDTVLocalSystemUnits.Specify("VOLUMIC POWER","kg/(mm*s\xB3)"); |
101 | MDTVLocalSystemUnits.Specify("THERMICAL CONDUCTIVITY","kg*mm/(s\xB3*\xB0K)"); |
102 | MDTVLocalSystemUnits.Specify("THERMICAL CONVECTIVITY","kg/(s\xB3*\xB0K)"); |
103 | MDTVLocalSystemUnits.Specify("THERMICAL MASSIC CAPACITY","mm\xB2/(s\xB2*\xB0K)"); |
104 | MDTVLocalSystemUnits.Specify("ENTROPY","kg*mm\xB2/(s\xB2*\xB0K)"); |
105 | MDTVLocalSystemUnits.Specify("ENTHALPY","kg*mm\xB2/s\xB2"); |
106 | MDTVLocalSystemUnits.Specify("LUMINANCE","cd/mm\xB2"); |
107 | MDTVLocalSystemUnits.Specify("LUMINOUS EFFICACITY","s\xB3*Lu/(kg*mm\xB2)"); |
108 | MDTVLocalSystemUnits.Specify("ELECTRIC FIELD","V/mm"); |
109 | MDTVLocalSystemUnits.Specify("ELECTRIC CAPACITANCE","s**4*A\xB2/(kg*mm\xB2)"); |
110 | MDTVLocalSystemUnits.Specify("MAGNETIC FIELD","A/mm"); |
111 | MDTVLocalSystemUnits.Specify("MAGNETIC FLUX","kg*mm\xB2/(s\xB2*A)"); |
112 | MDTVLocalSystemUnits.Specify("INDUCTANCE","kg*mm\xB2/(s\xB2*A\xB2)"); |
113 | MDTVLocalSystemUnits.Specify("RELUCTANCE","s\xB2*A\xB2/(kg*mm\xB2)"); |
114 | MDTVLocalSystemUnits.Specify("RESISTIVITY","O*mm"); |
115 | MDTVLocalSystemUnits.Specify("CONDUCTIVITY","S/mm"); |
116 | MDTVLocalSystemUnits.Specify("MOLAR MASS","kg/mol"); |
117 | MDTVLocalSystemUnits.Specify("MOLAR VOLUME","mm\xB3/mol"); |
118 | MDTVLocalSystemUnits.Specify("CONCENTRATION","kg/mm\xB3"); |
119 | MDTVLocalSystemUnits.Specify("MOLAR CONCENTRATION","mol/mm\xB3"); |
120 | MDTVLocalSystemUnits.Specify("ACCOUSTIC INTENSITY","mm/A\xB2"); |
121 | MDTVLocalSystemUnits.Specify("DOSE EQUIVALENT","mm\xB2/s\xB2"); |
122 | MDTVLocalSystemUnits.Specify("ABSORBED DOSE","mm\xB2/s\xB2"); |
123 | MDTVLocalSystemUnits.Specify("FLUX OF MAGNETIC INDUCTION","kg*mm\xB2/(s\xB2*A)"); |
124 | MDTVLocalSystemUnits.Specify("ROTATION ACCELERATION","rad/s\xB2"); |
125 | MDTVLocalSystemUnits.Specify("TRANSLATION STIFFNESS","kg/s\xB2"); |
126 | MDTVLocalSystemUnits.Specify("ROTATION STIFFNESS","kg*mm\xB2/(s\xB2*rad)"); |
127 | MDTVLocalSystemUnits.Activates(); |
128 | } |
129 | LocalSystemUnits = MDTVLocalSystemUnits; |
130 | break; |
131 | } |
132 | } |
133 | } |
134 | |
135 | |
136 | //======================================================================= |
137 | //function : CurrentToLS |
138 | //purpose : |
139 | //======================================================================= |
140 | |
141 | Standard_Real UnitsAPI::CurrentToLS(const Standard_Real aData, |
142 | const Standard_CString aQuantity) |
143 | { |
144 | Standard_Real aValue = aData; |
145 | CheckLoading (localSystem); |
146 | if( CurrentUnits->Find(aQuantity) ) { |
147 | TCollection_AsciiString current(CurrentUnits->Value(aQuantity)); |
148 | aValue = Units::ToSI(aData,current.ToCString()); |
149 | aValue = LocalSystemUnits.ConvertSIValueToUserSystem(aQuantity,aValue); |
150 | } |
0797d9d3 |
151 | #ifdef OCCT_DEBUG |
7fd59977 |
152 | else { |
153 | cout <<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
154 | } |
63c629aa |
155 | #endif |
7fd59977 |
156 | |
157 | return aValue; |
158 | } |
159 | |
160 | |
161 | //======================================================================= |
162 | //function : CurrentToSI |
163 | //purpose : |
164 | //======================================================================= |
165 | |
166 | Standard_Real UnitsAPI::CurrentToSI(const Standard_Real aData, |
167 | const Standard_CString aQuantity) |
168 | { |
169 | Standard_Real aValue = aData; |
170 | CheckLoading (UnitsAPI_DEFAULT); |
171 | if( CurrentUnits->Find(aQuantity) ) { |
172 | TCollection_AsciiString current(CurrentUnits->Value(aQuantity)); |
173 | aValue = Units::ToSI(aData,current.ToCString()); |
174 | } |
0797d9d3 |
175 | #ifdef OCCT_DEBUG |
7fd59977 |
176 | else { |
177 | cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
178 | } |
63c629aa |
179 | #endif |
7fd59977 |
180 | |
181 | return aValue; |
182 | } |
183 | |
184 | |
185 | //======================================================================= |
186 | //function : CurrentFromLS |
187 | //purpose : |
188 | //======================================================================= |
189 | |
190 | Standard_Real UnitsAPI::CurrentFromLS(const Standard_Real aData, |
191 | const Standard_CString aQuantity) |
192 | { |
193 | Standard_Real aValue = aData; |
194 | CheckLoading (localSystem); |
195 | if( CurrentUnits->Find(aQuantity) ) { |
196 | TCollection_AsciiString current(CurrentUnits->Value(aQuantity)); |
197 | aValue = LocalSystemUnits.ConvertUserSystemValueToSI(aQuantity,aData); |
198 | aValue = Units::FromSI(aValue,current.ToCString()); |
199 | } |
0797d9d3 |
200 | #ifdef OCCT_DEBUG |
7fd59977 |
201 | else { |
202 | cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
203 | } |
63c629aa |
204 | #endif |
7fd59977 |
205 | |
206 | return aValue; |
207 | } |
208 | |
209 | |
210 | //======================================================================= |
211 | //function : CurrentFromSI |
212 | //purpose : |
213 | //======================================================================= |
214 | |
215 | Standard_Real UnitsAPI::CurrentFromSI(const Standard_Real aData, |
216 | const Standard_CString aQuantity) |
217 | { |
218 | Standard_Real aValue = aData; |
219 | CheckLoading (UnitsAPI_DEFAULT); |
220 | if( CurrentUnits->Find(aQuantity) ) { |
221 | TCollection_AsciiString current(CurrentUnits->Value(aQuantity)); |
222 | aValue = Units::FromSI(aData,current.ToCString()); |
223 | } |
0797d9d3 |
224 | #ifdef OCCT_DEBUG |
7fd59977 |
225 | else { |
226 | cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
227 | } |
63c629aa |
228 | #endif |
7fd59977 |
229 | |
230 | return aValue; |
231 | } |
232 | |
233 | |
234 | //======================================================================= |
235 | //function : CurrentToAny |
236 | //purpose : |
237 | //======================================================================= |
238 | |
239 | Standard_Real UnitsAPI::CurrentToAny(const Standard_Real aData, |
240 | const Standard_CString aQuantity, |
241 | const Standard_CString aUnit) { |
242 | Standard_Real aValue = aData; |
243 | CheckLoading (UnitsAPI_DEFAULT); |
244 | if( CurrentUnits->Find(aQuantity) ) { |
245 | TCollection_AsciiString current(CurrentUnits->Value(aQuantity)); |
246 | aValue = AnyToAny(aData,current.ToCString(),aUnit); |
247 | } |
0797d9d3 |
248 | #ifdef OCCT_DEBUG |
7fd59977 |
249 | else { |
250 | cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
251 | } |
63c629aa |
252 | #endif |
7fd59977 |
253 | |
254 | return aValue; |
255 | } |
256 | |
257 | |
258 | //======================================================================= |
259 | //function : CurrentFromAny |
260 | //purpose : |
261 | //======================================================================= |
262 | |
263 | Standard_Real UnitsAPI::CurrentFromAny(const Standard_Real aData, |
264 | const Standard_CString aQuantity, |
265 | const Standard_CString aUnit) |
266 | { |
267 | Standard_Real aValue = aData; |
268 | CheckLoading (UnitsAPI_DEFAULT); |
269 | if( CurrentUnits->Find(aQuantity) ) { |
270 | TCollection_AsciiString current(CurrentUnits->Value(aQuantity)); |
271 | aValue = AnyToAny(aData,aUnit,current.ToCString()); |
272 | } |
0797d9d3 |
273 | #ifdef OCCT_DEBUG |
7fd59977 |
274 | else { |
275 | cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
276 | } |
63c629aa |
277 | #endif |
7fd59977 |
278 | |
279 | return aValue; |
280 | } |
281 | |
282 | |
283 | //======================================================================= |
284 | //function : AnyToLS |
285 | //purpose : |
286 | //======================================================================= |
287 | |
288 | Standard_Real UnitsAPI::AnyToLS(const Standard_Real aData, |
289 | const Standard_CString aUnit) |
290 | { |
291 | Standard_Real aValue = aData; |
292 | CheckLoading (localSystem); |
293 | Handle(Units_Dimensions) aDim; |
294 | aValue = Units::ToSI(aValue,aUnit,aDim); |
295 | if(aDim.IsNull()) |
296 | return aValue; |
297 | Standard_CString quantity = aDim->Quantity(); |
298 | if( quantity ) { |
299 | aValue = LocalSystemUnits.ConvertSIValueToUserSystem(quantity,aValue); |
300 | } |
0797d9d3 |
301 | #ifdef OCCT_DEBUG |
7fd59977 |
302 | else |
303 | cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << ")" << endl; |
63c629aa |
304 | #endif |
7fd59977 |
305 | return aValue; |
306 | } |
307 | |
308 | |
309 | //======================================================================= |
310 | //function : AnyToLS |
311 | //purpose : |
312 | //======================================================================= |
313 | |
314 | Standard_Real UnitsAPI::AnyToLS(const Standard_Real aData, |
315 | const Standard_CString aUnit, |
316 | Handle(Units_Dimensions) &aDim) |
317 | { |
318 | Standard_Real aValue = aData; |
319 | CheckLoading (localSystem); |
320 | aValue = Units::ToSI(aValue,aUnit,aDim); |
321 | Standard_CString quantity = aDim->Quantity(); |
322 | if(aDim.IsNull()) |
323 | return aValue; |
324 | if( quantity ) { |
325 | aValue = LocalSystemUnits.ConvertSIValueToUserSystem(quantity,aValue); |
326 | } |
0797d9d3 |
327 | #ifdef OCCT_DEBUG |
7fd59977 |
328 | else |
1c29294e |
329 | cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << "," << aDim.get() << ")" << endl; |
63c629aa |
330 | #endif |
7fd59977 |
331 | return aValue; |
332 | } |
333 | |
334 | |
335 | //======================================================================= |
336 | //function : AnyToSI |
337 | //purpose : |
338 | //======================================================================= |
339 | |
340 | Standard_Real UnitsAPI::AnyToSI(const Standard_Real aData, |
341 | const Standard_CString aUnit) |
342 | { |
343 | Standard_Real aValue; |
344 | CheckLoading (UnitsAPI_DEFAULT); |
345 | aValue = Units::ToSI(aData,aUnit); |
346 | return aValue; |
347 | } |
348 | |
349 | |
350 | //======================================================================= |
351 | //function : AnyToSI |
352 | //purpose : |
353 | //======================================================================= |
354 | |
355 | Standard_Real UnitsAPI::AnyToSI(const Standard_Real aData, |
356 | const Standard_CString aUnit, |
357 | Handle(Units_Dimensions) &aDim) |
358 | { |
359 | Standard_Real aValue; |
360 | CheckLoading (UnitsAPI_DEFAULT); |
361 | aValue = Units::ToSI(aData,aUnit,aDim); |
362 | return aValue; |
363 | } |
364 | |
365 | |
366 | //======================================================================= |
367 | //function : AnyFromLS |
368 | //purpose : |
369 | //======================================================================= |
370 | |
371 | Standard_Real UnitsAPI::AnyFromLS(const Standard_Real aData, |
372 | const Standard_CString aUnit) |
373 | { |
374 | Standard_Real aValue = aData; |
375 | CheckLoading (localSystem); |
376 | Handle(Units_Dimensions) aDim; |
377 | aValue = Units::FromSI(aValue,aUnit,aDim); |
378 | Standard_CString quantity = aDim->Quantity(); |
379 | if( quantity ) { |
380 | aValue = LocalSystemUnits.ConvertUserSystemValueToSI(quantity,aValue); |
381 | } |
0797d9d3 |
382 | #ifdef OCCT_DEBUG |
7fd59977 |
383 | else |
384 | cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << ")" << endl; |
63c629aa |
385 | #endif |
7fd59977 |
386 | |
387 | return aValue; |
388 | } |
389 | |
390 | |
391 | //======================================================================= |
392 | //function : AnyFromSI |
393 | //purpose : |
394 | //======================================================================= |
395 | |
396 | Standard_Real UnitsAPI::AnyFromSI(const Standard_Real aData, |
397 | const Standard_CString aUnit) |
398 | { |
399 | Standard_Real aValue; |
400 | CheckLoading (UnitsAPI_DEFAULT); |
401 | aValue = Units::FromSI(aData,aUnit); |
402 | return aValue; |
403 | } |
404 | |
405 | |
406 | //======================================================================= |
407 | //function : AnyToAny |
408 | //purpose : |
409 | //======================================================================= |
410 | |
411 | Standard_Real UnitsAPI::AnyToAny(const Standard_Real aData, |
412 | const Standard_CString aUnit1, |
413 | const Standard_CString aUnit2) |
414 | { |
415 | Standard_Real aValue = aData; |
416 | CheckLoading (UnitsAPI_DEFAULT); |
417 | aValue = Units::Convert(aValue,aUnit1,aUnit2); |
418 | return aValue; |
419 | } |
420 | |
421 | |
422 | //======================================================================= |
423 | //function : LSToSI |
424 | //purpose : |
425 | //======================================================================= |
426 | |
427 | Standard_Real UnitsAPI::LSToSI(const Standard_Real aData, |
428 | const Standard_CString aQuantity) |
429 | { |
430 | Standard_Real aValue = aData; |
431 | CheckLoading (localSystem); |
432 | if( CurrentUnits->Find(aQuantity) ) { |
433 | aValue = LocalSystemUnits.ConvertUserSystemValueToSI(aQuantity,aData); |
434 | } |
0797d9d3 |
435 | #ifdef OCCT_DEBUG |
7fd59977 |
436 | else { |
437 | cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
438 | } |
63c629aa |
439 | #endif |
7fd59977 |
440 | |
441 | return aValue; |
442 | } |
443 | |
444 | |
445 | //======================================================================= |
446 | //function : SIToLS |
447 | //purpose : |
448 | //======================================================================= |
449 | |
450 | Standard_Real UnitsAPI::SIToLS(const Standard_Real aData, |
451 | const Standard_CString aQuantity) |
452 | { |
453 | Standard_Real aValue = aData; |
454 | CheckLoading (localSystem); |
455 | if( CurrentUnits->Find(aQuantity) ) { |
456 | aValue = LocalSystemUnits.ConvertSIValueToUserSystem(aQuantity,aValue); |
457 | } |
0797d9d3 |
458 | #ifdef OCCT_DEBUG |
7fd59977 |
459 | else { |
460 | cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl; |
461 | } |
63c629aa |
462 | #endif |
7fd59977 |
463 | |
464 | return aValue; |
465 | } |
466 | |
467 | |
468 | //======================================================================= |
469 | //function : SetLocalSystem |
470 | //purpose : |
471 | //======================================================================= |
472 | |
473 | void UnitsAPI::SetLocalSystem(const UnitsAPI_SystemUnits aSystemUnits) |
474 | { |
475 | CheckLoading (aSystemUnits); |
476 | localSystem = currentSystem; |
477 | } |
478 | |
479 | |
480 | //======================================================================= |
481 | //function : LocalSystem |
482 | //purpose : |
483 | //======================================================================= |
484 | |
485 | UnitsAPI_SystemUnits UnitsAPI::LocalSystem() |
486 | { |
487 | return localSystem; |
488 | } |
489 | |
490 | |
491 | //======================================================================= |
492 | //function : SetCurrentUnit |
493 | //purpose : |
494 | //======================================================================= |
495 | |
496 | void UnitsAPI::SetCurrentUnit(const Standard_CString aQuantity, |
497 | const Standard_CString anUnit) |
498 | { |
499 | CheckLoading(localSystem); |
500 | CurrentUnits->SetResource(aQuantity,anUnit); |
501 | } |
502 | |
503 | |
504 | //======================================================================= |
505 | //function : Save |
506 | //purpose : |
507 | //======================================================================= |
508 | |
509 | void UnitsAPI::Save() |
510 | { |
511 | CheckLoading(localSystem); |
512 | CurrentUnits->Save(); |
513 | } |
514 | |
515 | |
516 | //======================================================================= |
517 | //function : Reload |
518 | //purpose : |
519 | //======================================================================= |
520 | |
521 | void UnitsAPI::Reload() |
522 | { |
523 | currentSystem = UnitsAPI_DEFAULT; |
524 | CheckLoading(localSystem); |
525 | } |
526 | |
527 | |
528 | //======================================================================= |
529 | //function : CurrentUnit |
530 | //purpose : |
531 | //======================================================================= |
532 | |
533 | static TCollection_AsciiString astring; |
534 | Standard_CString UnitsAPI::CurrentUnit(const Standard_CString aQuantity) |
535 | { |
536 | CheckLoading(localSystem); |
537 | astring = CurrentUnits->Value(aQuantity); |
538 | return astring.ToCString(); |
539 | } |
540 | |
541 | |
542 | //======================================================================= |
543 | //function : Dimensions |
544 | //purpose : |
545 | //======================================================================= |
546 | |
547 | Handle(Units_Dimensions) UnitsAPI::Dimensions(const Standard_CString aType) |
548 | { |
549 | return Units::Dimensions(aType); |
550 | } |
551 | |
552 | |
553 | //======================================================================= |
554 | //function : DimensionLess |
555 | //purpose : |
556 | //======================================================================= |
557 | |
558 | Handle(Units_Dimensions) UnitsAPI::DimensionLess() |
559 | { |
560 | return Units_Dimensions::ALess(); |
561 | } |
562 | |
563 | |
564 | //======================================================================= |
565 | //function : DimensionMass |
566 | //purpose : |
567 | //======================================================================= |
568 | |
569 | Handle(Units_Dimensions) UnitsAPI::DimensionMass() |
570 | { |
571 | return Units_Dimensions::AMass(); |
572 | } |
573 | |
574 | |
575 | //======================================================================= |
576 | //function : DimensionLength |
577 | //purpose : |
578 | //======================================================================= |
579 | |
580 | Handle(Units_Dimensions) UnitsAPI::DimensionLength() |
581 | { |
582 | return Units_Dimensions::ALength(); |
583 | } |
584 | |
585 | |
586 | //======================================================================= |
587 | //function : DimensionTime |
588 | //purpose : |
589 | //======================================================================= |
590 | |
591 | Handle(Units_Dimensions) UnitsAPI::DimensionTime() |
592 | { |
593 | return Units_Dimensions::ATime() ; |
594 | } |
595 | |
596 | |
597 | //======================================================================= |
598 | //function : DimensionElectricCurrent |
599 | //purpose : |
600 | //======================================================================= |
601 | |
602 | Handle(Units_Dimensions) UnitsAPI::DimensionElectricCurrent() |
603 | { |
604 | return Units_Dimensions::AElectricCurrent() ; |
605 | } |
606 | |
607 | |
608 | //======================================================================= |
609 | //function : DimensionThermodynamicTemperature |
610 | //purpose : |
611 | //======================================================================= |
612 | |
613 | Handle(Units_Dimensions) UnitsAPI::DimensionThermodynamicTemperature() |
614 | { |
615 | return Units_Dimensions::AThermodynamicTemperature(); |
616 | } |
617 | |
618 | |
619 | //======================================================================= |
620 | //function : DimensionAmountOfSubstance |
621 | //purpose : |
622 | //======================================================================= |
623 | |
624 | Handle(Units_Dimensions) UnitsAPI::DimensionAmountOfSubstance() |
625 | { |
626 | return Units_Dimensions::AAmountOfSubstance(); |
627 | } |
628 | |
629 | |
630 | //======================================================================= |
631 | //function : DimensionLuminousIntensity |
632 | //purpose : |
633 | //======================================================================= |
634 | |
635 | Handle(Units_Dimensions) UnitsAPI::DimensionLuminousIntensity() |
636 | { |
637 | return Units_Dimensions::ALuminousIntensity(); |
638 | } |
639 | |
640 | |
641 | //======================================================================= |
642 | //function : DimensionPlaneAngle |
643 | //purpose : |
644 | //======================================================================= |
645 | |
646 | Handle(Units_Dimensions) UnitsAPI::DimensionPlaneAngle() |
647 | { |
648 | return Units_Dimensions::APlaneAngle(); |
649 | } |
650 | |
651 | |
652 | //======================================================================= |
653 | //function : DimensionSolidAngle |
654 | //purpose : |
655 | //======================================================================= |
656 | |
657 | Handle(Units_Dimensions) UnitsAPI::DimensionSolidAngle() |
658 | { |
659 | return Units_Dimensions::ASolidAngle(); |
660 | } |
661 | |
662 | |
663 | //======================================================================= |
664 | //function : Check |
665 | //purpose : |
666 | //======================================================================= |
667 | |
668 | Standard_Boolean UnitsAPI::Check(const Standard_CString aQuantity, |
669 | const Standard_CString /*aUnit*/) |
670 | { |
671 | Standard_Boolean status = Standard_False; |
672 | CheckLoading (UnitsAPI_DEFAULT); |
673 | if( CurrentUnits->Find(aQuantity) ) { |
674 | TCollection_AsciiString current(CurrentUnits->Value(aQuantity)); |
675 | // aValue = AnyToAny(aData,current.ToCString(),aUnit); |
676 | // aValue = Units::Convert(aValue,aUnit1,aUnit2); |
677 | } |
678 | |
679 | return status; |
680 | } |