#include "SMESH_2smeshpy.hxx"
-#include "SMESH_Gen_i.hxx"
#include "utilities.h"
#include "SMESH_PythonDump.hxx"
#include "Resource_DataMapOfAsciiStringAsciiString.hxx"
+#include "SMESH_Gen_i.hxx"
+/* SALOME headers that include CORBA headers that include windows.h
+ * that defines GetObject symbol as GetObjectA should stand before SALOME headers
+ * that declare methods named GetObject - to apply the same rules of GetObject renaming
+ * and thus to avoid mess with GetObject symbol on Windows */
+
IMPLEMENT_STANDARD_HANDLE (_pyObject ,Standard_Transient);
IMPLEMENT_STANDARD_HANDLE (_pyCommand ,Standard_Transient);
IMPLEMENT_STANDARD_HANDLE (_pyGen ,_pyObject);
#undef DUMP_CONVERSION
#endif
+
namespace {
//================================================================================
AddMeshAccessorMethod( aCommand );
// Add access to a wrapped algorithm
- AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ???
+ // AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ???
// PAL12227. PythonDump was not updated at proper time; result is
// aCriteria.append(SMESH.Filter.Criterion(17,26,0,'L1',26,25,1e-07,SMESH.EDGE,-1))
// Concatenate( [mesh1, ...], ... )
// CreateHypothesis( theHypType, theLibName )
// Compute( mesh, geom )
-
// mesh creation
if ( theCommand->GetMethod() == "CreateMesh" ||
- theCommand->GetMethod() == "CreateEmptyMesh" )
+ theCommand->GetMethod() == "CreateEmptyMesh" ||
+ theCommand->GetMethod() == "CreateMeshesFromUNV" ||
+ theCommand->GetMethod() == "CreateMeshesFromSTL")
{
Handle(_pyMesh) mesh = new _pyMesh( theCommand );
myMeshes.insert( make_pair( mesh->GetID(), mesh ));
return;
}
+ if(theCommand->GetMethod() == "CreateMeshesFromMED")
+ {
+ for(int ind = 0;ind<theCommand->GetNbResultValues();ind++)
+ {
+ Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue(ind));
+ myMeshes.insert( make_pair( theCommand->GetResultValue(ind), mesh ));
+ }
+ }
+
// CreateHypothesis()
if ( theCommand->GetMethod() == "CreateHypothesis" )
{
//================================================================================
/*!
- * \brief Add access method to mesh that is an object or an argument
+ * \brief Add access method to mesh that is an argument
* \param theCmd - command to add access method
* \retval bool - true if added
*/
{
// convert my creation command
Handle(_pyCommand) creationCmd = GetCreationCmd();
- creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() );
- creationCmd->SetMethod( "Mesh" );
+ TCollection_AsciiString str = creationCmd->GetMethod();
+
+ creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() );
+ if(str != "CreateMeshesFromUNV" &&
+ str != "CreateMeshesFromMED" &&
+ str != "CreateMeshesFromSTL")
+ creationCmd->SetMethod( "Mesh" );
theGen->SetAccessorMethod( GetID(), "GetMesh()" );
}
+//================================================================================
+/*!
+ * \brief
+ * \param theCreationCmd -
+ */
+//================================================================================
+_pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd, const TCollection_AsciiString& id):
+ _pyObject(theCreationCmd), myHasEditor(false)
+{
+ // convert my creation command
+ Handle(_pyCommand) creationCmd = GetCreationCmd();
+ creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() );
+ theGen->SetAccessorMethod( id, "GetMesh()" );
+}
+
//================================================================================
/*!
* \brief Convert a IDL API command of SMESH::Mesh to a method call of python Mesh
}
}
Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
- if ( ! hasAddCmd ) { // hypo addition already wrapped
+ if ( ! hasAddCmd && hypID.Length() != 0 ) { // hypo addition already wrapped
// RemoveHypothesis(geom, hyp) --> RemoveHypothesis( hyp, geom=0 )
_pyID geom = theCommand->GetArg( 1 );
theCommand->RemoveArgs();
"MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders",
"SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes",
"GetLastCreatedElems",
- "" }; // <- mark of end
+ "MirrorMakeMesh","MirrorObjectMakeMesh","TranslateMakeMesh",
+ "TranslateObjectMakeMesh","RotateMakeMesh","RotateObjectMakeMesh",
+ "" }; // <- mark of the end
sameMethods.Insert( names );
}
+ //theGen->AddMeshAccessorMethod( theCommand ); // for *Object()
if ( sameMethods.Contains( theCommand->GetMethod() )) {
theCommand->SetObject( myMesh );
+
+ // meshes made by *MakeMesh() methods are not wrapped by _pyMesh,
+ // so let _pyMesh care of it (TMP?)
+ if ( theCommand->GetMethod().Search("MakeMesh") != -1 )
+ _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod()
}
else {
// editor creation command is needed only if any editor function is called
return myRes;
}
+//================================================================================
+/*!
+ * \brief Return number of python command result value ResultValue = Obj.Meth()
+ * \retval const int
+ */
+//================================================================================
+
+const int _pyCommand::GetNbResultValues()
+{
+ int begPos = 1;
+ int Nb=0;
+ int endPos = myString.Location( "=", 1, Length() );
+ TCollection_AsciiString str = "";
+ while ( begPos < endPos) {
+ str = GetWord( myString, begPos, true );
+ begPos = begPos+ str.Length();
+ Nb++;
+ }
+ return (Nb-1);
+}
+
+
+//================================================================================
+/*!
+ * \brief Return substring of python command looking like
+ * ResultValue1 , ResultValue1,... = Obj.Meth() with res index
+ * \retval const TCollection_AsciiString & - ResultValue with res index substring
+ */
+//================================================================================
+const TCollection_AsciiString & _pyCommand::GetResultValue(int res)
+{
+ int begPos = 1;
+ int Nb=0;
+ int endPos = myString.Location( "=", 1, Length() );
+ while ( begPos < endPos) {
+ myRes = GetWord( myString, begPos, true );
+ begPos = begPos + myRes.Length();
+ Nb++;
+ if(res == Nb){
+ myRes.RemoveAll('[');myRes.RemoveAll(']');
+ return myRes;
+ }
+ if(Nb>res)
+ break;
+ }
+ return theEmptyString;
+}
+
//================================================================================
/*!
* \brief Return substring of python command looking like ResVal = Object.Meth()