// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <UnitsAPI.ixx>
+
+#include <OSD_Environment.hxx>
+#include <Resource_Manager.hxx>
+#include <Standard_NoSuchObject.hxx>
+#include <TCollection_AsciiString.hxx>
#include <Units.hxx>
-#include <Units_Unit.hxx>
+#include <Units_Dimensions.hxx>
#include <Units_Quantity.hxx>
+#include <Units_Unit.hxx>
#include <Units_UnitsSystem.hxx>
-#include <Resource_Manager.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <OSD_Environment.hxx>
+#include <UnitsAPI.hxx>
static Handle(Resource_Manager) CurrentUnits,SICurrentUnits,MDTVCurrentUnits;
static Units_UnitsSystem LocalSystemUnits,SILocalSystemUnits,MDTVLocalSystemUnits;
static TCollection_AsciiString rstring;
static UnitsAPI_SystemUnits localSystem = UnitsAPI_SI;
static UnitsAPI_SystemUnits currentSystem = UnitsAPI_DEFAULT;
-static OSD_Environment env1("CSF_UnitsLexicon");
-static OSD_Environment env2("CSF_UnitsDefinition");
-#ifdef WNT
-static OSD_Environment env3("CSF_CurrentUnits");
-static OSD_Environment env4("CSF_MDTVCurrentUnits");
-#endif
-
//=======================================================================
//function : CheckLoading
void UnitsAPI::CheckLoading (const UnitsAPI_SystemUnits aSystemUnits)
{
if( currentSystem != aSystemUnits || CurrentUnits.IsNull()) {
- TCollection_AsciiString slexiconfile(env1.Value());
- if( slexiconfile.Length() > 0 )
- Units::LexiconFile(slexiconfile.ToCString());
- else {
- OSD_Environment CasRootEnv("CASROOT");
- TCollection_AsciiString CasRootString(CasRootEnv.Value());
- if (CasRootString.Length() > 0 ) {
- CasRootString += "/src/UnitsAPI/Lexi_Expr.dat" ;
- Units::LexiconFile(CasRootString.ToCString());
- }
- else {
- Standard_NoSuchObject::Raise("environment variable CSF_UnitsLexicon undefined");
- }
- }
- TCollection_AsciiString sunitsfile(env2.Value());
- if( sunitsfile.Length() > 0 )
- Units::UnitsFile(sunitsfile.ToCString());
- else {
- OSD_Environment CasRootEnv("CASROOT");
- TCollection_AsciiString CasRootString(CasRootEnv.Value());
- if (CasRootString.Length() > 0 ) {
- CasRootString += "/src/UnitsAPI/Units.dat";
- Units::UnitsFile(CasRootString.ToCString());
- }
- else {
- Standard_NoSuchObject::Raise("environment variable CSF_UnitsDefinition undefined");
- }
- }
switch (aSystemUnits) {
case UnitsAPI_DEFAULT :
if( !CurrentUnits.IsNull() ) break;
+ Standard_FALLTHROUGH
case UnitsAPI_SI :
currentSystem = UnitsAPI_SI;
if( SICurrentUnits.IsNull() ) {
-#ifdef WNT
+#ifdef _WIN32
+ OSD_Environment env3("CSF_CurrentUnits");
TCollection_AsciiString csfcurrent (env3.Value());
if( csfcurrent.Length() > 0 )
SICurrentUnits = new Resource_Manager(csfcurrent.ToCString());
case UnitsAPI_MDTV :
currentSystem = UnitsAPI_MDTV;
if( MDTVCurrentUnits.IsNull() ) {
-#ifdef WNT
+#ifdef _WIN32
+ OSD_Environment env4("CSF_MDTVCurrentUnits");
TCollection_AsciiString csfmdtvcurrent (env4.Value());
if( csfmdtvcurrent.Length() > 0 )
MDTVCurrentUnits = new Resource_Manager(csfmdtvcurrent.ToCString());
aValue = Units::ToSI(aData,current.ToCString());
aValue = LocalSystemUnits.ConvertSIValueToUserSystem(aQuantity,aValue);
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout <<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout <<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif
TCollection_AsciiString current(CurrentUnits->Value(aQuantity));
aValue = Units::ToSI(aData,current.ToCString());
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif
aValue = LocalSystemUnits.ConvertUserSystemValueToSI(aQuantity,aData);
aValue = Units::FromSI(aValue,current.ToCString());
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif
TCollection_AsciiString current(CurrentUnits->Value(aQuantity));
aValue = Units::FromSI(aData,current.ToCString());
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif
TCollection_AsciiString current(CurrentUnits->Value(aQuantity));
aValue = AnyToAny(aData,current.ToCString(),aUnit);
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif
TCollection_AsciiString current(CurrentUnits->Value(aQuantity));
aValue = AnyToAny(aData,aUnit,current.ToCString());
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif
if( quantity ) {
aValue = LocalSystemUnits.ConvertSIValueToUserSystem(quantity,aValue);
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else
- cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << ")" << endl;
+ std::cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << ")" << std::endl;
#endif
return aValue;
}
if( quantity ) {
aValue = LocalSystemUnits.ConvertSIValueToUserSystem(quantity,aValue);
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else
- cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << "," << aDim << ")" << endl;
+ std::cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << "," << aDim.get() << ")" << std::endl;
#endif
return aValue;
}
if( quantity ) {
aValue = LocalSystemUnits.ConvertUserSystemValueToSI(quantity,aValue);
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else
- cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << ")" << endl;
+ std::cout<<"Warning: BAD Quantity returns in UnitsAPI::AnyToLS(" << aData << "," << aUnit << ")" << std::endl;
#endif
return aValue;
if( CurrentUnits->Find(aQuantity) ) {
aValue = LocalSystemUnits.ConvertUserSystemValueToSI(aQuantity,aData);
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif
if( CurrentUnits->Find(aQuantity) ) {
aValue = LocalSystemUnits.ConvertSIValueToUserSystem(aQuantity,aValue);
}
-#ifdef UNITSAPI_DEB
+#ifdef OCCT_DEBUG
else {
- cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << endl;
+ std::cout<<"Warning: UnitsAPI,the quantity '" << aQuantity << "' does not exist in the current units system" << std::endl;
}
#endif