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