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

@ -23,6 +23,7 @@
#include <GEOM_Function.hxx>
#include <GEOM_Object.hxx>
#include <GEOM_Solver.hxx>
#include <GEOM_ISubShape.hxx>
#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 (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;
}
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;
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
MESSAGE("GEOM_Function::GetValue Error: " << aFail->GetMessageString());
return aShape;
// 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;
#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);
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;
}

View File

@ -38,9 +38,10 @@
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#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
@ -136,7 +137,7 @@ GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
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,7 +150,7 @@ 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);
}

View File

@ -115,13 +115,11 @@ class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
};
#include <Standard_GUID.hxx>
#include <TDataStd_TreeNode.hxx>
#include "GEOM_Function.hxx"
#include "GEOM_Engine.hxx"
class GEOM_Object : public MMgt_TShared
{
friend class GEOM_Engine;
@ -144,10 +142,11 @@ class GEOM_Object : public MMgt_TShared
//
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);
@ -181,6 +180,11 @@ class GEOM_Object : public MMgt_TShared
//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();
@ -206,21 +210,22 @@ class GEOM_Object : public MMgt_TShared
//Returns false if the object is a sub shape of another object
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; }
//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
@ -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
//###########################################################
//Returns a label which could be used to store some additional data
Standard_EXPORT TDF_Label GetFreeLabel();
//###########################################################
// Internal methods
//###########################################################
//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

View File

@ -82,6 +82,8 @@
#include <qvaluelist.h>
#include <qstringlist.h>
#include <set>
#include "GEOMImpl_Types.hxx"
using namespace std;
@ -849,18 +851,30 @@ QString GEOMBase::GetDefaultName(const QString& theOperation)
{
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;
_PTR(Study) aStudy = appStudy->studyDS();
int aNumber = 0;
_PTR(SObject) obj;
do
{
aName = theOperation+"_"+QString::number(++aNumber);
obj = aStudy->FindObject(aName.latin1());
std::set<std::string> 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;
}

View File

@ -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

View File

@ -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);
}
}
}