X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM%2FGEOM_Engine.cxx;h=90faf13feca75632a95730280e45cb12ef2e8fb5;hb=8af6f2a74ecd53c356e81e728d91af4d865b8261;hp=f7ae8fc8e82a29a7217fa2d1dbebecc175e989ee;hpb=4d8c0024728a305fb2858aa407bb87418d1ec47c;p=modules%2Fgeom.git diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index f7ae8fc8e..90faf13fe 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -34,8 +34,6 @@ #include "GEOM_SubShapeDriver.hxx" #include "Sketcher_Profile.hxx" -#include - #include "utilities.h" #include @@ -66,11 +64,9 @@ #include -#if OCC_VERSION_LARGE > 0x07000000 #include #include #include -#endif #include @@ -90,6 +86,14 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif +// VSR 29/08/2017: 0023327, 0023428: eliminate unnecessary lines in Python dump +// Next macro, when defined, causes appearing of SubShapeAllIDs(), SubShapeAllSortedIDs(), GetSameIDs() +// and other such commands in Python dump. +// See also GEOMImpl_IShapesOperations.cxx. +// --------------------------------------- +// #define DUMP_SUBSHAPE_IDS +// --------------------------------------- + typedef std::map< TCollection_AsciiString, TCollection_AsciiString > TSting2StringMap; typedef std::map< TCollection_AsciiString, TObjectData > TSting2ObjDataMap; typedef std::map< TCollection_AsciiString, TObjectData* > TSting2ObjDataPtrMap; @@ -165,6 +169,8 @@ static TCollection_AsciiString GetPublishCommands const TIntToListIntMap &theMapRefs, std::set< int > &thePublished); +void Prettify(TCollection_AsciiString& theScript); + //================================================================================ /*! * \brief Fix up the name of python variable @@ -231,11 +237,9 @@ GEOM_Engine::GEOM_Engine() TFunction_DriverTable::Get()->AddDriver(GEOM_Object::GetSubShapeID(), new GEOM_SubShapeDriver()); _OCAFApp = new GEOM_Application(); -#if OCC_VERSION_LARGE > 0x07000000 _OCAFApp->DefineFormat("SALOME_GEOM", "GEOM Document Version 1.0", "sgd", new StdDrivers_DocumentRetrievalDriver, 0); BinDrivers::DefineFormat(_OCAFApp); -#endif _UndoLimit = 0; } @@ -275,11 +279,7 @@ Handle(TDocStd_Document) GEOM_Engine::GetDocument(int theDocID, bool force) aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID)); } else if (force) { -#if OCC_VERSION_MAJOR > 6 _OCAFApp->NewDocument("BinOcaf", aDoc); -#else - _OCAFApp->NewDocument("SALOME_GEOM", aDoc); -#endif aDoc->SetUndoLimit(_UndoLimit); _mapIDDocument.Bind(theDocID, aDoc); TDataStd_Integer::Set(aDoc->Main(), theDocID); @@ -440,9 +440,8 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) th return NULL; } } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - MESSAGE("GEOM_Engine::AddSubShape Error: " << aFail->GetMessageString()); + catch (Standard_Failure& aFail) { + MESSAGE("GEOM_Engine::AddSubShape Error: " << aFail.GetMessageString()); return NULL; } @@ -578,12 +577,10 @@ bool GEOM_Engine::Load(int theDocID, const char* theFileName) return false; } -#if OCC_VERSION_MAJOR > 6 // Replace old document format by the new one. if (aDoc->StorageFormat().IsEqual("SALOME_GEOM")) { aDoc->ChangeStorageFormat("BinOcaf"); } -#endif aDoc->SetUndoLimit(_UndoLimit); @@ -869,6 +866,11 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, aScript.Insert( posToInsertGlobalVars, globalVars ); } + // VSR 29/08/2017: 0023327, 0023428: eliminate unnecessary lines in Python dump +#ifndef DUMP_SUBSHAPE_IDS + Prettify(aScript); +#endif + return aScript; } @@ -1918,6 +1920,43 @@ TCollection_AsciiString GetPublishCommands return aResult; } +void Prettify(TCollection_AsciiString& theScript) +{ + TCollection_AsciiString output; + static std::list ToRemove; + if (ToRemove.empty()) { + ToRemove.push_back("geompy.SubShapeAllIDs"); + ToRemove.push_back("geompy.SubShapeAllSortedCentresIDs"); + ToRemove.push_back("geompy.SubShapeAllSortedIDs"); + ToRemove.push_back("geompy.GetFreeFacesIDs"); + ToRemove.push_back("geompy.GetShapesOnBoxIDs"); + ToRemove.push_back("geompy.GetShapesOnShapeIDs"); + ToRemove.push_back("geompy.GetShapesOnPlaneIDs"); + ToRemove.push_back("geompy.GetShapesOnPlaneWithLocationIDs"); + ToRemove.push_back("geompy.GetShapesOnCylinderIDs"); + ToRemove.push_back("geompy.GetShapesOnCylinderWithLocationIDs"); + ToRemove.push_back("geompy.GetShapesOnSphereIDs"); + ToRemove.push_back("geompy.GetShapesOnQuadrangleIDs"); + ToRemove.push_back("geompy.GetSameIDs"); + } + + int start = 1; + while (start <= theScript.Length()) { + int end = theScript.Location("\n", start, theScript.Length()); + if (end == -1) end = theScript.Length(); + TCollection_AsciiString line = theScript.SubString(start, end); + bool found = false; + for (std::list::const_iterator it = ToRemove.begin(); it != ToRemove.end() && !found; ++it) + found = line.Search( *it ) != -1; + if (!found) + output += line; + start = end + 1; + } + theScript = output; + + //OK @@@@@@@@@@@@@@@@@@@@@@@@@@@ +} + //================================================================================ /*! * \brief Constructor