From a25fd8351962cfb6b28080c844f43852d7f00560 Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 8 Dec 2006 15:40:42 +0000 Subject: [PATCH] PAL14122: EDF307: GetInPlace --> COMM_FAILURE. Use new method GEOMAlgo_BuilderShape::ImagesResult() to obtain partition history. --- src/GEOM/GEOM_Function.cxx | 97 ++++++++++---- src/GEOM/GEOM_Object.cxx | 116 +++++++++++----- src/GEOM/GEOM_Object.hxx | 139 ++++++++++---------- src/GEOMBase/GEOMBase.cxx | 30 +++-- src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 12 +- src/GEOMImpl/GEOMImpl_PartitionDriver.cxx | 12 +- 6 files changed, 265 insertions(+), 141 deletions(-) diff --git a/src/GEOM/GEOM_Function.cxx b/src/GEOM/GEOM_Function.cxx index 03cd586af..b3166ad0b 100644 --- a/src/GEOM/GEOM_Function.cxx +++ b/src/GEOM/GEOM_Function.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 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 +// 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 +// +// 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 +// 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 @@ -23,6 +23,7 @@ #include #include #include +#include #include "utilities.h" @@ -161,30 +162,58 @@ TopoDS_Shape GEOM_Function::GetValue() TopoDS_Shape aShape; TDF_Label aLabel = GetOwnerEntry(); - if(aLabel.IsRoot()) return aShape; + if (aLabel.IsRoot()) return aShape; Handle(GEOM_Object) anObject = GEOM_Object::GetObject(aLabel); - if(anObject.IsNull()) return aShape; - if(!anObject->IsMainShape()) { - try { + if (anObject.IsNull()) return aShape; + + if (!anObject->IsMainShape()) { + bool isResult = false; + TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL); + if (!aResultLabel.IsNull()) { + Handle(TNaming_NamedShape) aNS; + if (aResultLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + isResult = true; + } + + // compare tics + if (isResult) { + // tic of this + Standard_Integer aTic = anObject->GetTic(); + + // tic of main shape + GEOM_ISubShape aCI (this); + TDF_Label aLabelObjMainSh = aCI.GetMainShape()->GetOwnerEntry(); + if (aLabelObjMainSh.IsRoot()) return aShape; + Handle(GEOM_Object) anObjMainSh = GEOM_Object::GetObject(aLabelObjMainSh); + if (anObjMainSh.IsNull()) return aShape; + Standard_Integer aTicMainSh = anObjMainSh->GetTic(); + + // compare + isResult = ((aTic == aTicMainSh) ? true : false); + } + + if (!isResult) { + try { #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; + OCC_CATCH_SIGNALS; #endif - GEOM_Solver aSolver(GEOM_Engine::GetEngine()); - if (!aSolver.ComputeFunction(this)) { - MESSAGE("GEOM_Object::GetValue Error : Can't build a sub shape"); - return aShape; + GEOM_Solver aSolver(GEOM_Engine::GetEngine()); + if (!aSolver.ComputeFunction(this)) { + MESSAGE("GEOM_Object::GetValue Error : Can't build a sub shape"); + return aShape; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + MESSAGE("GEOM_Function::GetValue Error: " << aFail->GetMessageString()); + return aShape; } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - MESSAGE("GEOM_Function::GetValue Error: " << aFail->GetMessageString()); - return aShape; } } TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL); Handle(TNaming_NamedShape) aNS; - if(!aResultLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; + if (!aResultLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; aShape = aNS->Get(); @@ -194,7 +223,7 @@ TopoDS_Shape GEOM_Function::GetValue() //============================================================================= /*! - * GetValue + * SetValue */ //============================================================================= void GEOM_Function::SetValue(TopoDS_Shape& theShape) @@ -205,6 +234,26 @@ void GEOM_Function::SetValue(TopoDS_Shape& theShape) aBuilder.Generated(theShape); + // synchronisation between main shape and its sub-shapes + TDF_Label aLabel = GetOwnerEntry(); + if (aLabel.IsRoot()) return; + Handle(GEOM_Object) anObject = GEOM_Object::GetObject(aLabel); + if (anObject.IsNull()) return; + if (anObject->IsMainShape()) { + // increase modifications counter of this (main) shape + anObject->IncrementTic(); + } + else { + // update modifications counter of this (sub-) shape to be the same as on main shape + GEOM_ISubShape aCI (this); + TDF_Label aLabelObjMainSh = aCI.GetMainShape()->GetOwnerEntry(); + if (aLabelObjMainSh.IsRoot()) return; + Handle(GEOM_Object) anObjMainSh = GEOM_Object::GetObject(aLabelObjMainSh); + if (anObjMainSh.IsNull()) return; + + anObject->SetTic(anObjMainSh->GetTic()); + } + _isDone = true; } diff --git a/src/GEOM/GEOM_Object.cxx b/src/GEOM/GEOM_Object.cxx index e36ddc909..b07b9d390 100644 --- a/src/GEOM/GEOM_Object.cxx +++ b/src/GEOM/GEOM_Object.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 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 +// 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 +// +// 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 +// 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 @@ -38,9 +38,10 @@ #include #include -#define TYPE 2 #define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb))) +#define TYPE_LABEL 2 #define FREE_LABEL 3 +#define TIC_LABEL 4 //======================================================================= //function : GetObjectID @@ -50,7 +51,7 @@ const Standard_GUID& GEOM_Object::GetObjectID() { static Standard_GUID anObjectID("FF1BBB01-5D14-4df2-980B-3A668264EA16"); return anObjectID; -} +} //======================================================================= //function : GetSubShapeID @@ -61,7 +62,7 @@ const Standard_GUID& GEOM_Object::GetSubShapeID() static Standard_GUID anObjectID("FF1BBB68-5D14-4df2-980B-3A668264EA16"); return anObjectID; } - + //============================================================================= /*! * GetObject @@ -79,7 +80,7 @@ Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel) Handle(TDataStd_Integer) anID; if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return NULL; - + GEOM_Engine* anEngine= GEOM_Engine::GetEngine(); if(anEngine == NULL) return NULL; @@ -107,7 +108,7 @@ Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel) // Get label of the referenced object TDF_Label aLabel = aFather->Label(); - + return GEOM_Object::GetObject(aLabel); } @@ -117,9 +118,9 @@ Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel) */ //============================================================================= GEOM_Object::GEOM_Object(TDF_Label& theEntry) -: _label(theEntry), _ior("") +: _label(theEntry), _ior("") { - if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root)) + if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root)) _root = TDataStd_TreeNode::Set(theEntry); } @@ -129,14 +130,14 @@ GEOM_Object::GEOM_Object(TDF_Label& theEntry) */ //============================================================================= GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType) -: _label(theEntry), _ior("") +: _label(theEntry), _ior("") { theEntry.ForgetAllAttributes(Standard_True); - if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root)) + if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root)) _root = TDataStd_TreeNode::Set(theEntry); - TDataStd_Integer::Set(theEntry.FindChild(TYPE), theType); + TDataStd_Integer::Set(theEntry.FindChild(TYPE_LABEL), theType); TDataStd_UAttribute::Set(theEntry, GetObjectID()); } @@ -149,8 +150,8 @@ GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType) int GEOM_Object::GetType() { Handle(TDataStd_Integer) aType; - if(!_label.FindChild(TYPE).FindAttribute(TDataStd_Integer::GetID(), aType)) return -1; - + if(!_label.FindChild(TYPE_LABEL).FindAttribute(TDataStd_Integer::GetID(), aType)) return -1; + return aType->Get(); } @@ -161,8 +162,57 @@ int GEOM_Object::GetType() //============================================================================= void GEOM_Object::SetType(int theType) { - TDataStd_Integer::Set(_label.FindChild(TYPE), theType); - return; + TDataStd_Integer::Set(_label.FindChild(TYPE_LABEL), theType); +} + + +//============================================================================= +/*! + * Returns modifications counter of this object. + * Comparing this value with modifications counters of argument objects + * (on which this object depends) we decide whether this object needs to be updated. + */ +//============================================================================= +int GEOM_Object::GetTic() +{ + Handle(TDataStd_Integer) aTicAttr; + if (!_label.FindChild(TIC_LABEL).FindAttribute(TDataStd_Integer::GetID(), aTicAttr)) + return 0; + + return aTicAttr->Get(); +} + +//============================================================================= +/*! + * Set another value of modifications counter. + * + * Use this method to update modifications counter of dependent object + * to be equal to modifications counter of its argument. + * This is commonly done in GEOM_Function::GetValue() + */ +//============================================================================= +void GEOM_Object::SetTic(int theTic) +{ + TDataStd_Integer::Set(_label.FindChild(TIC_LABEL), theTic); +} + +//============================================================================= +/*! + * Increment modifications counter to mark this object as modified. + * + * Commonly called from GEOM_Function::SetValue() + */ +//============================================================================= +void GEOM_Object::IncrementTic() +{ + TDF_Label aTicLabel = _label.FindChild(TIC_LABEL); + + Standard_Integer aTic = 0; + Handle(TDataStd_Integer) aTicAttr; + if (aTicLabel.FindAttribute(TDataStd_Integer::GetID(), aTicAttr)) + aTic = aTicAttr->Get(); + + TDataStd_Integer::Set(aTicLabel, aTic + 1); } @@ -178,7 +228,7 @@ int GEOM_Object::GetDocID() Handle(TDataStd_Integer) anID; if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return -1; - + return anID->Get(); } @@ -196,7 +246,7 @@ TopoDS_Shape GEOM_Object::GetValue() if (!aFunction.IsNull()) aShape = aFunction->GetValue(); - + return aShape; } @@ -219,7 +269,7 @@ char* GEOM_Object::GetName() { Handle(TDataStd_Name) aNameAttr; if(!_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) return NULL; - + TCollection_AsciiString aName(aNameAttr->Get()); return aName.ToCString(); } @@ -255,7 +305,7 @@ TCollection_AsciiString GEOM_Object::GetAuxData() /*! * IsSubShape */ -//============================================================================= +//============================================================================= bool GEOM_Object::IsMainShape() { Handle(GEOM_Function) aFunction = GetFunction(1); @@ -317,7 +367,7 @@ Handle(GEOM_Function) GEOM_Object::GetLastFunction() { Standard_Integer nb = GetNbFunctions(); if(nb) return GetFunction(nb); - + return NULL; } @@ -340,12 +390,12 @@ Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetAllDependency() } Standard_Integer aLength = aSeq.Length(); - if(aLength > 0) { + if(aLength > 0) { anArray = new TColStd_HSequenceOfTransient; for(Standard_Integer j =1; j<=aLength; j++) anArray->Append(GetReferencedObject(aSeq(j))); } - + return anArray; } @@ -385,15 +435,15 @@ TDF_Label GEOM_Object::GetFreeLabel() //======================================================================= //function : GEOM_Object_Type_ //purpose : -//======================================================================= +//======================================================================= Standard_EXPORT Handle_Standard_Type& GEOM_Object_Type_() { static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient); if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); - + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOM_Object", @@ -407,7 +457,7 @@ Standard_EXPORT Handle_Standard_Type& GEOM_Object_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= +//======================================================================= const Handle(GEOM_Object) Handle(GEOM_Object)::DownCast(const Handle(Standard_Transient)& AnObject) { diff --git a/src/GEOM/GEOM_Object.hxx b/src/GEOM/GEOM_Object.hxx index 414c61af2..154798f65 100644 --- a/src/GEOM/GEOM_Object.hxx +++ b/src/GEOM/GEOM_Object.hxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 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 +// 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 +// +// 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 +// 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 @@ -34,10 +34,10 @@ #endif #ifndef _Handle_MMgt_TShared_HeaderFile #include -#endif +#endif #ifndef _MMgt_TShared_HeaderFile #include -#endif +#endif #ifndef _Standard_GUID_HeaderFile #include #endif @@ -65,25 +65,25 @@ Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object); class Handle(GEOM_Object) : public Handle(MMgt_TShared) { public: - inline void* operator new(size_t,void* anAddress) + inline void* operator new(size_t,void* anAddress) { return anAddress; } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); + inline void* operator new(size_t size) + { + return Standard::Allocate(size); } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); } - Handle(GEOM_Object)():Handle(MMgt_TShared)() {} - Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle) + Handle(GEOM_Object)():Handle(MMgt_TShared)() {} + Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle) { } - Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) { } @@ -99,55 +99,54 @@ class Handle(GEOM_Object) : public Handle(MMgt_TShared) { return *this; } - GEOM_Object* operator->() + GEOM_Object* operator->() { return (GEOM_Object *)ControlAccess(); } - GEOM_Object* operator->() const + GEOM_Object* operator->() const { return (GEOM_Object *)ControlAccess(); } Standard_EXPORT ~Handle(GEOM_Object)() {}; - + Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject); }; - #include #include #include "GEOM_Function.hxx" #include "GEOM_Engine.hxx" - class GEOM_Object : public MMgt_TShared { - friend class GEOM_Engine; + friend class GEOM_Engine; public: - inline void* operator new(size_t,void* anAddress) + inline void* operator new(size_t,void* anAddress) { return anAddress; } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); + inline void* operator new(size_t size) + { + return Standard::Allocate(size); } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); } - + // Type management // Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_(); Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOM_Object) ; } - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); } + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const + { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); } private: - GEOM_Object(TDF_Label& theLabel); + GEOM_Object(TDF_Label& theLabel); public: Standard_EXPORT GEOM_Object(TDF_Label& theEntry, int theType); @@ -166,25 +165,30 @@ class GEOM_Object : public MMgt_TShared Standard_EXPORT static const Standard_GUID& GetSubShapeID(); //########################################################### - //Access to properties + //Access to properties //########################################################### //Returns a TreeNode that presents a root of a function tree for this GEOM_Object - Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; } - + Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; } + //Returns a label of this GEOM_Object Standard_EXPORT TDF_Label GetEntry() { return _label; } - + //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...) - Standard_EXPORT int GetType(); + Standard_EXPORT int GetType(); //Sets the type of this GEOM_Object Standard_EXPORT void SetType(int theType); - + + //Modifications counter management + Standard_EXPORT int GetTic(); + Standard_EXPORT void SetTic(int theTic); + Standard_EXPORT void IncrementTic(); + //Returns an ID of the OCAF document where this GEOM_Object is stored - Standard_EXPORT int GetDocID(); + Standard_EXPORT int GetDocID(); - //Returns a value (as TopoDS_Shape) of this GEOM_Object + //Returns a value (as TopoDS_Shape) of this GEOM_Object Standard_EXPORT TopoDS_Shape GetValue(); //Sets a name of this GEOM_Object @@ -199,36 +203,37 @@ class GEOM_Object : public MMgt_TShared //Returns an auxiliary data Standard_EXPORT TCollection_AsciiString GetAuxData(); - //########################################################### + //########################################################### // Sub shape methods //########################################################### - + //Returns false if the object is a sub shape of another object Standard_EXPORT bool IsMainShape(); - //########################################################### - // CORBA related methods - //########################################################### - - //Sets an IOR of CORBA GEOM_Object_i which refers to this object - Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; } + //########################################################### + // CORBA related methods + //########################################################### + + //Sets an IOR of CORBA GEOM_Object_i which refers to this object + Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; } - //Returns an IOR of CORBA GEOM_Object_i which refers to this object - Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; } + //Returns an IOR of CORBA GEOM_Object_i which refers to this object + Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; } //########################################################### //Functions methods //########################################################### - //Adds a function with a driver GUID = theGUID and a type theFunctionType to the function tree of this GEOM_Object + //Adds a function with a driver GUID = theGUID and a type theFunctionType + //to the function tree of this GEOM_Object Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType); - + //Returns a number of functions of this GEOM_Object - Standard_EXPORT int GetNbFunctions(); - + Standard_EXPORT int GetNbFunctions(); + //Returns a function with given number theFunctionNumber Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber); - + //Return the last function of this GEOM_Object Standard_EXPORT Handle(GEOM_Function) GetLastFunction(); @@ -238,19 +243,17 @@ class GEOM_Object : public MMgt_TShared //Returns the dependencies of the last function Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency(); - //########################################################### - // Internal methods - //########################################################### + //########################################################### + // Internal methods + //########################################################### - //Returns a label which could be used to store some additional data - Standard_EXPORT TDF_Label GetFreeLabel(); - + //Returns a label which could be used to store some additional data + Standard_EXPORT TDF_Label GetFreeLabel(); private: - Handle(TDataStd_TreeNode) _root; - TDF_Label _label; - TCollection_AsciiString _ior; + TDF_Label _label; + TCollection_AsciiString _ior; }; #endif diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index a716f062a..83dc547b7 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -82,6 +82,8 @@ #include #include +#include + #include "GEOMImpl_Types.hxx" using namespace std; @@ -849,18 +851,30 @@ QString GEOMBase::GetDefaultName(const QString& theOperation) { QString aName = ""; - SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + // collect all object names of GEOM component + SalomeApp_Study* appStudy = + dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); if ( !appStudy ) return aName; _PTR(Study) aStudy = appStudy->studyDS(); - int aNumber = 0; - _PTR(SObject) obj; - do - { - aName = theOperation+"_"+QString::number(++aNumber); - obj = aStudy->FindObject(aName.latin1()); + std::set aSet; + _PTR(SComponent) aGeomCompo (aStudy->FindComponent("GEOM")); + if (aGeomCompo) { + _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeomCompo)); + _PTR(SObject) obj; + for (it->InitEx(true); it->More(); it->Next()) { + obj = it->Value(); + aSet.insert(obj->GetName()); } - while (obj); + } + + // build a unique name + int aNumber = 0; + bool isUnique = false; + while (!isUnique) { + aName = theOperation + "_" + QString::number(++aNumber); + isUnique = (aSet.count(aName.latin1()) == 0); + } return aName; } diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 199f2c0c5..c3f2afce2 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -608,12 +608,14 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode anArray = new TColStd_HArray1OfInteger(1,1); anArray->SetValue(1, anIndices.FindIndex(aValue)); anObj = GetEngine()->AddSubShape(theShape, anArray); - aSeq->Append(anObj); + if (!anObj.IsNull()) { + aSeq->Append(anObj); - // for python command - TDF_Tool::Entry(anObj->GetEntry(), anEntry); - anAsciiList += anEntry; - anAsciiList += ","; + // for python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; + } } //Make a Python command diff --git a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx index ffa8e2b71..db6b6e381 100644 --- a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx @@ -209,6 +209,9 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const TopTools_IndexedMapOfShape aResIndices; TopExp::MapShapes(aShape, aResIndices); + // Map: source_shape/images of source_shape in Result + const TopTools_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult(); + // history for all argument shapes TDF_LabelSequence aLabelSeq; aFunction->GetDependency(aLabelSeq); @@ -231,7 +234,9 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) { TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie); - const TopTools_ListOfShape& aModified = PS.Modified(anEntity); + if (!aMR.Contains(anEntity)) continue; + + const TopTools_ListOfShape& aModified = aMR.FindFromKey(anEntity); Standard_Integer nbModified = aModified.Extent(); if (nbModified > 0) { @@ -239,10 +244,11 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const Handle(TDataStd_IntegerArray) anAttr = TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified); + int ih = 1; TopTools_ListIteratorOfListOfShape itM (aModified); - for (int im = 1; itM.More(); itM.Next(), ++im) { + for (; itM.More(); itM.Next(), ++ih) { int id = aResIndices.FindIndex(itM.Value()); - anAttr->SetValue(im, id); + anAttr->SetValue(ih, id); } } } -- 2.39.2