#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>
+#if OCC_VERSION_LARGE < 0x07050000
+#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
+#endif
+
+#include <cstring>
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
if(!aCollection.IsEmpty())
{
- const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
+ const std::string & objEntry = aSMESHGen->GetLastObjEntry();
if ( !objEntry.empty() )
aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
aSMESHGen->AddToPythonScript(aCollection);
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;
}
{
#ifdef _DEBUG_
std::cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << std::endl;
+#else
+ (void)text; // unused in release mode
#endif
}
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
}
myPythonScript->Clear();
}
}
+
+//================================================================================
+/*!
+ * \brief Count inclusions of a string in a raw Python dump script
+ */
+//================================================================================
+
+int SMESH_Gen_i::CountInPyDump(const TCollection_AsciiString& theText)
+{
+ int count = 0;
+
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if ( CORBA::is_nil( aStudy ))
+ return count;
+
+ SMESH_Gen_i* me = GetSMESHGen();
+ CORBA::String_var compDataType = me->ComponentDataType();
+ SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
+ if ( CORBA::is_nil( aSO ))
+ return count;
+
+ // Trace saved in the study
+ SALOMEDS::GenericAttribute_wrap attr;
+ if ( aSO->FindAttribute( attr.inout(), "AttributePythonObject" ))
+ {
+ SALOMEDS::AttributePythonObject_var pyAttr =
+ SALOMEDS::AttributePythonObject::_narrow( attr );
+ CORBA::String_var script = pyAttr->GetObject();
+ for ( const char * scriptPos = script.in(); true; ++scriptPos )
+ if (( scriptPos = strstr( scriptPos, theText.ToCString() )))
+ ++count;
+ else
+ break;
+ }
+
+ // New python commands
+ if ( !me->myPythonScript.IsNull() )
+ {
+ const int nbLines = me->myPythonScript->Length();
+ for ( int i = 1; i <= nbLines; ++i )
+ {
+ const TCollection_AsciiString& line = me->myPythonScript->Value( i );
+ for ( int loc = 1; loc <= line.Length(); ++loc )
+ if (( loc = line.Location( theText, loc, line.Length() )))
+ ++count;
+ else
+ break;
+ }
+ }
+
+ return count;
+}