PAL14122: EDF307: GetInPlace --> COMM_FAILURE. Use new method GEOMAlgo_BuilderShape::ImagesResult() to obtain partition history.

This commit is contained in:
jfa 2006-12-08 15:40:42 +00:00
parent 11568f579b
commit a25fd83519
6 changed files with 268 additions and 144 deletions

View File

@ -1,18 +1,18 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful // This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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
@ -23,6 +23,7 @@
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <GEOM_Object.hxx> #include <GEOM_Object.hxx>
#include <GEOM_Solver.hxx> #include <GEOM_Solver.hxx>
#include <GEOM_ISubShape.hxx>
#include "utilities.h" #include "utilities.h"
@ -161,30 +162,58 @@ TopoDS_Shape GEOM_Function::GetValue()
TopoDS_Shape aShape; TopoDS_Shape aShape;
TDF_Label aLabel = GetOwnerEntry(); TDF_Label aLabel = GetOwnerEntry();
if(aLabel.IsRoot()) return aShape; if (aLabel.IsRoot()) return aShape;
Handle(GEOM_Object) anObject = GEOM_Object::GetObject(aLabel); Handle(GEOM_Object) anObject = GEOM_Object::GetObject(aLabel);
if(anObject.IsNull()) return aShape; if (anObject.IsNull()) return aShape;
if(!anObject->IsMainShape()) {
try { if (!anObject->IsMainShape()) {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 bool isResult = false;
OCC_CATCH_SIGNALS; TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL);
#endif if (!aResultLabel.IsNull()) {
GEOM_Solver aSolver(GEOM_Engine::GetEngine()); Handle(TNaming_NamedShape) aNS;
if (!aSolver.ComputeFunction(this)) { if (aResultLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS))
MESSAGE("GEOM_Object::GetValue Error : Can't build a sub shape"); isResult = true;
return aShape;
}
} }
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); // compare tics
MESSAGE("GEOM_Function::GetValue Error: " << aFail->GetMessageString()); if (isResult) {
return aShape; // 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;
#endif
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;
}
} }
} }
TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL); TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL);
Handle(TNaming_NamedShape) aNS; 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(); aShape = aNS->Get();
@ -194,7 +223,7 @@ TopoDS_Shape GEOM_Function::GetValue()
//============================================================================= //=============================================================================
/*! /*!
* GetValue * SetValue
*/ */
//============================================================================= //=============================================================================
void GEOM_Function::SetValue(TopoDS_Shape& theShape) void GEOM_Function::SetValue(TopoDS_Shape& theShape)
@ -205,6 +234,26 @@ void GEOM_Function::SetValue(TopoDS_Shape& theShape)
aBuilder.Generated(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; _isDone = true;
} }

View File

@ -1,18 +1,18 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful // This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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
@ -38,9 +38,10 @@
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#define TYPE 2
#define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb))) #define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb)))
#define TYPE_LABEL 2
#define FREE_LABEL 3 #define FREE_LABEL 3
#define TIC_LABEL 4
//======================================================================= //=======================================================================
//function : GetObjectID //function : GetObjectID
@ -50,7 +51,7 @@ const Standard_GUID& GEOM_Object::GetObjectID()
{ {
static Standard_GUID anObjectID("FF1BBB01-5D14-4df2-980B-3A668264EA16"); static Standard_GUID anObjectID("FF1BBB01-5D14-4df2-980B-3A668264EA16");
return anObjectID; return anObjectID;
} }
//======================================================================= //=======================================================================
//function : GetSubShapeID //function : GetSubShapeID
@ -61,7 +62,7 @@ const Standard_GUID& GEOM_Object::GetSubShapeID()
static Standard_GUID anObjectID("FF1BBB68-5D14-4df2-980B-3A668264EA16"); static Standard_GUID anObjectID("FF1BBB68-5D14-4df2-980B-3A668264EA16");
return anObjectID; return anObjectID;
} }
//============================================================================= //=============================================================================
/*! /*!
* GetObject * GetObject
@ -79,7 +80,7 @@ Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel)
Handle(TDataStd_Integer) anID; Handle(TDataStd_Integer) anID;
if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return NULL; if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return NULL;
GEOM_Engine* anEngine= GEOM_Engine::GetEngine(); GEOM_Engine* anEngine= GEOM_Engine::GetEngine();
if(anEngine == NULL) return NULL; if(anEngine == NULL) return NULL;
@ -107,7 +108,7 @@ Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel)
// Get label of the referenced object // Get label of the referenced object
TDF_Label aLabel = aFather->Label(); TDF_Label aLabel = aFather->Label();
return GEOM_Object::GetObject(aLabel); 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) 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); _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) GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
: _label(theEntry), _ior("") : _label(theEntry), _ior("")
{ {
theEntry.ForgetAllAttributes(Standard_True); theEntry.ForgetAllAttributes(Standard_True);
if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root)) if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
_root = TDataStd_TreeNode::Set(theEntry); _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()); TDataStd_UAttribute::Set(theEntry, GetObjectID());
} }
@ -149,8 +150,8 @@ GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
int GEOM_Object::GetType() int GEOM_Object::GetType()
{ {
Handle(TDataStd_Integer) aType; 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(); return aType->Get();
} }
@ -161,8 +162,57 @@ int GEOM_Object::GetType()
//============================================================================= //=============================================================================
void GEOM_Object::SetType(int theType) void GEOM_Object::SetType(int theType)
{ {
TDataStd_Integer::Set(_label.FindChild(TYPE), theType); TDataStd_Integer::Set(_label.FindChild(TYPE_LABEL), theType);
return; }
//=============================================================================
/*!
* 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; Handle(TDataStd_Integer) anID;
if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return -1; if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return -1;
return anID->Get(); return anID->Get();
} }
@ -196,7 +246,7 @@ TopoDS_Shape GEOM_Object::GetValue()
if (!aFunction.IsNull()) if (!aFunction.IsNull())
aShape = aFunction->GetValue(); aShape = aFunction->GetValue();
return aShape; return aShape;
} }
@ -219,7 +269,7 @@ char* GEOM_Object::GetName()
{ {
Handle(TDataStd_Name) aNameAttr; Handle(TDataStd_Name) aNameAttr;
if(!_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) return NULL; if(!_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) return NULL;
TCollection_AsciiString aName(aNameAttr->Get()); TCollection_AsciiString aName(aNameAttr->Get());
return aName.ToCString(); return aName.ToCString();
} }
@ -255,7 +305,7 @@ TCollection_AsciiString GEOM_Object::GetAuxData()
/*! /*!
* IsSubShape * IsSubShape
*/ */
//============================================================================= //=============================================================================
bool GEOM_Object::IsMainShape() bool GEOM_Object::IsMainShape()
{ {
Handle(GEOM_Function) aFunction = GetFunction(1); Handle(GEOM_Function) aFunction = GetFunction(1);
@ -317,7 +367,7 @@ Handle(GEOM_Function) GEOM_Object::GetLastFunction()
{ {
Standard_Integer nb = GetNbFunctions(); Standard_Integer nb = GetNbFunctions();
if(nb) return GetFunction(nb); if(nb) return GetFunction(nb);
return NULL; return NULL;
} }
@ -340,12 +390,12 @@ Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetAllDependency()
} }
Standard_Integer aLength = aSeq.Length(); Standard_Integer aLength = aSeq.Length();
if(aLength > 0) { if(aLength > 0) {
anArray = new TColStd_HSequenceOfTransient; anArray = new TColStd_HSequenceOfTransient;
for(Standard_Integer j =1; j<=aLength; j++) for(Standard_Integer j =1; j<=aLength; j++)
anArray->Append(GetReferencedObject(aSeq(j))); anArray->Append(GetReferencedObject(aSeq(j)));
} }
return anArray; return anArray;
} }
@ -385,15 +435,15 @@ TDF_Label GEOM_Object::GetFreeLabel()
//======================================================================= //=======================================================================
//function : GEOM_Object_Type_ //function : GEOM_Object_Type_
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_EXPORT Handle_Standard_Type& GEOM_Object_Type_() Standard_EXPORT Handle_Standard_Type& GEOM_Object_Type_()
{ {
static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); 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); static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient);
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient);
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL};
static Handle_Standard_Type _aType = new Standard_Type("GEOM_Object", static Handle_Standard_Type _aType = new Standard_Type("GEOM_Object",
@ -407,7 +457,7 @@ Standard_EXPORT Handle_Standard_Type& GEOM_Object_Type_()
//======================================================================= //=======================================================================
//function : DownCast //function : DownCast
//purpose : //purpose :
//======================================================================= //=======================================================================
const Handle(GEOM_Object) Handle(GEOM_Object)::DownCast(const Handle(Standard_Transient)& AnObject) const Handle(GEOM_Object) Handle(GEOM_Object)::DownCast(const Handle(Standard_Transient)& AnObject)
{ {

View File

@ -1,18 +1,18 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // 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. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful // This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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
@ -34,10 +34,10 @@
#endif #endif
#ifndef _Handle_MMgt_TShared_HeaderFile #ifndef _Handle_MMgt_TShared_HeaderFile
#include <Handle_MMgt_TShared.hxx> #include <Handle_MMgt_TShared.hxx>
#endif #endif
#ifndef _MMgt_TShared_HeaderFile #ifndef _MMgt_TShared_HeaderFile
#include <MMgt_TShared.hxx> #include <MMgt_TShared.hxx>
#endif #endif
#ifndef _Standard_GUID_HeaderFile #ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx> #include <Standard_GUID.hxx>
#endif #endif
@ -65,25 +65,25 @@ Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object);
class Handle(GEOM_Object) : public Handle(MMgt_TShared) { class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
public: public:
inline void* operator new(size_t,void* anAddress) inline void* operator new(size_t,void* anAddress)
{ {
return anAddress; return anAddress;
} }
inline void* operator new(size_t size) inline void* operator new(size_t size)
{ {
return Standard::Allocate(size); return Standard::Allocate(size);
} }
inline void operator delete(void *anAddress) inline void operator delete(void *anAddress)
{ {
if (anAddress) Standard::Free((Standard_Address&)anAddress); if (anAddress) Standard::Free((Standard_Address&)anAddress);
} }
Handle(GEOM_Object)():Handle(MMgt_TShared)() {} Handle(GEOM_Object)():Handle(MMgt_TShared)() {}
Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle) 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; return *this;
} }
GEOM_Object* operator->() GEOM_Object* operator->()
{ {
return (GEOM_Object *)ControlAccess(); return (GEOM_Object *)ControlAccess();
} }
GEOM_Object* operator->() const GEOM_Object* operator->() const
{ {
return (GEOM_Object *)ControlAccess(); return (GEOM_Object *)ControlAccess();
} }
Standard_EXPORT ~Handle(GEOM_Object)() {}; Standard_EXPORT ~Handle(GEOM_Object)() {};
Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject); Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject);
}; };
#include <Standard_GUID.hxx> #include <Standard_GUID.hxx>
#include <TDataStd_TreeNode.hxx> #include <TDataStd_TreeNode.hxx>
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOM_Engine.hxx" #include "GEOM_Engine.hxx"
class GEOM_Object : public MMgt_TShared class GEOM_Object : public MMgt_TShared
{ {
friend class GEOM_Engine; friend class GEOM_Engine;
public: public:
inline void* operator new(size_t,void* anAddress) inline void* operator new(size_t,void* anAddress)
{ {
return anAddress; return anAddress;
} }
inline void* operator new(size_t size) inline void* operator new(size_t size)
{ {
return Standard::Allocate(size); return Standard::Allocate(size);
} }
inline void operator delete(void *anAddress) inline void operator delete(void *anAddress)
{ {
if (anAddress) Standard::Free((Standard_Address&)anAddress); if (anAddress) Standard::Free((Standard_Address&)anAddress);
} }
// Type management // Type management
// //
Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_(); Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOM_Object) ; } 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: private:
GEOM_Object(TDF_Label& theLabel); GEOM_Object(TDF_Label& theLabel);
public: public:
Standard_EXPORT GEOM_Object(TDF_Label& theEntry, int theType); 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(); 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 //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 //Returns a label of this GEOM_Object
Standard_EXPORT TDF_Label GetEntry() { return _label; } Standard_EXPORT TDF_Label GetEntry() { return _label; }
//Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...) //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 //Sets the type of this GEOM_Object
Standard_EXPORT void SetType(int theType); Standard_EXPORT void SetType(int theType);
//Returns an ID of the OCAF document where this GEOM_Object is stored
Standard_EXPORT int GetDocID();
//Returns a value (as TopoDS_Shape) of this GEOM_Object //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();
//Returns a value (as TopoDS_Shape) of this GEOM_Object
Standard_EXPORT TopoDS_Shape GetValue(); Standard_EXPORT TopoDS_Shape GetValue();
//Sets a name of this GEOM_Object //Sets a name of this GEOM_Object
@ -199,36 +203,37 @@ class GEOM_Object : public MMgt_TShared
//Returns an auxiliary data //Returns an auxiliary data
Standard_EXPORT TCollection_AsciiString GetAuxData(); Standard_EXPORT TCollection_AsciiString GetAuxData();
//########################################################### //###########################################################
// Sub shape methods // Sub shape methods
//########################################################### //###########################################################
//Returns false if the object is a sub shape of another object //Returns false if the object is a sub shape of another object
Standard_EXPORT bool IsMainShape(); Standard_EXPORT bool IsMainShape();
//########################################################### //###########################################################
// CORBA related methods // 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 //Sets an IOR of CORBA GEOM_Object_i which refers to this object
Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; } 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; }
//########################################################### //###########################################################
//Functions methods //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); Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType);
//Returns a number of functions of this GEOM_Object //Returns a number of functions of this GEOM_Object
Standard_EXPORT int GetNbFunctions(); Standard_EXPORT int GetNbFunctions();
//Returns a function with given number theFunctionNumber //Returns a function with given number theFunctionNumber
Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber); Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
//Return the last function of this GEOM_Object //Return the last function of this GEOM_Object
Standard_EXPORT Handle(GEOM_Function) GetLastFunction(); Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
@ -238,19 +243,17 @@ class GEOM_Object : public MMgt_TShared
//Returns the dependencies of the last function //Returns the dependencies of the last function
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency(); Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
//########################################################### //###########################################################
// Internal methods // Internal methods
//########################################################### //###########################################################
//Returns a label which could be used to store some additional data //Returns a label which could be used to store some additional data
Standard_EXPORT TDF_Label GetFreeLabel(); Standard_EXPORT TDF_Label GetFreeLabel();
private: private:
Handle(TDataStd_TreeNode) _root; Handle(TDataStd_TreeNode) _root;
TDF_Label _label; TDF_Label _label;
TCollection_AsciiString _ior; TCollection_AsciiString _ior;
}; };
#endif #endif

View File

@ -82,6 +82,8 @@
#include <qvaluelist.h> #include <qvaluelist.h>
#include <qstringlist.h> #include <qstringlist.h>
#include <set>
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
using namespace std; using namespace std;
@ -849,18 +851,30 @@ QString GEOMBase::GetDefaultName(const QString& theOperation)
{ {
QString aName = ""; QString aName = "";
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() ); // collect all object names of GEOM component
SalomeApp_Study* appStudy =
dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( !appStudy ) return aName; if ( !appStudy ) return aName;
_PTR(Study) aStudy = appStudy->studyDS(); _PTR(Study) aStudy = appStudy->studyDS();
int aNumber = 0; std::set<std::string> aSet;
_PTR(SObject) obj; _PTR(SComponent) aGeomCompo (aStudy->FindComponent("GEOM"));
do if (aGeomCompo) {
{ _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeomCompo));
aName = theOperation+"_"+QString::number(++aNumber); _PTR(SObject) obj;
obj = aStudy->FindObject(aName.latin1()); 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; return aName;
} }

View File

@ -608,12 +608,14 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
anArray = new TColStd_HArray1OfInteger(1,1); anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, anIndices.FindIndex(aValue)); anArray->SetValue(1, anIndices.FindIndex(aValue));
anObj = GetEngine()->AddSubShape(theShape, anArray); anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj); if (!anObj.IsNull()) {
aSeq->Append(anObj);
// for python command // for python command
TDF_Tool::Entry(anObj->GetEntry(), anEntry); TDF_Tool::Entry(anObj->GetEntry(), anEntry);
anAsciiList += anEntry; anAsciiList += anEntry;
anAsciiList += ","; anAsciiList += ",";
}
} }
//Make a Python command //Make a Python command

View File

@ -209,6 +209,9 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
TopTools_IndexedMapOfShape aResIndices; TopTools_IndexedMapOfShape aResIndices;
TopExp::MapShapes(aShape, 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 // history for all argument shapes
TDF_LabelSequence aLabelSeq; TDF_LabelSequence aLabelSeq;
aFunction->GetDependency(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++) { for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
TopoDS_Shape anEntity = anArgumentIndices.FindKey(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(); Standard_Integer nbModified = aModified.Extent();
if (nbModified > 0) { if (nbModified > 0) {
@ -239,10 +244,11 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const
Handle(TDataStd_IntegerArray) anAttr = Handle(TDataStd_IntegerArray) anAttr =
TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified); TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);
int ih = 1;
TopTools_ListIteratorOfListOfShape itM (aModified); 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()); int id = aResIndices.FindIndex(itM.Value());
anAttr->SetValue(im, id); anAttr->SetValue(ih, id);
} }
} }
} }