-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <vector>
#include <string>
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
using namespace std;
*/
void SetVariable(Handle(_pyCommand) theCommand,
const SMESH_ObjectStates* theStates,
- int position, int theArgNb)
+ size_t position, int theArgNb)
{
if(theStates->GetCurrectState().size() > position)
if(!theStates->GetCurrectState().at(position).IsEmpty())
//================================================================================
TState SMESH_ObjectStates::GetCurrectState() const
{
- if(_states.size() > _dumpstate)
+ if ( (int) _states.size() > _dumpstate)
return _states[_dumpstate];
TState empty;
return empty;
/*!
* \brief Replace parameters of the functions on the Salome NoteBook Variables
* \param theString - Input string
- * \retval TCollection_AsciiString - Convertion result
+ * \retval TCollection_AsciiString - Conversion result
*/
//================================================================================
void SMESH_NoteBook::ReplaceVariables()
{
- for(int i=0;i<_commands.size();i++)
+ for ( size_t i = 0 ; i < _commands.size(); i++ )
{
Handle(_pyCommand) aCmd = _commands[i];
TCollection_AsciiString aMethod = aCmd->GetMethod();
TCollection_AsciiString aObject = aCmd->GetObject();
TCollection_AsciiString aResultValue = aCmd->GetResultValue();
- if(MYDEBUG) {
+ if(SALOME::VerbosityActivated()) {
cout<<"Command before : "<< aCmd->GetString()<<endl;
cout<<"Method : "<< aMethod<<endl;
cout<<"Object : "<< aObject<<endl;
const char* varIndexPtr = cmdStr.ToCString() + pos;
if ( '0' <= *varIndexPtr && *varIndexPtr <= '9' )
varIndex = atoi( varIndexPtr );
- if ( 0 <= varIndex && varIndex < vars.size() && !vars[varIndex].empty() )
+ if ( 0 <= (int)varIndex && varIndex < vars.size() && !vars[varIndex].empty() )
{
- // replace '$VarIndex$' either by var name of var value
+ // replace '$VarIndex$' either by var name or var value
const char var0 = vars[varIndex][0];
const bool isValue = (( '0' <= var0 && var0 <= '9' ) || var0 == '-');
if ( isValue ) // remove TVar::Quote() as well
}
if(it != _objectMap.end()) {
- if(MYDEBUG)
+ if(SALOME::VerbosityActivated())
cout << "Found object : " << (*it).first << endl;
SMESH_ObjectStates *aStates = (*it).second;
// Case for LocalLength hypothesis
if(aMethod == "SetLayerDistribution"){
LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
aLDStates->AddDistribution(aCmd->GetArg(1));
- if(MYDEBUG)
+ if(SALOME::VerbosityActivated())
cout<<"Add Distribution :"<<aCmd->GetArg(1)<<endl;
}
}
// dumped calls due to the fix of
// issue 0021364:: Dump of netgen parameters has duplicate lines
SMESH_Gen_i * aGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aGen->GetCurrentStudy();
- SALOMEDS::SObject_wrap sobj = aStudy->FindObjectID( (*it).first.ToCString() );
+ SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( (*it).first.ToCString() );
CORBA::Object_var obj = aGen->SObjectToObject( sobj );
if ( SMESH_Hypothesis_i* h = SMESH::DownCast< SMESH_Hypothesis_i*>( obj ))
{
TState aCurrentState = aStates->GetCurrectState();
int argIndex = h->getParamIndex( aMethod, aCurrentState.size() );
- if ( 0 <= argIndex && argIndex < aCurrentState.size() &&
+ if ( 0 <= argIndex && argIndex < (int)aCurrentState.size() &&
!aCurrentState[argIndex].IsEmpty() )
aCmd->SetArg( 1, aCurrentState[argIndex] );
}
}
else {
- if(MYDEBUG)
+ if(SALOME::VerbosityActivated())
cout << "Object not found" << endl;
}
- if(MYDEBUG) {
+ if(SALOME::VerbosityActivated()) {
cout<<"Command after: "<< aCmd->GetString()<<endl;
}
}
if(!aGen)
return;
- SALOMEDS::Study_var aStudy = aGen->GetCurrentStudy();
+ SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
if(aStudy->_is_nil())
return;
std::vector< std::string > allVars = aGen->GetAllParameters( anID.in() );
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters.in());
_entry2VarsMap[ TCollection_AsciiString( anID.in() )] = allVars;
- if(MYDEBUG) {
+ if(SALOME::VerbosityActivated()) {
cout<<"Entry : "<< anID<<endl;
cout<<"aParameters : "<<aParameters<<endl;
}
else if (!aMesh->_is_nil() ) {
anObjType = "Mesh";
}
- if(MYDEBUG)
+ if(SALOME::VerbosityActivated())
cout<<"The object Type : "<<anObjType<<endl;
SMESH_ObjectStates *aState = NULL;
if(anObjType == "LayerDistribution")
else
aState = new SMESH_ObjectStates(anObjType);
- for(int i = 0; i < aSections->length(); i++) {
+ for ( size_t i = 0; i < aSections->length(); i++ ) {
TState aVars;
SALOMEDS::ListOfStrings aListOfVars = aSections[i];
- for ( int j = 0; j<aListOfVars.length(); j++)
+ for ( size_t j = 0; j < aListOfVars.length(); j++)
{
TCollection_AsciiString aVar(aListOfVars[j].in());
if(!aVar.IsEmpty() && aStudy->IsVariable(aVar.ToCString())) {
aVar.InsertAfter(aVar.Length(), SMESH::TVar::Quote() );
}
aVars.push_back(aVar);
- if(MYDEBUG) {
+ if(SALOME::VerbosityActivated()) {
cout<<"Variable: '"<<aVar<<"'"<<endl;
}
}
//================================================================================
void SMESH_NoteBook::AddCommand(const TCollection_AsciiString& theString)
{
- if(MYDEBUG)
+ if(SALOME::VerbosityActivated())
cout<<theString<<endl;
Handle(_pyCommand) aCommand = new _pyCommand( theString, -1);
_commands.push_back(aCommand);
return;
// 2) Initialize all type of 1D Distribution hypothesis
- for(int i=0;i<_commands.size();i++){
- for(int j =0;j < aLDS.size();j++){
+ for ( size_t i = 0; i < _commands.size(); i++ ) {
+ for ( size_t j = 0; j < aLDS.size(); j++ ) {
TCollection_AsciiString aResultValue = _commands[i]->GetResultValue();
if(_commands[i]->GetMethod() == "CreateHypothesis" &&
aLDS[j]->HasDistribution(aResultValue)){
}
// 3) ... and replase variables ...
- for(int i=0;i<_commands.size();i++){
- for(int j =0;j < aLDS.size();j++){
+ for ( size_t i = 0; i < _commands.size(); i++ ) {
+ for ( size_t j = 0; j < aLDS.size(); j++ ) {
TCollection_AsciiString anObject = _commands[i]->GetObject();
if(aLDS[j]->HasDistribution(anObject)) {
TCollection_AsciiString SMESH_NoteBook::GetResultScript() const
{
TCollection_AsciiString aResult;
- for(int i=0;i<_commands.size();i++)
- aResult+=_commands[i]->GetString()+"\n";
+ for ( size_t i = 0; i < _commands.size(); i++ )
+ aResult += _commands[i]->GetString() + "\n";
return aResult;
}
+//================================================================================
+/*!
+ * \brief Return lines of the result script
+ */
+//================================================================================
+void SMESH_NoteBook::GetResultLines(std::list< TCollection_AsciiString >& lines) const
+{
+ for ( size_t i = 0; i < _commands.size(); i++ )
+ lines.push_back( _commands[i]->GetString() );
+}
+
//================================================================================
/*!
* \brief Return value of the variable
{
bool ok = false;
- SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen();
- if(!aGen)
- return ok;
-
- SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy();
+ SALOMEDS::Study_ptr aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant();
if(aStudy->_is_nil())
return ok;
return ok;
}
-