-// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "SMESH_MeshEditor_i.hxx"
#include <Basics_Utils.hxx>
+#include <Basics_OCCTVersion.hxx>
#include <SALOMEDS_wrap.hxx>
#include <LDOMParser.hxx>
-#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <TCollection_AsciiString.hxx>
-#include <cstring>
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
+#if OCC_VERSION_LARGE < 0x07050000
+#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
#endif
+#include <cstring>
+
#include "SMESH_TryCatch.hxx"
namespace SMESH
size_t TPythonDump::myCounter = 0;
const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
- TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
- TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::LongLong value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
{
for ( size_t i = 0; i < value.length(); i++)
myVals[i] = SMESH_Comment(value[i]);
}
+
+ TPythonDump::TPythonDump():myVarsCounter(0),mySmesh(SMESH_Gen_i::GetSMESHGen())
+ {
+ ++myCounter;
+ }
- TPythonDump::
- TPythonDump():myVarsCounter(0)
+ TPythonDump::TPythonDump(SMESH_Gen_i *smesh):myVarsCounter(0),mySmesh(smesh)
{
++myCounter;
}
if ( !objEntry.empty() )
aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
aSMESHGen->AddToPythonScript(aCollection);
- if(MYDEBUG) MESSAGE(aString);
+ MESSAGE(aString);
// prevent misuse of already treated variables
aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
}
return *this;
}
+ TPythonDump&
+ TPythonDump::
+ operator<<(long long theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
TPythonDump&
TPythonDump::
operator<<(double theArg){
return *this;
}
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::smIdType_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
TPythonDump&
TPythonDump::operator<<(const SMESH::double_array& theArg)
{
operator<<(CORBA::Object_ptr theArg)
{
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
if(!aSObject->_is_nil()) {
CORBA::String_var id = aSObject->GetID();
myStream << id;
TPythonDump::
operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
{
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
myStream << "hyp_" << theArg->GetId();
else
{
if ( CORBA::is_nil( theArg ) )
return *this << "None";
- SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ SALOMEDS::SObject_wrap aSObject = mySmesh->ObjectToSObject(theArg);
if(!aSObject->_is_nil())
{
return *this << aSObject;
}
if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
{
- SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
- SMESH::long_array_var anElementsId = theArg->GetIDs();
- SMESH::array_of_ElementType_var types = theArg->GetTypes();
- SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
- SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
+ SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
+ SMESH::smIdType_array_var anElementsId = theArg->GetIDs();
+ SMESH::array_of_ElementType_var types = theArg->GetTypes();
+ SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
+ SALOMEDS::SObject_wrap meshSO = mySmesh->ObjectToSObject(mesh);
+
if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
return *this << mesh << ".GetIDSource([], " << type << ")";
else
TPythonDump&
TPythonDump::
- operator<<(SMESH::FilterManager_i* theArg)
+ operator<<(SMESH::FilterManager_i* /*theArg*/)
{
myStream<<"aFilterManager";
return *this;
TPythonDump&
TPythonDump::
- operator<<(SMESH::Measurements_i* theArg)
+ operator<<(SMESH::Measurements_i* /*theArg*/)
{
myStream<<"aMeasurements";
return *this;
}
- TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
+ TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* /*theArg*/)
{
myStream << SMESHGenName(); return *this;
}
void printException( const char* text )
{
-#ifdef _DEBUG_
- std::cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << std::endl;
-#endif
+ if (SALOME::VerbosityActivated())
+ std::cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << std::endl;
}
//=======================================================================
TCollection_AsciiString anUpdatedScript;
Resource_DataMapOfAsciiStringAsciiString mapRemoved;
- Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
+ Resource_DataMapOfAsciiStringAsciiString mapEntries; // { entry: name } present in anUpdatedScript
Standard_Integer objectCounter = 0;
TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
+ std::string compDataType = ComponentDataType(); // SMESH module's data type
+ SALOMEDS::SComponent_var smeshSO = getStudyServant()->FindComponent( compDataType.c_str() );
+ CORBA::String_var smeshID = smeshSO->GetID();
+ TCollection_AsciiString smeshEntry = smeshID.in();
+
// Treat every script line and add it to anUpdatedScript
for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
{
}
else
{
- // Removed Object
- do {
- aName = aBaseName + (++objectCounter);
- } while (theObjectNames.IsBound(aName));
+ if ( !anEntry.StartsWith( smeshEntry )) // not SMESH object
+ {
+ aName = SMESH::TPythonDump::NotPublishedObjectName();
+ }
+ else
+ {
+ // Removed Object
+ do {
+ aName = aBaseName + (++objectCounter);
+ } while (theObjectNames.IsBound(aName));
- if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
- mapRemoved.Bind(anEntry, aName);
+ if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
+ mapRemoved.Bind(anEntry, aName);
- theObjectNames.Bind(anEntry, aName);
+ theObjectNames.Bind(anEntry, aName);
+ }
}
theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
}