-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 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_Gen_i.hxx"
#include "SMESH_MeshEditor_i.hxx"
+#include <Basics_Utils.hxx>
#include <SALOMEDS_wrap.hxx>
#include <LDOMParser.hxx>
return *this;
}
- template<class TArray>
- void DumpArray(const TArray& theArray, TPythonDump & theStream)
- {
- if ( theArray.length() == 0 )
- {
- theStream << "[]";
- }
- else
- {
- theStream << "[ ";
- for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
- theStream << theArray[i-1];
- if ( i < theArray.length() )
- theStream << ", ";
- }
- theStream << " ]";
- }
- }
-
TPythonDump&
TPythonDump::operator<<(const SMESH::long_array& theArg)
{
case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
case FT_Length: myStream<< "aLength"; break;
case FT_Length2D: myStream<< "aLength2D"; break;
+ case FT_Length3D: myStream<< "aLength3D"; break;
case FT_Deflection2D: myStream<< "aDeflection2D"; break;
case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
DumpArray( theList, *this );
return *this;
}
+ TPythonDump& TPythonDump::operator<<(const SMESH::submesh_array& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfHypothesis& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
{
// dump CoincidentFreeBorders as a list of lists, each enclosed list
void printException( const char* text )
{
#ifdef _DEBUG_
- cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
+ std::cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << std::endl;
#endif
}
-}
//=======================================================================
//function : RemoveTabulation
//purpose :
//=======================================================================
-void RemoveTabulation( TCollection_AsciiString& theScript )
-{
- std::string aString( theScript.ToCString() );
- std::string::size_type aPos = 0;
- while( aPos < aString.length() )
+ void RemoveTabulation( TCollection_AsciiString& theScript )
{
- aPos = aString.find( "\n\t", aPos );
- if( aPos == std::string::npos )
- break;
- aString.replace( aPos, 2, "\n" );
- aPos++;
+ std::string aString( theScript.ToCString() );
+ std::string::size_type aPos = 0;
+ while( aPos < aString.length() )
+ {
+ aPos = aString.find( "\n\t", aPos );
+ if( aPos == std::string::npos )
+ break;
+ aString.replace( aPos, 2, "\n" );
+ aPos++;
+ }
+ theScript = aString.c_str();
}
- theScript = aString.c_str();
}
//=======================================================================
//function : DumpPython
//purpose :
//=======================================================================
-Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
+Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript)
{
+ // localizing
+ Kernel_Utils::Localizer loc;
+
SALOMEDS::Study_var aStudy = getStudyServant();
if (CORBA::is_nil(aStudy))
return new Engines::TMPFile(0);
bool isValidName = true;
int nbUnderscore = 0;
int p;
-// // replace not allowed chars by underscore
-// const char* name = aName.ToCString();
-// for ( p = 0; name[p]; ++p ) {
-// if ( !isalnum( name[p] ) && name[p] != '_' )
-// {
-// if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
-// {
-// aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
-// --p;
-// name = aName.ToCString();
-// }
-// else
-// {
-// aName.SetValue( p+1, '_');
-// nbUnderscore++;
-// }
-// isValidName = false;
-// }
-// }
+ // replace not allowed chars by underscore
+ const char* name = aName.ToCString();
+ for ( p = 0; name[p]; ++p ) {
+ if ( !isalnum( name[p] ) && name[p] != '_' )
+ {
+ if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
+ {
+ aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
+ --p;
+ name = aName.ToCString();
+ }
+ else
+ {
+ aName.SetValue( p+1, '_');
+ nbUnderscore++;
+ }
+ isValidName = false;
+ }
+ }
// aName must not start with a digit
if ( aName.IsIntegerValue() ) {
aName.Insert( 1, 'a' );
//================================================================================
/*!
- * \brief Createa a Dump Python script
+ * \brief Creates a Dump Python script
* \param [in,out] theObjectNames - map of an entry to a study and python name
* \param [in] theNames - - map of an entry to a study name
* \param [in] isPublished - \c true if dump of object publication in study is needed
const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
-
+ TCollection_AsciiString optionalComment;
+
std::list< TCollection_AsciiString > lines; // lines of a script
std::list< TCollection_AsciiString >::iterator linesIt;
+ lines.push_back( aSMESHGen + " = smeshBuilder.New()" );
if ( isPublished )
- lines.push_back( aSMESHGen + " = smeshBuilder.New()" );
- else
- lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" );
+ optionalComment = "#";
+ lines.push_back( optionalComment + aSMESHGen + ".SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations:" );
+ lines.push_back( " # multiples meshes built in parallel, complex and numerous mesh edition (performance)\n" );
lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );