Dump Python: Enlarge precision of real and double values mapping

This commit is contained in:
jfa 2005-04-04 06:32:07 +00:00
parent 699a8a6deb
commit cc14acdac2
20 changed files with 760 additions and 1451 deletions

View File

@ -5,11 +5,10 @@
#include "GEOM_ISubShape.hxx" #include "GEOM_ISubShape.hxx"
#include "GEOM_SubShapeDriver.hxx" #include "GEOM_SubShapeDriver.hxx"
#include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx" #include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx"
#include "GEOM_PythonDump.hxx"
#include "utilities.h" #include "utilities.h"
#include <Interface_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
#include <TDF_Data.hxx> #include <TDF_Data.hxx>
#include <TDF_LabelSequence.hxx> #include <TDF_LabelSequence.hxx>
@ -24,12 +23,10 @@
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx> #include <TCollection_ExtendedString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx> #include <TColStd_SequenceOfAsciiString.hxx>
#include <TColStd_SequenceOfTransient.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TColStd_ListOfTransient.hxx>
#include <TColStd_MapOfTransient.hxx> #include <TColStd_MapOfTransient.hxx>
#include <TColStd_HSequenceOfInteger.hxx> #include <TColStd_HSequenceOfInteger.hxx>
#include <Interface_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx> #include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
#include <map> #include <map>
@ -211,26 +208,18 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
if(_objects.IsBound(anID)) _objects.UnBind(anID); if(_objects.IsBound(anID)) _objects.UnBind(anID);
_objects.Bind(anID, anObject); _objects.Bind(anID, anObject);
TCollection_AsciiString aDescr(""); GEOM::TPythonDump pd (aFunction);
if (isStandaloneOperation) { if (isStandaloneOperation) {
TCollection_AsciiString anEntry; pd << anObject << " = geompy.GetSubShape(" << theMainShape << ", [";
TDF_Tool::Entry(anObject->GetEntry(), anEntry); Standard_Integer i = theIndices->Lower(), up = theIndices->Upper();
aDescr += anEntry; for (; i <= up - 1; i++) {
aDescr += " = geom.AddSubShape("; pd << theIndices->Value(i) << ", ";
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))+", ");
} }
aDescr.Trunc(aDescr.Length()-1); pd << theIndices->Value(up) << "])";
aDescr += "])";
} }
else else
TCollection_AsciiString aDescr("None"); pd << "None";
aFunction->SetDescription(aDescr);
return anObject; return anObject;
} }
@ -364,7 +353,8 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
if(aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n"); 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 += "def RebuildData(theStudy):";
aScript += "\n\tgeompy.init_geom(theStudy)"; aScript += "\n\tgeompy.init_geom(theStudy)";
@ -526,6 +516,23 @@ const char* GEOM_Engine::GetDumpName (const char* theStudyEntry) const
return NULL; 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 // Internal functions

View File

@ -3,16 +3,14 @@
#define _GEOM_Engine_HXX_ #define _GEOM_Engine_HXX_
#include "GEOM_Application.hxx" #include "GEOM_Application.hxx"
#include "GEOM_Object.hxx"
#include "GEOM_DataMapOfAsciiStringTransient.hxx"
#include <Interface_DataMapOfIntegerTransient.hxx> #include <Interface_DataMapOfIntegerTransient.hxx>
#include <Resource_DataMapOfAsciiStringAsciiString.hxx> #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
#include <TDF_Label.hxx>
#include <TDocStd_Document.hxx> #include <TDocStd_Document.hxx>
#include "GEOM_Object.hxx"
#include <TColStd_HArray1OfInteger.hxx> #include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx> #include <TColStd_HSequenceOfAsciiString.hxx>
#include <TopAbs.hxx>
#include "GEOM_DataMapOfAsciiStringTransient.hxx"
class GEOM_Engine class GEOM_Engine
{ {
@ -71,6 +69,8 @@ class GEOM_Engine
const char* GetDumpName (const char* theStudyEntry) const; const char* GetDumpName (const char* theStudyEntry) const;
Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
protected: protected:
static void SetEngine(GEOM_Engine* theEngine); static void SetEngine(GEOM_Engine* theEngine);

View File

@ -218,10 +218,11 @@ TCollection_AsciiString GEOM_Function::GetDescription()
* SetDescription * SetDescription
*/ */
//============================================================================= //=============================================================================
void GEOM_Function::SetDescription(TCollection_AsciiString& theDescription) void GEOM_Function::SetDescription(const TCollection_AsciiString& theDescription)
{ {
TDF_Label aChild = _label.FindChild(DESCRIPTION_LABEL); 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));
} }
//============================================================================= //=============================================================================

View File

@ -165,7 +165,7 @@ public:
TCollection_AsciiString GetDescription(); TCollection_AsciiString GetDescription();
//Sets aPython description of the function //Sets aPython description of the function
void SetDescription(TCollection_AsciiString& theDescription); void SetDescription(const TCollection_AsciiString& theDescription);
//Access to arguments //Access to arguments

View File

@ -222,11 +222,13 @@ void GEOM_Object::SetAuxData(const char* theData)
//============================================================================= //=============================================================================
TCollection_AsciiString GEOM_Object::GetAuxData() TCollection_AsciiString GEOM_Object::GetAuxData()
{ {
Handle(TDataStd_Comment) aCommentAttr; TCollection_AsciiString aData;
if(!_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr)) return NULL;
TCollection_AsciiString aData(aCommentAttr->Get()); Handle(TDataStd_Comment) aCommentAttr;
return aData.ToCString(); if (_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr))
aData = aCommentAttr->Get();
return aData;
} }

View File

@ -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 <TDF_Tool.hxx>
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<<theArg;
return *this;
}
TPythonDump& TPythonDump::operator<< (int theArg)
{
myStream<<theArg;
return *this;
}
TPythonDump& TPythonDump::operator<< (double theArg)
{
myStream.precision(16);
myStream<<theArg;
return *this;
}
TPythonDump& TPythonDump::operator<< (float theArg)
{
myStream.precision(8);
myStream<<theArg;
return *this;
}
TPythonDump& TPythonDump::operator<< (const void* theArg)
{
myStream<<theArg;
return *this;
}
TPythonDump& TPythonDump::operator<< (const char* theArg)
{
myStream<<theArg;
return *this;
}
TPythonDump& TPythonDump::operator<< (const Handle(GEOM_Object)& theObject)
{
TCollection_AsciiString anEntry;
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
myStream << anEntry.ToCString();
return *this;
}
}

View File

@ -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 <SALOMEconfig.h>
#include "GEOM_Object.hxx"
#include "GEOM_Function.hxx"
#include <TCollection_AsciiString.hxx>
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

View File

@ -17,6 +17,7 @@ LIB_SRC = GEOM_Application.cxx \
GEOM_IOperations.cxx \ GEOM_IOperations.cxx \
GEOM_Solver.cxx \ GEOM_Solver.cxx \
GEOM_SubShapeDriver.cxx \ GEOM_SubShapeDriver.cxx \
GEOM_PythonDump.cxx \
GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx \ GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx \
GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx \ GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx \
GEOM_DataMapOfAsciiStringTransient_0.cxx GEOM_DataMapOfAsciiStringTransient_0.cxx
@ -39,6 +40,7 @@ EXPORT_HEADERS= GEOM_Application.hxx \
GEOM_IOperations.hxx \ GEOM_IOperations.hxx \
GEOM_ISubShape.hxx \ GEOM_ISubShape.hxx \
GEOM_Solver.hxx \ GEOM_Solver.hxx \
GEOM_PythonDump.hxx \
GEOM_DataMapOfAsciiStringTransient.hxx \ GEOM_DataMapOfAsciiStringTransient.hxx \
Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx

View File

@ -12,6 +12,8 @@ using namespace std;
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
#include "GEOMImpl_BoxDriver.hxx" #include "GEOMImpl_BoxDriver.hxx"
@ -99,15 +101,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, dou
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
TDF_Tool::Entry(aBox->GetEntry(), anEntry); << theDX << ", " << theDY << ", " << theDZ << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeBoxDXDYDZ(";
aDescr += (TCollection_AsciiString(theDX)+", ");
aDescr += (TCollection_AsciiString(theDY)+", ");
aDescr += (TCollection_AsciiString(theDZ)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aBox; return aBox;
@ -160,16 +155,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Objec
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
TDF_Tool::Entry(aBox->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeBoxTwoPnt(";
TDF_Tool::Entry(thePnt1->GetEntry(), anEntry);
aDescr += (anEntry+", ");
TDF_Tool::Entry(thePnt2->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aBox; return aBox;
@ -214,14 +201,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, dou
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aCylinder
TDF_Tool::Entry(aCylinder->GetEntry(), anEntry); << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeCylinderRH(";
aDescr += (TCollection_AsciiString(theR)+", ");
aDescr += (TCollection_AsciiString(theH)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCylinder; return aCylinder;
@ -278,18 +259,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
TDF_Tool::Entry(aCylinder->GetEntry(), anEntry); << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCylinder; return aCylinder;
@ -337,15 +308,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, dou
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
TDF_Tool::Entry(aCone->GetEntry(), anEntry); << theR1 << ", " << theR2 << ", " << theH << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeConeR1R2H(";
aDescr += (TCollection_AsciiString(theR1)+", ");
aDescr += (TCollection_AsciiString(theR2)+", ");
aDescr += (TCollection_AsciiString(theH)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCone; return aCone;
@ -404,19 +368,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
TDF_Tool::Entry(aCone->GetEntry(), anEntry); << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCone; return aCone;
@ -460,13 +413,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
TDF_Tool::Entry(aSphere->GetEntry(), anEntry);
aDescr += anEntry;
aDescr += " = geompy.MakeSphereR(";
aDescr += (TCollection_AsciiString(theR)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aSphere; return aSphere;
@ -518,15 +465,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Obje
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aSphere
TDF_Tool::Entry(aSphere->GetEntry(), anEntry); << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeSpherePntR(";
TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theR)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aSphere; return aSphere;
@ -573,14 +513,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
TDF_Tool::Entry(anEll->GetEntry(), anEntry); << theRMajor << ", " << theRMinor << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeTorusRR(";
aDescr += (TCollection_AsciiString(theRMajor)+", ");
aDescr += (TCollection_AsciiString(theRMinor)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return anEll; return anEll;
@ -636,18 +570,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
TDF_Tool::Entry(anEll->GetEntry(), anEntry); << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return anEll; return anEll;
@ -703,17 +627,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Objec
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH("
TDF_Tool::Entry(aPrism->GetEntry(), anEntry); << theBase << ", " << theVec << ", " << theH << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aPrism; return aPrism;
@ -769,18 +684,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism("
TDF_Tool::Entry(aPrism->GetEntry(), anEntry); << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aPrism; return aPrism;
@ -834,15 +739,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) th
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
TDF_Tool::Entry(aPipe->GetEntry(), anEntry); << theBase << ", " << thePath << ")";
aDescr += (anEntry + " = geompy.MakePipe(");
TDF_Tool::Entry(theBase->GetEntry(), anEntry);
aDescr += (anEntry + ", ");
TDF_Tool::Entry(thePath->GetEntry(), anEntry);
aDescr += (anEntry + ")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aPipe; return aPipe;
@ -898,17 +796,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr("import math\n\t"); GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
TDF_Tool::Entry(aRevolution->GetEntry(), anEntry); << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aRevolution; return aRevolution;
@ -959,14 +848,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Obje
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
TDF_Tool::Entry(aSolid->GetEntry(), anEntry);
aDescr += anEntry;
aDescr += " = geompy.MakeSolid(";
TDF_Tool::Entry(theShell->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aSolid; return aSolid;
@ -977,7 +859,9 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Obje
* MakeFilling * 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); SetErrorCode(KO);
@ -1020,19 +904,9 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling (Handle(GEOM_Object)
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aFilling << " = geompy.MakeFilling("
TDF_Tool::Entry(aFilling->GetEntry(), anEntry); << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
aDescr += anEntry; << theTol2D << ", " << theTol3D << ", " << theNbIter << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aFilling; return aFilling;

View File

@ -12,6 +12,7 @@ using namespace std;
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_PointDriver.hxx" #include "GEOMImpl_PointDriver.hxx"
#include "GEOMImpl_VectorDriver.hxx" #include "GEOMImpl_VectorDriver.hxx"
@ -92,14 +93,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertex("
TDF_Tool::Entry(aPoint->GetEntry(), anEntry); << theX << ", " << theY << ", " << theZ << ")";
aDescr += (anEntry+" = geompy.MakeVertex(");
aDescr += (TCollection_AsciiString(theX)+", ");
aDescr += (TCollection_AsciiString(theY)+", ");
aDescr += (TCollection_AsciiString(theZ)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aPoint; return aPoint;
@ -150,16 +145,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexWithRef("
TDF_Tool::Entry(aPoint->GetEntry(), anEntry); << theReference << ", " << theX << ", " << theY << ", " << theZ << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aPoint; return aPoint;
@ -208,14 +195,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
TDF_Tool::Entry(aPoint->GetEntry(), anEntry); << theCurve << ", " << theParameter << ")";
aDescr += (anEntry+" = geompy.MakeVertexOnCurve(");
TDF_Tool::Entry(theCurve->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theParameter)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aPoint; return aPoint;
@ -263,14 +244,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVectorDXDYDZ("
TDF_Tool::Entry(aVector->GetEntry(), anEntry); << theDX << ", " << theDY << ", " << theDZ << ")";
aDescr += (anEntry+" = geompy.MakeVectorDXDYDZ(");
aDescr += (TCollection_AsciiString(theDX)+", ");
aDescr += (TCollection_AsciiString(theDY)+", ");
aDescr += (TCollection_AsciiString(theDZ)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aVector; return aVector;
@ -321,15 +296,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aVector << " = geompy.MakeVector("
TDF_Tool::Entry(aVector->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ")";
aDescr += (anEntry+" = geompy.MakeVector(");
TDF_Tool::Entry(thePnt1->GetEntry(), anEntry);
aDescr += (anEntry+", ");
TDF_Tool::Entry(thePnt2->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aVector; return aVector;
@ -381,15 +349,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLine("
TDF_Tool::Entry(aLine->GetEntry(), anEntry); << thePnt << ", " << theDir << ")";
aDescr += (anEntry+" = geompy.MakeLine(");
TDF_Tool::Entry(thePnt->GetEntry(), anEntry);
aDescr += (anEntry+", ");
TDF_Tool::Entry(theDir->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aLine; return aLine;
@ -440,15 +401,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aLine << " = geompy.MakeLineTwoPnt("
TDF_Tool::Entry(aLine->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ")";
aDescr += (anEntry+" = geompy.MakeLineTwoPnt(");
TDF_Tool::Entry(thePnt1->GetEntry(), anEntry);
aDescr += (anEntry+", ");
TDF_Tool::Entry(thePnt2->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aLine; return aLine;
@ -504,18 +458,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneThreePnt("
TDF_Tool::Entry(aPlane->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << theSize << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aPlane; return aPlane;
@ -568,16 +512,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlane("
TDF_Tool::Entry(aPlane->GetEntry(), anEntry); << thePnt << ", " << theVec << ", " << theSize << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aPlane; return aPlane;
@ -627,14 +563,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPlane << " = geompy.MakePlaneFace("
TDF_Tool::Entry(aPlane->GetEntry(), anEntry); << theFace << ", " << theSize << ")";
aDescr += (anEntry+" = geompy.MakePlaneFace(");
TDF_Tool::Entry(theFace->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += TCollection_AsciiString(theSize) + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aPlane; return aPlane;
@ -684,20 +614,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarker("
TDF_Tool::Entry(aMarker->GetEntry(), anEntry); << theOX << ", " << theOY << ", " << theOZ << ", "
aDescr += anEntry + " = geompy.MakeMarker("; << theXDX << ", " << theXDY << ", " << theXDZ << ", "
aDescr += TCollection_AsciiString(theOX) + ", "; << theYDX << ", " << theYDY << ", " << theYDZ << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aMarker; return aMarker;

View File

@ -11,6 +11,7 @@ using namespace std;
#include "GEOMImpl_Block6Explorer.hxx" #include "GEOMImpl_Block6Explorer.hxx"
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMAlgo_GlueAnalyser.hxx" #include "GEOMAlgo_GlueAnalyser.hxx"
#include "GEOMAlgo_CoupleOfShapes.hxx" #include "GEOMAlgo_CoupleOfShapes.hxx"
@ -149,19 +150,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeQuad("
TDF_Tool::Entry(aFace->GetEntry(), anEntry); << theEdge1 << ", " << theEdge2 << ", " << theEdge3 << ", " << theEdge4 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aFace; return aFace;
@ -215,15 +205,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad2Edges
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeQuad2Edges("
TDF_Tool::Entry(aFace->GetEntry(), anEntry); << theEdge1 << ", " << theEdge2 << ")";
aDescr += anEntry + " = geompy.MakeQuad2Edges(";
TDF_Tool::Entry(theEdge1->GetEntry(), anEntry);
aDescr += anEntry + ", ";
TDF_Tool::Entry(theEdge2->GetEntry(), anEntry);
aDescr += anEntry + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aFace; return aFace;
@ -284,19 +267,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad4Vertices
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeQuad4Vertices("
TDF_Tool::Entry(aFace->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ", " << thePnt4 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aFace; return aFace;
@ -364,23 +336,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aBlock << " = geompy.MakeHexa("
TDF_Tool::Entry(aBlock->GetEntry(), anEntry); << theFace1 << ", " << theFace2 << ", " << theFace3 << ")"
aDescr += anEntry + " = geompy.MakeHexa("; << theFace4 << ", " << theFace5 << ", " << theFace6 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aBlock; return aBlock;
@ -434,15 +392,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa2Faces
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aBlock << " = geompy.MakeHexa2Faces("
TDF_Tool::Entry(aBlock->GetEntry(), anEntry); << theFace1 << ", " << theFace2 << ")";
aDescr += anEntry + " = geompy.MakeHexa2Faces(";
TDF_Tool::Entry(theFace1->GetEntry(), anEntry);
aDescr += anEntry + ", ";
TDF_Tool::Entry(theFace2->GetEntry(), anEntry);
aDescr += anEntry + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aBlock; return aBlock;
@ -494,13 +445,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeBlockCompound
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aBlockComp
TDF_Tool::Entry(aBlockComp->GetEntry(), anEntry); << " = geompy.MakeBlockCompound(" << theCompound << ")";
aDescr += anEntry + " = geompy.BlocksOp.MakeBlockCompound(";
TDF_Tool::Entry(theCompound->GetEntry(), anEntry);
aDescr += anEntry + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aBlockComp; return aBlockComp;
@ -574,21 +520,12 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetPoint
//The GetPoint() doesn't change object so no new function is required. //The GetPoint() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << aResult << " = geompy.GetPoint(" << theShape << ", "
aDescr += anEntry + " = geompy.GetPoint("; << theX << ", " << theY << ", " << theZ << ", " << theEpsilon << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -696,23 +633,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdge
return NULL; return NULL;
} }
//The GetEdge() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetEdge("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theShape << ", " << thePoint1 << ", " << thePoint2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -826,21 +751,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdgeNearPoint
return NULL; return NULL;
} }
//The GetEdgeNearPoint() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetEdgeNearPoint("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theShape << ", " << thePoint << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -982,27 +897,12 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByPoints
return NULL; return NULL;
} }
//The GetFaceByPoints() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceByPoints("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theShape << ", " << thePoint1 << ", " << thePoint2
aDescr += anEntry + " = geompy.GetFaceByPoints("; << ", " << thePoint3 << ", " << thePoint4 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -1125,23 +1025,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByEdges
return NULL; return NULL;
} }
//The GetFaceByEdges() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceByEdges("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theShape << ", " << theEdge1 << ", " << theEdge2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -1204,21 +1092,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetOppositeFace
return NULL; return NULL;
} }
//The GetOppositeFace() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetOppositeFace("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theShape << ", " << theFace << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -1233,9 +1111,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint
(Handle(GEOM_Object) theShape, (Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePoint) Handle(GEOM_Object) thePoint)
{ {
// OSD_Timer timer1, timer2, timer3, timer4, timer5;
// timer1.Start();
SetErrorCode(KO); SetErrorCode(KO);
//New object //New object
@ -1275,9 +1150,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint
Standard_Real PX, PY, PZ; Standard_Real PX, PY, PZ;
aPnt.Coord(PX, PY, PZ); aPnt.Coord(PX, PY, PZ);
// timer1.Stop();
// timer2.Start();
// 1. Classify the point relatively each face // 1. Classify the point relatively each face
Standard_Integer nearest = 2, nbFound = 0; Standard_Integer nearest = 2, nbFound = 0;
TopTools_DataMapOfShapeInteger mapShapeDist; TopTools_DataMapOfShapeInteger mapShapeDist;
@ -1328,9 +1200,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint
} // if (!mapShapeDist.IsBound(aFace)) } // if (!mapShapeDist.IsBound(aFace))
} }
// timer2.Stop();
// timer3.Start();
// 2. Define face, containing the point or having minimum distance to it // 2. Define face, containing the point or having minimum distance to it
if (nbFound > 1) { if (nbFound > 1) {
if (nearest == 0) { if (nearest == 0) {
@ -1401,9 +1270,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint
} }
} // if (nbFound > 1) } // if (nbFound > 1)
// timer3.Stop();
// timer4.Start();
if (nbFound == 0) { if (nbFound == 0) {
SetErrorCode("There are no faces near the given point"); SetErrorCode("There are no faces near the given point");
return NULL; return NULL;
@ -1414,8 +1280,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint
anArray->SetValue(1, anIndices.FindIndex(aShape)); anArray->SetValue(1, anIndices.FindIndex(aShape));
aResult = GetEngine()->AddSubShape(theShape, anArray); aResult = GetEngine()->AddSubShape(theShape, anArray);
} }
// timer4.Stop();
} }
catch (Standard_Failure) { catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
@ -1423,35 +1287,13 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint
return NULL; return NULL;
} }
// timer5.Start(); Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
//The GetFaceNearPoint() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceNearPoint("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theShape << ", " << thePoint << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
// timer5.Stop();
//
// cout << "Show current face times:" << endl;
// timer1.Show();
// timer2.Show();
// timer3.Show();
// timer4.Show();
// timer5.Show();
return aResult; return aResult;
} }
@ -1578,21 +1420,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale
return NULL; return NULL;
} }
//The GetFaceByNormale() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetFaceByNormale("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theShape << ", " << theVector << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -2483,13 +2315,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << " = geompy.RemoveExtraEdges(" << theObject << ")";
aDescr += anEntry + " = geompy.RemoveExtraEdges(";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += anEntry + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -2537,13 +2364,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::CheckAndImprove
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << " = geompy.CheckAndImprove(" << theObject << ")";
aDescr += anEntry + " = geompy.CheckAndImprove(";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += anEntry + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -2570,7 +2392,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound
Handle(GEOM_Function) aFunction; Handle(GEOM_Function) aFunction;
TopTools_MapOfShape mapShape; TopTools_MapOfShape mapShape;
TCollection_AsciiString anAsciiList = "[", anEntry; TCollection_AsciiString anAsciiList, anEntry;
// Map shapes // Map shapes
TopTools_IndexedMapOfShape anIndices; TopTools_IndexedMapOfShape anIndices;
@ -2601,8 +2423,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound
//Make a Python command //Make a Python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry); TDF_Tool::Entry(anObj->GetEntry(), anEntry);
anAsciiList += anEntry; anAsciiList += anEntry + ", ";
anAsciiList += ",";
} }
} }
} }
@ -2618,23 +2439,16 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound
return aBlocks; return aBlocks;
} }
anAsciiList.Trunc(anAsciiList.Length() - 1); anAsciiList.Trunc(anAsciiList.Length() - 2);
anAsciiList += "]";
//The explode doesn't change object so no new function is required. //The explode doesn't change object so no new function is required.
aFunction = theCompound->GetLastFunction(); aFunction = theCompound->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
TCollection_AsciiString aDescr (anAsciiList); GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t["
aDescr += " = geompy.MakeBlockExplode("; << anAsciiList.ToCString() << "] = geompy.MakeBlockExplode("
TDF_Tool::Entry(theCompound->GetEntry(), anEntry); << theCompound << ", " << theMinNbFaces << ", " << theMaxNbFaces << ")";
aDescr += anEntry + ", ";
aDescr += TCollection_AsciiString(theMinNbFaces) + ", ";
aDescr += TCollection_AsciiString(theMaxNbFaces) + ")";
TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t";
aNewDescr += aDescr;
aFunction->SetDescription(aNewDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aBlocks; return aBlocks;
@ -2805,21 +2619,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint
return NULL; return NULL;
} }
//The GetBlockNearPoint() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theCompound->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetBlockNearPoint("
TDF_Tool::Entry(aResult->GetEntry(), anEntry); << theCompound << ", " << thePoint << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -2929,20 +2733,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockByParts
return NULL; return NULL;
} }
//The GetBlockByParts() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
Handle(GEOM_Function) aFunction = theCompound->GetLastFunction();
//Make a Python command //Make a Python command
TDF_Tool::Entry(aResult->GetEntry(), anEntry); GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetBlockByParts("
TCollection_AsciiString aDescr (anEntry); << theCompound << ", [" << aPartsDescr.ToCString() << "])";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;
@ -2970,7 +2765,8 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart
//Get the parts //Get the parts
Standard_Integer argi, aLen = theParts->Length(); Standard_Integer argi, aLen = theParts->Length();
TopTools_Array1OfShape anArgs (1, aLen); TopTools_Array1OfShape anArgs (1, aLen);
TCollection_AsciiString anEntry, aPartsDescr, anAsciiList = "["; TCollection_AsciiString anEntry, aPartsDescr, anAsciiList;
for (argi = 1; argi <= aLen; argi++) { for (argi = 1; argi <= aLen; argi++) {
Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theParts->Value(argi)); Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theParts->Value(argi));
Handle(GEOM_Function) aRef = anObj->GetLastFunction(); Handle(GEOM_Function) aRef = anObj->GetLastFunction();
@ -2985,8 +2781,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart
// For Python command // For Python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry); TDF_Tool::Entry(anObj->GetEntry(), anEntry);
if (argi > 1) aPartsDescr += ", "; aPartsDescr += anEntry + ", ";
aPartsDescr += anEntry;
} }
//Get the Blocks //Get the Blocks
@ -3049,10 +2844,11 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart
anObj = GetEngine()->AddSubShape(theCompound, anArray); anObj = GetEngine()->AddSubShape(theCompound, anArray);
aBlocks->Append(anObj); aBlocks->Append(anObj);
//Make a Python command // For Python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry); TDF_Tool::Entry(anObj->GetEntry(), anEntry);
anAsciiList += anEntry; anAsciiList += anEntry + ", ";
anAsciiList += ","; if (aFunction.IsNull())
aFunction = anObj->GetLastFunction();
} }
} }
} }
@ -3062,22 +2858,13 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart
return NULL; 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 //Make a Python command
TCollection_AsciiString aDescr (anAsciiList); aPartsDescr.Trunc(aPartsDescr.Length() - 2);
aDescr += " = geompy.GetBlocksByParts("; anAsciiList.Trunc(anAsciiList.Length() - 2);
TDF_Tool::Entry(theCompound->GetEntry(), anEntry);
aDescr += anEntry + ", [";
aDescr += aPartsDescr + "])";
TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n\t"; GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
aNewDescr += aDescr; << "] = geompy.GetBlocksByParts(" << theCompound
aFunction->SetDescription(aNewDescr); << ", [" << aPartsDescr.ToCString() << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aBlocks; return aBlocks;
@ -3131,16 +2918,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation1D
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTransformation1D("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theDirFace1 << ", " << theDirFace2 << ", " << theNbTimes << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -3200,19 +2979,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation2D
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTransformation2D("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theDirFace1U << ", " << theDirFace2U << ", " << theNbTimesU
aDescr += anEntry + " = geompy.MakeMultiTransformation2D("; << ", " << theDirFace1V << ", " << theDirFace2V << ", " << theNbTimesV << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -3245,6 +3014,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TopTools_MapOfShape mapAcceptedEdges; TopTools_MapOfShape mapAcceptedEdges;
TCollection_AsciiString aListRes, anEntry;
for (ie = 1; ie <= nbEdges; ie++) { for (ie = 1; ie <= nbEdges; ie++) {
TopoDS_Shape curE = MEW.FindKey(ie); TopoDS_Shape curE = MEW.FindKey(ie);
@ -3329,6 +3099,10 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate
// Add the chain to the result // Add the chain to the result
aSeq->Append(aChain); aSeq->Append(aChain);
//Make a Python command
TDF_Tool::Entry(aChain->GetEntry(), anEntry);
aListRes += anEntry + ", ";
} }
if (aSeq->IsEmpty()) { if (aSeq->IsEmpty()) {
@ -3336,19 +3110,15 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate
return aSeq; return aSeq;
} }
aListRes.Trunc(aListRes.Length() - 2);
// The Propagation doesn't change object so no new function is required. // The Propagation doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
// Make a Python command // Make a Python command
TCollection_AsciiString aDescr GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t["
("\n\tlistPropagationChains = IShapesOperations.Propagate("); << aListRes.ToCString() << "] = geompy.Propagate(" << theShape << ")";
TCollection_AsciiString anEntry;
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry + ")");
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
anOldDescr = anOldDescr + aDescr;
aFunction->SetDescription(anOldDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;

View File

@ -3,6 +3,8 @@ using namespace std;
#include "GEOMImpl_IBooleanOperations.hxx" #include "GEOMImpl_IBooleanOperations.hxx"
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
#include "GEOMImpl_BooleanDriver.hxx" #include "GEOMImpl_BooleanDriver.hxx"
@ -96,17 +98,14 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aBool->GetEntry(), anEntry); pd << aBool;
aDescr += anEntry; if (theOp == 1) pd << " = geompy.MakeCommon(";
aDescr += " = geompy.MakeBoolean("; else if (theOp == 2) pd << " = geompy.MakeCut(";
TDF_Tool::Entry(theShape1->GetEntry(), anEntry); else if (theOp == 3) pd << " = geompy.MakeFuse(";
aDescr += (anEntry+", "); else if (theOp == 4) pd << " = geompy.MakeSection(";
TDF_Tool::Entry(theShape2->GetEntry(), anEntry); else {}
aDescr += (anEntry+", "); pd << theShape1 << ", " << theShape2 << ")";
aDescr += (TCollection_AsciiString(theOp)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aBool; return aBool;
@ -253,36 +252,24 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition
} }
//Make a Python command //Make a Python command
TCollection_AsciiString aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aPartition->GetEntry(), anEntry); pd << aPartition << " = geompy.MakePartition([";
aDescr += anEntry; // Shapes, Tools
aDescr += " = geompy.MakePartition(["; pd << aShapesDescr.ToCString() << "], [" << aToolsDescr.ToCString() << "], [";
// Shapes // Keep Ins, Remove Ins
aDescr += aShapesDescr + "], ["; pd << aKeepInsDescr.ToCString() << "], [" << aRemoveInsDescr.ToCString() << "], ";
// Tools // Limit, Remove Webs
aDescr += aToolsDescr + "], ["; pd << theLimit << ", " << (int)theRemoveWebs << ", [";
// Keep Ins
aDescr += aKeepInsDescr + "], [";
// Remove Ins
aDescr += aRemoveInsDescr + "], ";
// Limit
aDescr += TCollection_AsciiString(theLimit) + ", ";
// Remove Webs
if (theRemoveWebs) aDescr += "1, [";
else aDescr += "0, [";
// Materials // Materials
if (theMaterials->Length() > 0) { if (theMaterials->Length() > 0) {
int i = theMaterials->Lower(); int i = theMaterials->Lower();
aDescr += TCollection_AsciiString(theMaterials->Value(i)); pd << theMaterials->Value(i);
i++; i++;
for (; i <= theMaterials->Upper(); i++) { for (; i <= theMaterials->Upper(); i++) {
aDescr += ", "; pd << ", " << theMaterials->Value(i);
aDescr += TCollection_AsciiString(theMaterials->Value(i));
} }
} }
aDescr += "])"; pd << "])";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aPartition; return aPartition;
@ -335,16 +322,8 @@ Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aPart << " = geompy.MakeHalfPartition("
TDF_Tool::Entry(aPart->GetEntry(), anEntry); << theShape << ", " << thePlane << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeHalfPartition(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry+", ");
TDF_Tool::Entry(thePlane->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aPart; return aPart;

View File

@ -3,6 +3,8 @@ using namespace std;
#include "GEOMImpl_ICurvesOperations.hxx" #include "GEOMImpl_ICurvesOperations.hxx"
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
#include "GEOMImpl_PolylineDriver.hxx" #include "GEOMImpl_PolylineDriver.hxx"
@ -97,22 +99,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list<Handle(GEOM_O
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aPolyline->GetEntry(), anEntry); pd << aPolyline << " = geompy.MakePolyline([";
aDescr += anEntry;
aDescr += " = 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;
}
aDescr += "])";
aFunction->SetDescription(aDescr); it = thePoints.begin();
pd << (*it++);
while (it != thePoints.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aPolyline; return aPolyline;
@ -168,18 +163,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircleThreePnt("
TDF_Tool::Entry(aCircle->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCircle; return aCircle;
@ -233,17 +218,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aCircle << " = geompy.MakeCircle("
TDF_Tool::Entry(aCircle->GetEntry(), anEntry); << thePnt << ", " << theVec << ", " << theR << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCircle; return aCircle;
@ -299,18 +275,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse("
TDF_Tool::Entry(anEll->GetEntry(), anEntry); << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return anEll; return anEll;
@ -366,18 +332,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc("
TDF_Tool::Entry(anArc->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return anArc; return anArc;
@ -433,22 +389,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aSpline->GetEntry(), anEntry); pd << aSpline << " = geompy.MakeBezier([";
aDescr += anEntry;
aDescr += " = 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;
}
aDescr += "])";
aFunction->SetDescription(aDescr); it = thePoints.begin();
pd << (*it++);
while (it != thePoints.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aSpline; return aSpline;
@ -504,22 +453,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aSpline->GetEntry(), anEntry); pd << aSpline << " = geompy.MakeInterpol([";
aDescr += anEntry;
aDescr += " = 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;
}
aDescr += "])";
aFunction->SetDescription(aDescr); it = thePoints.begin();
pd << (*it++);
while (it != thePoints.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aSpline; return aSpline;
@ -573,23 +515,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aSketcher->GetEntry(), anEntry); pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand << "\", [";
aDescr += anEntry;
aDescr += " = geompy.MakeSketcher( \"";
aDescr += aCommand+"\", [";
it = theWorkingPlane.begin(); it = theWorkingPlane.begin();
aDescr += TCollection_AsciiString(*it); pd << (*it++);
it++; while (it != theWorkingPlane.end()) {
for (; it != theWorkingPlane.end(); it++) { pd << ", " << (*it++);
aDescr += ", ";
aDescr += TCollection_AsciiString(*it);
} }
pd << "])";
aDescr += "])";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aSketcher; return aSketcher;

View File

@ -6,6 +6,7 @@ using namespace std;
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_ISubShape.hxx" #include "GEOM_ISubShape.hxx"
#include "GEOM_PythonDump.hxx"
#include "utilities.h" #include "utilities.h"
#include "OpUtil.hxx" #include "OpUtil.hxx"
@ -54,7 +55,8 @@ GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations()
* CreateGroup * 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); SetErrorCode(KO);
@ -72,15 +74,12 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup(Handle(GEOM_Object) t
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType); TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType);
//Make a Python command //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)+")");
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); 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); SetErrorCode(OK);
return aGroup; return aGroup;
@ -120,13 +119,10 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr("geompy.AddObject( "); TCollection_AsciiString anOldDescr = aFunction->GetDescription();
TDF_Tool::Entry(theGroup->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theSubShapeID)+" )");
aDescr = aFunction->GetDescription() + "\n\t" + aDescr; GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
aFunction->SetDescription(aDescr); << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
SetErrorCode(OK); SetErrorCode(OK);
return; return;
@ -189,12 +185,10 @@ void GEOMImpl_IGroupOperations::RemoveObject(Handle(GEOM_Object) theGroup, int t
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr("geompy.RemoveObject( "); TCollection_AsciiString anOldDescr = aFunction->GetDescription();
TDF_Tool::Entry(theGroup->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theSubShapeID)+" )");
aFunction->SetDescription(aDescr); GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
<< "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
SetErrorCode(OK); SetErrorCode(OK);
return; return;
@ -330,18 +324,17 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
} }
aSSI.SetIndices(aNewSeq); 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); SetErrorCode(OK);
@ -481,19 +474,17 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
} }
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
//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 ) ? ", " : " ])");;
} }
aFunction->SetDescription(aDescr); //Make a Python command
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
GEOM::TPythonDump pd (aFunction);
pd << anOldDescr.ToCString() << "\n\t" << "geompy.DifferenceList(" << 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); SetErrorCode(OK);
@ -527,27 +518,22 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape(Handle(GEOM_Object)
if(theGroup.IsNull()) return NULL; if(theGroup.IsNull()) return NULL;
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); Handle(GEOM_Function) aGroupFunction = theGroup->GetFunction(1);
if(aFunction.IsNull()) return NULL; if (aGroupFunction.IsNull()) return NULL;
GEOM_ISubShape aSSI(aFunction); GEOM_ISubShape aSSI (aGroupFunction);
aFunction = aSSI.GetMainShape(); Handle(GEOM_Function) aMainShapeFunction = aSSI.GetMainShape();
if(aFunction.IsNull()) return NULL; if (aMainShapeFunction.IsNull()) return NULL;
TDF_Label aLabel = aFunction->GetOwnerEntry(); TDF_Label aLabel = aMainShapeFunction->GetOwnerEntry();
Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel); Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel);
if (aMainShape.IsNull()) return NULL; if (aMainShape.IsNull()) return NULL;
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; TCollection_AsciiString anOldDescr = aGroupFunction->GetDescription();
TDF_Tool::Entry(aMainShape->GetEntry(), aDescr);
aDescr += " = geompy.GetMainShape( ";
TDF_Tool::Entry(theGroup->GetEntry(), anEntry);
aDescr += (anEntry+" )");
aFunction = theGroup->GetFunction(1); GEOM::TPythonDump(aGroupFunction) << anOldDescr.ToCString() << "\n\t"
aDescr = aFunction->GetDescription() + "\n\t" + aDescr; << aMainShape << " = geompy.GetMainShape(" << theGroup << ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aMainShape; return aMainShape;

View File

@ -2,6 +2,8 @@ using namespace std;
#include "GEOMImpl_IHealingOperations.hxx" #include "GEOMImpl_IHealingOperations.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_HealingDriver.hxx" #include "GEOMImpl_HealingDriver.hxx"
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
#include "GEOMImpl_IHealing.hxx" #include "GEOMImpl_IHealing.hxx"
@ -125,34 +127,30 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Objec
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
aDescr += " = geompy.ProcessShape( ";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry+", [ ");
// list of operators // list of operators
int i = theOperators->Lower(), nb = theOperators->Upper(); int i = theOperators->Lower(), nb = theOperators->Upper();
for ( ; i <= nb; i++) { for ( ; i <= nb; i++) {
aDescr += "\""; pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
aDescr += theOperators->Value( i ); << (( i < nb ) ? "\", " : "\"");
aDescr += "\"";
aDescr += (char*)(( i < nb ) ? ", " : " ], [ ");
} }
pd << "], [";
// list of parameters // list of parameters
i = theParams->Lower(); nb = theParams->Upper(); i = theParams->Lower(); nb = theParams->Upper();
for ( ; i <= nb; i++) { for ( ; i <= nb; i++) {
aDescr += "\""; pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
aDescr += TCollection_AsciiString(theParams->Value( i )); << (( i < nb ) ? "\", " : "\"");
aDescr += "\"";
aDescr += (char*)(( i < nb ) ? ", " : " ], [ ");
} }
pd << "], [";
// list of values // list of values
i = theValues->Lower(); nb = theValues->Upper(); i = theValues->Lower(); nb = theValues->Upper();
for ( ; i <= nb; i++) for ( ; i <= nb; i++) {
aDescr += TCollection_AsciiString(theValues->Value( i )) pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
+ (char*)(( i < nb ) ? ", " : " ])"); << (( i < nb ) ? "\", " : "\"");
}
aFunction->SetDescription(aDescr); pd << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;
@ -291,8 +289,8 @@ bool GEOMImpl_IHealingOperations::GetParameters (const string theOperation,
* SuppressFaces * SuppressFaces
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces (Handle(GEOM_Object) theObject, Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
const Handle(TColStd_HArray1OfInteger)& theFaces) (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
{ {
// set error code, check parameters // set error code, check parameters
SetErrorCode(KO); SetErrorCode(KO);
@ -336,19 +334,13 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces (Handle(GEOM_Obje
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
aDescr += " = geompy.SuppressFaces( ";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry+", [ ");
// list of face ids // list of face ids
int i = theFaces->Lower(), nb = theFaces->Upper(); int i = theFaces->Lower(), nb = theFaces->Upper();
for ( ; i <= nb; i++) for ( ; i <= nb; i++)
aDescr += pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
TCollection_AsciiString(theFaces->Value( i ))
+ (char*)(( i < nb ) ? ", " : " ])");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;
@ -360,7 +352,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces (Handle(GEOM_Obje
* CloseContour * CloseContour
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour (Handle(GEOM_Object) theObject, Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
(Handle(GEOM_Object) theObject,
const Handle(TColStd_HArray1OfInteger)& theWires, const Handle(TColStd_HArray1OfInteger)& theWires,
bool isCommonVertex) bool isCommonVertex)
{ {
@ -407,19 +400,15 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour (Handle(GEOM_Objec
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
aDescr += " = geompy.CloseContour( ";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry+", [ ");
// list of wire ids // list of wire ids
int i = theWires->Lower(), nb = theWires->Upper(); int i = theWires->Lower(), nb = theWires->Upper();
for ( ; i <= nb; i++) for ( ; i <= nb; i++)
aDescr += TCollection_AsciiString(theWires->Value( i )) pd << theWires->Value( i ) << (( i < nb ) ? ", " : "], ");
+ (char*)(( i < nb ) ? ", " : " ], ");
aDescr += (char*)( isCommonVertex ? "1 )" : "0 )" );
aFunction->SetDescription(aDescr); pd << (int)isCommonVertex << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;
@ -430,8 +419,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour (Handle(GEOM_Objec
* RemoveIntWires * RemoveIntWires
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires (Handle(GEOM_Object) theObject, Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
const Handle(TColStd_HArray1OfInteger)& theWires) (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
{ {
// set error code, check parameters // set error code, check parameters
SetErrorCode(KO); SetErrorCode(KO);
@ -475,18 +464,17 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires (Handle(GEOM_Obj
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
aDescr += " = geompy.SuppressInternalWires( ";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry+", [ ");
// list of wire ids // list of wire ids
if (!theWires.IsNull()) {
int i = theWires->Lower(), nb = theWires->Upper(); int i = theWires->Lower(), nb = theWires->Upper();
for ( ; i <= nb; i++) for ( ; i <= nb; i++)
aDescr += TCollection_AsciiString(theWires->Value( i )) pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
+ (char*)(( i < nb ) ? ", " : " ])"); } else {
pd << "])";
aFunction->SetDescription(aDescr); }
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;
@ -542,18 +530,13 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object)
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
aDescr += " = geompy.SuppressHoles( ";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry+", [ ");
// list of wire ids // list of wire ids
int i = theWires->Lower(), nb = theWires->Upper(); int i = theWires->Lower(), nb = theWires->Upper();
for ( ; i <= nb; i++) for ( ; i <= nb; i++)
aDescr += TCollection_AsciiString(theWires->Value( i )) pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
+ (char*)(( i < nb ) ? ", " : " ])");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;
@ -609,13 +592,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); << theObject << ", " << theTolerance << ")";
aDescr += " = geompy.Sew( ";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += anEntry+", " + theTolerance + " )";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;
@ -675,12 +653,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object)
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
TDF_Tool::Entry(aNewObject->GetEntry(), aDescr); << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
aDescr += " = geompy.DivideEdge( ";
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += anEntry + ", " + theIndex + ", " + theValue + ", ";
aDescr += (char*)( isByParameter ? "1 )" : "0 )" );
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;
@ -731,6 +705,35 @@ bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject
theOpen->Append(anObj); 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); SetErrorCode(OK);
return true; return true;
} }

View File

@ -12,6 +12,7 @@ using namespace std;
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_CopyDriver.hxx" #include "GEOMImpl_CopyDriver.hxx"
#include "GEOMImpl_ExportDriver.hxx" #include "GEOMImpl_ExportDriver.hxx"
@ -90,13 +91,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) the
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeCopy(" << theOriginal << ")";
TDF_Tool::Entry(aCopy->GetEntry(), anEntry);
aDescr += (anEntry+" = geompy.MakeCopy(");
TDF_Tool::Entry(theOriginal->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -154,14 +149,8 @@ void GEOMImpl_IInsertOperations::Export
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal
aDescr = "geompy.Export("; << ", \"" << theFileName << "\", \"" << theFormatName << "\")";
TDF_Tool::Entry(theOriginal->GetEntry(), anEntry);
aDescr += (anEntry + ", \"");
aDescr += (TCollection_AsciiString(aFileName) + "\", \"");
aDescr += (TCollection_AsciiString(aFormatName) + "\")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
} }
@ -216,13 +205,8 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\""
TDF_Tool::Entry(result->GetEntry(), anEntry); << theFileName << "\", \"" << theFormatName << "\")";
aDescr += (anEntry + " = geompy.Import(\"");
aDescr += (TCollection_AsciiString(aFileName) + "\", \"");
aDescr += (TCollection_AsciiString(aFormatName) + "\")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return result; return result;

View File

@ -3,6 +3,8 @@ using namespace std;
#include "GEOMImpl_ILocalOperations.hxx" #include "GEOMImpl_ILocalOperations.hxx"
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
#include "GEOMImpl_FilletDriver.hxx" #include "GEOMImpl_FilletDriver.hxx"
@ -94,14 +96,8 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
TDF_Tool::Entry(aFillet->GetEntry(), anEntry); << theShape << ", " << theR << ")";
aDescr = anEntry + " = geompy.MakeFilletAll(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theR)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aFillet; return aFillet;
@ -158,22 +154,16 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aFillet->GetEntry(), anEntry); pd << aFillet << " = geompy.MakeFillet(" << theShape
aDescr = anEntry + " = geompy.MakeFillet("; << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theR)+", geompy.ShapeType[\"EDGE\"], [");
it = theEdges.begin();
aDescr += TCollection_AsciiString(*it);
it++;
for (; it != theEdges.end(); it++) {
aDescr += ", ";
aDescr += TCollection_AsciiString(*it);
}
aDescr += "])";
aFunction->SetDescription(aDescr); it = theEdges.begin();
pd << (*it++);
while (it != theEdges.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aFillet; return aFillet;
@ -230,22 +220,16 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aFillet->GetEntry(), anEntry); pd << aFillet << " = geompy.MakeFillet(" << theShape
aDescr = anEntry + " = geompy.MakeFillet("; << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theR)+", geompy.ShapeType[\"FACE\"], [");
it = theFaces.begin();
aDescr += TCollection_AsciiString(*it);
it++;
for (; it != theFaces.end(); it++) {
aDescr += ", ";
aDescr += TCollection_AsciiString(*it);
}
aDescr += "])";
aFunction->SetDescription(aDescr); it = theFaces.begin();
pd << (*it++);
while (it != theFaces.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aFillet; return aFillet;
@ -293,15 +277,8 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Objec
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); << theShape << ", " << theD << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeChamferAll(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theD)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aChamfer; return aChamfer;
@ -354,18 +331,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aChamfer
TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
aDescr += anEntry; << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aChamfer; return aChamfer;
@ -424,24 +392,16 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
aDescr += anEntry; << ", " << theD1 << ", " << theD2 << ", [";
aDescr += " = geompy.MakeChamferFaces(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theD1)+", ");
aDescr += (TCollection_AsciiString(theD2)+", [");
it = theFaces.begin();
aDescr += TCollection_AsciiString(*it);
it++;
for (; it != theFaces.end(); it++) {
aDescr += ", ";
aDescr += TCollection_AsciiString(*it);
}
aDescr += "])";
aFunction->SetDescription(aDescr); it = theFaces.begin();
pd << (*it++);
while (it != theFaces.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK); SetErrorCode(OK);
return aChamfer; return aChamfer;
@ -493,17 +453,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aChamfer
TDF_Tool::Entry(aChamfer->GetEntry(), anEntry); << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
aDescr += anEntry; << theWaterDensity << ", " << theMeshingDeflection << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aChamfer; return aChamfer;

View File

@ -7,6 +7,7 @@ using namespace std;
#include "GEOMImpl_IMeasure.hxx" #include "GEOMImpl_IMeasure.hxx"
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "utilities.h" #include "utilities.h"
#include "OpUtil.hxx" #include "OpUtil.hxx"
@ -110,13 +111,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCDG << " = geompy.MakeCDG(" << theShape << ")";
TDF_Tool::Entry(aCDG->GetEntry(), anEntry);
aDescr += anEntry + " = geompy.MakeCDG(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += anEntry + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCDG; return aCDG;

View File

@ -16,6 +16,7 @@ using namespace std;
#include "GEOMImpl_Block6Explorer.hxx" #include "GEOMImpl_Block6Explorer.hxx"
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMAlgo_FinderShapeOn.hxx" #include "GEOMAlgo_FinderShapeOn.hxx"
@ -139,15 +140,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdge
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << anEdge << " = geompy.MakeEdge("
TDF_Tool::Entry(anEdge->GetEntry(), anEntry); << thePnt1 << ", " << thePnt2 << ")";
aDescr += (anEntry+" = geompy.MakeEdge(");
TDF_Tool::Entry(thePnt1->GetEntry(), anEntry);
aDescr += (anEntry+", ");
TDF_Tool::Entry(thePnt2->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return anEdge; return anEdge;
@ -210,18 +204,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFace("
TDF_Tool::Entry(aFace->GetEntry(), anEntry); << theWire << ", " << (int)isPlanarWanted << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeFace(";
TDF_Tool::Entry(theWire->GetEntry(), anEntry);
aDescr += anEntry;
if (isPlanarWanted)
aDescr += ", 1)";
else
aDescr += ", 0)";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aFace; return aFace;
@ -281,28 +265,18 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aShape->GetEntry(), anEntry); pd << aShape << " = geompy.MakeFaceWires([";
aDescr += (anEntry + " = geompy.MakeFaceWires([");
// Shapes // Shapes
it = theShapes.begin(); it = theShapes.begin();
if (it != theShapes.end()) { if (it != theShapes.end()) {
TDF_Tool::Entry((*it)->GetEntry(), anEntry); pd << (*it++);
aDescr += anEntry; while (it != theShapes.end()) {
it++; pd << ", " << (*it++);
for (; it != theShapes.end(); it++) {
aDescr += ", ";
TDF_Tool::Entry((*it)->GetEntry(), anEntry);
aDescr += anEntry;
} }
} }
if (isPlanarWanted) pd << "], " << (int)isPlanarWanted << ")";
aDescr += "], 1)";
else
aDescr += "], 0)";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aShape; return aShape;
@ -374,14 +348,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSolidShell (Handle(GEOM_Obje
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump(aFunction) << aSolid
TDF_Tool::Entry(aSolid->GetEntry(), anEntry); << " = geompy.MakeSolid(" << theShell << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeSolid(";
TDF_Tool::Entry(theShell->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aSolid; return aSolid;
@ -452,25 +420,18 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr(""); GEOM::TPythonDump pd (aFunction);
TDF_Tool::Entry(aShape->GetEntry(), anEntry); pd << aShape << " = geompy." << theMethodName.ToCString() << "([";
aDescr += (anEntry + " = geompy.");
aDescr += (theMethodName + "([");
// Shapes // Shapes
it = theShapes.begin(); it = theShapes.begin();
if (it != theShapes.end()) { if (it != theShapes.end()) {
TDF_Tool::Entry((*it)->GetEntry(), anEntry); pd << (*it++);
aDescr += anEntry; while (it != theShapes.end()) {
it++; pd << ", " << (*it++);
for (; it != theShapes.end(); it++) {
aDescr += ", ";
TDF_Tool::Entry((*it)->GetEntry(), anEntry);
aDescr += anEntry;
} }
} }
aDescr += "])"; pd << "])";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aShape; return aShape;
@ -528,15 +489,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aGlued << " = geompy.MakeGlueFaces("
TDF_Tool::Entry(aGlued->GetEntry(), anEntry); << theShape << ", " << theTolerance << ")";
aDescr += anEntry;
aDescr += " = geompy.MakeGlueFaces(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += anEntry + ", ";
aDescr += TCollection_AsciiString(theTolerance) + ")";
aFunction->SetDescription(aDescr);
// to provide warning // to provide warning
if (!isWarning) SetErrorCode(OK); if (!isWarning) SetErrorCode(OK);
@ -553,9 +507,6 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
const Standard_Boolean isSorted) const Standard_Boolean isSorted)
{ {
// OSD_Timer timer1, timer2, timer3, timer4;
// timer1.Start();
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull()) return NULL; if (theShape.IsNull()) return NULL;
@ -593,21 +544,15 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
return aSeq; return aSeq;
} }
// timer1.Stop();
// timer2.Start();
if (isSorted) if (isSorted)
SortShapes(listShape); SortShapes(listShape);
// timer2.Stop();
// timer3.Start();
TopTools_IndexedMapOfShape anIndices; TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices); TopExp::MapShapes(aShape, anIndices);
Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HArray1OfInteger) anArray;
TopTools_ListIteratorOfListOfShape itSub (listShape); TopTools_ListIteratorOfListOfShape itSub (listShape);
TCollection_AsciiString anAsciiList = "[", anEntry; TCollection_AsciiString anAsciiList, anEntry;
for (int index = 1; itSub.More(); itSub.Next(), ++index) { for (int index = 1; itSub.More(); itSub.Next(), ++index) {
TopoDS_Shape aValue = itSub.Value(); TopoDS_Shape aValue = itSub.Value();
anArray = new TColStd_HArray1OfInteger(1,1); anArray = new TColStd_HArray1OfInteger(1,1);
@ -615,50 +560,24 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
anObj = GetEngine()->AddSubShape(theShape, anArray); anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj); aSeq->Append(anObj);
// for python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry); TDF_Tool::Entry(anObj->GetEntry(), anEntry);
anAsciiList += anEntry; anAsciiList += anEntry;
anAsciiList += ","; anAsciiList += ",";
} }
// timer3.Stop();
// timer4.Start();
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 //Make a Python command
TCollection_AsciiString aDescr(anAsciiList); anAsciiList.Trunc(anAsciiList.Length() - 1);
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
if (isSorted)
aDescr += " = geompy.SubShapeAllSorted( ";
else
aDescr += " = geompy.SubShapeAll( ";
aDescr += (anEntry + ", ");
aDescr += theShapeType;
aDescr += " )";
aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); TCollection_AsciiString anOldDescr = aFunction->GetDescription();
anOldDescr = anOldDescr + aDescr;
aFunction->SetDescription(anOldDescr); GEOM::TPythonDump pd (aFunction);
pd << anOldDescr.ToCString() << "\n\t[" << anAsciiList.ToCString();
pd << "] = geompy.SubShapeAll" << (isSorted ? "Sorted(" : "(");
pd << theShape << ", " << theShapeType << ")";
SetErrorCode(OK); 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();
return aSeq; return aSeq;
} }
@ -720,23 +639,14 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs
aSeq->Append(anIndices.FindIndex(aValue)); aSeq->Append(anIndices.FindIndex(aValue));
} }
//The explode doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
TCollection_AsciiString aDescr GEOM::TPythonDump pd (aFunction);
("\n\tlistSubShapeAllIDs = geompy.SubShapeAllIDs("); pd << anOldDescr.ToCString() << "\n\tlistSubShapeIDs = geompy.SubShapeAll";
TCollection_AsciiString anEntry; pd << (isSorted ? "SortedIDs(" : "IDs(");
TDF_Tool::Entry(theShape->GetEntry(), anEntry); pd << theShape << ", " << theShapeType << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -763,20 +673,11 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSubShape
return NULL; return NULL;
} }
//The GetSubShape() doesn't change object so no new function is requiered. Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
Handle(GEOM_Function) aFunction = theMainShape->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString aDescr ("\n\t"); GEOM::TPythonDump(aFunction) << anObj << " = geompy.GetSubShape("
TCollection_AsciiString anEntry; << theMainShape << ", [" << theID << "])";
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);
SetErrorCode(OK); SetErrorCode(OK);
return anObj; return anObj;
@ -878,14 +779,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object)
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aReversed
TDF_Tool::Entry(aReversed->GetEntry(), anEntry); << " = geompy.ChangeOrientation(" << theShape << ")";
aDescr += anEntry;
aDescr += " = geompy.ChangeOrientation(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += anEntry + ")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aReversed; return aReversed;
@ -931,16 +826,11 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetFreeFacesIDs
//The explode doesn't change object so no new function is required. //The explode doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
//Make a Python command //Make a Python command
TCollection_AsciiString aDescr ("\n\tlistFreeFacesIDs = geompy.GetFreeFacesIDs("); GEOM::TPythonDump(aFunction) << anOldDescr.ToCString()
TCollection_AsciiString anEntry; << "\n\tlistFreeFacesIDs = geompy.GetFreeFacesIDs(" << theShape << ")";
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += (anEntry + ")");
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
anOldDescr = anOldDescr + aDescr;
aFunction->SetDescription(anOldDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -974,6 +864,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
Handle(GEOM_Object) anObj; Handle(GEOM_Object) anObj;
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TCollection_AsciiString anAsciiList, anEntry;
TopTools_MapOfShape mapShape2; TopTools_MapOfShape mapShape2;
TopExp_Explorer exp (aShape2, TopAbs_ShapeEnum(theShapeType)); TopExp_Explorer exp (aShape2, TopAbs_ShapeEnum(theShapeType));
@ -984,6 +875,11 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
anArray->SetValue(1, anIndices.FindIndex(aSS)); anArray->SetValue(1, anIndices.FindIndex(aSS));
anObj = GetEngine()->AddSubShape(theShape1, anArray); anObj = GetEngine()->AddSubShape(theShape1, anArray);
aSeq->Append(anObj); 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; return aSeq;
} }
//The explode doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape1->GetLastFunction();
//Make a Python command //Make a Python command
TCollection_AsciiString aDescr anAsciiList.Trunc(anAsciiList.Length() - 1);
("\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) + ")";
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
anOldDescr = anOldDescr + aDescr;
aFunction->SetDescription(anOldDescr); GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetSharedShapes(" << theShape1 << ", "
<< theShape2 << ", " << theShapeType << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; 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 * GetShapesOnPlane
@ -1102,6 +1021,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan
Handle(GEOM_Object) anObj; Handle(GEOM_Object) anObj;
Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HArray1OfInteger) anArray;
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TCollection_AsciiString anAsciiList, anEntry;
TopTools_ListIteratorOfListOfShape itSub (listSS); TopTools_ListIteratorOfListOfShape itSub (listSS);
for (int index = 1; itSub.More(); itSub.Next(), ++index) { for (int index = 1; itSub.More(); itSub.Next(), ++index) {
@ -1110,23 +1030,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan
anArray->SetValue(1, id); anArray->SetValue(1, id);
anObj = GetEngine()->AddSubShape(theShape, anArray); anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj); 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 // Make a Python command
TCollection_AsciiString anEntry, aDescr anAsciiList.Trunc(anAsciiList.Length() - 1);
("\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) + ")";
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
anOldDescr += aDescr;
aFunction->SetDescription(anOldDescr); GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetShapesOnPlane(" << theShape << ", "
<< theShapeType << ", " << theAx1 << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -1227,6 +1145,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCyli
Handle(GEOM_Object) anObj; Handle(GEOM_Object) anObj;
Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HArray1OfInteger) anArray;
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TCollection_AsciiString anAsciiList, anEntry;
TopTools_ListIteratorOfListOfShape itSub (listSS); TopTools_ListIteratorOfListOfShape itSub (listSS);
for (int index = 1; itSub.More(); itSub.Next(), ++index) { for (int index = 1; itSub.More(); itSub.Next(), ++index) {
@ -1235,24 +1154,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCyli
anArray->SetValue(1, id); anArray->SetValue(1, id);
anObj = GetEngine()->AddSubShape(theShape, anArray); anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj); 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 // Make a Python command
TCollection_AsciiString anEntry, aDescr anAsciiList.Trunc(anAsciiList.Length() - 1);
("\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) + ")";
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
anOldDescr += aDescr;
aFunction->SetDescription(anOldDescr); GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetShapesOnCylinder(" << theShape << ", " << theShapeType
<< ", " << theAxis << ", " << theRadius << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -1338,6 +1254,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnSphe
Handle(GEOM_Object) anObj; Handle(GEOM_Object) anObj;
Handle(TColStd_HArray1OfInteger) anArray; Handle(TColStd_HArray1OfInteger) anArray;
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TCollection_AsciiString anAsciiList, anEntry;
TopTools_ListIteratorOfListOfShape itSub (listSS); TopTools_ListIteratorOfListOfShape itSub (listSS);
for (int index = 1; itSub.More(); itSub.Next(), ++index) { for (int index = 1; itSub.More(); itSub.Next(), ++index) {
@ -1346,24 +1263,21 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnSphe
anArray->SetValue(1, id); anArray->SetValue(1, id);
anObj = GetEngine()->AddSubShape(theShape, anArray); anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj); 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 // Make a Python command
TCollection_AsciiString anEntry, aDescr anAsciiList.Trunc(anAsciiList.Length() - 1);
("\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) + ")";
TCollection_AsciiString anOldDescr = aFunction->GetDescription(); Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
anOldDescr += aDescr;
aFunction->SetDescription(anOldDescr); GEOM::TPythonDump(aFunction) << "[" << anAsciiList.ToCString()
<< "] = geompy.GetShapesOnSphere(" << theShape << ", " << theShapeType
<< ", " << theCenter << ", " << theRadius << ", " << theState << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
@ -1481,17 +1395,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace
} }
//Make a Python command //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); Handle(GEOM_Function) aFunction = aResult->GetFunction(1);
aFunction->SetDescription(aDescr);
GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetInPlace("
<< theShapeWhere << ", " << theShapeWhat << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aResult; return aResult;

View File

@ -12,6 +12,7 @@ using namespace std;
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMImpl_TranslateDriver.hxx" #include "GEOMImpl_TranslateDriver.hxx"
#include "GEOMImpl_MirrorDriver.hxx" #include "GEOMImpl_MirrorDriver.hxx"
@ -101,15 +102,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -158,14 +152,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateDXDYDZ("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
aDescr += (anEntry+" = geompy.TrsfOp.TranslateDXDYDZ(");
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theX)+", ");
aDescr += (TCollection_AsciiString(theY)+", ");
aDescr += (TCollection_AsciiString(theZ)+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -217,16 +205,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -277,15 +257,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -336,13 +309,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << theVector << ")";
aDescr += (anEntry+" = geompy.TrsfOp.TranslateVector(");
aDescr += (anEntry+", ");
TDF_Tool::Entry(theVector->GetEntry(), anEntry);
aDescr += (anEntry+") ");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -392,14 +360,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theVector << ")";
aDescr += (anEntry+" = geompy.MakeTranslationVector(");
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry+", ");
TDF_Tool::Entry(theVector->GetEntry(), anEntry);
aDescr += (anEntry+")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -451,17 +413,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -520,21 +473,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Obje
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
aDescr += (anEntry+" = geompy.MakeMultiTranslation2D("); << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -585,13 +526,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << thePlane << ")";
aDescr += (anEntry + " = geompy.TrsfOp.MirrorPlane(");
aDescr += (anEntry + ", ");
TDF_Tool::Entry(thePlane->GetEntry(), anEntry);
aDescr += (anEntry + ") ");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -640,14 +576,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << thePlane << ")";
aDescr += (anEntry + " = geompy.MakeMirrorByPlane(");
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry + ", ");
TDF_Tool::Entry(thePlane->GetEntry(), anEntry);
aDescr += (anEntry + ")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -697,13 +627,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << thePoint << ")";
aDescr += (anEntry + " = geompy.TrsfOp.MirrorPoint(");
aDescr += (anEntry + ", ");
TDF_Tool::Entry(thePoint->GetEntry(), anEntry);
aDescr += (anEntry + ") ");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return NULL; return NULL;
@ -752,14 +677,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << thePoint << ")";
aDescr += (anEntry + " = geompy.MakeMirrorByPoint(");
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry + ", ");
TDF_Tool::Entry(thePoint->GetEntry(), anEntry);
aDescr += (anEntry + ")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -809,13 +728,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << theAxis << ")";
aDescr += (anEntry + " = geompy.TrsfOp.MirrorAxis(");
aDescr += (anEntry + ", ");
TDF_Tool::Entry(theAxis->GetEntry(), anEntry);
aDescr += (anEntry + ") ");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return NULL; return NULL;
@ -864,14 +778,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theAxis << ")";
aDescr += (anEntry + " = geompy.MakeMirrorByAxis(");
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry + ", ");
TDF_Tool::Entry(theAxis->GetEntry(), anEntry);
aDescr += (anEntry + ")");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -919,12 +827,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << theOffset << ")";
aDescr += (anEntry+" = geompy.TrsfOp.OffsetShape(");
aDescr += (anEntry+", ");
aDescr += TCollection_AsciiString(theOffset)+")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -974,13 +878,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theOffset << ")";
aDescr += (anEntry+" = geompy.MakeOffset(");
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += TCollection_AsciiString(theOffset)+")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -1032,14 +931,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << thePoint << ", " << theFactor << ")";
aDescr += (anEntry+" = geompy.TrsfOp.ScaleShape(");
aDescr += (anEntry+", ");
TDF_Tool::Entry(thePoint->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += TCollection_AsciiString(theFactor)+")";
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -1090,15 +983,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << thePoint << ", " << theFactor << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -1150,15 +1036,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -1209,16 +1088,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
TDF_Tool::Entry(aCopy->GetEntry(), anEntry); << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -1270,14 +1141,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
aDescr += (anEntry+" = geompy.TrsfOp.Rotate(");
aDescr += (anEntry+", ");
TDF_Tool::Entry(theAxis->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theAngle)+") ");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return theObject; return theObject;
@ -1326,15 +1191,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Objec
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
TDF_Tool::Entry(aCopy->GetEntry(), aDescr); << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -1385,14 +1243,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object)
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << theAxis << ", " << theNbTimes << ")";
aDescr += (anEntry+" = geompy.MultiRotate1D(");
aDescr += (anEntry+", ");
TDF_Tool::Entry(theAxis->GetEntry(), anEntry);
aDescr += (anEntry+", ");
aDescr += (TCollection_AsciiString(theNbTimes)+") ");
aFunction->SetDescription(aDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;
@ -1449,17 +1301,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object)
} }
//Make a Python command //Make a Python command
TCollection_AsciiString anEntry, aDescr; GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
TDF_Tool::Entry(theObject->GetEntry(), anEntry); << theObject << ", " << theAxis << ", " << theAngle << ", "
aDescr += (anEntry+" = geompy.MultiRotate2D("); << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
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);
SetErrorCode(OK); SetErrorCode(OK);
return aCopy; return aCopy;