X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM%2FGEOM_Function.cxx;h=b3166ad0b2e91fc038161b1eb7f1d6e685bd2f5b;hb=652535d4666120e80c3d1a452fd6067b02a793a1;hp=e11f8cf7b0c84965aad888bfda7cbe2fb15fbccf;hpb=d3dd282390888d7dc091ba2c2ffe7923bd7458e6;p=modules%2Fgeom.git diff --git a/src/GEOM/GEOM_Function.cxx b/src/GEOM/GEOM_Function.cxx index e11f8cf7b..b3166ad0b 100644 --- a/src/GEOM/GEOM_Function.cxx +++ b/src/GEOM/GEOM_Function.cxx @@ -1,12 +1,34 @@ -using namespace std; - -#include "GEOM_Function.hxx" -#include "GEOM_Object.hxx" -#include "GEOM_Solver.hxx" +// 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 +// 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. +// +// 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 +// + +#include + +#include +#include +#include +#include #include "utilities.h" #include +#include #include #include #include @@ -25,17 +47,22 @@ using namespace std; #include #include +#include +#include #include #include #include #include #include +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #define ARGUMENT_LABEL 1 #define RESULT_LABEL 2 #define DESCRIPTION_LABEL 3 +#define HISTORY_LABEL 4 + #define ARGUMENTS _label.FindChild((ARGUMENT_LABEL)) #define ARGUMENT(thePosition) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePosition)) #define SUB_ARGUMENT(thePos1, thePos2) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePos1)).FindChild((thePos2)) @@ -135,27 +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 { - 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(); @@ -165,7 +223,7 @@ TopoDS_Shape GEOM_Function::GetValue() //============================================================================= /*! - * GetValue + * SetValue */ //============================================================================= void GEOM_Function::SetValue(TopoDS_Shape& theShape) @@ -176,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; } @@ -213,10 +291,11 @@ TCollection_AsciiString GEOM_Function::GetDescription() * SetDescription */ //============================================================================= -void GEOM_Function::SetDescription(TCollection_AsciiString& theDescription) +void GEOM_Function::SetDescription(const TCollection_AsciiString& theDescription) { TDF_Label aChild = _label.FindChild(DESCRIPTION_LABEL); - Handle(TDataStd_Comment) aComment = TDataStd_Comment::Set(aChild, TCollection_ExtendedString(theDescription)); + Handle(TDataStd_Comment) aComment = + TDataStd_Comment::Set(aChild, TCollection_ExtendedString(theDescription)); } //============================================================================= @@ -542,38 +621,38 @@ Handle(TColStd_HSequenceOfTransient) GEOM_Function::GetReferenceList(int thePosi * SetShape */ //============================================================================= -void GEOM_Function::SetShape(int thePosition, const TopoDS_Shape& theShape) -{ - _isDone = false; - if(thePosition <= 0 || theShape.IsNull()) return; - - TDF_Label anArgLabel = ARGUMENT(thePosition); - TNaming_Builder aBuilder(anArgLabel); - aBuilder.Generated(theShape); - - _isDone = true; - return; -} - +//void GEOM_Function::SetShape(int thePosition, const TopoDS_Shape& theShape) +//{ +// _isDone = false; +// if(thePosition <= 0 || theShape.IsNull()) return; +// +// TDF_Label anArgLabel = ARGUMENT(thePosition); +// TNaming_Builder aBuilder(anArgLabel); +// aBuilder.Generated(theShape); +// +// _isDone = true; +// return; +//} +// //============================================================================= /*! * GetShape */ //============================================================================= -TopoDS_Shape GEOM_Function::GetShape(int thePosition) -{ - _isDone = false; - TopoDS_Shape aShape; - if(thePosition <= 0) return aShape; - - TDF_Label anArgLabel = ARGUMENT(thePosition); - Handle(TNaming_NamedShape) aNS; - if(!anArgLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; - - aShape = aNS->Get(); - _isDone = true; - return aShape; -} +//TopoDS_Shape GEOM_Function::GetShape(int thePosition) +//{ +// _isDone = false; +// TopoDS_Shape aShape; +// if(thePosition <= 0) return aShape; +// +// TDF_Label anArgLabel = ARGUMENT(thePosition); +// Handle(TNaming_NamedShape) aNS; +// if(!anArgLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; +// +// aShape = aNS->Get(); +// _isDone = true; +// return aShape; +//} //============================================================================= @@ -589,6 +668,49 @@ void GEOM_Function::GetDependency(TDF_LabelSequence& theSeq) } } +//============================================================================= +/*! + * GetHistoryEntry + */ +//============================================================================= +TDF_Label GEOM_Function::GetHistoryEntry (const Standard_Boolean create) +{ + return _label.FindChild(HISTORY_LABEL, create); +} + +//============================================================================= +/*! + * GetArgumentHistoryEntry + */ +//============================================================================= +TDF_Label GEOM_Function::GetArgumentHistoryEntry (const TDF_Label& theArgumentRefEntry, + const Standard_Boolean create) +{ + TColStd_ListOfInteger anArgumentRefTags; + TDF_Tool::TagList(theArgumentRefEntry, anArgumentRefTags); + Standard_Integer anArgumentRefLabelPos = anArgumentRefTags.Extent(); + + TDF_Label aHistoryLabel = GetHistoryEntry(create); + if (aHistoryLabel.IsNull()) + return aHistoryLabel; + Standard_Integer aHistoryLabelPos = aHistoryLabel.Depth() + 1; + + Standard_Integer itag; + TDF_Label aHistoryCurLabel = aHistoryLabel; + TColStd_ListIteratorOfListOfInteger aListIter (anArgumentRefTags); + for (itag = 1; itag <= aHistoryLabelPos; itag++) { + aListIter.Next(); + } + for (; itag <= anArgumentRefLabelPos; itag++) { + aHistoryCurLabel = aHistoryCurLabel.FindChild(aListIter.Value(), create); + if (aHistoryCurLabel.IsNull()) + return aHistoryCurLabel; + aListIter.Next(); + } + + return aHistoryCurLabel; +} + //======================================================================= //function : GEOM_Function_Type_ //purpose :