// Created on: 1995-02-23 // Created by: Remi LEQUETTE // Copyright (c) 1995-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include #include #include #include #include #include #include //======================================================================= //function : parsing //purpose : parsing of unit's expression //======================================================================= static Standard_Integer parsing (Draw_Interpretor& di, Standard_Integer argc, const char** argv) { if (argc < 2) { di << "Usage : " << argv[0] << " string [nbiter]\n"; return 1; } TCollection_AsciiString aStrTok(argv[1]); Standard_Integer nbIter =1; if(argc >2) nbIter = Draw::Atoi(argv[2]); UnitsAPI::SetLocalSystem(); Handle(Units_Token) atoken; Units_UnitSentence aUnitSent(aStrTok.ToCString()); if(!aUnitSent.IsDone()) { di<<"can not create a sentence\n"; return 1; } Standard_Integer i =1; for( ; i <= nbIter; i++) { aUnitSent.Analyse(); //aUnitSent.Dump(); Handle(Units_TokensSequence) aseq = aUnitSent.Sequence(); } atoken = aUnitSent.Evaluate(); di<<"Token word : "<Word().ToCString()<<"\n"; return 0; } //======================================================================= //function : unitsdico //purpose : dump dictionary of units //======================================================================= static Standard_Integer unitsdico (Draw_Interpretor& /* di */, Standard_Integer /*argc*/, const char** /*argv*/) { UnitsAPI::SetLocalSystem(); Standard_Integer mode = 2; Units::DictionaryOfUnits(Standard_False)->Dump(mode); return 0; } //======================================================================= //function : converttoSI //purpose : //======================================================================= static Standard_Integer converttoSI (Draw_Interpretor& di, Standard_Integer argc, const char** argv) { if (argc < 3) { di<<"Invalid number of parameter, use: unitconvtoSI real string\n"; return 1; } Standard_Real aData = Draw::Atof(argv[1]); Standard_CString aUnit = argv[2]; Standard_Real res = UnitsAPI::AnyToSI(aData,aUnit); di<<"result: "<