-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 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 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.
+// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT
#include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx"
#include "GEOM_PythonDump.hxx"
+#include <Basics_OCCTVersion.hxx>
+
#include "utilities.h"
#include <Basics_Utils.hxx>
#include <TDataStd_ChildNodeIterator.hxx>
#include <TFunction_Driver.hxx>
#include <TFunction_DriverTable.hxx>
-#include <TDataStd_HArray1OfByte.hxx>
#include <TDataStd_ByteArray.hxx>
#include <TDataStd_UAttribute.hxx>
#include <TDF_ChildIterator.hxx>
#include <TColStd_MapOfTransient.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+#include <TColStd_HArray1OfByte.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
+#else
+#include <TDataStd_HArray1OfByte.hxx>
#include <Interface_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
+#endif
+
#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
#include <set>
TSting2ObjDataMap& theEntry2ObjData,
const TSting2ObjDataPtrMap& theStEntry2ObjDataPtr,
Resource_DataMapOfAsciiStringAsciiString& theNameToEntry,
- TSting2StringMap& theEntryToCmdMap,
+ std::map< int, TCollection_AsciiString >& theEntryToCmdMap,
std::set<TCollection_AsciiString>& theMapOfPublished);
namespace
GEOM_Engine::GEOM_Engine()
{
TFunction_DriverTable::Get()->AddDriver(GEOM_Object::GetSubShapeID(), new GEOM_SubShapeDriver());
-
+
_OCAFApp = new GEOM_Application();
_UndoLimit = 10;
}
RemoveObject(*objit);
//Close all documents not closed
- for(Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr(_mapIDDocument); anItr.More(); anItr.Next())
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ TColStd_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
+#else
+ Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
+#endif
+ for (; anItr.More(); anItr.Next())
Close(anItr.Key());
_mapIDDocument.Clear();
//=============================================================================
int GEOM_Engine::GetDocID(Handle(TDocStd_Document) theDocument)
{
- if(theDocument.IsNull()) return -1;
- for(Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr(_mapIDDocument); anItr.More(); anItr.Next())
- if(anItr.Value() == theDocument) return anItr.Key();
+ if (theDocument.IsNull()) return -1;
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ TColStd_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
+#else
+ Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr (_mapIDDocument);
+#endif
+ for (; anItr.More(); anItr.Next())
+ if (anItr.Value() == theDocument) return anItr.Key();
return -1;
-
}
//=============================================================================
aSSI.SetIndices(theIndices);
try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
GEOM_Solver aSolver (GEOM_Engine::GetEngine());
if (_objects.IsBound(anID)) _objects.UnBind(anID);
_objects.Bind(anID, anObject);
- // Put this subshape in the list of subshapes of theMainShape
+ // Put this sub-shape in the list of sub-shapes of theMainShape
aMainShape->AddSubShapeReference(aFunction);
GEOM::TPythonDump pd (aFunction);
TCollection_AsciiString anID = BuildIDFromObject(theObject);
if (_objects.IsBound(anID)) _objects.UnBind(anID);
- // If subshape, remove it from the list of subshapes of its main shape
+ // If sub-shape, remove it from the list of sub-shapes of its main shape
if (!theObject->IsMainShape()) {
Handle(GEOM_Function) aFunction = theObject->GetFunction(1);
GEOM_ISubShape aSSI (aFunction);
bool GEOM_Engine::Load(int theDocID, char* theFileName)
{
Handle(TDocStd_Document) aDoc;
- if(_OCAFApp->Open(theFileName, aDoc) != CDF_RS_OK) {
+#if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
+ if (_OCAFApp->Open(theFileName, aDoc) != PCDM_RS_OK) {
+#else
+ if (_OCAFApp->Open(theFileName, aDoc) != CDF_RS_OK) {
+#endif
return false;
}
aScript += "import SALOMEDS\n\n";
if( isMultiFile )
aScript += "def RebuildData(theStudy):";
- else
- aScript += "theStudy = salome.myStudy";
+
aScript += "\n\tgeompy.init_geom(theStudy)\n";
AddTextures(theDocID, aScript);
continue;
// add function description before dump
if (!aCurScript.IsEmpty())
+ {
+ if ( aFunction->GetDriverGUID() == GEOM_Object::GetSubShapeID() )
+ // avoid repeated SubShape...() command at the end
+ if (aFuncScript.Location( aCurScript,
+ aFuncScript.Length() - aCurScript.Length(),
+ aFuncScript.Length()))
+ continue;
aFuncScript += aCurScript;
+ }
if (isDumpCollected ) {
// Replace entries by the names
ReplaceEntriesByNames( aFuncScript, aEntry2ObjData, isPublished,
aObjListToPublish, objectCounter, aNameToEntry );
// publish collected objects
- TSting2StringMap anEntryToCmdMap; // sort publishing commands by study entry
+ std::map< int, TCollection_AsciiString > anEntryToCmdMap; // sort publishing commands by study entry
int i = 1, n = aObjListToPublish.Length();
for ( ; i <= n; i++ )
{
aNameToEntry, anEntryToCmdMap, anIgnoreObjMap );
}
// add publishing commands to the script
- TSting2StringMap::iterator anEntryToCmd = anEntryToCmdMap.begin();
+ std::map< int, TCollection_AsciiString >::iterator anEntryToCmd = anEntryToCmdMap.begin();
for ( ; anEntryToCmd != anEntryToCmdMap.end(); ++anEntryToCmd )
aFuncScript += anEntryToCmd->second;
TSting2ObjDataPtrMap::iterator aStEntry2ObjDataPtrIt;
if ( isPublished )
{
- TSting2StringMap anEntryToCmdMap; // sort publishing commands by object entry
+ std::map< int, TCollection_AsciiString > anEntryToCmdMap; // sort publishing commands by object entry
for (aStEntry2ObjDataPtrIt = aStEntry2ObjDataPtr.begin();
aStEntry2ObjDataPtrIt != aStEntry2ObjDataPtr.end();
aNameToEntry, anEntryToCmdMap, anIgnoreObjMap );
}
// add publishing commands to the script
- TSting2StringMap::iterator anEntryToCmd = anEntryToCmdMap.begin();
+ std::map< int, TCollection_AsciiString >::iterator anEntryToCmd = anEntryToCmdMap.begin();
for ( ; anEntryToCmd != anEntryToCmdMap.end(); ++anEntryToCmd )
aScript += anEntryToCmd->second;
}
+ //RNV: issue 16219: EDF PAL 469: "RemoveFromStudy" Function
+ //Add unpublish command if need
+ TCollection_AsciiString unpublishCmd("\n");
+ if(isMultiFile)
+ unpublishCmd += "\t";
+ unpublishCmd += "geompy.hideInStudy(";
+
+ for (aStEntry2ObjDataPtrIt = aStEntry2ObjDataPtr.begin();
+ aStEntry2ObjDataPtrIt != aStEntry2ObjDataPtr.end();
+ ++aStEntry2ObjDataPtrIt)
+ {
+ TObjectData* data = aStEntry2ObjDataPtrIt->second;
+ if ( data->_unpublished && !data->_pyName.IsEmpty() ) {
+ aScript += unpublishCmd + data->_pyName + ")";
+ }
+ }
+
//aScript += "\n\tpass\n";
aScript += "\n";
aValidScript = true;
#define TEXTURE_LABEL_DATA 5
int GEOM_Engine::addTexture(int theDocID, int theWidth, int theHeight,
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ const Handle(TColStd_HArray1OfByte)& theTexture,
+#else
const Handle(TDataStd_HArray1OfByte)& theTexture,
+#endif
const TCollection_AsciiString& theFileName)
{
Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
return aTextureID;
}
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+Handle(TColStd_HArray1OfByte) GEOM_Engine::getTexture(int theDocID, int theTextureID,
+#else
Handle(TDataStd_HArray1OfByte) GEOM_Engine::getTexture(int theDocID, int theTextureID,
- int& theWidth, int& theHeight,
- TCollection_AsciiString& theFileName)
+#endif
+ int& theWidth, int& theHeight,
+ TCollection_AsciiString& theFileName)
{
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ Handle(TColStd_HArray1OfByte) anArray;
+#else
Handle(TDataStd_HArray1OfByte) anArray;
+#endif
theWidth = theHeight = 0;
Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
else if(i == aTotalNbParams)
{
aStartPos = aCommand.Location(i-1, COMMA, 1, aCommand.Length()) + 2;
- aEndPos = aCommand.Location(C_BRACKET, 1, aCommand.Length());
+ aEndPos = aCommand.Location(C_BRACKET, aStartPos , aCommand.Length());
}
//Replace other parameters (bettwen two ',' characters)
else if(i != aFirstParam && i != aTotalNbParams )
else
aEndParamPos = aSection.Length() + 1;
+ if(MYDEBUG)
+ cout<<"aParamIndex: "<<aParamIndex<<" aStartParamPos: " <<aStartParamPos<<" aEndParamPos: "<<aEndParamPos<<endl;
+
+ if ( aStartParamPos == aEndParamPos)
+ continue;
+
aParameter = aSection.SubString(aStartParamPos, aEndParamPos-1);
if(MYDEBUG)
cout<<"aParameter: "<<aParameter<<endl;
healPyName( data._pyName, anEntry, aNameToEntry);
}
else {
- do {
- data._pyName = aBaseName + TCollection_AsciiString(++objectCounter);
- } while(aNameToEntry.IsBound(data._pyName));
+ do {
+ data._pyName = aBaseName + TCollection_AsciiString(++objectCounter);
+ } while(aNameToEntry.IsBound(data._pyName));
}
}
}
}
-static TCollection_AsciiString pack_data(const Handle(TDataStd_HArray1OfByte)& aData )
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+static TCollection_AsciiString pack_data (const Handle(TColStd_HArray1OfByte)& aData)
+#else
+static TCollection_AsciiString pack_data (const Handle(TDataStd_HArray1OfByte)& aData)
+#endif
{
TCollection_AsciiString stream;
if (!aData.IsNull()) {
if (*it <= 0) continue;
Standard_Integer aWidth, aHeight;
TCollection_AsciiString aFileName;
- Handle(TDataStd_HArray1OfByte) aTexture = engine->getTexture(theDocID, *it, aWidth, aHeight, aFileName);
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ Handle(TColStd_HArray1OfByte) aTexture =
+#else
+ Handle(TDataStd_HArray1OfByte) aTexture =
+#endif
+ engine->getTexture(theDocID, *it, aWidth, aHeight, aFileName);
if (aWidth > 0 && aHeight > 0 && !aTexture.IsNull() && aTexture->Length() > 0 ) {
TCollection_AsciiString aCommand = "\n\t";
aCommand += "texture_map["; aCommand += *it; aCommand += "] = ";
TSting2ObjDataMap& theEntry2ObjData,
const TSting2ObjDataPtrMap& theStEntry2ObjDataPtr,
Resource_DataMapOfAsciiStringAsciiString& theNameToEntry,
- TSting2StringMap& theEntryToCmdMap,
+ std::map< int, TCollection_AsciiString >& theEntryToCmdMap,
std::set< TCollection_AsciiString>& theIgnoreMap)
{
if ( theObjectData._studyEntry.IsEmpty() )
if ( stEntry2DataPtr != theStEntry2ObjDataPtr.end() )
aFatherData = stEntry2DataPtr->second;
+ const int geomObjDepth = 3;
+
// treat multiply published object
if ( theObjectData._pyName.IsEmpty() )
{
aCreationCommand += theObjectData._pyName + " = " + data0._pyName;
// store aCreationCommand before publishing commands
- TCollection_AsciiString mapKey(" ");
- mapKey += theObjectData._studyEntry;
- theEntryToCmdMap.insert( std::make_pair( mapKey, aCreationCommand ));
+ int tag = theObjectData._entry.Token( ":", geomObjDepth ).IntegerValue();
+ theEntryToCmdMap.insert( std::make_pair( tag + 2*theEntry2ObjData.size(), aCreationCommand ));
}
// make a command
aCommand += theObjectData._pyName + ", '" + theObjectData._name + "' )";
// bind a command to the study entry
- theEntryToCmdMap.insert( std::make_pair( theObjectData._studyEntry, aCommand ));
+ int tag = theObjectData._entry.Token( ":", geomObjDepth ).IntegerValue();
+ theEntryToCmdMap.insert( std::make_pair( tag, aCommand ));
theObjectData._studyEntry.Clear(); // not to publish any more
}