From: jfa Date: Mon, 4 Apr 2005 06:32:07 +0000 (+0000) Subject: Dump Python: Enlarge precision of real and double values mapping X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cc14acdac2a5a559e0f267f8eba5c6954ba7231d;p=modules%2Fgeom.git Dump Python: Enlarge precision of real and double values mapping --- diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index 2fb7c32e2..1af3ef5e3 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -5,11 +5,10 @@ #include "GEOM_ISubShape.hxx" #include "GEOM_SubShapeDriver.hxx" #include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx" +#include "GEOM_PythonDump.hxx" #include "utilities.h" -#include - #include #include #include @@ -24,12 +23,10 @@ #include #include #include -#include -#include -#include #include #include +#include #include #include @@ -211,26 +208,18 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape, if(_objects.IsBound(anID)) _objects.UnBind(anID); _objects.Bind(anID, anObject); - TCollection_AsciiString aDescr(""); + GEOM::TPythonDump pd (aFunction); - if(isStandaloneOperation) { - TCollection_AsciiString anEntry; - TDF_Tool::Entry(anObject->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geom.AddSubShape("; - TDF_Tool::Entry(theMainShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (", ["); - for(Standard_Integer i=theIndices->Lower(); i<=theIndices->Upper(); i++) { - aDescr += (TCollection_AsciiString(theIndices->Value(i))+", "); + if (isStandaloneOperation) { + pd << anObject << " = geompy.GetSubShape(" << theMainShape << ", ["; + Standard_Integer i = theIndices->Lower(), up = theIndices->Upper(); + for (; i <= up - 1; i++) { + pd << theIndices->Value(i) << ", "; } - aDescr.Trunc(aDescr.Length()-1); - aDescr += "])"; + pd << theIndices->Value(up) << "])"; } - else - TCollection_AsciiString aDescr("None"); - - aFunction->SetDescription(aDescr); + else + pd << "None"; return anObject; } @@ -364,7 +353,8 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, if(aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n"); - aScript = "import geompy\n\n"; + aScript = "import geompy\n"; + aScript += "import math\n\n"; aScript += "def RebuildData(theStudy):"; aScript += "\n\tgeompy.init_geom(theStudy)"; @@ -526,6 +516,23 @@ const char* GEOM_Engine::GetDumpName (const char* theStudyEntry) const return NULL; } +//======================================================================= +//function : GetAllDumpNames +//purpose : +//======================================================================= + +Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const +{ + Handle(TColStd_HSequenceOfAsciiString) aRetSeq = new TColStd_HSequenceOfAsciiString; + + Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString it (_studyEntry2NameMap); + for (; it.More(); it.Next()) { + aRetSeq->Append(it.Value()); + } + + return aRetSeq; +} + //=========================================================================== // Internal functions diff --git a/src/GEOM/GEOM_Engine.hxx b/src/GEOM/GEOM_Engine.hxx index 7765fea9f..b5ea794e3 100644 --- a/src/GEOM/GEOM_Engine.hxx +++ b/src/GEOM/GEOM_Engine.hxx @@ -3,16 +3,14 @@ #define _GEOM_Engine_HXX_ #include "GEOM_Application.hxx" +#include "GEOM_Object.hxx" +#include "GEOM_DataMapOfAsciiStringTransient.hxx" + #include #include -#include #include -#include "GEOM_Object.hxx" #include #include -#include - -#include "GEOM_DataMapOfAsciiStringTransient.hxx" class GEOM_Engine { @@ -71,6 +69,8 @@ class GEOM_Engine const char* GetDumpName (const char* theStudyEntry) const; + Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const; + protected: static void SetEngine(GEOM_Engine* theEngine); diff --git a/src/GEOM/GEOM_Function.cxx b/src/GEOM/GEOM_Function.cxx index 4112c03ad..0f42f76c3 100644 --- a/src/GEOM/GEOM_Function.cxx +++ b/src/GEOM/GEOM_Function.cxx @@ -218,10 +218,11 @@ TCollection_AsciiString GEOM_Function::GetDescription() * SetDescription */ //============================================================================= -void GEOM_Function::SetDescription(TCollection_AsciiString& theDescription) +void GEOM_Function::SetDescription(const TCollection_AsciiString& theDescription) { TDF_Label aChild = _label.FindChild(DESCRIPTION_LABEL); - Handle(TDataStd_Comment) aComment = TDataStd_Comment::Set(aChild, TCollection_ExtendedString(theDescription)); + Handle(TDataStd_Comment) aComment = + TDataStd_Comment::Set(aChild, TCollection_ExtendedString(theDescription)); } //============================================================================= diff --git a/src/GEOM/GEOM_Function.hxx b/src/GEOM/GEOM_Function.hxx index 92879bf0c..f5b21c02d 100644 --- a/src/GEOM/GEOM_Function.hxx +++ b/src/GEOM/GEOM_Function.hxx @@ -165,7 +165,7 @@ public: TCollection_AsciiString GetDescription(); //Sets aPython description of the function - void SetDescription(TCollection_AsciiString& theDescription); + void SetDescription(const TCollection_AsciiString& theDescription); //Access to arguments diff --git a/src/GEOM/GEOM_Object.cxx b/src/GEOM/GEOM_Object.cxx index 3084f8e09..e36de6cf1 100644 --- a/src/GEOM/GEOM_Object.cxx +++ b/src/GEOM/GEOM_Object.cxx @@ -222,11 +222,13 @@ void GEOM_Object::SetAuxData(const char* theData) //============================================================================= TCollection_AsciiString GEOM_Object::GetAuxData() { + TCollection_AsciiString aData; + Handle(TDataStd_Comment) aCommentAttr; - if(!_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr)) return NULL; - - TCollection_AsciiString aData(aCommentAttr->Get()); - return aData.ToCString(); + if (_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr)) + aData = aCommentAttr->Get(); + + return aData; } diff --git a/src/GEOM/GEOM_PythonDump.cxx b/src/GEOM/GEOM_PythonDump.cxx new file mode 100644 index 000000000..ee18fca2a --- /dev/null +++ b/src/GEOM/GEOM_PythonDump.cxx @@ -0,0 +1,94 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "GEOM_PythonDump.hxx" + +#include + +namespace GEOM +{ + size_t TPythonDump::myCounter = 0; + + TPythonDump::TPythonDump (Handle(GEOM_Function)& theFunction) + { + myFunction = theFunction; + myCounter++; + } + + TPythonDump::~TPythonDump() + { + if (--myCounter == 0) { + myFunction->SetDescription((char *)myStream.str().c_str()); + } + } + +// TPythonDump::operator TCollection_AsciiString () const +// { +// if (myCounter == 1) { +// return TCollection_AsciiString ((char *)myStream.str().c_str()); +// } +// return TCollection_AsciiString (); +// } + + TPythonDump& TPythonDump::operator<< (long int theArg) + { + myStream<GetEntry(), anEntry); + myStream << anEntry.ToCString(); + return *this; + } +} diff --git a/src/GEOM/GEOM_PythonDump.hxx b/src/GEOM/GEOM_PythonDump.hxx new file mode 100644 index 000000000..867abac78 --- /dev/null +++ b/src/GEOM/GEOM_PythonDump.hxx @@ -0,0 +1,55 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _GEOM_PYTHONDUMP_HXX_ +#define _GEOM_PYTHONDUMP_HXX_ + +#include + +#include "GEOM_Object.hxx" +#include "GEOM_Function.hxx" + +#include + +namespace GEOM +{ + class TPythonDump + { + std::ostringstream myStream; + static size_t myCounter; + + Handle(GEOM_Function) myFunction; + + public: + TPythonDump (Handle(GEOM_Function)& theFunction); + virtual ~TPythonDump(); + +// operator TCollection_AsciiString () const; + + TPythonDump& operator<< (long int theArg); + TPythonDump& operator<< (int theArg); + TPythonDump& operator<< (double theArg); + TPythonDump& operator<< (float theArg); + TPythonDump& operator<< (const void* theArg); + TPythonDump& operator<< (const char* theArg); + TPythonDump& operator<< (const Handle(GEOM_Object)& theObject); + }; +} + +#endif diff --git a/src/GEOM/Makefile.in b/src/GEOM/Makefile.in index d61a7fa10..175113e5c 100644 --- a/src/GEOM/Makefile.in +++ b/src/GEOM/Makefile.in @@ -17,6 +17,7 @@ LIB_SRC = GEOM_Application.cxx \ GEOM_IOperations.cxx \ GEOM_Solver.cxx \ GEOM_SubShapeDriver.cxx \ + GEOM_PythonDump.cxx \ GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx \ GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx \ GEOM_DataMapOfAsciiStringTransient_0.cxx @@ -39,6 +40,7 @@ EXPORT_HEADERS= GEOM_Application.hxx \ GEOM_IOperations.hxx \ GEOM_ISubShape.hxx \ GEOM_Solver.hxx \ + GEOM_PythonDump.hxx \ GEOM_DataMapOfAsciiStringTransient.hxx \ Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index dc8ff1bab..eb733fdb4 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -12,6 +12,8 @@ using namespace std; #include #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" + #include "GEOMImpl_Types.hxx" #include "GEOMImpl_BoxDriver.hxx" @@ -99,15 +101,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, dou } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aBox->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeBoxDXDYDZ("; - aDescr += (TCollection_AsciiString(theDX)+", "); - aDescr += (TCollection_AsciiString(theDY)+", "); - aDescr += (TCollection_AsciiString(theDZ)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ(" + << theDX << ", " << theDY << ", " << theDZ << ")"; SetErrorCode(OK); return aBox; @@ -160,16 +155,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Objec } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aBox->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeBoxTwoPnt("; - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt(" + << thePnt1 << ", " << thePnt2 << ")"; SetErrorCode(OK); return aBox; @@ -214,14 +201,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, dou } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aCylinder->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeCylinderRH("; - aDescr += (TCollection_AsciiString(theR)+", "); - aDescr += (TCollection_AsciiString(theH)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCylinder + << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")"; SetErrorCode(OK); return aCylinder; @@ -278,18 +259,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aCylinder->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeCylinder("; - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVec->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theR)+", "); - aDescr += (TCollection_AsciiString(theH)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder(" + << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")"; SetErrorCode(OK); return aCylinder; @@ -337,15 +308,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, dou } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aCone->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeConeR1R2H("; - aDescr += (TCollection_AsciiString(theR1)+", "); - aDescr += (TCollection_AsciiString(theR2)+", "); - aDescr += (TCollection_AsciiString(theH)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H(" + << theR1 << ", " << theR2 << ", " << theH << ")"; SetErrorCode(OK); return aCone; @@ -404,19 +368,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aCone->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeCone("; - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVec->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theR1)+", "); - aDescr += (TCollection_AsciiString(theR2)+", "); - aDescr += (TCollection_AsciiString(theH)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt + << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")"; SetErrorCode(OK); return aCone; @@ -460,13 +413,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR) } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aSphere->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeSphereR("; - aDescr += (TCollection_AsciiString(theR)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")"; SetErrorCode(OK); return aSphere; @@ -518,15 +465,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Obje } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aSphere->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeSpherePntR("; - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theR)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aSphere + << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")"; SetErrorCode(OK); return aSphere; @@ -573,14 +513,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(anEll->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeTorusRR("; - aDescr += (TCollection_AsciiString(theRMajor)+", "); - aDescr += (TCollection_AsciiString(theRMinor)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR(" + << theRMajor << ", " << theRMinor << ")"; SetErrorCode(OK); return anEll; @@ -636,18 +570,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(anEll->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeTorus("; - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVec->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theRMajor)+", "); - aDescr += (TCollection_AsciiString(theRMinor)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt + << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")"; SetErrorCode(OK); return anEll; @@ -703,17 +627,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Objec } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aPrism->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakePrismVecH("; - TDF_Tool::Entry(theBase->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVec->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theH)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH(" + << theBase << ", " << theVec << ", " << theH << ")"; SetErrorCode(OK); return aPrism; @@ -769,18 +684,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aPrism->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakePrism("; - TDF_Tool::Entry(theBase->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism(" + << theBase << ", " << thePoint1 << ", " << thePoint2 << ")"; SetErrorCode(OK); return aPrism; @@ -834,15 +739,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) th } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPipe->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.MakePipe("); - TDF_Tool::Entry(theBase->GetEntry(), anEntry); - aDescr += (anEntry + ", "); - TDF_Tool::Entry(thePath->GetEntry(), anEntry); - aDescr += (anEntry + ")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe(" + << theBase << ", " << thePath << ")"; SetErrorCode(OK); return aPipe; @@ -898,17 +796,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle( } //Make a Python command - TCollection_AsciiString anEntry, aDescr("import math\n\t"); - TDF_Tool::Entry(aRevolution->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeRevolution("; - TDF_Tool::Entry(theBase->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theAngle/PI)+"*math.pi)"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution(" + << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; SetErrorCode(OK); return aRevolution; @@ -959,14 +848,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Obje } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aSolid->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeSolid("; - TDF_Tool::Entry(theShell->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")"; SetErrorCode(OK); return aSolid; @@ -977,7 +859,9 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Obje * MakeFilling */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter) +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling + (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, + double theTol2D, double theTol3D, int theNbIter) { SetErrorCode(KO); @@ -1020,19 +904,9 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling (Handle(GEOM_Object) } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aFilling->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeFilling("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theMinDeg)+", "); - aDescr += (TCollection_AsciiString(theMaxDeg)+", "); - aDescr += (TCollection_AsciiString(theTol2D)+", "); - aDescr += (TCollection_AsciiString(theTol3D)+", "); - aDescr += (TCollection_AsciiString(theNbIter)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aFilling << " = geompy.MakeFilling(" + << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", " + << theTol2D << ", " << theTol3D << ", " << theNbIter << ")"; SetErrorCode(OK); return aFilling; diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index e74f671e3..3178373b5 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -12,6 +12,7 @@ using namespace std; #include #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" #include "GEOMImpl_PointDriver.hxx" #include "GEOMImpl_VectorDriver.hxx" @@ -92,14 +93,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPoint->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeVertex("); - aDescr += (TCollection_AsciiString(theX)+", "); - aDescr += (TCollection_AsciiString(theY)+", "); - aDescr += (TCollection_AsciiString(theZ)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex(" + << theX << ", " << theY << ", " << theZ << ")"; SetErrorCode(OK); return aPoint; @@ -150,16 +145,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPoint->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeVertexWithRef("); - TDF_Tool::Entry(theReference->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theX)+", "); - aDescr += (TCollection_AsciiString(theY)+", "); - aDescr += (TCollection_AsciiString(theZ)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef(" + << theReference << ", " << theX << ", " << theY << ", " << theZ << ")"; SetErrorCode(OK); return aPoint; @@ -208,14 +195,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPoint->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeVertexOnCurve("); - TDF_Tool::Entry(theCurve->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theParameter)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve(" + << theCurve << ", " << theParameter << ")"; SetErrorCode(OK); return aPoint; @@ -263,14 +244,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aVector->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeVectorDXDYDZ("); - aDescr += (TCollection_AsciiString(theDX)+", "); - aDescr += (TCollection_AsciiString(theDY)+", "); - aDescr += (TCollection_AsciiString(theDZ)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ(" + << theDX << ", " << theDY << ", " << theDZ << ")"; SetErrorCode(OK); return aVector; @@ -321,15 +296,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aVector->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeVector("); - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector(" + << thePnt1 << ", " << thePnt2 << ")"; SetErrorCode(OK); return aVector; @@ -381,15 +349,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aLine->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeLine("); - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theDir->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine(" + << thePnt << ", " << theDir << ")"; SetErrorCode(OK); return aLine; @@ -440,15 +401,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aLine->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeLineTwoPnt("); - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt(" + << thePnt1 << ", " << thePnt2 << ")"; SetErrorCode(OK); return aLine; @@ -504,18 +458,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPlane->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakePlaneThreePnt("); - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += TCollection_AsciiString(theSize) + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")"; SetErrorCode(OK); return aPlane; @@ -568,16 +512,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPlane->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakePlane("); - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVec->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += TCollection_AsciiString(theSize) + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane(" + << thePnt << ", " << theVec << ", " << theSize << ")"; SetErrorCode(OK); return aPlane; @@ -627,14 +563,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPlane->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakePlaneFace("); - TDF_Tool::Entry(theFace->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += TCollection_AsciiString(theSize) + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace(" + << theFace << ", " << theSize << ")"; SetErrorCode(OK); return aPlane; @@ -684,20 +614,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aMarker->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeMarker("; - aDescr += TCollection_AsciiString(theOX) + ", "; - aDescr += TCollection_AsciiString(theOY) + ", "; - aDescr += TCollection_AsciiString(theOZ) + ", "; - aDescr += TCollection_AsciiString(theXDX) + ", "; - aDescr += TCollection_AsciiString(theXDY) + ", "; - aDescr += TCollection_AsciiString(theXDZ) + ", "; - aDescr += TCollection_AsciiString(theYDX) + ", "; - aDescr += TCollection_AsciiString(theYDY) + ", "; - aDescr += TCollection_AsciiString(theYDZ) + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker(" + << theOX << ", " << theOY << ", " << theOZ << ", " + << theXDX << ", " << theXDY << ", " << theXDZ << ", " + << theYDX << ", " << theYDY << ", " << theYDZ << ")"; SetErrorCode(OK); return aMarker; diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index 7d668aa47..ba9e3e1ae 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -11,6 +11,7 @@ using namespace std; #include "GEOMImpl_Block6Explorer.hxx" #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" #include "GEOMAlgo_GlueAnalyser.hxx" #include "GEOMAlgo_CoupleOfShapes.hxx" @@ -149,19 +150,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aFace->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeQuad("; - TDF_Tool::Entry(theEdge1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theEdge2->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theEdge3->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theEdge4->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeQuad(" + << theEdge1 << ", " << theEdge2 << ", " << theEdge3 << ", " << theEdge4 << ")"; SetErrorCode(OK); return aFace; @@ -215,15 +205,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad2Edges } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aFace->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeQuad2Edges("; - TDF_Tool::Entry(theEdge1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theEdge2->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeQuad2Edges(" + << theEdge1 << ", " << theEdge2 << ")"; SetErrorCode(OK); return aFace; @@ -284,19 +267,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad4Vertices } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aFace->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeQuad4Vertices("; - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePnt4->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeQuad4Vertices(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << thePnt4 << ")"; SetErrorCode(OK); return aFace; @@ -364,23 +336,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aBlock->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeHexa("; - TDF_Tool::Entry(theFace1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theFace2->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theFace3->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theFace4->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theFace5->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theFace6->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aBlock << " = geompy.MakeHexa(" + << theFace1 << ", " << theFace2 << ", " << theFace3 << ")" + << theFace4 << ", " << theFace5 << ", " << theFace6 << ")"; SetErrorCode(OK); return aBlock; @@ -434,15 +392,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa2Faces } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aBlock->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeHexa2Faces("; - TDF_Tool::Entry(theFace1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theFace2->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aBlock << " = geompy.MakeHexa2Faces(" + << theFace1 << ", " << theFace2 << ")"; SetErrorCode(OK); return aBlock; @@ -494,13 +445,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeBlockCompound } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aBlockComp->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.BlocksOp.MakeBlockCompound("; - TDF_Tool::Entry(theCompound->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aBlockComp + << " = geompy.MakeBlockCompound(" << theCompound << ")"; SetErrorCode(OK); return aBlockComp; @@ -574,21 +520,12 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetPoint //The GetPoint() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetPoint("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - aDescr += TCollection_AsciiString(theX) + ", "; - aDescr += TCollection_AsciiString(theY) + ", "; - aDescr += TCollection_AsciiString(theZ) + ", "; - aDescr += TCollection_AsciiString(theEpsilon) + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" + << aResult << " = geompy.GetPoint(" << theShape << ", " + << theX << ", " << theY << ", " << theZ << ", " << theEpsilon << ")"; SetErrorCode(OK); return aResult; @@ -696,23 +633,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdge return NULL; } - //The GetEdge() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetEdge("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetEdge(" + << theShape << ", " << thePoint1 << ", " << thePoint2 << ")"; SetErrorCode(OK); return aResult; @@ -826,21 +751,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdgeNearPoint return NULL; } - //The GetEdgeNearPoint() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetEdgeNearPoint("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetEdgeNearPoint(" + << theShape << ", " << thePoint << ")"; SetErrorCode(OK); return aResult; @@ -982,27 +897,12 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByPoints return NULL; } - //The GetFaceByPoints() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetFaceByPoints("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint3->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint4->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceByPoints(" + << theShape << ", " << thePoint1 << ", " << thePoint2 + << ", " << thePoint3 << ", " << thePoint4 << ")"; SetErrorCode(OK); return aResult; @@ -1125,23 +1025,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByEdges return NULL; } - //The GetFaceByEdges() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetFaceByEdges("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theEdge1->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theEdge2->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceByEdges(" + << theShape << ", " << theEdge1 << ", " << theEdge2 << ")"; SetErrorCode(OK); return aResult; @@ -1204,21 +1092,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetOppositeFace return NULL; } - //The GetOppositeFace() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetOppositeFace("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theFace->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetOppositeFace(" + << theShape << ", " << theFace << ")"; SetErrorCode(OK); return aResult; @@ -1233,9 +1111,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint (Handle(GEOM_Object) theShape, Handle(GEOM_Object) thePoint) { -// OSD_Timer timer1, timer2, timer3, timer4, timer5; -// timer1.Start(); - SetErrorCode(KO); //New object @@ -1275,9 +1150,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint Standard_Real PX, PY, PZ; aPnt.Coord(PX, PY, PZ); -// timer1.Stop(); -// timer2.Start(); - // 1. Classify the point relatively each face Standard_Integer nearest = 2, nbFound = 0; TopTools_DataMapOfShapeInteger mapShapeDist; @@ -1328,9 +1200,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint } // if (!mapShapeDist.IsBound(aFace)) } -// timer2.Stop(); -// timer3.Start(); - // 2. Define face, containing the point or having minimum distance to it if (nbFound > 1) { if (nearest == 0) { @@ -1401,9 +1270,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint } } // if (nbFound > 1) -// timer3.Stop(); -// timer4.Start(); - if (nbFound == 0) { SetErrorCode("There are no faces near the given point"); return NULL; @@ -1414,8 +1280,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint anArray->SetValue(1, anIndices.FindIndex(aShape)); aResult = GetEngine()->AddSubShape(theShape, anArray); } - -// timer4.Stop(); } catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); @@ -1423,35 +1287,13 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint return NULL; } -// timer5.Start(); - - //The GetFaceNearPoint() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetFaceNearPoint("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceNearPoint(" + << theShape << ", " << thePoint << ")"; SetErrorCode(OK); - -// timer5.Stop(); -// -// cout << "Show current face times:" << endl; -// timer1.Show(); -// timer2.Show(); -// timer3.Show(); -// timer4.Show(); -// timer5.Show(); - return aResult; } @@ -1578,21 +1420,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale return NULL; } - //The GetFaceByNormale() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetFaceByNormale("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(theVector->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceByNormale(" + << theShape << ", " << theVector << ")"; SetErrorCode(OK); return aResult; @@ -2483,13 +2315,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.RemoveExtraEdges("; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy + << " = geompy.RemoveExtraEdges(" << theObject << ")"; SetErrorCode(OK); return aCopy; @@ -2537,13 +2364,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::CheckAndImprove } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.CheckAndImprove("; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy + << " = geompy.CheckAndImprove(" << theObject << ")"; SetErrorCode(OK); return aCopy; @@ -2570,7 +2392,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound Handle(GEOM_Function) aFunction; TopTools_MapOfShape mapShape; - TCollection_AsciiString anAsciiList = "[", anEntry; + TCollection_AsciiString anAsciiList, anEntry; // Map shapes TopTools_IndexedMapOfShape anIndices; @@ -2601,8 +2423,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound //Make a Python command TDF_Tool::Entry(anObj->GetEntry(), anEntry); - anAsciiList += anEntry; - anAsciiList += ","; + anAsciiList += anEntry + ", "; } } } @@ -2618,23 +2439,16 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound return aBlocks; } - anAsciiList.Trunc(anAsciiList.Length() - 1); - anAsciiList += "]"; + anAsciiList.Trunc(anAsciiList.Length() - 2); //The explode doesn't change object so no new function is required. aFunction = theCompound->GetLastFunction(); + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); //Make a Python command - TCollection_AsciiString aDescr (anAsciiList); - aDescr += " = geompy.MakeBlockExplode("; - TDF_Tool::Entry(theCompound->GetEntry(), anEntry); - aDescr += anEntry + ", "; - aDescr += TCollection_AsciiString(theMinNbFaces) + ", "; - aDescr += TCollection_AsciiString(theMaxNbFaces) + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t[" + << anAsciiList.ToCString() << "] = geompy.MakeBlockExplode(" + << theCompound << ", " << theMinNbFaces << ", " << theMaxNbFaces << ")"; SetErrorCode(OK); return aBlocks; @@ -2805,21 +2619,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint return NULL; } - //The GetBlockNearPoint() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theCompound->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetBlockNearPoint("; - TDF_Tool::Entry(theCompound->GetEntry(), anEntry); - aDescr += anEntry + ", "; - TDF_Tool::Entry(thePoint->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetBlockNearPoint(" + << theCompound << ", " << thePoint << ")"; SetErrorCode(OK); return aResult; @@ -2929,20 +2733,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockByParts return NULL; } - //The GetBlockByParts() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theCompound->GetLastFunction(); + Handle(GEOM_Function) aFunction = aResult->GetLastFunction(); //Make a Python command - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - TCollection_AsciiString aDescr (anEntry); - aDescr += " = geompy.GetBlockByParts("; - TDF_Tool::Entry(theCompound->GetEntry(), anEntry); - aDescr += anEntry + ", ["; - aDescr += aPartsDescr + "])"; - - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetBlockByParts(" + << theCompound << ", [" << aPartsDescr.ToCString() << "])"; SetErrorCode(OK); return aResult; @@ -2970,7 +2765,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart //Get the parts Standard_Integer argi, aLen = theParts->Length(); TopTools_Array1OfShape anArgs (1, aLen); - TCollection_AsciiString anEntry, aPartsDescr, anAsciiList = "["; + TCollection_AsciiString anEntry, aPartsDescr, anAsciiList; + for (argi = 1; argi <= aLen; argi++) { Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theParts->Value(argi)); Handle(GEOM_Function) aRef = anObj->GetLastFunction(); @@ -2985,8 +2781,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart // For Python command TDF_Tool::Entry(anObj->GetEntry(), anEntry); - if (argi > 1) aPartsDescr += ", "; - aPartsDescr += anEntry; + aPartsDescr += anEntry + ", "; } //Get the Blocks @@ -3049,10 +2844,11 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart anObj = GetEngine()->AddSubShape(theCompound, anArray); aBlocks->Append(anObj); - //Make a Python command + // For Python command TDF_Tool::Entry(anObj->GetEntry(), anEntry); - anAsciiList += anEntry; - anAsciiList += ","; + anAsciiList += anEntry + ", "; + if (aFunction.IsNull()) + aFunction = anObj->GetLastFunction(); } } } @@ -3062,22 +2858,13 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart return NULL; } - anAsciiList.Trunc(anAsciiList.Length() - 1); - anAsciiList += "]"; - - //The GetBlocksByParts() doesn't change object so no new function is required. - aFunction = theCompound->GetLastFunction(); - //Make a Python command - TCollection_AsciiString aDescr (anAsciiList); - aDescr += " = geompy.GetBlocksByParts("; - TDF_Tool::Entry(theCompound->GetEntry(), anEntry); - aDescr += anEntry + ", ["; - aDescr += aPartsDescr + "])"; + aPartsDescr.Trunc(aPartsDescr.Length() - 2); + anAsciiList.Trunc(anAsciiList.Length() - 2); - TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; - aNewDescr += aDescr; - aFunction->SetDescription(aNewDescr); + GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() + << "] = geompy.GetBlocksByParts(" << theCompound + << ", [" << aPartsDescr.ToCString() << "])"; SetErrorCode(OK); return aBlocks; @@ -3131,16 +2918,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation1D } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeMultiTransformation1D("; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += anEntry + ", "; - aDescr += TCollection_AsciiString(theDirFace1) + ", "; - aDescr += TCollection_AsciiString(theDirFace2) + ", "; - aDescr += TCollection_AsciiString(theNbTimes) + ") "; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTransformation1D(" + << theObject << ", " << theDirFace1 << ", " << theDirFace2 << ", " << theNbTimes << ")"; SetErrorCode(OK); return aCopy; @@ -3200,19 +2979,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation2D } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeMultiTransformation2D("; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += anEntry + ", "; - aDescr += TCollection_AsciiString(theDirFace1U) + ", "; - aDescr += TCollection_AsciiString(theDirFace2U) + ", "; - aDescr += TCollection_AsciiString(theNbTimesU) + ", "; - aDescr += TCollection_AsciiString(theDirFace1V) + ", "; - aDescr += TCollection_AsciiString(theDirFace2V) + ", "; - aDescr += TCollection_AsciiString(theNbTimesV) + ") "; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTransformation2D(" + << theObject << ", " << theDirFace1U << ", " << theDirFace2U << ", " << theNbTimesU + << ", " << theDirFace1V << ", " << theDirFace2V << ", " << theNbTimesV << ")"; SetErrorCode(OK); return aCopy; @@ -3245,6 +3014,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; TopTools_MapOfShape mapAcceptedEdges; + TCollection_AsciiString aListRes, anEntry; for (ie = 1; ie <= nbEdges; ie++) { TopoDS_Shape curE = MEW.FindKey(ie); @@ -3329,6 +3099,10 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate // Add the chain to the result aSeq->Append(aChain); + + //Make a Python command + TDF_Tool::Entry(aChain->GetEntry(), anEntry); + aListRes += anEntry + ", "; } if (aSeq->IsEmpty()) { @@ -3336,19 +3110,15 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate return aSeq; } + aListRes.Trunc(aListRes.Length() - 2); + // The Propagation doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); // Make a Python command - TCollection_AsciiString aDescr - ("\n\tlistPropagationChains = IShapesOperations.Propagate("); - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry + ")"); - - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr = anOldDescr + aDescr; - aFunction->SetDescription(anOldDescr); + GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t[" + << aListRes.ToCString() << "] = geompy.Propagate(" << theShape << ")"; SetErrorCode(OK); return aSeq; diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx index 804763dc8..61b65e4b5 100644 --- a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx @@ -3,6 +3,8 @@ using namespace std; #include "GEOMImpl_IBooleanOperations.hxx" #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" + #include "GEOMImpl_Types.hxx" #include "GEOMImpl_BooleanDriver.hxx" @@ -95,18 +97,15 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object return NULL; } - //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aBool->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeBoolean("; - TDF_Tool::Entry(theShape1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theShape2->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theOp)+")"); - - aFunction->SetDescription(aDescr); + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aBool; + if (theOp == 1) pd << " = geompy.MakeCommon("; + else if (theOp == 2) pd << " = geompy.MakeCut("; + else if (theOp == 3) pd << " = geompy.MakeFuse("; + else if (theOp == 4) pd << " = geompy.MakeSection("; + else {} + pd << theShape1 << ", " << theShape2 << ")"; SetErrorCode(OK); return aBool; @@ -253,36 +252,24 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition } //Make a Python command - TCollection_AsciiString aDescr; - TDF_Tool::Entry(aPartition->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakePartition(["; - // Shapes - aDescr += aShapesDescr + "], ["; - // Tools - aDescr += aToolsDescr + "], ["; - // Keep Ins - aDescr += aKeepInsDescr + "], ["; - // Remove Ins - aDescr += aRemoveInsDescr + "], "; - // Limit - aDescr += TCollection_AsciiString(theLimit) + ", "; - // Remove Webs - if (theRemoveWebs) aDescr += "1, ["; - else aDescr += "0, ["; + GEOM::TPythonDump pd (aFunction); + pd << aPartition << " = geompy.MakePartition(["; + // Shapes, Tools + pd << aShapesDescr.ToCString() << "], [" << aToolsDescr.ToCString() << "], ["; + // Keep Ins, Remove Ins + pd << aKeepInsDescr.ToCString() << "], [" << aRemoveInsDescr.ToCString() << "], "; + // Limit, Remove Webs + pd << theLimit << ", " << (int)theRemoveWebs << ", ["; // Materials if (theMaterials->Length() > 0) { int i = theMaterials->Lower(); - aDescr += TCollection_AsciiString(theMaterials->Value(i)); + pd << theMaterials->Value(i); i++; for (; i <= theMaterials->Upper(); i++) { - aDescr += ", "; - aDescr += TCollection_AsciiString(theMaterials->Value(i)); + pd << ", " << theMaterials->Value(i); } } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aPartition; @@ -335,16 +322,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aPart->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeHalfPartition("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePlane->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aPart << " = geompy.MakeHalfPartition(" + << theShape << ", " << thePlane << ")"; SetErrorCode(OK); return aPart; diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index afc3f812d..d694ff537 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -3,6 +3,8 @@ using namespace std; #include "GEOMImpl_ICurvesOperations.hxx" #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" + #include "GEOMImpl_Types.hxx" #include "GEOMImpl_PolylineDriver.hxx" @@ -97,22 +99,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (listGetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakePolyline(["; + GEOM::TPythonDump pd (aFunction); + pd << aPolyline << " = geompy.MakePolyline(["; + it = thePoints.begin(); - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; - it++; - for (; it != thePoints.end(); it++) { - aDescr += ", "; - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; + pd << (*it++); + while (it != thePoints.end()) { + pd << ", " << (*it++); } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aPolyline; @@ -168,18 +163,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_ } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aCircle->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeCircleThreePnt("; - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; SetErrorCode(OK); return aCircle; @@ -233,17 +218,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aCircle->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeCircle("; - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVec->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theR)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle(" + << thePnt << ", " << theVec << ", " << theR << ")"; SetErrorCode(OK); return aCircle; @@ -299,18 +275,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(anEll->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeEllipse("; - TDF_Tool::Entry(thePnt->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVec->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theRMajor)+", "); - aDescr += (TCollection_AsciiString(theRMinor)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse(" + << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")"; SetErrorCode(OK); return anEll; @@ -366,18 +332,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(anArc->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeArc("; - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; SetErrorCode(OK); return anArc; @@ -433,22 +389,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aSpline->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeBezier(["; + GEOM::TPythonDump pd (aFunction); + pd << aSpline << " = geompy.MakeBezier(["; + it = thePoints.begin(); - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; - it++; - for (; it != thePoints.end(); it++) { - aDescr += ", "; - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; + pd << (*it++); + while (it != thePoints.end()) { + pd << ", " << (*it++); } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aSpline; @@ -504,22 +453,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aSpline->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeInterpol(["; + GEOM::TPythonDump pd (aFunction); + pd << aSpline << " = geompy.MakeInterpol(["; + it = thePoints.begin(); - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; - it++; - for (; it != thePoints.end(); it++) { - aDescr += ", "; - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; + pd << (*it++); + while (it != thePoints.end()) { + pd << ", " << (*it++); } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aSpline; @@ -573,23 +515,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aSketcher->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeSketcher( \""; - aDescr += aCommand+"\", ["; + GEOM::TPythonDump pd (aFunction); + pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand << "\", ["; it = theWorkingPlane.begin(); - aDescr += TCollection_AsciiString(*it); - it++; - for (; it != theWorkingPlane.end(); it++) { - aDescr += ", "; - aDescr += TCollection_AsciiString(*it); + pd << (*it++); + while (it != theWorkingPlane.end()) { + pd << ", " << (*it++); } - - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aSketcher; diff --git a/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx index e271df9c5..ca99d1af1 100644 --- a/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx @@ -6,6 +6,7 @@ using namespace std; #include "GEOM_Function.hxx" #include "GEOM_ISubShape.hxx" +#include "GEOM_PythonDump.hxx" #include "utilities.h" #include "OpUtil.hxx" @@ -54,14 +55,15 @@ GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations() * CreateGroup */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup(Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType) +Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup + (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType) { SetErrorCode(KO); Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); anArray->SetValue(1, -1); - //Add a new Fillet object + //Add a new Fillet object Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, anArray); //Set a GROUP type @@ -70,17 +72,14 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup(Handle(GEOM_Object) t //Set a sub shape type TDF_Label aFreeLabel = aGroup->GetFreeLabel(); TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType); - - //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aGroup->GetEntry(), anEntry); - aDescr = anEntry + " = geompy.CreateGroup("; - TDF_Tool::Entry(theMainShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString((int)theShapeType)+")"); + //Make a Python command Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); - aFunction->SetDescription(aDescr); + //TCollection_AsciiString anOldDescr = aFunction->GetDescription(); + + //GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" << aGroup + GEOM::TPythonDump(aFunction) << aGroup + << " = geompy.CreateGroup(" << theMainShape << ", " << (int)theShapeType << ")"; SetErrorCode(OK); return aGroup; @@ -120,13 +119,10 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS } //Make a Python command - TCollection_AsciiString anEntry, aDescr("geompy.AddObject( "); - TDF_Tool::Entry(theGroup->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theSubShapeID)+" )"); + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - aDescr = aFunction->GetDescription() + "\n\t" + aDescr; - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" + << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")"; SetErrorCode(OK); return; @@ -137,7 +133,7 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS * RemoveObject */ //============================================================================= -void GEOMImpl_IGroupOperations::RemoveObject(Handle(GEOM_Object) theGroup, int theSubShapeID) +void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int theSubShapeID) { SetErrorCode(KO); if(theGroup.IsNull()) return; @@ -189,12 +185,10 @@ void GEOMImpl_IGroupOperations::RemoveObject(Handle(GEOM_Object) theGroup, int t } //Make a Python command - TCollection_AsciiString anEntry, aDescr("geompy.RemoveObject( "); - TDF_Tool::Entry(theGroup->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theSubShapeID)+" )"); + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" + << "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")"; SetErrorCode(OK); return; @@ -330,18 +324,17 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup, } aSSI.SetIndices(aNewSeq); + } - //Make a Python command - TCollection_AsciiString anEntry, aDescr("geompy.UnionList( "); - TDF_Tool::Entry(theGroup->GetEntry(), anEntry); - aDescr += (anEntry+", [ "); - for (i = 1; i <= aLen; i++) { - Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); - TDF_Tool::Entry(anObj_i->GetEntry(), anEntry); - aDescr += anEntry + (char*)(( i < aLen ) ? ", " : " ])"); - } - - aFunction->SetDescription(aDescr); + //Make a Python command + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); + + GEOM::TPythonDump pd (aFunction); + pd << anOldDescr.ToCString() << "\n\t" << "geompy.UnionList(" << theGroup << ", ["; + + for (i = 1; i <= aLen; i++) { + Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); + pd << anObj_i << (( i < aLen ) ? ", " : "])"); } SetErrorCode(OK); @@ -481,19 +474,17 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup, } aSSI.SetIndices(aNewSeq); + } + //Make a Python command + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - //Make a Python command - TCollection_AsciiString anEntry, aDescr("geompy.DifferenceList( "); - TDF_Tool::Entry(theGroup->GetEntry(), anEntry); - aDescr += (anEntry+", [ "); - for (i = 1; i <= aLen; i++) { - Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); - TDF_Tool::Entry(anObj_i->GetEntry(), anEntry); - aDescr += anEntry + (char*)(( i < aLen ) ? ", " : " ])");; - } + GEOM::TPythonDump pd (aFunction); + pd << anOldDescr.ToCString() << "\n\t" << "geompy.DifferenceList(" << theGroup << ", ["; - aFunction->SetDescription(aDescr); + for (i = 1; i <= aLen; i++) { + Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i)); + pd << anObj_i << (( i < aLen ) ? ", " : "])"); } SetErrorCode(OK); @@ -521,33 +512,28 @@ TopAbs_ShapeEnum GEOMImpl_IGroupOperations::GetType(Handle(GEOM_Object) theGroup * GetMainShape */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape(Handle(GEOM_Object) theGroup) +Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object) theGroup) { SetErrorCode(KO); if(theGroup.IsNull()) return NULL; - Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); - if(aFunction.IsNull()) return NULL; - - GEOM_ISubShape aSSI(aFunction); - aFunction = aSSI.GetMainShape(); - if(aFunction.IsNull()) return NULL; + Handle(GEOM_Function) aGroupFunction = theGroup->GetFunction(1); + if (aGroupFunction.IsNull()) return NULL; + + GEOM_ISubShape aSSI (aGroupFunction); + Handle(GEOM_Function) aMainShapeFunction = aSSI.GetMainShape(); + if (aMainShapeFunction.IsNull()) return NULL; - TDF_Label aLabel = aFunction->GetOwnerEntry(); + TDF_Label aLabel = aMainShapeFunction->GetOwnerEntry(); Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel); - if(aMainShape.IsNull()) return NULL; - + if (aMainShape.IsNull()) return NULL; + //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aMainShape->GetEntry(), aDescr); - aDescr += " = geompy.GetMainShape( "; - TDF_Tool::Entry(theGroup->GetEntry(), anEntry); - aDescr += (anEntry+" )"); - - aFunction = theGroup->GetFunction(1); - aDescr = aFunction->GetDescription() + "\n\t" + aDescr; - aFunction->SetDescription(aDescr); + TCollection_AsciiString anOldDescr = aGroupFunction->GetDescription(); + + GEOM::TPythonDump(aGroupFunction) << anOldDescr.ToCString() << "\n\t" + << aMainShape << " = geompy.GetMainShape(" << theGroup << ")"; SetErrorCode(OK); return aMainShape; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 1619695fc..a87816fb3 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -2,6 +2,8 @@ using namespace std; #include "GEOMImpl_IHealingOperations.hxx" +#include "GEOM_PythonDump.hxx" + #include "GEOMImpl_HealingDriver.hxx" #include "GEOMImpl_Types.hxx" #include "GEOMImpl_IHealing.hxx" @@ -124,35 +126,31 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Objec return NULL; } - //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); - aDescr += " = geompy.ProcessShape( "; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", [ "); + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", ["; + // list of operators int i = theOperators->Lower(), nb = theOperators->Upper(); for ( ; i <= nb; i++) { - aDescr += "\""; - aDescr += theOperators->Value( i ); - aDescr += "\""; - aDescr += (char*)(( i < nb ) ? ", " : " ], [ "); + pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString() + << (( i < nb ) ? "\", " : "\""); } + pd << "], ["; // list of parameters i = theParams->Lower(); nb = theParams->Upper(); for ( ; i <= nb; i++) { - aDescr += "\""; - aDescr += TCollection_AsciiString(theParams->Value( i )); - aDescr += "\""; - aDescr += (char*)(( i < nb ) ? ", " : " ], [ "); + pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString() + << (( i < nb ) ? "\", " : "\""); } + pd << "], ["; // list of values i = theValues->Lower(); nb = theValues->Upper(); - for ( ; i <= nb; i++) - aDescr += TCollection_AsciiString(theValues->Value( i )) - + (char*)(( i < nb ) ? ", " : " ])"); - - aFunction->SetDescription(aDescr); + for ( ; i <= nb; i++) { + pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString() + << (( i < nb ) ? "\", " : "\""); + } + pd << "])"; SetErrorCode(OK); return aNewObject; @@ -291,8 +289,8 @@ bool GEOMImpl_IHealingOperations::GetParameters (const string theOperation, * SuppressFaces */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces (Handle(GEOM_Object) theObject, - const Handle(TColStd_HArray1OfInteger)& theFaces) +Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces + (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces) { // set error code, check parameters SetErrorCode(KO); @@ -336,19 +334,13 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces (Handle(GEOM_Obje } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); - aDescr += " = geompy.SuppressFaces( "; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", [ "); + GEOM::TPythonDump pd (aFunction); + pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", ["; + // list of face ids int i = theFaces->Lower(), nb = theFaces->Upper(); for ( ; i <= nb; i++) - aDescr += - TCollection_AsciiString(theFaces->Value( i )) - + (char*)(( i < nb ) ? ", " : " ])"); - - aFunction->SetDescription(aDescr); + pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])"); SetErrorCode(OK); return aNewObject; @@ -360,9 +352,10 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces (Handle(GEOM_Obje * CloseContour */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour (Handle(GEOM_Object) theObject, - const Handle(TColStd_HArray1OfInteger)& theWires, - bool isCommonVertex) +Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour + (Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theWires, + bool isCommonVertex) { // set error code, check parameters SetErrorCode(KO); @@ -407,19 +400,15 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour (Handle(GEOM_Objec } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); - aDescr += " = geompy.CloseContour( "; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", [ "); + GEOM::TPythonDump pd (aFunction); + pd << aNewObject << " = geompy.CloseContour(" << theObject << ", ["; + // list of wire ids int i = theWires->Lower(), nb = theWires->Upper(); for ( ; i <= nb; i++) - aDescr += TCollection_AsciiString(theWires->Value( i )) - + (char*)(( i < nb ) ? ", " : " ], "); - aDescr += (char*)( isCommonVertex ? "1 )" : "0 )" ); + pd << theWires->Value( i ) << (( i < nb ) ? ", " : "], "); - aFunction->SetDescription(aDescr); + pd << (int)isCommonVertex << ")"; SetErrorCode(OK); return aNewObject; @@ -430,8 +419,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour (Handle(GEOM_Objec * RemoveIntWires */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires (Handle(GEOM_Object) theObject, - const Handle(TColStd_HArray1OfInteger)& theWires) +Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires + (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires) { // set error code, check parameters SetErrorCode(KO); @@ -475,18 +464,17 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires (Handle(GEOM_Obj } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); - aDescr += " = geompy.SuppressInternalWires( "; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", [ "); - // list of wire ids - int i = theWires->Lower(), nb = theWires->Upper(); - for ( ; i <= nb; i++) - aDescr += TCollection_AsciiString(theWires->Value( i )) - + (char*)(( i < nb ) ? ", " : " ])"); + GEOM::TPythonDump pd (aFunction); + pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", ["; - aFunction->SetDescription(aDescr); + // list of wire ids + if (!theWires.IsNull()) { + int i = theWires->Lower(), nb = theWires->Upper(); + for ( ; i <= nb; i++) + pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])"); + } else { + pd << "])"; + } SetErrorCode(OK); return aNewObject; @@ -542,18 +530,13 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); - aDescr += " = geompy.SuppressHoles( "; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", [ "); + GEOM::TPythonDump pd (aFunction); + pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", ["; + // list of wire ids int i = theWires->Lower(), nb = theWires->Upper(); for ( ; i <= nb; i++) - aDescr += TCollection_AsciiString(theWires->Value( i )) - + (char*)(( i < nb ) ? ", " : " ])"); - - aFunction->SetDescription(aDescr); + pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])"); SetErrorCode(OK); return aNewObject; @@ -609,13 +592,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); - aDescr += " = geompy.Sew( "; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += anEntry+", " + theTolerance + " )"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew(" + << theObject << ", " << theTolerance << ")"; SetErrorCode(OK); return aNewObject; @@ -675,12 +653,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); - aDescr += " = geompy.DivideEdge( "; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += anEntry + ", " + theIndex + ", " + theValue + ", "; - aDescr += (char*)( isByParameter ? "1 )" : "0 )" ); + GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject + << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")"; SetErrorCode(OK); return aNewObject; @@ -731,6 +705,35 @@ bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject theOpen->Append(anObj); } + //Make a Python command + GEOM::TPythonDump pd (aFunction); + + Standard_Integer i, aLen = theClosed->Length(); + if (aLen > 0) { + pd << "(isDone, ["; + for (i = 1; i <= aLen; i++) { + Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i)); + pd << anObj_i << ((i < aLen) ? ", " : ""); + } + pd << "], "; + } else { + pd << "(isDone, empty_list, "; + } + + aLen = theOpen->Length(); + if (aLen > 0) { + pd << "["; + for (i = 1; i <= aLen; i++) { + Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i)); + pd << anObj_i << ((i < aLen) ? ", " : ""); + } + pd << "]"; + } else { + pd << "empty_list"; + } + + pd << ") = geompy.GetFreeBoundary(" << theObject << ")"; + SetErrorCode(OK); return true; } diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx index 0def67b5a..bbf4e9980 100644 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx @@ -12,6 +12,7 @@ using namespace std; #include #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" #include "GEOMImpl_CopyDriver.hxx" #include "GEOMImpl_ExportDriver.hxx" @@ -90,13 +91,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) the } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeCopy("); - TDF_Tool::Entry(theOriginal->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeCopy(" << theOriginal << ")"; SetErrorCode(OK); return aCopy; @@ -154,14 +149,8 @@ void GEOMImpl_IInsertOperations::Export } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - aDescr = "geompy.Export("; - TDF_Tool::Entry(theOriginal->GetEntry(), anEntry); - aDescr += (anEntry + ", \""); - aDescr += (TCollection_AsciiString(aFileName) + "\", \""); - aDescr += (TCollection_AsciiString(aFormatName) + "\")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal + << ", \"" << theFileName << "\", \"" << theFormatName << "\")"; SetErrorCode(OK); } @@ -216,13 +205,8 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(result->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.Import(\""); - aDescr += (TCollection_AsciiString(aFileName) + "\", \""); - aDescr += (TCollection_AsciiString(aFormatName) + "\")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\"" + << theFileName << "\", \"" << theFormatName << "\")"; SetErrorCode(OK); return result; diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx index 1350771a6..031ab0eaf 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -3,6 +3,8 @@ using namespace std; #include "GEOMImpl_ILocalOperations.hxx" #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" + #include "GEOMImpl_Types.hxx" #include "GEOMImpl_FilletDriver.hxx" @@ -94,14 +96,8 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aFillet->GetEntry(), anEntry); - aDescr = anEntry + " = geompy.MakeFilletAll("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theR)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll(" + << theShape << ", " << theR << ")"; SetErrorCode(OK); return aFillet; @@ -158,22 +154,16 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aFillet->GetEntry(), anEntry); - aDescr = anEntry + " = geompy.MakeFillet("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theR)+", geompy.ShapeType[\"EDGE\"], ["); + GEOM::TPythonDump pd (aFunction); + pd << aFillet << " = geompy.MakeFillet(" << theShape + << ", " << theR << ", geompy.ShapeType[\"EDGE\"], ["; + it = theEdges.begin(); - aDescr += TCollection_AsciiString(*it); - it++; - for (; it != theEdges.end(); it++) { - aDescr += ", "; - aDescr += TCollection_AsciiString(*it); + pd << (*it++); + while (it != theEdges.end()) { + pd << ", " << (*it++); } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aFillet; @@ -230,22 +220,16 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aFillet->GetEntry(), anEntry); - aDescr = anEntry + " = geompy.MakeFillet("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theR)+", geompy.ShapeType[\"FACE\"], ["); + GEOM::TPythonDump pd (aFunction); + pd << aFillet << " = geompy.MakeFillet(" << theShape + << ", " << theR << ", geompy.ShapeType[\"FACE\"], ["; + it = theFaces.begin(); - aDescr += TCollection_AsciiString(*it); - it++; - for (; it != theFaces.end(); it++) { - aDescr += ", "; - aDescr += TCollection_AsciiString(*it); + pd << (*it++); + while (it != theFaces.end()) { + pd << ", " << (*it++); } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aFillet; @@ -293,15 +277,8 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Objec } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeChamferAll("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theD)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll(" + << theShape << ", " << theD << ")"; SetErrorCode(OK); return aChamfer; @@ -354,18 +331,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeChamferEdge("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theD1)+", "); - aDescr += (TCollection_AsciiString(theD2)+", "); - aDescr += (TCollection_AsciiString(theFace1)+", "); - aDescr += (TCollection_AsciiString(theFace2)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aChamfer + << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1 + << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")"; SetErrorCode(OK); return aChamfer; @@ -424,24 +392,16 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeChamferFaces("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theD1)+", "); - aDescr += (TCollection_AsciiString(theD2)+", ["); + GEOM::TPythonDump pd (aFunction); + pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape + << ", " << theD1 << ", " << theD2 << ", ["; + it = theFaces.begin(); - aDescr += TCollection_AsciiString(*it); - it++; - for (; it != theFaces.end(); it++) { - aDescr += ", "; - aDescr += TCollection_AsciiString(*it); + pd << (*it++); + while (it != theFaces.end()) { + pd << ", " << (*it++); } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aChamfer; @@ -493,17 +453,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.Archimede("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theWeight)+", "); - aDescr += (TCollection_AsciiString(theWaterDensity)+", "); - aDescr += (TCollection_AsciiString(theMeshingDeflection)+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aChamfer + << " = geompy.Archimede(" << theShape << ", " << theWeight << ", " + << theWaterDensity << ", " << theMeshingDeflection << ")"; SetErrorCode(OK); return aChamfer; diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 064fb0b72..e602396dc 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -7,6 +7,7 @@ using namespace std; #include "GEOMImpl_IMeasure.hxx" #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" #include "utilities.h" #include "OpUtil.hxx" @@ -110,13 +111,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCDG->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.MakeCDG("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCDG << " = geompy.MakeCDG(" << theShape << ")"; SetErrorCode(OK); return aCDG; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index d89912123..c1a25b380 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -16,6 +16,7 @@ using namespace std; #include "GEOMImpl_Block6Explorer.hxx" #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" #include "GEOMAlgo_FinderShapeOn.hxx" @@ -139,15 +140,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdge } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(anEdge->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeEdge("); - TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << anEdge << " = geompy.MakeEdge(" + << thePnt1 << ", " << thePnt2 << ")"; SetErrorCode(OK); return anEdge; @@ -210,18 +204,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aFace->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeFace("; - TDF_Tool::Entry(theWire->GetEntry(), anEntry); - aDescr += anEntry; - if (isPlanarWanted) - aDescr += ", 1)"; - else - aDescr += ", 0)"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFace(" + << theWire << ", " << (int)isPlanarWanted << ")"; SetErrorCode(OK); return aFace; @@ -281,28 +265,18 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aShape->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.MakeFaceWires(["); + GEOM::TPythonDump pd (aFunction); + pd << aShape << " = geompy.MakeFaceWires(["; + // Shapes it = theShapes.begin(); if (it != theShapes.end()) { - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; - it++; - for (; it != theShapes.end(); it++) { - aDescr += ", "; - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; + pd << (*it++); + while (it != theShapes.end()) { + pd << ", " << (*it++); } } - if (isPlanarWanted) - aDescr += "], 1)"; - - else - aDescr += "], 0)"; - - aFunction->SetDescription(aDescr); + pd << "], " << (int)isPlanarWanted << ")"; SetErrorCode(OK); return aShape; @@ -374,14 +348,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSolidShell (Handle(GEOM_Obje } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aSolid->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeSolid("; - TDF_Tool::Entry(theShell->GetEntry(), anEntry); - aDescr += (anEntry+")"); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aSolid + << " = geompy.MakeSolid(" << theShell << ")"; SetErrorCode(OK); return aSolid; @@ -452,25 +420,18 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape } //Make a Python command - TCollection_AsciiString anEntry, aDescr(""); - TDF_Tool::Entry(aShape->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy."); - aDescr += (theMethodName + "(["); + GEOM::TPythonDump pd (aFunction); + pd << aShape << " = geompy." << theMethodName.ToCString() << "(["; + // Shapes it = theShapes.begin(); if (it != theShapes.end()) { - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; - it++; - for (; it != theShapes.end(); it++) { - aDescr += ", "; - TDF_Tool::Entry((*it)->GetEntry(), anEntry); - aDescr += anEntry; + pd << (*it++); + while (it != theShapes.end()) { + pd << ", " << (*it++); } } - aDescr += "])"; - - aFunction->SetDescription(aDescr); + pd << "])"; SetErrorCode(OK); return aShape; @@ -528,15 +489,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aGlued->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.MakeGlueFaces("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ", "; - aDescr += TCollection_AsciiString(theTolerance) + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueFaces(" + << theShape << ", " << theTolerance << ")"; // to provide warning if (!isWarning) SetErrorCode(OK); @@ -553,9 +507,6 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode const Standard_Integer theShapeType, const Standard_Boolean isSorted) { -// OSD_Timer timer1, timer2, timer3, timer4; -// timer1.Start(); - SetErrorCode(KO); if (theShape.IsNull()) return NULL; @@ -593,21 +544,15 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode return aSeq; } -// timer1.Stop(); -// timer2.Start(); - if (isSorted) SortShapes(listShape); -// timer2.Stop(); -// timer3.Start(); - TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aShape, anIndices); Handle(TColStd_HArray1OfInteger) anArray; TopTools_ListIteratorOfListOfShape itSub (listShape); - TCollection_AsciiString anAsciiList = "[", anEntry; + TCollection_AsciiString anAsciiList, anEntry; for (int index = 1; itSub.More(); itSub.Next(), ++index) { TopoDS_Shape aValue = itSub.Value(); anArray = new TColStd_HArray1OfInteger(1,1); @@ -615,50 +560,24 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode anObj = GetEngine()->AddSubShape(theShape, anArray); aSeq->Append(anObj); + // for python command TDF_Tool::Entry(anObj->GetEntry(), anEntry); anAsciiList += anEntry; anAsciiList += ","; } -// timer3.Stop(); -// timer4.Start(); - + //Make a Python command anAsciiList.Trunc(anAsciiList.Length() - 1); - anAsciiList += "]"; - anAsciiList = TCollection_AsciiString("\n\t") + anAsciiList; - - //The explode doesn't change object so no new function is requiered. aFunction = theShape->GetLastFunction(); - - //Make a Python command - TCollection_AsciiString aDescr(anAsciiList); - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - if (isSorted) - aDescr += " = geompy.SubShapeAllSorted( "; - else - aDescr += " = geompy.SubShapeAll( "; - aDescr += (anEntry + ", "); - aDescr += theShapeType; - aDescr += " )"; - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr = anOldDescr + aDescr; - aFunction->SetDescription(anOldDescr); - - SetErrorCode(OK); - -// timer4.Stop(); -// cout << "Explosure takes:" << endl; -// timer1.Show(); -// cout << "Sorting takes:" << endl; -// timer2.Show(); -// cout << "Sub-shapes addition takes:" << endl; -// timer3.Show(); -// cout << "Update Description takes:" << endl; -// timer4.Show(); + GEOM::TPythonDump pd (aFunction); + pd << anOldDescr.ToCString() << "\n\t[" << anAsciiList.ToCString(); + pd << "] = geompy.SubShapeAll" << (isSorted ? "Sorted(" : "("); + pd << theShape << ", " << theShapeType << ")"; + SetErrorCode(OK); return aSeq; } @@ -720,23 +639,14 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs aSeq->Append(anIndices.FindIndex(aValue)); } - //The explode doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); //Make a Python command - TCollection_AsciiString aDescr - ("\n\tlistSubShapeAllIDs = geompy.SubShapeAllIDs("); - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry + ","); - if (isSorted) - aDescr += (TCollection_AsciiString(theShapeType) + ", 1)"); - else - aDescr += (TCollection_AsciiString(theShapeType) + ", 0)"); - - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr = anOldDescr + aDescr; - aFunction->SetDescription(anOldDescr); + GEOM::TPythonDump pd (aFunction); + pd << anOldDescr.ToCString() << "\n\tlistSubShapeIDs = geompy.SubShapeAll"; + pd << (isSorted ? "SortedIDs(" : "IDs("); + pd << theShape << ", " << theShapeType << ")"; SetErrorCode(OK); return aSeq; @@ -763,20 +673,11 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSubShape return NULL; } - //The GetSubShape() doesn't change object so no new function is requiered. - Handle(GEOM_Function) aFunction = theMainShape->GetLastFunction(); + Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); //Make a Python command - TCollection_AsciiString aDescr ("\n\t"); - TCollection_AsciiString anEntry; - TDF_Tool::Entry(anObj->GetEntry(), anEntry); - aDescr += anEntry + " = geompy.GetSubShape("; - TDF_Tool::Entry(theMainShape->GetEntry(), anEntry); - aDescr += anEntry + ", [" + theID + "])"; - - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr = anOldDescr + aDescr; - aFunction->SetDescription(anOldDescr); + GEOM::TPythonDump(aFunction) << anObj << " = geompy.GetSubShape(" + << theMainShape << ", [" << theID << "])"; SetErrorCode(OK); return anObj; @@ -878,14 +779,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object) } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aReversed->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.ChangeOrientation("; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + ")"; - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aReversed + << " = geompy.ChangeOrientation(" << theShape << ")"; SetErrorCode(OK); return aReversed; @@ -931,16 +826,11 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetFreeFacesIDs //The explode doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); //Make a Python command - TCollection_AsciiString aDescr ("\n\tlistFreeFacesIDs = geompy.GetFreeFacesIDs("); - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += (anEntry + ")"); - - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr = anOldDescr + aDescr; - aFunction->SetDescription(anOldDescr); + GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() + << "\n\tlistFreeFacesIDs = geompy.GetFreeFacesIDs(" << theShape << ")"; SetErrorCode(OK); return aSeq; @@ -974,6 +864,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes Handle(GEOM_Object) anObj; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + TCollection_AsciiString anAsciiList, anEntry; TopTools_MapOfShape mapShape2; TopExp_Explorer exp (aShape2, TopAbs_ShapeEnum(theShapeType)); @@ -984,6 +875,11 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes anArray->SetValue(1, anIndices.FindIndex(aSS)); anObj = GetEngine()->AddSubShape(theShape1, anArray); aSeq->Append(anObj); + + // for python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; } } @@ -992,27 +888,50 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes return aSeq; } - //The explode doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape1->GetLastFunction(); - //Make a Python command - TCollection_AsciiString aDescr - ("\n\tlistSharedShapes = geompy.GetSharedShapes("); - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theShape1->GetEntry(), anEntry); - aDescr += (anEntry + ","); - TDF_Tool::Entry(theShape2->GetEntry(), anEntry); - aDescr += (anEntry + ","); - aDescr += TCollection_AsciiString(theShapeType) + ")"; + anAsciiList.Trunc(anAsciiList.Length() - 1); - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr = anOldDescr + aDescr; - aFunction->SetDescription(anOldDescr); + Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); + + GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() + << "] = geompy.GetSharedShapes(" << theShape1 << ", " + << theShape2 << ", " << theShapeType << ")"; SetErrorCode(OK); return aSeq; } +//============================================================================= +/*! + * + */ +//============================================================================= +static GEOM::TPythonDump& operator<< (GEOM::TPythonDump& theDump, + const GEOMAlgo_State theState) +{ + switch (theState) { + case GEOMAlgo_ST_IN: + theDump << "geompy.GEOM.ST_IN"; + break; + case GEOMAlgo_ST_OUT: + theDump << "geompy.GEOM.ST_OUT"; + break; + case GEOMAlgo_ST_ON: + theDump << "geompy.GEOM.ST_ON"; + break; + case GEOMAlgo_ST_ONIN: + theDump << "geompy.GEOM.ST_ONIN"; + break; + case GEOMAlgo_ST_ONOUT: + theDump << "geompy.GEOM.ST_ONOUT"; + break; + default: + theDump << "geompy.GEOM.ST_UNKNOWN"; + break; + } + return theDump; +} + //============================================================================= /*! * GetShapesOnPlane @@ -1102,6 +1021,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan Handle(GEOM_Object) anObj; Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + TCollection_AsciiString anAsciiList, anEntry; TopTools_ListIteratorOfListOfShape itSub (listSS); for (int index = 1; itSub.More(); itSub.Next(), ++index) { @@ -1110,23 +1030,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan anArray->SetValue(1, id); anObj = GetEngine()->AddSubShape(theShape, anArray); aSeq->Append(anObj); + + // for python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; } - // The GetShapesOnPlane() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); - // Make a Python command - TCollection_AsciiString anEntry, aDescr - ("\n\tlistShapesOnPlane = geompy.GetShapesOnPlane("); - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + TCollection_AsciiString(theShapeType) + ","; - TDF_Tool::Entry(theAx1->GetEntry(), anEntry); - aDescr += anEntry + ","; - aDescr += TCollection_AsciiString(theState) + ")"; + anAsciiList.Trunc(anAsciiList.Length() - 1); - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr += aDescr; - aFunction->SetDescription(anOldDescr); + Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); + + GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() + << "] = geompy.GetShapesOnPlane(" << theShape << ", " + << theShapeType << ", " << theAx1 << ", " << theState << ")"; SetErrorCode(OK); return aSeq; @@ -1227,6 +1145,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCyli Handle(GEOM_Object) anObj; Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + TCollection_AsciiString anAsciiList, anEntry; TopTools_ListIteratorOfListOfShape itSub (listSS); for (int index = 1; itSub.More(); itSub.Next(), ++index) { @@ -1235,24 +1154,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCyli anArray->SetValue(1, id); anObj = GetEngine()->AddSubShape(theShape, anArray); aSeq->Append(anObj); + + // for python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; } - // The GetShapesOnCylinder() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); - // Make a Python command - TCollection_AsciiString anEntry, aDescr - ("\n\tlistShapesOnCylinder = geompy.GetShapesOnCylinder("); - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + TCollection_AsciiString(theShapeType) + ","; - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += anEntry + ","; - aDescr += TCollection_AsciiString(theRadius) + ","; - aDescr += TCollection_AsciiString(theState) + ")"; + anAsciiList.Trunc(anAsciiList.Length() - 1); - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr += aDescr; - aFunction->SetDescription(anOldDescr); + Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); + + GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() + << "] = geompy.GetShapesOnCylinder(" << theShape << ", " << theShapeType + << ", " << theAxis << ", " << theRadius << ", " << theState << ")"; SetErrorCode(OK); return aSeq; @@ -1338,6 +1254,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnSphe Handle(GEOM_Object) anObj; Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + TCollection_AsciiString anAsciiList, anEntry; TopTools_ListIteratorOfListOfShape itSub (listSS); for (int index = 1; itSub.More(); itSub.Next(), ++index) { @@ -1346,24 +1263,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnSphe anArray->SetValue(1, id); anObj = GetEngine()->AddSubShape(theShape, anArray); aSeq->Append(anObj); + + // for python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; } - // The GetShapesOnSphere() doesn't change object so no new function is required. - Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); - // Make a Python command - TCollection_AsciiString anEntry, aDescr - ("\n\tlistShapesOnSphere = geompy.GetShapesOnSphere("); - TDF_Tool::Entry(theShape->GetEntry(), anEntry); - aDescr += anEntry + TCollection_AsciiString(theShapeType) + ","; - TDF_Tool::Entry(theCenter->GetEntry(), anEntry); - aDescr += anEntry + ","; - aDescr += TCollection_AsciiString(theRadius) + ","; - aDescr += TCollection_AsciiString(theState) + ")"; + anAsciiList.Trunc(anAsciiList.Length() - 1); - TCollection_AsciiString anOldDescr = aFunction->GetDescription(); - anOldDescr += aDescr; - aFunction->SetDescription(anOldDescr); + Handle(GEOM_Function) aFunction = anObj->GetLastFunction(); + + GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString() + << "] = geompy.GetShapesOnSphere(" << theShape << ", " << theShapeType + << ", " << theCenter << ", " << theRadius << ", " << theState << ")"; SetErrorCode(OK); return aSeq; @@ -1481,17 +1395,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aResult->GetEntry(), anEntry); - aDescr += anEntry; - aDescr += " = geompy.GetInPlace("; - TDF_Tool::Entry(theShapeWhere->GetEntry(), anEntry); - aDescr += anEntry + ","; - TDF_Tool::Entry(theShapeWhat->GetEntry(), anEntry); - aDescr += anEntry + ")"; - Handle(GEOM_Function) aFunction = aResult->GetFunction(1); - aFunction->SetDescription(aDescr); + + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetInPlace(" + << theShapeWhere << ", " << theShapeWhat << ")"; SetErrorCode(OK); return aResult; diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index b288a54c4..5b287e669 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -12,6 +12,7 @@ using namespace std; #include #include "GEOM_Function.hxx" +#include "GEOM_PythonDump.hxx" #include "GEOMImpl_TranslateDriver.hxx" #include "GEOMImpl_MirrorDriver.hxx" @@ -101,15 +102,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.TrsfOp.TranslateTwoPoints("); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); - aDescr += (anEntry+")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints(" + << theObject << ", " << thePoint1 << ", " << thePoint2 << ")"; SetErrorCode(OK); return theObject; @@ -158,14 +152,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.TrsfOp.TranslateDXDYDZ("); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theX)+", "); - aDescr += (TCollection_AsciiString(theY)+", "); - aDescr += (TCollection_AsciiString(theZ)+")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateDXDYDZ(" + << theObject << ", " << theX << ", " << theY << ", " << theZ << ")"; SetErrorCode(OK); return theObject; @@ -217,16 +205,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeTranslationTwoPoints("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); - aDescr += (anEntry+")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints(" + << theObject << ", " << thePoint1 << ", " << thePoint2 << ")"; SetErrorCode(OK); return aCopy; @@ -277,15 +257,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeTranslation("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theX)+", "); - aDescr += (TCollection_AsciiString(theY)+", "); - aDescr += (TCollection_AsciiString(theZ)+")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation(" + << theObject << ", " << theX << ", " << theY << ", " << theZ << ")"; SetErrorCode(OK); return aCopy; @@ -336,13 +309,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.TrsfOp.TranslateVector("); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVector->GetEntry(), anEntry); - aDescr += (anEntry+") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector(" + << theObject << ", " << theVector << ")"; SetErrorCode(OK); return theObject; @@ -392,14 +360,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeTranslationVector("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVector->GetEntry(), anEntry); - aDescr += (anEntry+")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector(" + << theObject << ", " << theVector << ")"; SetErrorCode(OK); return aCopy; @@ -451,17 +413,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeMultiTranslation1D("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVector->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theStep)+", "); - aDescr += (TCollection_AsciiString(theNbTimes)+") "); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D(" + << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")"; SetErrorCode(OK); return aCopy; @@ -520,21 +473,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Obje } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeMultiTranslation2D("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theVector->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theStep1)+", "); - aDescr += (TCollection_AsciiString(theNbTimes2)+", "); - TDF_Tool::Entry(theVector2->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theStep2)+", "); - aDescr += (TCollection_AsciiString(theNbTimes2)+") "); - - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D(" + << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1 + << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")"; SetErrorCode(OK); return aCopy; @@ -585,13 +526,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.TrsfOp.MirrorPlane("); - aDescr += (anEntry + ", "); - TDF_Tool::Entry(thePlane->GetEntry(), anEntry); - aDescr += (anEntry + ") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane(" + << theObject << ", " << thePlane << ")"; SetErrorCode(OK); return theObject; @@ -640,14 +576,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.MakeMirrorByPlane("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry + ", "); - TDF_Tool::Entry(thePlane->GetEntry(), anEntry); - aDescr += (anEntry + ")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane(" + << theObject << ", " << thePlane << ")"; SetErrorCode(OK); return aCopy; @@ -697,13 +627,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.TrsfOp.MirrorPoint("); - aDescr += (anEntry + ", "); - TDF_Tool::Entry(thePoint->GetEntry(), anEntry); - aDescr += (anEntry + ") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint(" + << theObject << ", " << thePoint << ")"; SetErrorCode(OK); return NULL; @@ -752,14 +677,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.MakeMirrorByPoint("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry + ", "); - TDF_Tool::Entry(thePoint->GetEntry(), anEntry); - aDescr += (anEntry + ")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint(" + << theObject << ", " << thePoint << ")"; SetErrorCode(OK); return aCopy; @@ -809,13 +728,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.TrsfOp.MirrorAxis("); - aDescr += (anEntry + ", "); - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += (anEntry + ") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis(" + << theObject << ", " << theAxis << ")"; SetErrorCode(OK); return NULL; @@ -864,14 +778,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry + " = geompy.MakeMirrorByAxis("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry + ", "); - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += (anEntry + ")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis(" + << theObject << ", " << theAxis << ")"; SetErrorCode(OK); return aCopy; @@ -919,12 +827,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.TrsfOp.OffsetShape("); - aDescr += (anEntry+", "); - aDescr += TCollection_AsciiString(theOffset)+")"; - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape(" + << theObject << ", " << theOffset << ")"; SetErrorCode(OK); return theObject; @@ -974,13 +878,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeOffset("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += TCollection_AsciiString(theOffset)+")"; - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset(" + << theObject << ", " << theOffset << ")"; SetErrorCode(OK); return aCopy; @@ -1032,14 +931,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.TrsfOp.ScaleShape("); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += TCollection_AsciiString(theFactor)+")"; - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape(" + << theObject << ", " << thePoint << ", " << theFactor << ")"; SetErrorCode(OK); return theObject; @@ -1090,15 +983,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakeScaleTransform("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(thePoint->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += TCollection_AsciiString(theFactor)+")"; - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform(" + << theObject << ", " << thePoint << ", " << theFactor << ")"; SetErrorCode(OK); return aCopy; @@ -1150,15 +1036,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.TrsfOp.PositionShape("); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theStartLCS->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theEndLCS->GetEntry(), anEntry); - aDescr += (anEntry+") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape(" + << theObject << ", " << theStartLCS << ", " << theEndLCS << ")"; SetErrorCode(OK); return theObject; @@ -1209,16 +1088,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MakePosition("); - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theStartLCS->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theEndLCS->GetEntry(), anEntry); - aDescr += (anEntry+")"); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition(" + << theObject << ", " << theStartLCS << ", " << theEndLCS << ")"; SetErrorCode(OK); return aCopy; @@ -1270,14 +1141,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.TrsfOp.Rotate("); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theAngle)+") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject + << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; SetErrorCode(OK); return theObject; @@ -1326,15 +1191,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Objec } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(aCopy->GetEntry(), aDescr); - aDescr += " = geompy.MakeRotation("; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theAngle)+") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject + << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; SetErrorCode(OK); return aCopy; @@ -1385,14 +1243,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MultiRotate1D("); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theNbTimes)+") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D(" + << theObject << ", " << theAxis << ", " << theNbTimes << ")"; SetErrorCode(OK); return aCopy; @@ -1449,17 +1301,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) } //Make a Python command - TCollection_AsciiString anEntry, aDescr; - TDF_Tool::Entry(theObject->GetEntry(), anEntry); - aDescr += (anEntry+" = geompy.MultiRotate2D("); - aDescr += (anEntry+", "); - TDF_Tool::Entry(theAxis->GetEntry(), anEntry); - aDescr += (anEntry+", "); - aDescr += (TCollection_AsciiString(theAngle)+", "); - aDescr += (TCollection_AsciiString(theNbTimes1)+", "); - aDescr += (TCollection_AsciiString(theStep)+", "); - aDescr += (TCollection_AsciiString(theNbTimes2)+") "); - aFunction->SetDescription(aDescr); + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D(" + << theObject << ", " << theAxis << ", " << theAngle << ", " + << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")"; SetErrorCode(OK); return aCopy;