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